From fdd245a2fa16d44197e2c35aeb80e40aaf7bb321 Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Sat, 9 May 2026 13:46:46 +0900 Subject: [PATCH 1/5] [#177] Add story edit panel: cover image upload, genre, language, NSFW - Add uploadCoverImage() and updateStoryline() helpers in publish.ts using createOwsAccount for wallet signing with exact PlotLink message formats - Add POST /api/publish/upload-cover and /api/publish/update-storyline routes with file validation (500KB, image type) and wallet authentication - Add edit panel UI in PreviewPanel for published genesis files: cover image upload with preview, genre/language dropdowns, NSFW toggle - Wire walletAddress from StoriesPage to PreviewPanel for authorship check - Update AGENTS.md post-publishing guidance to reference in-app edit panel - Bump version to 1.1.0 Co-Authored-By: Claude Opus 4.6 (1M context) --- AGENTS.md | 5 +- app/lib/publish.ts | 71 ++++++++ app/routes/publish.ts | 77 +++++++- app/web/components/PreviewPanel.tsx | 243 +++++++++++++++++++++---- app/web/components/StoriesPage.tsx | 10 + app/web/dist/assets/index-CXg4YULp.css | 32 ++++ app/web/dist/assets/index-CkTK65WZ.js | 130 +++++++++++++ app/web/dist/assets/index-DHjiVVCV.css | 32 ---- app/web/dist/assets/index-DWqOuJeA.js | 130 ------------- app/web/dist/index.html | 4 +- package.json | 2 +- 11 files changed, 536 insertions(+), 200 deletions(-) create mode 100644 app/web/dist/assets/index-CXg4YULp.css create mode 100644 app/web/dist/assets/index-CkTK65WZ.js delete mode 100644 app/web/dist/assets/index-DHjiVVCV.css delete mode 100644 app/web/dist/assets/index-DWqOuJeA.js diff --git a/AGENTS.md b/AGENTS.md index 774dbcb..14ee17d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -110,12 +110,13 @@ You focus on the writing. The human handles publishing. ### After Publishing -After a storyline is created, inform the user they can customize it on the PlotLink website: +After a storyline is created, inform the user they can customize it directly in the OWS app: - **Story URL**: `https://plotlink.xyz/story/{storylineId}` -- The **Edit Details** button is available to the story author when connected with their wallet +- The **Edit Story** button appears in the preview panel for published genesis files - Editable fields: cover image (WebP/JPEG, max 500KB, recommended 600x900px), genre, language, NSFW flag - Uploading a cover image significantly improves the story's visibility on PlotLink +- All edits are signed with the OWS wallet and sent to PlotLink automatically ## Content Flags diff --git a/app/lib/publish.ts b/app/lib/publish.ts index 9cdfee3..a028cf4 100644 --- a/app/lib/publish.ts +++ b/app/lib/publish.ts @@ -424,3 +424,74 @@ export async function publishPlot( return { txHash, contentCid, storylineId, plotIndex: confirmation.plotIndex >= 0 ? confirmation.plotIndex : undefined, gasCost: confirmation.gasCost, indexError }; } + +/** + * Upload a cover image to PlotLink via signed API call. + * Uses createOwsAccount for signing (not raw owsSignMsg). + * Returns the IPFS CID of the uploaded image. + */ +export async function uploadCoverImage( + walletName: string, + walletAddress: `0x${string}`, + imageFile: File, +): Promise { + const PLOTLINK_URL = process.env.NEXT_PUBLIC_APP_URL || "https://plotlink.xyz"; + const account = createOwsAccount(walletName, walletAddress); + + const timestamp = Date.now(); + const message = `PlotLink: Upload cover image\nTimestamp: ${timestamp}`; + const signature = await account.signMessage({ message }); + + const formData = new FormData(); + formData.append("file", imageFile); + formData.append("message", message); + formData.append("signature", signature); + + const res = await fetch(`${PLOTLINK_URL}/api/upload-cover`, { + method: "POST", + body: formData, + }); + + if (!res.ok) { + const err = await res.json().catch(() => ({})) as Record; + throw new Error(err.error || `Cover upload failed: HTTP ${res.status}`); + } + + const data = await res.json() as { cid: string }; + return data.cid; +} + +/** + * Update storyline metadata (cover, genre, language, NSFW) on PlotLink via signed API call. + * Uses createOwsAccount for signing (not raw owsSignMsg). + * Message format must match: /^PlotLink: Update storyline #(\d+)\nTimestamp: (\d+)$/ + */ +export async function updateStoryline( + walletName: string, + walletAddress: `0x${string}`, + storylineId: number, + updates: { coverCid?: string | null; genre?: string; language?: string; isNsfw?: boolean }, +): Promise { + const PLOTLINK_URL = process.env.NEXT_PUBLIC_APP_URL || "https://plotlink.xyz"; + const account = createOwsAccount(walletName, walletAddress); + + const timestamp = Date.now(); + const message = `PlotLink: Update storyline #${storylineId}\nTimestamp: ${timestamp}`; + const signature = await account.signMessage({ message }); + + const res = await fetch(`${PLOTLINK_URL}/api/storyline/update`, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + storylineId, + signature, + message, + ...updates, + }), + }); + + if (!res.ok) { + const err = await res.json().catch(() => ({})) as Record; + throw new Error(err.error || `Storyline update failed: HTTP ${res.status}`); + } +} diff --git a/app/routes/publish.ts b/app/routes/publish.ts index 9cc4031..d1719e8 100644 --- a/app/routes/publish.ts +++ b/app/routes/publish.ts @@ -1,6 +1,6 @@ import { Hono } from "hono"; import { streamSSE } from "hono/streaming"; -import { publishStoryline, publishPlot, getEthBalance, estimatePublishCost } from "../lib/publish"; +import { publishStoryline, publishPlot, getEthBalance, estimatePublishCost, uploadCoverImage, updateStoryline } from "../lib/publish"; import { keccak256, toBytes } from "viem"; import { listAgentWallets, getBaseAddress } from "../../lib/ows/wallet"; @@ -196,4 +196,79 @@ publish.post("/retry-index", async (c) => { } }); +/** POST /api/publish/upload-cover — upload cover image with wallet signature */ +publish.post("/upload-cover", async (c) => { + try { + const wallets = listAgentWallets(); + const wallet = wallets.find((w) => w.name.startsWith("plotlink-writer")); + if (!wallet) return c.json({ error: "No OWS wallet" }, 400); + + const address = getBaseAddress(wallet); + if (!address) return c.json({ error: "No EVM address on wallet" }, 400); + + const formData = await c.req.formData(); + const file = formData.get("file"); + if (!file || !(file instanceof File)) { + return c.json({ error: "No image file provided" }, 400); + } + + // Validate file size (500KB max) + if (file.size > 500 * 1024) { + return c.json({ error: "Image exceeds 500KB limit" }, 400); + } + + // Validate file type + if (!file.type.startsWith("image/")) { + return c.json({ error: "File must be an image (WebP or JPEG recommended)" }, 400); + } + + const cid = await uploadCoverImage(wallet.name, address as `0x${string}`, file); + return c.json({ cid }); + } catch (err: unknown) { + const message = err instanceof Error ? err.message : "Cover upload failed"; + return c.json({ error: message }, 500); + } +}); + +/** POST /api/publish/update-storyline — update storyline metadata with wallet signature */ +publish.post("/update-storyline", async (c) => { + try { + const wallets = listAgentWallets(); + const wallet = wallets.find((w) => w.name.startsWith("plotlink-writer")); + if (!wallet) return c.json({ error: "No OWS wallet" }, 400); + + const address = getBaseAddress(wallet); + if (!address) return c.json({ error: "No EVM address on wallet" }, 400); + + const body = await c.req.json<{ + storylineId: number; + coverCid?: string | null; + genre?: string; + language?: string; + isNsfw?: boolean; + }>(); + + if (!body.storylineId) { + return c.json({ error: "storylineId required" }, 400); + } + + await updateStoryline( + wallet.name, + address as `0x${string}`, + body.storylineId, + { + coverCid: body.coverCid, + genre: body.genre, + language: body.language, + isNsfw: body.isNsfw, + }, + ); + + return c.json({ ok: true }); + } catch (err: unknown) { + const message = err instanceof Error ? err.message : "Update failed"; + return c.json({ error: message }, 500); + } +}); + export { publish as publishRoutes }; diff --git a/app/web/components/PreviewPanel.tsx b/app/web/components/PreviewPanel.tsx index 0a2b3cd..59b16e5 100644 --- a/app/web/components/PreviewPanel.tsx +++ b/app/web/components/PreviewPanel.tsx @@ -11,6 +11,7 @@ interface PreviewPanelProps { authFetch: (url: string, opts?: RequestInit) => Promise; onPublish?: (storyName: string, fileName: string, genre: string, language: string, isNsfw: boolean) => void; publishingFile?: string | null; + walletAddress?: string | null; } interface FileData { @@ -26,7 +27,7 @@ interface FileData { type Tab = "preview" | "edit"; -export function PreviewPanel({ storyName, fileName, authFetch, onPublish, publishingFile }: PreviewPanelProps) { +export function PreviewPanel({ storyName, fileName, authFetch, onPublish, publishingFile, walletAddress }: PreviewPanelProps) { const [fileData, setFileData] = useState(null); const [loading, setLoading] = useState(false); const [activeTab, setActiveTab] = useState("preview"); @@ -41,6 +42,18 @@ export function PreviewPanel({ storyName, fileName, authFetch, onPublish, publis const textareaRef = useRef(null); const dirtyRef = useRef(false); + // Edit panel state for published stories + const [showEditPanel, setShowEditPanel] = useState(false); + const [editGenre, setEditGenre] = useState(GENRES[0] as string); + const [editLanguage, setEditLanguage] = useState(LANGUAGES[0] as string); + const [editNsfw, setEditNsfw] = useState(false); + const [coverFile, setCoverFile] = useState(null); + const [coverPreview, setCoverPreview] = useState(null); + const [editSaving, setEditSaving] = useState(false); + const [editError, setEditError] = useState(null); + const [editSuccess, setEditSuccess] = useState(false); + const coverInputRef = useRef(null); + const prevFileRef = useRef(null); const loadFile = useCallback(async () => { @@ -121,6 +134,86 @@ export function PreviewPanel({ storyName, fileName, authFetch, onPublish, publis setSaving(false); }, [storyName, fileName, authFetch, editContent]); + // Handle cover image selection + const handleCoverSelect = useCallback((e: React.ChangeEvent) => { + const file = e.target.files?.[0]; + if (!file) return; + if (file.size > 500 * 1024) { + setEditError("Image exceeds 500KB limit"); + return; + } + if (!file.type.startsWith("image/")) { + setEditError("File must be an image"); + return; + } + setCoverFile(file); + setCoverPreview(URL.createObjectURL(file)); + setEditError(null); + }, []); + + // Save storyline edits (cover upload + metadata update) + const handleEditSave = useCallback(async () => { + if (!fileData?.storylineId) return; + setEditSaving(true); + setEditError(null); + setEditSuccess(false); + + try { + let coverCid: string | undefined; + + // Upload cover image if selected + if (coverFile) { + const formData = new FormData(); + formData.append("file", coverFile); + const uploadRes = await authFetch("/api/publish/upload-cover", { + method: "POST", + body: formData, + }); + if (!uploadRes.ok) { + const err = await uploadRes.json(); + throw new Error(err.error || "Cover upload failed"); + } + const uploadData = await uploadRes.json(); + coverCid = uploadData.cid; + } + + // Update storyline metadata + const updateRes = await authFetch("/api/publish/update-storyline", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + storylineId: fileData.storylineId, + ...(coverCid !== undefined && { coverCid }), + genre: editGenre, + language: editLanguage, + isNsfw: editNsfw, + }), + }); + + if (!updateRes.ok) { + const err = await updateRes.json(); + throw new Error(err.error || "Update failed"); + } + + setEditSuccess(true); + setCoverFile(null); + setTimeout(() => setEditSuccess(false), 3000); + } catch (err) { + setEditError(err instanceof Error ? err.message : "Update failed"); + } finally { + setEditSaving(false); + } + }, [fileData?.storylineId, coverFile, editGenre, editLanguage, editNsfw, authFetch]); + + // Reset edit panel state when toggling or changing files + useEffect(() => { + setShowEditPanel(false); + setCoverFile(null); + setCoverPreview(null); + setEditError(null); + setEditSuccess(false); + }, [storyName, fileName]); + // Ctrl+S / Cmd+S to save useEffect(() => { if (activeTab !== "edit") return; @@ -364,37 +457,123 @@ export function PreviewPanel({ storyName, fileName, authFetch, onPublish, publis )} ) : fileData?.status === "published" ? ( -
- Published - {fileData.storylineId && ( - { - const base = `https://plotlink.xyz/story/${fileData.storylineId}`; - if (!isPlot) return base; - // plotIndex convention: contract emits 0-based (genesis=0, plot-01=1) - // plotlink.xyz URLs use the same 0-based index - // Filename fallback: plot-01.md → parseInt("01") = 1 (matches contract) - const idx = fileData.plotIndex != null && fileData.plotIndex > 0 - ? fileData.plotIndex - : parseInt(fileName?.match(/^plot-(\d+)\.md$/)?.[1] ?? "1"); - return `${base}/${idx}`; - })()} - target="_blank" - rel="noopener noreferrer" - className="text-accent underline" - > - View on PlotLink - - )} - {fileData.txHash && ( - - BaseScan - +
+
+ Published + {fileData.storylineId && ( + { + const base = `https://plotlink.xyz/story/${fileData.storylineId}`; + if (!isPlot) return base; + const idx = fileData.plotIndex != null && fileData.plotIndex > 0 + ? fileData.plotIndex + : parseInt(fileName?.match(/^plot-(\d+)\.md$/)?.[1] ?? "1"); + return `${base}/${idx}`; + })()} + target="_blank" + rel="noopener noreferrer" + className="text-accent underline" + > + View on PlotLink + + )} + {fileData.txHash && ( + + BaseScan + + )} + {isGenesis && walletAddress && fileData.storylineId && ( + + )} +
+ {/* Edit panel for published genesis files */} + {showEditPanel && isGenesis && fileData.storylineId && ( +
+ {/* Cover image upload */} +
+ Cover Image +
+ {coverPreview && ( +
+ Cover preview + +
+ )} +
+ + WebP/JPEG, max 500KB, 600x900px recommended +
+
+
+ {/* Genre & Language */} +
+ + +
+ {/* NSFW toggle */} + + {/* Save / status */} +
+ + {editSuccess && Updated!} + {editError && {editError}} +
+
)}
) : ( diff --git a/app/web/components/StoriesPage.tsx b/app/web/components/StoriesPage.tsx index 8129f83..28f7422 100644 --- a/app/web/components/StoriesPage.tsx +++ b/app/web/components/StoriesPage.tsx @@ -38,6 +38,7 @@ export function StoriesPage({ token, authFetch }: StoriesPageProps) { const [selectedFile, setSelectedFile] = useState(null); const [publishingFile, setPublishingFile] = useState(null); const [publishProgress, setPublishProgress] = useState(""); + const [walletAddress, setWalletAddress] = useState(null); const [ratio, setRatio] = useState(loadRatio); const [untitledSessions, setUntitledSessions] = useState([]); const knownStoriesRef = useRef>(new Set()); @@ -45,6 +46,14 @@ export function StoriesPage({ token, authFetch }: StoriesPageProps) { const containerRef = useRef(null); const dragging = useRef(false); + // Fetch wallet address for edit panel authorship check + useEffect(() => { + authFetch("/api/wallet") + .then((res) => res.ok ? res.json() : null) + .then((data) => { if (data?.address) setWalletAddress(data.address); }) + .catch(() => {}); + }, [authFetch]); + // Persist ratio to localStorage useEffect(() => { try { localStorage.setItem(STORAGE_KEY, String(ratio)); } catch { /* ignore */ } @@ -351,6 +360,7 @@ export function StoriesPage({ token, authFetch }: StoriesPageProps) { authFetch={authFetch} onPublish={handlePublish} publishingFile={publishingFile} + walletAddress={walletAddress} /> {publishProgress && (
diff --git a/app/web/dist/assets/index-CXg4YULp.css b/app/web/dist/assets/index-CXg4YULp.css new file mode 100644 index 0000000..c14ce93 --- /dev/null +++ b/app/web/dist/assets/index-CXg4YULp.css @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2014 The xterm.js authors. All rights reserved. + * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) + * https://github.com/chjj/term.js + * @license MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * Originally forked from (with the author's permission): + * Fabrice Bellard's javascript vt100 for jslinux: + * http://bellard.org/jslinux/ + * Copyright (c) 2011 Fabrice Bellard + * The original design remains. The terminal itself + * has been extended to include xterm CSI codes, among + * other features. + */.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{font-family:monospace;-webkit-user-select:text;user-select:text;white-space:pre}.xterm .xterm-accessibility-tree>div{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px!important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:#0000;transition:opacity .1s linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity .8s linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}/*! tailwindcss v4.2.2 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial}}}@layer theme{:root,:host{--font-serif:ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-700:oklch(50.5% .213 27.518);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-amber-700:oklch(55.5% .163 48.998);--color-green-600:oklch(62.7% .194 149.214);--color-green-700:oklch(52.7% .154 150.069);--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--container-lg:32rem;--container-2xl:42rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--font-weight-medium:500;--font-weight-bold:700;--tracking-tight:-.025em;--tracking-wider:.05em;--leading-relaxed:1.625;--radius-lg:.5rem;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent;font-family:Inter,system-ui,-apple-system,sans-serif;line-height:1.5}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.invisible{visibility:hidden}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.relative{position:relative}.static{position:static}.inset-0{inset:calc(var(--spacing) * 0)}.start{inset-inline-start:var(--spacing)}.start\!{inset-inline-start:var(--spacing)!important}.end{inset-inline-end:var(--spacing)}.-top-1\.5{top:calc(var(--spacing) * -1.5)}.top-1{top:calc(var(--spacing) * 1)}.-right-1\.5{right:calc(var(--spacing) * -1.5)}.right-1{right:calc(var(--spacing) * 1)}.z-10{z-index:10}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.mx-auto{margin-inline:auto}.prose{color:var(--tw-prose-body);max-width:65ch}.prose :where(p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em}.prose :where([class~=lead]):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-lead);margin-top:1.2em;margin-bottom:1.2em;font-size:1.25em;line-height:1.6}.prose :where(a):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-links);font-weight:500;text-decoration:underline}.prose :where(strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-bold);font-weight:600}.prose :where(a strong):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(blockquote strong):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(thead th strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em;padding-inline-start:1.625em;list-style-type:decimal}.prose :where(ol[type=A]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-alpha}.prose :where(ol[type=a]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-alpha}.prose :where(ol[type=A s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-alpha}.prose :where(ol[type=a s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-alpha}.prose :where(ol[type=I]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-roman}.prose :where(ol[type=i]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-roman}.prose :where(ol[type=I s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-roman}.prose :where(ol[type=i s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-roman}.prose :where(ol[type="1"]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:decimal}.prose :where(ul):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em;padding-inline-start:1.625em;list-style-type:disc}.prose :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *))::marker{color:var(--tw-prose-counters);font-weight:400}.prose :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *))::marker{color:var(--tw-prose-bullets)}.prose :where(dt):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:1.25em;font-weight:600}.prose :where(hr):not(:where([class~=not-prose],[class~=not-prose] *)){border-color:var(--tw-prose-hr);border-top-width:1px;margin-top:3em;margin-bottom:3em}.prose :where(blockquote):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-quotes);border-inline-start-width:.25rem;border-inline-start-color:var(--tw-prose-quote-borders);quotes:"“""”""‘""’";margin-top:1.6em;margin-bottom:1.6em;padding-inline-start:1em;font-style:italic;font-weight:500}.prose :where(blockquote p:first-of-type):not(:where([class~=not-prose],[class~=not-prose] *)):before{content:open-quote}.prose :where(blockquote p:last-of-type):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:close-quote}.prose :where(h1):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:0;margin-bottom:.888889em;font-size:2.25em;font-weight:800;line-height:1.11111}.prose :where(h1 strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-weight:900}.prose :where(h2):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:2em;margin-bottom:1em;font-size:1.5em;font-weight:700;line-height:1.33333}.prose :where(h2 strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-weight:800}.prose :where(h3):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:1.6em;margin-bottom:.6em;font-size:1.25em;font-weight:600;line-height:1.6}.prose :where(h3 strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-weight:700}.prose :where(h4):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:1.5em;margin-bottom:.5em;font-weight:600;line-height:1.5}.prose :where(h4 strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-weight:700}.prose :where(img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(picture):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em;display:block}.prose :where(video):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(kbd):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-kbd);box-shadow:0 0 0 1px var(--tw-prose-kbd-shadows),0 3px 0 var(--tw-prose-kbd-shadows);padding-top:.1875em;padding-inline-end:.375em;padding-bottom:.1875em;border-radius:.3125rem;padding-inline-start:.375em;font-family:inherit;font-size:.875em;font-weight:500}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-code);font-size:.875em;font-weight:600}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)):before,.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:"`"}.prose :where(a code):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(h1 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(h2 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-size:.875em}.prose :where(h3 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-size:.9em}.prose :where(h4 code):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(blockquote code):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(thead th code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(pre):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-pre-code);background-color:var(--tw-prose-pre-bg);padding-top:.857143em;padding-inline-end:1.14286em;padding-bottom:.857143em;border-radius:.375rem;margin-top:1.71429em;margin-bottom:1.71429em;padding-inline-start:1.14286em;font-size:.875em;font-weight:400;line-height:1.71429;overflow-x:auto}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:inherit;color:inherit;font-size:inherit;font-family:inherit;line-height:inherit;background-color:#0000;border-width:0;border-radius:0;padding:0}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)):before,.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:none}.prose :where(table):not(:where([class~=not-prose],[class~=not-prose] *)){table-layout:auto;width:100%;margin-top:2em;margin-bottom:2em;font-size:.875em;line-height:1.71429}.prose :where(thead):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-th-borders)}.prose :where(thead th):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);vertical-align:bottom;padding-inline-end:.571429em;padding-bottom:.571429em;padding-inline-start:.571429em;font-weight:600}.prose :where(tbody tr):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-td-borders)}.prose :where(tbody tr:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:0}.prose :where(tbody td):not(:where([class~=not-prose],[class~=not-prose] *)){vertical-align:baseline}.prose :where(tfoot):not(:where([class~=not-prose],[class~=not-prose] *)){border-top-width:1px;border-top-color:var(--tw-prose-th-borders)}.prose :where(tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){vertical-align:top}.prose :where(th,td):not(:where([class~=not-prose],[class~=not-prose] *)){text-align:start}.prose :where(figure>*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose :where(figcaption):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-captions);margin-top:.857143em;font-size:.875em;line-height:1.42857}.prose{--tw-prose-body:oklch(37.3% .034 259.733);--tw-prose-headings:oklch(21% .034 264.665);--tw-prose-lead:oklch(44.6% .03 256.802);--tw-prose-links:oklch(21% .034 264.665);--tw-prose-bold:oklch(21% .034 264.665);--tw-prose-counters:oklch(55.1% .027 264.364);--tw-prose-bullets:oklch(87.2% .01 258.338);--tw-prose-hr:oklch(92.8% .006 264.531);--tw-prose-quotes:oklch(21% .034 264.665);--tw-prose-quote-borders:oklch(92.8% .006 264.531);--tw-prose-captions:oklch(55.1% .027 264.364);--tw-prose-kbd:oklch(21% .034 264.665);--tw-prose-kbd-shadows:oklab(21% -.00316127 -.0338527/.1);--tw-prose-code:oklch(21% .034 264.665);--tw-prose-pre-code:oklch(92.8% .006 264.531);--tw-prose-pre-bg:oklch(27.8% .033 256.848);--tw-prose-th-borders:oklch(87.2% .01 258.338);--tw-prose-td-borders:oklch(92.8% .006 264.531);--tw-prose-invert-body:oklch(87.2% .01 258.338);--tw-prose-invert-headings:#fff;--tw-prose-invert-lead:oklch(70.7% .022 261.325);--tw-prose-invert-links:#fff;--tw-prose-invert-bold:#fff;--tw-prose-invert-counters:oklch(70.7% .022 261.325);--tw-prose-invert-bullets:oklch(44.6% .03 256.802);--tw-prose-invert-hr:oklch(37.3% .034 259.733);--tw-prose-invert-quotes:oklch(96.7% .003 264.542);--tw-prose-invert-quote-borders:oklch(37.3% .034 259.733);--tw-prose-invert-captions:oklch(70.7% .022 261.325);--tw-prose-invert-kbd:#fff;--tw-prose-invert-kbd-shadows:#ffffff1a;--tw-prose-invert-code:#fff;--tw-prose-invert-pre-code:oklch(87.2% .01 258.338);--tw-prose-invert-pre-bg:#00000080;--tw-prose-invert-th-borders:oklch(44.6% .03 256.802);--tw-prose-invert-td-borders:oklch(37.3% .034 259.733);font-size:1rem;line-height:1.75}.prose :where(picture>img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose :where(li):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5em;margin-bottom:.5em}.prose :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.375em}.prose :where(.prose>ul>li p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.prose :where(.prose>ul>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em}.prose :where(.prose>ul>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.25em}.prose :where(.prose>ol>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em}.prose :where(.prose>ol>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.25em}.prose :where(ul ul,ul ol,ol ul,ol ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.prose :where(dl):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em}.prose :where(dd):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5em;padding-inline-start:1.625em}.prose :where(hr+*):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(h2+*):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(h3+*):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(h4+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(thead th:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose :where(thead th:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose :where(tbody td,tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){padding-top:.571429em;padding-inline-end:.571429em;padding-bottom:.571429em;padding-inline-start:.571429em}.prose :where(tbody td:first-child,tfoot td:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose :where(tbody td:last-child,tfoot td:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose :where(figure):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(.prose>:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(.prose>:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:0}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-1\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.mb-6{margin-bottom:calc(var(--spacing) * 6)}.ml-0\.5{margin-left:calc(var(--spacing) * .5)}.ml-1{margin-left:calc(var(--spacing) * 1)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-auto{margin-left:auto}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.table{display:table}.h-0\.5{height:calc(var(--spacing) * .5)}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-4{height:calc(var(--spacing) * 4)}.h-14{height:calc(var(--spacing) * 14)}.h-24{height:calc(var(--spacing) * 24)}.h-\[calc\(100vh-3\.5rem\)\]{height:calc(100vh - 3.5rem)}.h-full{height:100%}.h-screen{height:100vh}.min-h-0{min-height:calc(var(--spacing) * 0)}.w-0\.5{width:calc(var(--spacing) * .5)}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-4{width:calc(var(--spacing) * 4)}.w-16{width:calc(var(--spacing) * 16)}.w-56{width:calc(var(--spacing) * 56)}.w-full{width:100%}.max-w-2xl{max-width:var(--container-2xl)}.max-w-\[120px\]{max-width:120px}.max-w-lg{max-width:var(--container-lg)}.max-w-none{max-width:none}.max-w-sm{max-width:var(--container-sm)}.min-w-0{min-width:calc(var(--spacing) * 0)}.flex-1{flex:1}.flex-shrink-0{flex-shrink:0}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.cursor-pointer{cursor:pointer}.resize{resize:both}.resize-none{resize:none}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1.5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1.5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 6) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)))}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-accent{border-color:#8b4513}.border-accent-dim\/30{border-color:#6b34104d}.border-accent\/30{border-color:#8b45134d}.border-amber-600\/30{border-color:#dd74004d}@supports (color:color-mix(in lab,red,red)){.border-amber-600\/30{border-color:color-mix(in oklab,var(--color-amber-600) 30%,transparent)}}.border-border{border-color:#d4c5b0}.border-green-700\/30{border-color:#0081384d}@supports (color:color-mix(in lab,red,red)){.border-green-700\/30{border-color:color-mix(in oklab,var(--color-green-700) 30%,transparent)}}.border-red-700\/30{border-color:#bf000f4d}@supports (color:color-mix(in lab,red,red)){.border-red-700\/30{border-color:color-mix(in oklab,var(--color-red-700) 30%,transparent)}}.border-transparent{border-color:#0000}.bg-accent{background-color:#8b4513}.bg-accent\/10{background-color:#8b45131a}.bg-amber-500{background-color:var(--color-amber-500)}.bg-background{background-color:#e8dfd0}.bg-error{background-color:#c33}.bg-green-600{background-color:var(--color-green-600)}.bg-muted\/50{background-color:#8b735580}.bg-surface{background-color:#f0ebe1}.object-cover{object-fit:cover}.p-1\.5{padding:calc(var(--spacing) * 1.5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.p-8{padding:calc(var(--spacing) * 8)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-6{padding-inline:calc(var(--spacing) * 6)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.pt-1\.5{padding-top:calc(var(--spacing) * 1.5)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pr-16{padding-right:calc(var(--spacing) * 16)}.pl-3{padding-left:calc(var(--spacing) * 3)}.pl-4{padding-left:calc(var(--spacing) * 4)}.text-center{text-align:center}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.font-serif{font-family:var(--font-serif)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.break-all{word-break:break-all}.text-accent{color:#8b4513}.text-accent-dim{color:#6b3410}.text-amber-600{color:var(--color-amber-600)}.text-amber-700{color:var(--color-amber-700)}.text-error{color:#c33}.text-foreground{color:#2c1810}.text-green-700{color:var(--color-green-700)}.text-muted{color:#8b7355}.text-red-700{color:var(--color-red-700)}.text-white{color:var(--color-white)}.uppercase{text-transform:uppercase}.italic{font-style:italic}.overline{text-decoration-line:overline}.underline{text-decoration-line:underline}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.outline-none{--tw-outline-style:none;outline-style:none}.placeholder\:text-muted\/50::placeholder{color:#8b735580}@media(hover:hover){.hover\:border-accent:hover{border-color:#8b4513}.hover\:border-error:hover{border-color:#c33}.hover\:bg-accent-dim:hover{background-color:#6b3410}.hover\:bg-accent\/10:hover{background-color:#8b45131a}.hover\:bg-border\/50:hover{background-color:#d4c5b080}.hover\:bg-surface:hover{background-color:#f0ebe1}.hover\:text-accent:hover{color:#8b4513}.hover\:text-accent-dim:hover{color:#6b3410}.hover\:text-error:hover{color:#c33}.hover\:text-foreground:hover{color:#2c1810}.hover\:opacity-80:hover{opacity:.8}}.focus\:border-accent:focus{border-color:#8b4513}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}}:root{--bg:#e8dfd0;--bg-surface:#f0ebe1;--bg-shelf:#ddd3c2;--text:#2c1810;--text-muted:#8b7355;--accent:#8b4513;--accent-dim:#6b3410;--border:#d4c5b0;--error:#c33;--paper-bg:#f5f0e8}body{background:var(--bg);color:var(--text);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,system-ui,-apple-system,sans-serif}::selection{background:var(--accent);color:#fff}h1,h2,h3,h4{font-family:Lora,Georgia,Times New Roman,serif}.prose{--tw-prose-body:var(--text);--tw-prose-headings:var(--text);--tw-prose-links:var(--accent);--tw-prose-bold:var(--text);--tw-prose-quotes:var(--text-muted);--tw-prose-quote-borders:var(--border);--tw-prose-code:var(--text);--tw-prose-hr:var(--border)}.prose,.prose p,.prose li,.prose blockquote{font-family:Lora,Georgia,Times New Roman,serif}code,pre{font-family:Geist Mono,ui-monospace,monospace}.xterm .xterm-dim{opacity:1!important;color:#8b7355!important}.xterm,.xterm-viewport{border:none!important;outline:none!important}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false} diff --git a/app/web/dist/assets/index-CkTK65WZ.js b/app/web/dist/assets/index-CkTK65WZ.js new file mode 100644 index 0000000..0bf084a --- /dev/null +++ b/app/web/dist/assets/index-CkTK65WZ.js @@ -0,0 +1,130 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();function xu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Wh={exports:{}},Xl={};/** + * @license React + * react-jsx-runtime.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Gg;function vx(){if(Gg)return Xl;Gg=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,a,o){var c=null;if(o!==void 0&&(c=""+o),a.key!==void 0&&(c=""+a.key),"key"in a){o={};for(var f in a)f!=="key"&&(o[f]=a[f])}else o=a;return a=o.ref,{$$typeof:e,type:s,key:c,ref:a!==void 0?a:null,props:o}}return Xl.Fragment=t,Xl.jsx=n,Xl.jsxs=n,Xl}var $g;function yx(){return $g||($g=1,Wh.exports=vx()),Wh.exports}var S=yx(),Yh={exports:{}},Ee={};/** + * @license React + * react.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Zg;function bx(){if(Zg)return Ee;Zg=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),b=Symbol.iterator;function y(D){return D===null||typeof D!="object"?null:(D=b&&D[b]||D["@@iterator"],typeof D=="function"?D:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,L={};function M(D,K,C){this.props=D,this.context=K,this.refs=L,this.updater=C||x}M.prototype.isReactComponent={},M.prototype.setState=function(D,K){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,K,"setState")},M.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function Z(){}Z.prototype=M.prototype;function I(D,K,C){this.props=D,this.context=K,this.refs=L,this.updater=C||x}var Q=I.prototype=new Z;Q.constructor=I,k(Q,M.prototype),Q.isPureReactComponent=!0;var W=Array.isArray;function O(){}var ie={H:null,A:null,T:null,S:null},ue=Object.prototype.hasOwnProperty;function me(D,K,C){var J=C.ref;return{$$typeof:e,type:D,key:K,ref:J!==void 0?J:null,props:C}}function U(D,K){return me(D.type,K,D.props)}function le(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function V(D){var K={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(C){return K[C]})}var B=/\/+/g;function A(D,K){return typeof D=="object"&&D!==null&&D.key!=null?V(""+D.key):K.toString(36)}function R(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(O,O):(D.status="pending",D.then(function(K){D.status==="pending"&&(D.status="fulfilled",D.value=K)},function(K){D.status==="pending"&&(D.status="rejected",D.reason=K)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function T(D,K,C,J,fe){var de=typeof D;(de==="undefined"||de==="boolean")&&(D=null);var xe=!1;if(D===null)xe=!0;else switch(de){case"bigint":case"string":case"number":xe=!0;break;case"object":switch(D.$$typeof){case e:case t:xe=!0;break;case g:return xe=D._init,T(xe(D._payload),K,C,J,fe)}}if(xe)return fe=fe(D),xe=J===""?"."+A(D,0):J,W(fe)?(C="",xe!=null&&(C=xe.replace(B,"$&/")+"/"),T(fe,K,C,"",function(rt){return rt})):fe!=null&&(le(fe)&&(fe=U(fe,C+(fe.key==null||D&&D.key===fe.key?"":(""+fe.key).replace(B,"$&/")+"/")+xe)),K.push(fe)),1;xe=0;var Ne=J===""?".":J+":";if(W(D))for(var Ce=0;Ce>>1,E=T[oe];if(0>>1;oea(C,H))Ja(fe,C)?(T[oe]=fe,T[J]=H,oe=J):(T[oe]=C,T[K]=H,oe=K);else if(Ja(fe,H))T[oe]=fe,T[J]=H,oe=J;else break e}}return j}function a(T,j){var H=T.sortIndex-j.sortIndex;return H!==0?H:T.id-j.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,f=c.now();e.unstable_now=function(){return c.now()-f}}var p=[],h=[],g=1,_=null,b=3,y=!1,x=!1,k=!1,L=!1,M=typeof setTimeout=="function"?setTimeout:null,Z=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;function Q(T){for(var j=n(h);j!==null;){if(j.callback===null)s(h);else if(j.startTime<=T)s(h),j.sortIndex=j.expirationTime,t(p,j);else break;j=n(h)}}function W(T){if(k=!1,Q(T),!x)if(n(p)!==null)x=!0,O||(O=!0,V());else{var j=n(h);j!==null&&R(W,j.startTime-T)}}var O=!1,ie=-1,ue=5,me=-1;function U(){return L?!0:!(e.unstable_now()-meT&&U());){var oe=_.callback;if(typeof oe=="function"){_.callback=null,b=_.priorityLevel;var E=oe(_.expirationTime<=T);if(T=e.unstable_now(),typeof E=="function"){_.callback=E,Q(T),j=!0;break t}_===n(p)&&s(p),Q(T)}else s(p);_=n(p)}if(_!==null)j=!0;else{var D=n(h);D!==null&&R(W,D.startTime-T),j=!1}}break e}finally{_=null,b=H,y=!1}j=void 0}}finally{j?V():O=!1}}}var V;if(typeof I=="function")V=function(){I(le)};else if(typeof MessageChannel<"u"){var B=new MessageChannel,A=B.port2;B.port1.onmessage=le,V=function(){A.postMessage(null)}}else V=function(){M(le,0)};function R(T,j){ie=M(function(){T(e.unstable_now())},j)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(T){T.callback=null},e.unstable_forceFrameRate=function(T){0>T||125oe?(T.sortIndex=H,t(h,T),n(p)===null&&T===n(h)&&(k?(Z(ie),ie=-1):k=!0,R(W,H-oe))):(T.sortIndex=E,t(p,T),x||y||(x=!0,O||(O=!0,V()))),T},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(T){var j=b;return function(){var H=b;b=j;try{return T.apply(this,arguments)}finally{b=H}}}})(Xh)),Xh}var ev;function wx(){return ev||(ev=1,Kh.exports=xx()),Kh.exports}var Gh={exports:{}},ei={};/** + * @license React + * react-dom.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var tv;function Cx(){if(tv)return ei;tv=1;var e=wd();function t(p){var h="https://react.dev/errors/"+p;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Gh.exports=Cx(),Gh.exports}/** + * @license React + * react-dom-client.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var nv;function Ex(){if(nv)return Gl;nv=1;var e=wx(),t=wd(),n=kx();function s(i){var r="https://react.dev/errors/"+i;if(1E||(i.current=oe[E],oe[E]=null,E--)}function C(i,r){E++,oe[E]=i.current,i.current=r}var J=D(null),fe=D(null),de=D(null),xe=D(null);function Ne(i,r){switch(C(de,r),C(fe,i),C(J,null),r.nodeType){case 9:case 11:i=(i=r.documentElement)&&(i=i.namespaceURI)?vg(i):0;break;default:if(i=r.tagName,r=r.namespaceURI)r=vg(r),i=yg(r,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}K(J),C(J,i)}function Ce(){K(J),K(fe),K(de)}function rt(i){i.memoizedState!==null&&C(xe,i);var r=J.current,l=yg(r,i.type);r!==l&&(C(fe,i),C(J,l))}function et(i){fe.current===i&&(K(J),K(fe)),xe.current===i&&(K(xe),Wl._currentValue=H)}var ut,we;function Et(i){if(ut===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);ut=r&&r[1]||"",we=-1)":-1d||N[u]!==q[d]){var ee=` +`+N[u].replace(" at new "," at ");return i.displayName&&ee.includes("")&&(ee=ee.replace("",i.displayName)),ee}while(1<=u&&0<=d);break}}}finally{en=!1,Error.prepareStackTrace=l}return(l=i?i.displayName||i.name:"")?Et(l):""}function ss(i,r){switch(i.tag){case 26:case 27:case 5:return Et(i.type);case 16:return Et("Lazy");case 13:return i.child!==r&&r!==null?Et("Suspense Fallback"):Et("Suspense");case 19:return Et("SuspenseList");case 0:case 15:return Wn(i.type,!1);case 11:return Wn(i.type.render,!1);case 1:return Wn(i.type,!0);case 31:return Et("Activity");default:return""}}function Er(i){try{var r="",l=null;do r+=ss(i,l),l=i,i=i.return;while(i);return r}catch(u){return` +Error generating stack: `+u.message+` +`+u.stack}}var pn=Object.prototype.hasOwnProperty,Tr=e.unstable_scheduleCallback,mn=e.unstable_cancelCallback,_n=e.unstable_shouldYield,gn=e.unstable_requestPaint,Wt=e.unstable_now,vn=e.unstable_getCurrentPriorityLevel,te=e.unstable_ImmediatePriority,X=e.unstable_UserBlockingPriority,he=e.unstable_NormalPriority,ve=e.unstable_LowPriority,Te=e.unstable_IdlePriority,vt=e.log,Yt=e.unstable_setDisableYieldValue,Tt=null,At=null;function hi(i){if(typeof vt=="function"&&Yt(i),At&&typeof At.setStrictMode=="function")try{At.setStrictMode(Tt,i)}catch{}}var $e=Math.clz32?Math.clz32:r0,Yn=Math.log,Xi=Math.LN2;function r0(i){return i>>>=0,i===0?32:31-(Yn(i)/Xi|0)|0}var Ba=256,Na=262144,La=4194304;function Ar(i){var r=i&42;if(r!==0)return r;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function za(i,r,l){var u=i.pendingLanes;if(u===0)return 0;var d=0,m=i.suspendedLanes,v=i.pingedLanes;i=i.warmLanes;var w=u&134217727;return w!==0?(u=w&~m,u!==0?d=Ar(u):(v&=w,v!==0?d=Ar(v):l||(l=w&~i,l!==0&&(d=Ar(l))))):(w=u&~m,w!==0?d=Ar(w):v!==0?d=Ar(v):l||(l=u&~i,l!==0&&(d=Ar(l)))),d===0?0:r!==0&&r!==d&&(r&m)===0&&(m=d&-d,l=r&-r,m>=l||m===32&&(l&4194048)!==0)?r:d}function nl(i,r){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&r)===0}function s0(i,r){switch(i){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Jd(){var i=La;return La<<=1,(La&62914560)===0&&(La=4194304),i}function Bu(i){for(var r=[],l=0;31>l;l++)r.push(i);return r}function rl(i,r){i.pendingLanes|=r,r!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function l0(i,r,l,u,d,m){var v=i.pendingLanes;i.pendingLanes=l,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=l,i.entangledLanes&=l,i.errorRecoveryDisabledLanes&=l,i.shellSuspendCounter=0;var w=i.entanglements,N=i.expirationTimes,q=i.hiddenUpdates;for(l=v&~l;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var f0=/[\n"\\]/g;function Li(i){return i.replace(f0,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Hu(i,r,l,u,d,m,v,w){i.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?i.type=v:i.removeAttribute("type"),r!=null?v==="number"?(r===0&&i.value===""||i.value!=r)&&(i.value=""+Ni(r)):i.value!==""+Ni(r)&&(i.value=""+Ni(r)):v!=="submit"&&v!=="reset"||i.removeAttribute("value"),r!=null?Pu(i,v,Ni(r)):l!=null?Pu(i,v,Ni(l)):u!=null&&i.removeAttribute("value"),d==null&&m!=null&&(i.defaultChecked=!!m),d!=null&&(i.checked=d&&typeof d!="function"&&typeof d!="symbol"),w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?i.name=""+Ni(w):i.removeAttribute("name")}function fp(i,r,l,u,d,m,v,w){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(i.type=m),r!=null||l!=null){if(!(m!=="submit"&&m!=="reset"||r!=null)){ju(i);return}l=l!=null?""+Ni(l):"",r=r!=null?""+Ni(r):l,w||r===i.value||(i.value=r),i.defaultValue=r}u=u??d,u=typeof u!="function"&&typeof u!="symbol"&&!!u,i.checked=w?i.checked:!!u,i.defaultChecked=!!u,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(i.name=v),ju(i)}function Pu(i,r,l){r==="number"&&Ha(i.ownerDocument)===i||i.defaultValue===""+l||(i.defaultValue=""+l)}function hs(i,r,l,u){if(i=i.options,r){r={};for(var d=0;d"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Wu=!1;if(Sn)try{var ol={};Object.defineProperty(ol,"passive",{get:function(){Wu=!0}}),window.addEventListener("test",ol,ol),window.removeEventListener("test",ol,ol)}catch{Wu=!1}var Kn=null,Yu=null,Ua=null;function yp(){if(Ua)return Ua;var i,r=Yu,l=r.length,u,d="value"in Kn?Kn.value:Kn.textContent,m=d.length;for(i=0;i=hl),kp=" ",Ep=!1;function Tp(i,r){switch(i){case"keyup":return U0.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ap(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var ms=!1;function F0(i,r){switch(i){case"compositionend":return Ap(r);case"keypress":return r.which!==32?null:(Ep=!0,kp);case"textInput":return i=r.data,i===kp&&Ep?null:i;default:return null}}function q0(i,r){if(ms)return i==="compositionend"||!$u&&Tp(i,r)?(i=yp(),Ua=Yu=Kn=null,ms=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1=r)return{node:l,offset:r-i};i=u}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Op(l)}}function Hp(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?Hp(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function Pp(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var r=Ha(i.document);r instanceof i.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)i=r.contentWindow;else break;r=Ha(i.document)}return r}function Ju(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}var Z0=Sn&&"documentMode"in document&&11>=document.documentMode,_s=null,ec=null,ml=null,tc=!1;function Up(i,r,l){var u=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;tc||_s==null||_s!==Ha(u)||(u=_s,"selectionStart"in u&&Ju(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),ml&&pl(ml,u)||(ml=u,u=Lo(ec,"onSelect"),0>=v,d-=v,tn=1<<32-$e(r)+d|l<De?(He=ge,ge=null):He=ge.sibling;var Fe=Y(P,ge,F[De],ne);if(Fe===null){ge===null&&(ge=He);break}i&&ge&&Fe.alternate===null&&r(P,ge),z=m(Fe,z,De),Ie===null?ye=Fe:Ie.sibling=Fe,Ie=Fe,ge=He}if(De===F.length)return l(P,ge),Pe&&wn(P,De),ye;if(ge===null){for(;DeDe?(He=ge,ge=null):He=ge.sibling;var mr=Y(P,ge,Fe.value,ne);if(mr===null){ge===null&&(ge=He);break}i&&ge&&mr.alternate===null&&r(P,ge),z=m(mr,z,De),Ie===null?ye=mr:Ie.sibling=mr,Ie=mr,ge=He}if(Fe.done)return l(P,ge),Pe&&wn(P,De),ye;if(ge===null){for(;!Fe.done;De++,Fe=F.next())Fe=re(P,Fe.value,ne),Fe!==null&&(z=m(Fe,z,De),Ie===null?ye=Fe:Ie.sibling=Fe,Ie=Fe);return Pe&&wn(P,De),ye}for(ge=u(ge);!Fe.done;De++,Fe=F.next())Fe=G(ge,P,De,Fe.value,ne),Fe!==null&&(i&&Fe.alternate!==null&&ge.delete(Fe.key===null?De:Fe.key),z=m(Fe,z,De),Ie===null?ye=Fe:Ie.sibling=Fe,Ie=Fe);return i&&ge.forEach(function(gx){return r(P,gx)}),Pe&&wn(P,De),ye}function Xe(P,z,F,ne){if(typeof F=="object"&&F!==null&&F.type===k&&F.key===null&&(F=F.props.children),typeof F=="object"&&F!==null){switch(F.$$typeof){case y:e:{for(var ye=F.key;z!==null;){if(z.key===ye){if(ye=F.type,ye===k){if(z.tag===7){l(P,z.sibling),ne=d(z,F.props.children),ne.return=P,P=ne;break e}}else if(z.elementType===ye||typeof ye=="object"&&ye!==null&&ye.$$typeof===ue&&Pr(ye)===z.type){l(P,z.sibling),ne=d(z,F.props),Sl(ne,F),ne.return=P,P=ne;break e}l(P,z);break}else r(P,z);z=z.sibling}F.type===k?(ne=Lr(F.props.children,P.mode,ne,F.key),ne.return=P,P=ne):(ne=$a(F.type,F.key,F.props,null,P.mode,ne),Sl(ne,F),ne.return=P,P=ne)}return v(P);case x:e:{for(ye=F.key;z!==null;){if(z.key===ye)if(z.tag===4&&z.stateNode.containerInfo===F.containerInfo&&z.stateNode.implementation===F.implementation){l(P,z.sibling),ne=d(z,F.children||[]),ne.return=P,P=ne;break e}else{l(P,z);break}else r(P,z);z=z.sibling}ne=oc(F,P.mode,ne),ne.return=P,P=ne}return v(P);case ue:return F=Pr(F),Xe(P,z,F,ne)}if(R(F))return _e(P,z,F,ne);if(V(F)){if(ye=V(F),typeof ye!="function")throw Error(s(150));return F=ye.call(F),Se(P,z,F,ne)}if(typeof F.then=="function")return Xe(P,z,no(F),ne);if(F.$$typeof===I)return Xe(P,z,Ja(P,F),ne);ro(P,F)}return typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint"?(F=""+F,z!==null&&z.tag===6?(l(P,z.sibling),ne=d(z,F),ne.return=P,P=ne):(l(P,z),ne=ac(F,P.mode,ne),ne.return=P,P=ne),v(P)):l(P,z)}return function(P,z,F,ne){try{bl=0;var ye=Xe(P,z,F,ne);return Ts=null,ye}catch(ge){if(ge===Es||ge===to)throw ge;var Ie=wi(29,ge,null,P.mode);return Ie.lanes=ne,Ie.return=P,Ie}finally{}}}var Ir=um(!0),cm=um(!1),Qn=!1;function bc(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Sc(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function Jn(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function er(i,r,l){var u=i.updateQueue;if(u===null)return null;if(u=u.shared,(qe&2)!==0){var d=u.pending;return d===null?r.next=r:(r.next=d.next,d.next=r),u.pending=r,r=Ga(i),Kp(i,null,l),r}return Xa(i,u,r,l),Ga(i)}function xl(i,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194048)!==0)){var u=r.lanes;u&=i.pendingLanes,l|=u,r.lanes=l,tp(i,l)}}function xc(i,r){var l=i.updateQueue,u=i.alternate;if(u!==null&&(u=u.updateQueue,l===u)){var d=null,m=null;if(l=l.firstBaseUpdate,l!==null){do{var v={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};m===null?d=m=v:m=m.next=v,l=l.next}while(l!==null);m===null?d=m=r:m=m.next=r}else d=m=r;l={baseState:u.baseState,firstBaseUpdate:d,lastBaseUpdate:m,shared:u.shared,callbacks:u.callbacks},i.updateQueue=l;return}i=l.lastBaseUpdate,i===null?l.firstBaseUpdate=r:i.next=r,l.lastBaseUpdate=r}var wc=!1;function wl(){if(wc){var i=ks;if(i!==null)throw i}}function Cl(i,r,l,u){wc=!1;var d=i.updateQueue;Qn=!1;var m=d.firstBaseUpdate,v=d.lastBaseUpdate,w=d.shared.pending;if(w!==null){d.shared.pending=null;var N=w,q=N.next;N.next=null,v===null?m=q:v.next=q,v=N;var ee=i.alternate;ee!==null&&(ee=ee.updateQueue,w=ee.lastBaseUpdate,w!==v&&(w===null?ee.firstBaseUpdate=q:w.next=q,ee.lastBaseUpdate=N))}if(m!==null){var re=d.baseState;v=0,ee=q=N=null,w=m;do{var Y=w.lane&-536870913,G=Y!==w.lane;if(G?(je&Y)===Y:(u&Y)===Y){Y!==0&&Y===Cs&&(wc=!0),ee!==null&&(ee=ee.next={lane:0,tag:w.tag,payload:w.payload,callback:null,next:null});e:{var _e=i,Se=w;Y=r;var Xe=l;switch(Se.tag){case 1:if(_e=Se.payload,typeof _e=="function"){re=_e.call(Xe,re,Y);break e}re=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Se.payload,Y=typeof _e=="function"?_e.call(Xe,re,Y):_e,Y==null)break e;re=_({},re,Y);break e;case 2:Qn=!0}}Y=w.callback,Y!==null&&(i.flags|=64,G&&(i.flags|=8192),G=d.callbacks,G===null?d.callbacks=[Y]:G.push(Y))}else G={lane:Y,tag:w.tag,payload:w.payload,callback:w.callback,next:null},ee===null?(q=ee=G,N=re):ee=ee.next=G,v|=Y;if(w=w.next,w===null){if(w=d.shared.pending,w===null)break;G=w,w=G.next,G.next=null,d.lastBaseUpdate=G,d.shared.pending=null}}while(!0);ee===null&&(N=re),d.baseState=N,d.firstBaseUpdate=q,d.lastBaseUpdate=ee,m===null&&(d.shared.lanes=0),sr|=v,i.lanes=v,i.memoizedState=re}}function hm(i,r){if(typeof i!="function")throw Error(s(191,i));i.call(r)}function fm(i,r){var l=i.callbacks;if(l!==null)for(i.callbacks=null,i=0;im?m:8;var v=T.T,w={};T.T=w,Fc(i,!1,r,l);try{var N=d(),q=T.S;if(q!==null&&q(w,N),N!==null&&typeof N=="object"&&typeof N.then=="function"){var ee=l1(N,u);Tl(i,r,ee,Ai(i))}else Tl(i,r,u,Ai(i))}catch(re){Tl(i,r,{then:function(){},status:"rejected",reason:re},Ai())}finally{j.p=m,v!==null&&w.types!==null&&(v.types=w.types),T.T=v}}function f1(){}function Uc(i,r,l,u){if(i.tag!==5)throw Error(s(476));var d=Wm(i).queue;qm(i,d,r,H,l===null?f1:function(){return Ym(i),l(u)})}function Wm(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:H,baseState:H,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Tn,lastRenderedState:H},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Tn,lastRenderedState:l},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function Ym(i){var r=Wm(i);r.next===null&&(r=i.alternate.memoizedState),Tl(i,r.next.queue,{},Ai())}function Ic(){return Xt(Wl)}function Vm(){return _t().memoizedState}function Km(){return _t().memoizedState}function d1(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var l=Ai();i=Jn(l);var u=er(r,i,l);u!==null&&(vi(u,r,l),xl(u,r,l)),r={cache:_c()},i.payload=r;return}r=r.return}}function p1(i,r,l){var u=Ai();l={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},mo(i)?Gm(r,l):(l=sc(i,r,l,u),l!==null&&(vi(l,i,u),$m(l,r,u)))}function Xm(i,r,l){var u=Ai();Tl(i,r,l,u)}function Tl(i,r,l,u){var d={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(mo(i))Gm(r,d);else{var m=i.alternate;if(i.lanes===0&&(m===null||m.lanes===0)&&(m=r.lastRenderedReducer,m!==null))try{var v=r.lastRenderedState,w=m(v,l);if(d.hasEagerState=!0,d.eagerState=w,xi(w,v))return Xa(i,r,d,0),Ze===null&&Ka(),!1}catch{}finally{}if(l=sc(i,r,d,u),l!==null)return vi(l,i,u),$m(l,r,u),!0}return!1}function Fc(i,r,l,u){if(u={lane:2,revertLane:bh(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},mo(i)){if(r)throw Error(s(479))}else r=sc(i,l,u,2),r!==null&&vi(r,i,2)}function mo(i){var r=i.alternate;return i===Ae||r!==null&&r===Ae}function Gm(i,r){Ds=ao=!0;var l=i.pending;l===null?r.next=r:(r.next=l.next,l.next=r),i.pending=r}function $m(i,r,l){if((l&4194048)!==0){var u=r.lanes;u&=i.pendingLanes,l|=u,r.lanes=l,tp(i,l)}}var Al={readContext:Xt,use:co,useCallback:ct,useContext:ct,useEffect:ct,useImperativeHandle:ct,useLayoutEffect:ct,useInsertionEffect:ct,useMemo:ct,useReducer:ct,useRef:ct,useState:ct,useDebugValue:ct,useDeferredValue:ct,useTransition:ct,useSyncExternalStore:ct,useId:ct,useHostTransitionStatus:ct,useFormState:ct,useActionState:ct,useOptimistic:ct,useMemoCache:ct,useCacheRefresh:ct};Al.useEffectEvent=ct;var Zm={readContext:Xt,use:co,useCallback:function(i,r){return si().memoizedState=[i,r===void 0?null:r],i},useContext:Xt,useEffect:Lm,useImperativeHandle:function(i,r,l){l=l!=null?l.concat([i]):null,fo(4194308,4,Hm.bind(null,r,i),l)},useLayoutEffect:function(i,r){return fo(4194308,4,i,r)},useInsertionEffect:function(i,r){fo(4,2,i,r)},useMemo:function(i,r){var l=si();r=r===void 0?null:r;var u=i();if(Fr){hi(!0);try{i()}finally{hi(!1)}}return l.memoizedState=[u,r],u},useReducer:function(i,r,l){var u=si();if(l!==void 0){var d=l(r);if(Fr){hi(!0);try{l(r)}finally{hi(!1)}}}else d=r;return u.memoizedState=u.baseState=d,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:d},u.queue=i,i=i.dispatch=p1.bind(null,Ae,i),[u.memoizedState,i]},useRef:function(i){var r=si();return i={current:i},r.memoizedState=i},useState:function(i){i=zc(i);var r=i.queue,l=Xm.bind(null,Ae,r);return r.dispatch=l,[i.memoizedState,l]},useDebugValue:Hc,useDeferredValue:function(i,r){var l=si();return Pc(l,i,r)},useTransition:function(){var i=zc(!1);return i=qm.bind(null,Ae,i.queue,!0,!1),si().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,l){var u=Ae,d=si();if(Pe){if(l===void 0)throw Error(s(407));l=l()}else{if(l=r(),Ze===null)throw Error(s(349));(je&127)!==0||vm(u,r,l)}d.memoizedState=l;var m={value:l,getSnapshot:r};return d.queue=m,Lm(bm.bind(null,u,m,i),[i]),u.flags|=2048,Ms(9,{destroy:void 0},ym.bind(null,u,m,l,r),null),l},useId:function(){var i=si(),r=Ze.identifierPrefix;if(Pe){var l=nn,u=tn;l=(u&~(1<<32-$e(u)-1)).toString(32)+l,r="_"+r+"R_"+l,l=oo++,0<\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof u.is=="string"?v.createElement("select",{is:u.is}):v.createElement("select"),u.multiple?m.multiple=!0:u.size&&(m.size=u.size);break;default:m=typeof u.is=="string"?v.createElement(d,{is:u.is}):v.createElement(d)}}m[Vt]=r,m[fi]=u;e:for(v=r.child;v!==null;){if(v.tag===5||v.tag===6)m.appendChild(v.stateNode);else if(v.tag!==4&&v.tag!==27&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===r)break e;for(;v.sibling===null;){if(v.return===null||v.return===r)break e;v=v.return}v.sibling.return=v.return,v=v.sibling}r.stateNode=m;e:switch($t(m,d,u),d){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&Dn(r)}}return it(r),ih(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,l),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==u&&Dn(r);else{if(typeof u!="string"&&r.stateNode===null)throw Error(s(166));if(i=de.current,xs(r)){if(i=r.stateNode,l=r.memoizedProps,u=null,d=Kt,d!==null)switch(d.tag){case 27:case 5:u=d.memoizedProps}i[Vt]=r,i=!!(i.nodeValue===l||u!==null&&u.suppressHydrationWarning===!0||_g(i.nodeValue,l)),i||$n(r,!0)}else i=zo(i).createTextNode(u),i[Vt]=r,r.stateNode=i}return it(r),null;case 31:if(l=r.memoizedState,i===null||i.memoizedState!==null){if(u=xs(r),l!==null){if(i===null){if(!u)throw Error(s(318));if(i=r.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[Vt]=r}else zr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;it(r),i=!1}else l=fc(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=l),i=!0;if(!i)return r.flags&256?(ki(r),r):(ki(r),null);if((r.flags&128)!==0)throw Error(s(558))}return it(r),null;case 13:if(u=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(d=xs(r),u!==null&&u.dehydrated!==null){if(i===null){if(!d)throw Error(s(318));if(d=r.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(s(317));d[Vt]=r}else zr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;it(r),d=!1}else d=fc(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=d),d=!0;if(!d)return r.flags&256?(ki(r),r):(ki(r),null)}return ki(r),(r.flags&128)!==0?(r.lanes=l,r):(l=u!==null,i=i!==null&&i.memoizedState!==null,l&&(u=r.child,d=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(d=u.alternate.memoizedState.cachePool.pool),m=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(m=u.memoizedState.cachePool.pool),m!==d&&(u.flags|=2048)),l!==i&&l&&(r.child.flags|=8192),bo(r,r.updateQueue),it(r),null);case 4:return Ce(),i===null&&Ch(r.stateNode.containerInfo),it(r),null;case 10:return kn(r.type),it(r),null;case 19:if(K(mt),u=r.memoizedState,u===null)return it(r),null;if(d=(r.flags&128)!==0,m=u.rendering,m===null)if(d)Rl(u,!1);else{if(ht!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(m=lo(i),m!==null){for(r.flags|=128,Rl(u,!1),i=m.updateQueue,r.updateQueue=i,bo(r,i),r.subtreeFlags=0,i=l,l=r.child;l!==null;)Xp(l,i),l=l.sibling;return C(mt,mt.current&1|2),Pe&&wn(r,u.treeForkCount),r.child}i=i.sibling}u.tail!==null&&Wt()>ko&&(r.flags|=128,d=!0,Rl(u,!1),r.lanes=4194304)}else{if(!d)if(i=lo(m),i!==null){if(r.flags|=128,d=!0,i=i.updateQueue,r.updateQueue=i,bo(r,i),Rl(u,!0),u.tail===null&&u.tailMode==="hidden"&&!m.alternate&&!Pe)return it(r),null}else 2*Wt()-u.renderingStartTime>ko&&l!==536870912&&(r.flags|=128,d=!0,Rl(u,!1),r.lanes=4194304);u.isBackwards?(m.sibling=r.child,r.child=m):(i=u.last,i!==null?i.sibling=m:r.child=m,u.last=m)}return u.tail!==null?(i=u.tail,u.rendering=i,u.tail=i.sibling,u.renderingStartTime=Wt(),i.sibling=null,l=mt.current,C(mt,d?l&1|2:l&1),Pe&&wn(r,u.treeForkCount),i):(it(r),null);case 22:case 23:return ki(r),kc(),u=r.memoizedState!==null,i!==null?i.memoizedState!==null!==u&&(r.flags|=8192):u&&(r.flags|=8192),u?(l&536870912)!==0&&(r.flags&128)===0&&(it(r),r.subtreeFlags&6&&(r.flags|=8192)):it(r),l=r.updateQueue,l!==null&&bo(r,l.retryQueue),l=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(l=i.memoizedState.cachePool.pool),u=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),u!==l&&(r.flags|=2048),i!==null&&K(Hr),null;case 24:return l=null,i!==null&&(l=i.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),kn(yt),it(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function y1(i,r){switch(cc(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return kn(yt),Ce(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return et(r),null;case 31:if(r.memoizedState!==null){if(ki(r),r.alternate===null)throw Error(s(340));zr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(ki(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(s(340));zr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return K(mt),null;case 4:return Ce(),null;case 10:return kn(r.type),null;case 22:case 23:return ki(r),kc(),i!==null&&K(Hr),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return kn(yt),null;case 25:return null;default:return null}}function S_(i,r){switch(cc(r),r.tag){case 3:kn(yt),Ce();break;case 26:case 27:case 5:et(r);break;case 4:Ce();break;case 31:r.memoizedState!==null&&ki(r);break;case 13:ki(r);break;case 19:K(mt);break;case 10:kn(r.type);break;case 22:case 23:ki(r),kc(),i!==null&&K(Hr);break;case 24:kn(yt)}}function Ml(i,r){try{var l=r.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var d=u.next;l=d;do{if((l.tag&i)===i){u=void 0;var m=l.create,v=l.inst;u=m(),v.destroy=u}l=l.next}while(l!==d)}}catch(w){Ye(r,r.return,w)}}function nr(i,r,l){try{var u=r.updateQueue,d=u!==null?u.lastEffect:null;if(d!==null){var m=d.next;u=m;do{if((u.tag&i)===i){var v=u.inst,w=v.destroy;if(w!==void 0){v.destroy=void 0,d=r;var N=l,q=w;try{q()}catch(ee){Ye(d,N,ee)}}}u=u.next}while(u!==m)}}catch(ee){Ye(r,r.return,ee)}}function x_(i){var r=i.updateQueue;if(r!==null){var l=i.stateNode;try{fm(r,l)}catch(u){Ye(i,i.return,u)}}}function w_(i,r,l){l.props=qr(i.type,i.memoizedProps),l.state=i.memoizedState;try{l.componentWillUnmount()}catch(u){Ye(i,r,u)}}function Bl(i,r){try{var l=i.ref;if(l!==null){switch(i.tag){case 26:case 27:case 5:var u=i.stateNode;break;case 30:u=i.stateNode;break;default:u=i.stateNode}typeof l=="function"?i.refCleanup=l(u):l.current=u}}catch(d){Ye(i,r,d)}}function rn(i,r){var l=i.ref,u=i.refCleanup;if(l!==null)if(typeof u=="function")try{u()}catch(d){Ye(i,r,d)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(d){Ye(i,r,d)}else l.current=null}function C_(i){var r=i.type,l=i.memoizedProps,u=i.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":l.autoFocus&&u.focus();break e;case"img":l.src?u.src=l.src:l.srcSet&&(u.srcset=l.srcSet)}}catch(d){Ye(i,i.return,d)}}function nh(i,r,l){try{var u=i.stateNode;I1(u,i.type,l,r),u[fi]=r}catch(d){Ye(i,i.return,d)}}function k_(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&cr(i.type)||i.tag===4}function rh(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||k_(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&cr(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function sh(i,r,l){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(i,r):(r=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,r.appendChild(i),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=bn));else if(u!==4&&(u===27&&cr(i.type)&&(l=i.stateNode,r=null),i=i.child,i!==null))for(sh(i,r,l),i=i.sibling;i!==null;)sh(i,r,l),i=i.sibling}function So(i,r,l){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?l.insertBefore(i,r):l.appendChild(i);else if(u!==4&&(u===27&&cr(i.type)&&(l=i.stateNode),i=i.child,i!==null))for(So(i,r,l),i=i.sibling;i!==null;)So(i,r,l),i=i.sibling}function E_(i){var r=i.stateNode,l=i.memoizedProps;try{for(var u=i.type,d=r.attributes;d.length;)r.removeAttributeNode(d[0]);$t(r,u,l),r[Vt]=i,r[fi]=l}catch(m){Ye(i,i.return,m)}}var Rn=!1,xt=!1,lh=!1,T_=typeof WeakSet=="function"?WeakSet:Set,zt=null;function b1(i,r){if(i=i.containerInfo,Th=Fo,i=Pp(i),Ju(i)){if("selectionStart"in i)var l={start:i.selectionStart,end:i.selectionEnd};else e:{l=(l=i.ownerDocument)&&l.defaultView||window;var u=l.getSelection&&l.getSelection();if(u&&u.rangeCount!==0){l=u.anchorNode;var d=u.anchorOffset,m=u.focusNode;u=u.focusOffset;try{l.nodeType,m.nodeType}catch{l=null;break e}var v=0,w=-1,N=-1,q=0,ee=0,re=i,Y=null;t:for(;;){for(var G;re!==l||d!==0&&re.nodeType!==3||(w=v+d),re!==m||u!==0&&re.nodeType!==3||(N=v+u),re.nodeType===3&&(v+=re.nodeValue.length),(G=re.firstChild)!==null;)Y=re,re=G;for(;;){if(re===i)break t;if(Y===l&&++q===d&&(w=v),Y===m&&++ee===u&&(N=v),(G=re.nextSibling)!==null)break;re=Y,Y=re.parentNode}re=G}l=w===-1||N===-1?null:{start:w,end:N}}else l=null}l=l||{start:0,end:0}}else l=null;for(Ah={focusedElem:i,selectionRange:l},Fo=!1,zt=r;zt!==null;)if(r=zt,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,zt=i;else for(;zt!==null;){switch(r=zt,m=r.alternate,i=r.flags,r.tag){case 0:if((i&4)!==0&&(i=r.updateQueue,i=i!==null?i.events:null,i!==null))for(l=0;l title"))),$t(m,u,l),m[Vt]=i,Lt(m),u=m;break e;case"link":var v=Ng("link","href",d).get(u+(l.href||""));if(v){for(var w=0;wXe&&(v=Xe,Xe=Se,Se=v);var P=jp(w,Se),z=jp(w,Xe);if(P&&z&&(G.rangeCount!==1||G.anchorNode!==P.node||G.anchorOffset!==P.offset||G.focusNode!==z.node||G.focusOffset!==z.offset)){var F=re.createRange();F.setStart(P.node,P.offset),G.removeAllRanges(),Se>Xe?(G.addRange(F),G.extend(z.node,z.offset)):(F.setEnd(z.node,z.offset),G.addRange(F))}}}}for(re=[],G=w;G=G.parentNode;)G.nodeType===1&&re.push({element:G,left:G.scrollLeft,top:G.scrollTop});for(typeof w.focus=="function"&&w.focus(),w=0;wl?32:l,T.T=null,l=dh,dh=null;var m=ar,v=zn;if(Dt=0,Os=ar=null,zn=0,(qe&6)!==0)throw Error(s(331));var w=qe;if(qe|=4,H_(m.current),z_(m,m.current,v,l),qe=w,Hl(0,!1),At&&typeof At.onPostCommitFiberRoot=="function")try{At.onPostCommitFiberRoot(Tt,m)}catch{}return!0}finally{j.p=d,T.T=u,ig(i,r)}}function rg(i,r,l){r=Oi(l,r),r=Vc(i.stateNode,r,2),i=er(i,r,2),i!==null&&(rl(i,2),sn(i))}function Ye(i,r,l){if(i.tag===3)rg(i,i,l);else for(;r!==null;){if(r.tag===3){rg(r,i,l);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(lr===null||!lr.has(u))){i=Oi(l,i),l=s_(2),u=er(r,l,2),u!==null&&(l_(l,u,r,i),rl(u,2),sn(u));break}}r=r.return}}function gh(i,r,l){var u=i.pingCache;if(u===null){u=i.pingCache=new w1;var d=new Set;u.set(r,d)}else d=u.get(r),d===void 0&&(d=new Set,u.set(r,d));d.has(l)||(uh=!0,d.add(l),i=A1.bind(null,i,r,l),r.then(i,i))}function A1(i,r,l){var u=i.pingCache;u!==null&&u.delete(r),i.pingedLanes|=i.suspendedLanes&l,i.warmLanes&=~l,Ze===i&&(je&l)===l&&(ht===4||ht===3&&(je&62914560)===je&&300>Wt()-Co?(qe&2)===0&&js(i,0):ch|=l,zs===je&&(zs=0)),sn(i)}function sg(i,r){r===0&&(r=Jd()),i=Nr(i,r),i!==null&&(rl(i,r),sn(i))}function D1(i){var r=i.memoizedState,l=0;r!==null&&(l=r.retryLane),sg(i,l)}function R1(i,r){var l=0;switch(i.tag){case 31:case 13:var u=i.stateNode,d=i.memoizedState;d!==null&&(l=d.retryLane);break;case 19:u=i.stateNode;break;case 22:u=i.stateNode._retryCache;break;default:throw Error(s(314))}u!==null&&u.delete(r),sg(i,l)}function M1(i,r){return Tr(i,r)}var Mo=null,Ps=null,vh=!1,Bo=!1,yh=!1,ur=0;function sn(i){i!==Ps&&i.next===null&&(Ps===null?Mo=Ps=i:Ps=Ps.next=i),Bo=!0,vh||(vh=!0,N1())}function Hl(i,r){if(!yh&&Bo){yh=!0;do for(var l=!1,u=Mo;u!==null;){if(i!==0){var d=u.pendingLanes;if(d===0)var m=0;else{var v=u.suspendedLanes,w=u.pingedLanes;m=(1<<31-$e(42|i)+1)-1,m&=d&~(v&~w),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(l=!0,ug(u,m))}else m=je,m=za(u,u===Ze?m:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(m&3)===0||nl(u,m)||(l=!0,ug(u,m));u=u.next}while(l);yh=!1}}function B1(){lg()}function lg(){Bo=vh=!1;var i=0;ur!==0&&q1()&&(i=ur);for(var r=Wt(),l=null,u=Mo;u!==null;){var d=u.next,m=ag(u,r);m===0?(u.next=null,l===null?Mo=d:l.next=d,d===null&&(Ps=l)):(l=u,(i!==0||(m&3)!==0)&&(Bo=!0)),u=d}Dt!==0&&Dt!==5||Hl(i),ur!==0&&(ur=0)}function ag(i,r){for(var l=i.suspendedLanes,u=i.pingedLanes,d=i.expirationTimes,m=i.pendingLanes&-62914561;0w)break;var ee=N.transferSize,re=N.initiatorType;ee&&gg(re)&&(N=N.responseEnd,v+=ee*(N"u"?null:document;function Dg(i,r,l){var u=Us;if(u&&typeof r=="string"&&r){var d=Li(r);d='link[rel="'+i+'"][href="'+d+'"]',typeof l=="string"&&(d+='[crossorigin="'+l+'"]'),Ag.has(d)||(Ag.add(d),i={rel:i,crossOrigin:l,href:r},u.querySelector(d)===null&&(r=u.createElement("link"),$t(r,"link",i),Lt(r),u.head.appendChild(r)))}}function Q1(i){On.D(i),Dg("dns-prefetch",i,null)}function J1(i,r){On.C(i,r),Dg("preconnect",i,r)}function ex(i,r,l){On.L(i,r,l);var u=Us;if(u&&i&&r){var d='link[rel="preload"][as="'+Li(r)+'"]';r==="image"&&l&&l.imageSrcSet?(d+='[imagesrcset="'+Li(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(d+='[imagesizes="'+Li(l.imageSizes)+'"]')):d+='[href="'+Li(i)+'"]';var m=d;switch(r){case"style":m=Is(i);break;case"script":m=Fs(i)}Fi.has(m)||(i=_({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:i,as:r},l),Fi.set(m,i),u.querySelector(d)!==null||r==="style"&&u.querySelector(Fl(m))||r==="script"&&u.querySelector(ql(m))||(r=u.createElement("link"),$t(r,"link",i),Lt(r),u.head.appendChild(r)))}}function tx(i,r){On.m(i,r);var l=Us;if(l&&i){var u=r&&typeof r.as=="string"?r.as:"script",d='link[rel="modulepreload"][as="'+Li(u)+'"][href="'+Li(i)+'"]',m=d;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=Fs(i)}if(!Fi.has(m)&&(i=_({rel:"modulepreload",href:i},r),Fi.set(m,i),l.querySelector(d)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(ql(m)))return}u=l.createElement("link"),$t(u,"link",i),Lt(u),l.head.appendChild(u)}}}function ix(i,r,l){On.S(i,r,l);var u=Us;if(u&&i){var d=us(u).hoistableStyles,m=Is(i);r=r||"default";var v=d.get(m);if(!v){var w={loading:0,preload:null};if(v=u.querySelector(Fl(m)))w.loading=5;else{i=_({rel:"stylesheet",href:i,"data-precedence":r},l),(l=Fi.get(m))&&zh(i,l);var N=v=u.createElement("link");Lt(N),$t(N,"link",i),N._p=new Promise(function(q,ee){N.onload=q,N.onerror=ee}),N.addEventListener("load",function(){w.loading|=1}),N.addEventListener("error",function(){w.loading|=2}),w.loading|=4,jo(v,r,u)}v={type:"stylesheet",instance:v,count:1,state:w},d.set(m,v)}}}function nx(i,r){On.X(i,r);var l=Us;if(l&&i){var u=us(l).hoistableScripts,d=Fs(i),m=u.get(d);m||(m=l.querySelector(ql(d)),m||(i=_({src:i,async:!0},r),(r=Fi.get(d))&&Oh(i,r),m=l.createElement("script"),Lt(m),$t(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(d,m))}}function rx(i,r){On.M(i,r);var l=Us;if(l&&i){var u=us(l).hoistableScripts,d=Fs(i),m=u.get(d);m||(m=l.querySelector(ql(d)),m||(i=_({src:i,async:!0,type:"module"},r),(r=Fi.get(d))&&Oh(i,r),m=l.createElement("script"),Lt(m),$t(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(d,m))}}function Rg(i,r,l,u){var d=(d=de.current)?Oo(d):null;if(!d)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(r=Is(l.href),l=us(d).hoistableStyles,u=l.get(r),u||(u={type:"style",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){i=Is(l.href);var m=us(d).hoistableStyles,v=m.get(i);if(v||(d=d.ownerDocument||d,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(i,v),(m=d.querySelector(Fl(i)))&&!m._p&&(v.instance=m,v.state.loading=5),Fi.has(i)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Fi.set(i,l),m||sx(d,i,l,v.state))),r&&u===null)throw Error(s(528,""));return v}if(r&&u!==null)throw Error(s(529,""));return null;case"script":return r=l.async,l=l.src,typeof l=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Fs(l),l=us(d).hoistableScripts,u=l.get(r),u||(u={type:"script",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,i))}}function Is(i){return'href="'+Li(i)+'"'}function Fl(i){return'link[rel="stylesheet"]['+i+"]"}function Mg(i){return _({},i,{"data-precedence":i.precedence,precedence:null})}function sx(i,r,l,u){i.querySelector('link[rel="preload"][as="style"]['+r+"]")?u.loading=1:(r=i.createElement("link"),u.preload=r,r.addEventListener("load",function(){return u.loading|=1}),r.addEventListener("error",function(){return u.loading|=2}),$t(r,"link",l),Lt(r),i.head.appendChild(r))}function Fs(i){return'[src="'+Li(i)+'"]'}function ql(i){return"script[async]"+i}function Bg(i,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var u=i.querySelector('style[data-href~="'+Li(l.href)+'"]');if(u)return r.instance=u,Lt(u),u;var d=_({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return u=(i.ownerDocument||i).createElement("style"),Lt(u),$t(u,"style",d),jo(u,l.precedence,i),r.instance=u;case"stylesheet":d=Is(l.href);var m=i.querySelector(Fl(d));if(m)return r.state.loading|=4,r.instance=m,Lt(m),m;u=Mg(l),(d=Fi.get(d))&&zh(u,d),m=(i.ownerDocument||i).createElement("link"),Lt(m);var v=m;return v._p=new Promise(function(w,N){v.onload=w,v.onerror=N}),$t(m,"link",u),r.state.loading|=4,jo(m,l.precedence,i),r.instance=m;case"script":return m=Fs(l.src),(d=i.querySelector(ql(m)))?(r.instance=d,Lt(d),d):(u=l,(d=Fi.get(m))&&(u=_({},l),Oh(u,d)),i=i.ownerDocument||i,d=i.createElement("script"),Lt(d),$t(d,"link",u),i.head.appendChild(d),r.instance=d);case"void":return null;default:throw Error(s(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(u=r.instance,r.state.loading|=4,jo(u,l.precedence,i));return r.instance}function jo(i,r,l){for(var u=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=u.length?u[u.length-1]:null,m=d,v=0;v title"):null)}function lx(i,r,l){if(l===1||r.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return i=r.disabled,typeof r.precedence=="string"&&i==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function zg(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function ax(i,r,l,u){if(l.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var d=Is(u.href),m=r.querySelector(Fl(d));if(m){r=m._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=Po.bind(i),r.then(i,i)),l.state.loading|=4,l.instance=m,Lt(m);return}m=r.ownerDocument||r,u=Mg(u),(d=Fi.get(d))&&zh(u,d),m=m.createElement("link"),Lt(m);var v=m;v._p=new Promise(function(w,N){v.onload=w,v.onerror=N}),$t(m,"link",u),l.instance=m}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(l,r),(r=l.state.preload)&&(l.state.loading&3)===0&&(i.count++,l=Po.bind(i),r.addEventListener("load",l),r.addEventListener("error",l))}}var jh=0;function ox(i,r){return i.stylesheets&&i.count===0&&Io(i,i.stylesheets),0jh?50:800)+r);return i.unsuspend=l,function(){i.unsuspend=null,clearTimeout(u),clearTimeout(d)}}:null}function Po(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Io(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Uo=null;function Io(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Uo=new Map,r.forEach(ux,i),Uo=null,Po.call(i))}function ux(i,r){if(!(r.state.loading&4)){var l=Uo.get(i);if(l)var u=l.get(null);else{l=new Map,Uo.set(i,l);for(var d=i.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Vh.exports=Ex(),Vh.exports}var Ax=Tx();const Dx=xu(Ax);function Rx({onLogin:e}){const[t,n]=$.useState(""),[s,a]=$.useState(null),[o,c]=$.useState(!1),f=async p=>{if(p.preventDefault(),!t.trim())return;c(!0),a(null);const h=await e(t);h&&a(h),c(!1)};return S.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:S.jsxs("div",{className:"w-full max-w-sm",children:[S.jsxs("div",{className:"border-border rounded border p-6",children:[S.jsxs("div",{className:"mb-6 text-center",children:[S.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),S.jsx("p",{className:"text-muted mt-1 text-xs",children:"local writer agent"})]}),S.jsxs("form",{onSubmit:f,className:"space-y-4",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),S.jsx("input",{type:"password",value:t,onChange:p=>n(p.target.value),placeholder:"enter your passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),s&&S.jsx("p",{className:"text-error text-xs",children:s}),S.jsx("button",{type:"submit",disabled:o||!t.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:o?"authenticating...":"unlock"})]})]}),S.jsx("p",{className:"text-muted mt-4 text-center text-[10px]",children:"enter your passphrase to unlock"})]})})}function Mx({onSetup:e}){const[t,n]=$.useState(""),[s,a]=$.useState(""),[o,c]=$.useState(null),[f,p]=$.useState(!1),h=async g=>{if(g.preventDefault(),!t.trim()||t.length<4){c("Passphrase must be at least 4 characters");return}if(t!==s){c("Passphrases do not match");return}p(!0),c(null);const _=await e(t);_&&c(_),p(!1)};return S.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:S.jsx("div",{className:"w-full max-w-sm",children:S.jsxs("div",{className:"border-border rounded border p-6",children:[S.jsxs("div",{className:"mb-6 text-center",children:[S.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),S.jsx("p",{className:"text-muted mt-1 text-xs",children:"first-time setup"})]}),S.jsx("p",{className:"text-muted mb-4 text-xs leading-relaxed",children:"Choose a passphrase to protect your local writer agent. This will be used to unlock the app and secure your OWS wallet."}),S.jsxs("form",{onSubmit:h,className:"space-y-4",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),S.jsx("input",{type:"password",value:t,onChange:g=>n(g.target.value),placeholder:"choose a passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Confirm"}),S.jsx("input",{type:"password",value:s,onChange:g=>a(g.target.value),placeholder:"repeat passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),o&&S.jsx("p",{className:"text-error text-xs",children:o}),S.jsx("button",{type:"submit",disabled:f||!t.trim()||!s.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:f?"setting up...":"create passphrase"})]})]})})})}const sv="http://localhost:7777";function eb({token:e}){const[t,n]=$.useState(null),[s,a]=$.useState(!1),[o,c]=$.useState(!1),[f,p]=$.useState(null),h=(x,k)=>fetch(x,{...k,headers:{...k==null?void 0:k.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),g=()=>{h(`${sv}/api/wallet`).then(x=>x.json()).then(x=>n(x)).catch(()=>n({exists:!1,error:"Failed to load wallet"}))};$.useEffect(()=>{g()},[]);const _=async()=>{a(!0),p(null);try{const x=await h(`${sv}/api/wallet/create`,{method:"POST"}),k=await x.json();if(!x.ok)throw new Error(k.error||"Creation failed");g()}catch(x){p(x instanceof Error?x.message:"Failed to create wallet")}a(!1)},b=()=>{t!=null&&t.address&&(navigator.clipboard.writeText(t.address),c(!0),setTimeout(()=>c(!1),2e3))},y=x=>`${x.slice(0,6)}...${x.slice(-4)}`;return S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"OWS Wallet"}),!t&&S.jsx("p",{className:"text-muted text-xs",children:"loading..."}),t&&!t.exists&&S.jsxs("div",{className:"space-y-3",children:[S.jsx("p",{className:"text-muted text-xs",children:"No wallet created yet. Create one to enable autonomous transactions."}),f&&S.jsx("p",{className:"text-error text-xs",children:f}),S.jsx("button",{onClick:_,disabled:s,className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 rounded border px-4 py-2 text-xs font-medium transition-colors",children:s?"creating...":"create wallet"})]}),t&&t.exists&&t.address&&S.jsxs("div",{className:"space-y-3",children:[S.jsxs("div",{className:"flex items-center justify-between",children:[S.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"Address (Base)"}),S.jsx("span",{className:`rounded border px-1.5 py-0.5 text-[9px] ${t.ethBalance&&parseFloat(t.ethBalance)>0?"border-accent/30 text-accent":"border-accent-dim/30 text-accent-dim"}`,children:t.ethBalance&&parseFloat(t.ethBalance)>0?"active":"no balance"})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("code",{className:"text-foreground bg-surface rounded px-2 py-1 text-xs font-mono",children:y(t.address)}),S.jsx("button",{onClick:b,className:"text-muted hover:text-accent text-xs transition-colors",children:o?"copied":"copy"})]}),S.jsxs("div",{className:"border-border space-y-1 border-t pt-3",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"ETH"}),S.jsxs("span",{className:"text-foreground font-medium",children:[t.ethBalance||"0.000000"," ETH"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"USDC"}),S.jsxs("span",{className:"text-foreground font-medium",children:["$",t.usdcBalance||"0.00"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"PLOT"}),S.jsxs("span",{className:"text-foreground font-medium",children:[t.plotBalance||"0.0000"," PLOT"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Network"}),S.jsx("span",{className:"text-foreground",children:"Base"})]})]}),S.jsxs("div",{className:"border-border border-t pt-3",children:[S.jsx("p",{className:"text-muted mb-2 text-[10px] font-medium uppercase tracking-wider",children:"Fund Wallet"}),S.jsx("p",{className:"text-muted text-[10px]",children:"Send ETH on Base for gas (~$0.01 per publish):"}),S.jsx("code",{className:"text-foreground bg-surface mt-1 block break-all rounded px-2 py-1.5 text-[10px] font-mono",children:t.address})]})]})]})}function Bx({token:e,onLogout:t}){const[n,s]=$.useState(""),[a,o]=$.useState(""),[c,f]=$.useState(null),[p,h]=$.useState(!1),[g,_]=$.useState(!1),[b,y]=$.useState(null),[x,k]=$.useState("AI Writer"),[L,M]=$.useState(""),[Z,I]=$.useState(""),[Q,W]=$.useState(!1),[O,ie]=$.useState(null),[ue,me]=$.useState(""),[U,le]=$.useState(null),[V,B]=$.useState(!1),[A,R]=$.useState(null),[T,j]=$.useState(null),H=$.useCallback((C,J)=>fetch(C,{...J,headers:{...J==null?void 0:J.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]);$.useEffect(()=>{H("/api/settings/link-status").then(C=>C.json()).then(C=>y(C)).catch(()=>y({linked:!1}))},[]);const oe=async()=>{if(!x.trim()){ie("Agent name is required");return}if(!L.trim()){ie("Description is required");return}W(!0),ie(null);try{const C=await H("/api/settings/register-agent",{method:"POST",body:JSON.stringify({name:x,description:L,...Z.trim()&&{genre:Z}})}),J=await C.json();if(!C.ok)throw new Error(J.error||"Registration failed");y({linked:!0,agentId:J.agentId,owsWallet:J.owsWallet,txHash:J.txHash})}catch(C){ie(C instanceof Error?C.message:"Registration failed")}W(!1)},E=async()=>{if(!ue.trim()||!/^0x[a-fA-F0-9]{40}$/.test(ue)){R("Enter a valid wallet address (0x...)");return}B(!0),R(null),le(null);try{const C=await H("/api/settings/generate-binding",{method:"POST",body:JSON.stringify({humanWallet:ue})}),J=await C.json();if(!C.ok)throw new Error(J.error||"Failed to generate binding code");le(J)}catch(C){R(C instanceof Error?C.message:"Failed to generate binding code")}B(!1)},D=async(C,J)=>{await navigator.clipboard.writeText(C),j(J),setTimeout(()=>j(null),2e3)},K=async()=>{if(f(null),h(!1),!n||n.length<4){f("Passphrase must be at least 4 characters");return}if(n!==a){f("Passphrases do not match");return}_(!0);try{const C=await H("/api/auth/reset-passphrase",{method:"POST",body:JSON.stringify({passphrase:n})});if(!C.ok){const J=await C.json();throw new Error(J.error||"Reset failed")}h(!0),s(""),o(""),setTimeout(()=>h(!1),3e3)}catch(C){f(C instanceof Error?C.message:"Reset failed")}_(!1)};return S.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-6",children:[S.jsx("h2",{className:"text-accent text-lg font-bold",children:"Settings"}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Identity"}),b!=null&&b.linked?S.jsxs("div",{className:"space-y-2",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"text-sm font-medium text-accent",children:"Registered"}),S.jsxs("span",{className:"text-muted text-xs",children:["Agent #",b.agentId]})]}),b.owsWallet&&S.jsxs("p",{className:"text-muted text-xs font-mono",children:["Wallet: ",b.owsWallet.slice(0,6),"...",b.owsWallet.slice(-4)]}),b.owner&&S.jsxs("p",{className:"text-muted text-xs font-mono",children:["Owner: ",b.owner.slice(0,6),"...",b.owner.slice(-4)]}),b.txHash&&S.jsx("p",{className:"text-muted text-xs",children:S.jsx("a",{href:`https://basescan.org/tx/${b.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View transaction on BaseScan"})}),S.jsx("p",{className:"text-muted text-xs",children:S.jsx("a",{href:`https://plotlink.xyz/profile/${b.owsWallet}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View agent profile on plotlink.xyz"})})]}):S.jsxs("div",{className:"space-y-3",children:[S.jsx("p",{className:"text-muted text-xs",children:"Register this AI writer on-chain via ERC-8004. Uses your OWS wallet's existing ETH balance for gas."}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Name"}),S.jsx("input",{value:x,onChange:C=>k(C.target.value),placeholder:"AI Writer",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Description"}),S.jsx("input",{value:L,onChange:C=>M(C.target.value),placeholder:"An AI writing assistant for fiction stories",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Genre (optional)"}),S.jsx("input",{value:Z,onChange:C=>I(C.target.value),placeholder:"e.g. Fiction, Sci-Fi, Fantasy",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),O&&S.jsx("p",{className:"text-error text-xs",children:O}),S.jsx("button",{onClick:oe,disabled:Q||!x.trim()||!L.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:Q?"Registering...":"Register Agent Identity"})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Link to PlotLink"}),b!=null&&b.owner?S.jsxs("p",{className:"text-muted text-xs",children:["Linked to owner ",S.jsxs("span",{className:"font-mono",children:[b.owner.slice(0,6),"...",b.owner.slice(-4)]})]}):S.jsxs("div",{className:"space-y-3",children:[S.jsx("p",{className:"text-muted text-xs",children:"Link this OWS wallet to your PlotLink account so your stories appear under your profile on plotlink.xyz."}),S.jsxs("div",{className:"text-muted text-xs space-y-1 pl-3",children:[S.jsx("p",{children:"1. Enter your PlotLink wallet address below"}),S.jsx("p",{children:'2. Click "Generate Binding Code"'}),S.jsx("p",{children:"3. Copy the code and paste it on plotlink.xyz → Agents → Link AI Writer"})]}),S.jsx("input",{value:ue,onChange:C=>me(C.target.value),placeholder:"Your PlotLink wallet address (0x...)",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent font-mono"}),A&&S.jsx("p",{className:"text-error text-xs",children:A}),S.jsx("button",{onClick:E,disabled:V||!ue.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:V?"Generating...":"Generate Binding Code"}),U&&S.jsxs("div",{className:"space-y-3 mt-3",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Binding Code (signature)"}),S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:U.signature}),S.jsx("button",{onClick:()=>D(U.signature,"signature"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:T==="signature"?"Copied!":"Copy"})]})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"OWS Wallet Address"}),S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:U.owsWallet}),S.jsx("button",{onClick:()=>D(U.owsWallet,"wallet"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:T==="wallet"?"Copied!":"Copy"})]})]}),U.agentId&&S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Agent ID"}),S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono text-foreground pr-16",children:U.agentId}),S.jsx("button",{onClick:()=>D(String(U.agentId),"agentId"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:T==="agentId"?"Copied!":"Copy"})]})]}),S.jsx("p",{className:"text-xs text-accent",children:'Now go to plotlink.xyz/agents and paste the values in the "Link AI Writer" section.'})]})]})]}),S.jsx(eb,{token:e}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Reset Passphrase"}),S.jsxs("div",{className:"space-y-3",children:[S.jsx("input",{type:"password",value:n,onChange:C=>s(C.target.value),placeholder:"new passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),S.jsx("input",{type:"password",value:a,onChange:C=>o(C.target.value),placeholder:"confirm passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),c&&S.jsx("p",{className:"text-error text-xs",children:c}),p&&S.jsx("p",{className:"text-xs text-accent",children:"passphrase updated"}),S.jsx("button",{onClick:K,disabled:g||!n.trim(),className:"border-border text-muted hover:border-accent hover:text-accent disabled:opacity-40 w-full rounded border px-4 py-2 text-xs font-medium transition-colors",children:g?"updating...":"update passphrase"})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Session"}),S.jsx("button",{onClick:t,className:"border-border text-muted hover:border-error hover:text-error rounded border px-4 py-2 text-xs font-medium transition-colors",children:"logout"})]})]})}const Nx="http://localhost:7777";function Lx({token:e}){const[t,n]=$.useState(null),s=(f,p)=>fetch(f,{...p,headers:{...p==null?void 0:p.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),a=()=>{s(`${Nx}/api/dashboard`).then(f=>f.json()).then(n)};$.useEffect(()=>{a()},[]);const o=f=>`${f.slice(0,6)}...${f.slice(-4)}`,c=f=>{if(!f)return"Unknown date";const p=new Date(f);return isNaN(p.getTime())?"Unknown date":p.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})};return t?S.jsxs("div",{className:"mx-auto max-w-2xl space-y-6 p-6",children:[S.jsx("h2",{className:"text-accent text-lg font-bold",children:"Writer Dashboard"}),S.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-accent text-lg font-bold",children:t.stories.totalPublished}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"published"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.pendingFiles}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"pending"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalStories}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"stories"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalFiles}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"files"})]})]}),t.wallet&&S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Wallet"}),S.jsxs("div",{className:"space-y-1.5",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Address"}),S.jsx("code",{className:"text-foreground font-mono text-[10px]",children:o(t.wallet.address)})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"ETH Balance"}),S.jsxs("span",{className:"text-foreground",children:[t.wallet.ethFormatted," ETH"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"USDC Balance"}),S.jsxs("span",{className:"text-foreground",children:["$",t.wallet.usdcBalance]})]})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Profit & Loss"}),S.jsxs("div",{className:"space-y-1.5",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Total costs (gas)"}),S.jsxs("span",{className:"text-error",children:["-",t.pnl.totalCostsEth," ETH (~$",t.pnl.totalCostsUsd,")"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Royalties earned"}),S.jsxs("span",{className:"text-accent",children:["+",t.pnl.totalRoyaltiesPlot," PLOT"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Unclaimed royalties"}),S.jsxs("span",{className:"text-foreground",children:[t.royalties.unclaimed," PLOT"]})]}),S.jsxs("div",{className:"border-border flex justify-between border-t pt-1.5 text-xs font-medium",children:[S.jsx("span",{className:"text-muted",children:"Net P&L (USD)"}),S.jsxs("span",{className:parseFloat(t.pnl.netPnlUsd)>=0?"text-accent":"text-error",children:[parseFloat(t.pnl.netPnlUsd)>=0?"+":"","$",t.pnl.netPnlUsd]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Stories published"}),S.jsx("span",{className:"text-foreground",children:t.costs.storiesPublished})]})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Published Stories"}),t.stories.published.length===0?S.jsx("p",{className:"text-muted text-xs",children:"no published stories yet"}):S.jsx("div",{className:"space-y-3",children:t.stories.published.map(f=>S.jsxs("div",{className:"bg-surface rounded border border-border p-4",children:[S.jsxs("div",{className:"flex items-start justify-between",children:[S.jsxs("div",{children:[f.genre&&S.jsx("span",{className:"bg-accent/10 text-accent rounded px-2 py-0.5 text-[10px] font-medium",children:f.genre}),S.jsx("h4",{className:"text-foreground mt-1 text-sm font-serif font-medium",children:f.title}),S.jsx("p",{className:"text-muted mt-0.5 text-[10px] font-mono",children:f.storyName})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[f.hasNotIndexed&&S.jsx("span",{className:"rounded border border-amber-600/30 px-1.5 py-0.5 text-[9px] text-amber-700",children:"not indexed"}),S.jsxs("span",{className:"rounded border border-green-700/30 px-1.5 py-0.5 text-[9px] text-green-700",children:[f.publishedFiles," published"]})]})]}),S.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-center",children:[S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium",children:f.plotCount}),S.jsx("div",{className:"text-muted text-[9px]",children:"Plots"})]}),S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium font-mono",children:f.storylineId?`#${f.storylineId}`:"—"}),S.jsx("div",{className:"text-muted text-[9px]",children:"Storyline"})]}),S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium",children:f.totalGasCostEth??"—"}),S.jsx("div",{className:"text-muted text-[9px]",children:"Gas (ETH)"})]})]}),S.jsx("div",{className:"mt-2 space-y-1",children:f.files.map(p=>S.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[S.jsxs("div",{className:"flex items-center gap-1.5",children:[S.jsx("span",{className:p.status==="published-not-indexed"?"text-amber-700":"text-green-700",children:p.status==="published-not-indexed"?"⚠":"✓"}),S.jsx("span",{className:"text-muted font-mono",children:p.file})]}),p.txHash&&S.jsxs("a",{href:`https://basescan.org/tx/${p.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-accent font-mono",children:["tx:",p.txHash.slice(0,8),"..."]})]},p.file))}),S.jsxs("div",{className:"mt-2 flex items-center justify-between text-[10px]",children:[S.jsx("span",{className:"text-muted",children:c(f.latestPublishedAt)}),f.storylineId&&S.jsx("a",{href:`https://plotlink.xyz/story/${f.storylineId}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"})]})]},f.id))})]}),t.stories.pendingFiles>0&&S.jsx("div",{className:"border-border rounded border p-4",children:S.jsxs("p",{className:"text-muted text-xs",children:[t.stories.pendingFiles," file(s) pending publish — go to Stories to publish them."]})})]}):S.jsx("div",{className:"flex h-full items-center justify-center",children:S.jsx("span",{className:"text-muted text-sm",children:"loading dashboard..."})})}const zx={published:"✓","published-not-indexed":"⚠",pending:"⏳",draft:"📝"},Ox={published:"text-green-700","published-not-indexed":"text-amber-700",pending:"text-amber-700",draft:"text-muted"};function jx({authFetch:e,selectedStory:t,selectedFile:n,onSelectFile:s,onNewStory:a,untitledSessions:o=[]}){const[c,f]=$.useState([]),[p,h]=$.useState([]),[g,_]=$.useState(new Set),[b,y]=$.useState(!1),x=$.useCallback(async()=>{try{const W=await e("/api/stories");if(W.ok){const O=await W.json();f(O.stories)}}catch{}},[e]),k=$.useCallback(async()=>{try{const W=await e("/api/stories/archived");if(W.ok){const O=await W.json();h(O.stories)}}catch{}},[e]),L=$.useCallback(async W=>{try{(await e("/api/stories/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:W})})).ok&&(k(),x())}catch{}},[e,k,x]);$.useEffect(()=>{x();const W=setInterval(x,5e3);return()=>clearInterval(W)},[x]),$.useEffect(()=>{b&&k()},[b,k]),$.useEffect(()=>{t&&_(W=>new Set(W).add(t))},[t]);const M=W=>{var ie;const O=W.map(ue=>{var me;return{file:ue.file,num:(me=ue.file.match(/^plot-(\d+)\.md$/))==null?void 0:me[1]}}).filter(ue=>ue.num!=null).sort((ue,me)=>parseInt(me.num)-parseInt(ue.num));return O.length>0?O[0].file:W.some(ue=>ue.file==="genesis.md")?"genesis.md":W.some(ue=>ue.file==="structure.md")?"structure.md":((ie=W[0])==null?void 0:ie.file)??null},Z=W=>{_(O=>{const ie=new Set(O);return ie.has(W)?ie.delete(W):ie.add(W),ie})},I=W=>{if(Z(W.name),!g.has(W.name)){const O=M(W.files);O&&s(W.name,O)}},Q=W=>{const O=ie=>{if(ie==="structure.md")return 0;if(ie==="genesis.md")return 1;const ue=ie.match(/^plot-(\d+)\.md$/);return ue?2+parseInt(ue[1]):100};return[...W].sort((ie,ue)=>O(ie.file)-O(ue.file))};return b?S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs font-mono text-muted",children:"Archives"}),S.jsx("span",{className:"text-xs text-muted",children:p.length})]}),S.jsx("div",{className:"px-3 py-2 border-b border-border",children:S.jsxs("button",{onClick:()=>y(!1),className:"w-full px-3 py-1.5 text-sm text-muted hover:text-foreground hover:bg-surface rounded flex items-center gap-1.5",children:[S.jsx("span",{children:"←"}),S.jsx("span",{children:"Back"})]})}),S.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:p.length===0?S.jsx("div",{className:"p-3 text-sm text-muted",children:S.jsx("p",{children:"No archived stories."})}):p.map(W=>S.jsxs("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-surface",children:[S.jsx("span",{className:"text-sm font-medium truncate",title:W.name,children:W.title||W.name}),S.jsx("button",{onClick:()=>L(W.name),className:"text-xs text-accent hover:text-accent-dim flex-shrink-0 ml-2",children:"Restore"})]},W.name))})]}):S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs font-mono text-muted",children:"Stories"}),S.jsx("span",{className:"text-xs text-muted",children:c.length})]}),a&&S.jsx("div",{className:"px-3 py-2 border-b border-border",children:S.jsxs("button",{onClick:a,className:"w-full px-3 py-1.5 text-sm bg-accent text-white rounded hover:bg-accent-dim flex items-center justify-center gap-1.5",children:[S.jsx("span",{children:"+"}),S.jsx("span",{children:"New Story"})]})}),S.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[o.map(W=>S.jsx("div",{children:S.jsxs("button",{onClick:()=>s(W,""),className:`w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm ${t===W?"bg-surface":""}`,children:[S.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-600 flex-shrink-0"}),S.jsx("span",{className:"font-medium italic text-muted",children:"Untitled"})]})},W)),c.length===0&&o.length===0?S.jsxs("div",{className:"p-3 text-sm text-muted",children:[S.jsx("p",{children:"No stories yet."}),S.jsx("p",{className:"mt-1 text-xs",children:'Click "+ New Story" above to start writing.'})]}):c.filter(W=>W.name!=="_example").map(W=>S.jsxs("div",{children:[S.jsxs("button",{onClick:()=>I(W),className:"w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm",children:[S.jsx("span",{className:"text-xs text-muted",children:g.has(W.name)?"▼":"▶"}),S.jsx("span",{className:"font-medium truncate",title:W.name,children:W.title||W.name}),S.jsxs("span",{className:"ml-auto text-xs text-muted",children:[W.publishedCount,"/",W.files.length]})]}),g.has(W.name)&&S.jsx("div",{className:"pl-4",children:Q(W.files).map(O=>{const ie=t===W.name&&n===O.file;return S.jsxs("button",{onClick:()=>s(W.name,O.file),className:`w-full px-3 py-1.5 text-left flex items-center gap-2 text-xs hover:bg-surface ${ie?"bg-surface font-medium":""}`,children:[S.jsx("span",{className:Ox[O.status],children:zx[O.status]}),S.jsx("span",{className:"truncate font-mono",children:O.file})]},O.file)})})]},W.name))]}),S.jsx("div",{className:"px-3 py-2 border-t border-border",children:S.jsx("button",{onClick:()=>y(!0),className:"w-full px-3 py-1.5 text-xs text-muted hover:text-foreground hover:bg-surface rounded flex items-center justify-center gap-1.5",children:S.jsx("span",{children:"Archives"})})})]})}/** + * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. + * @license MIT + * + * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) + * @license MIT + * + * Originally forked from (with the author's permission): + * Fabrice Bellard's javascript vt100 for jslinux: + * http://bellard.org/jslinux/ + * Copyright (c) 2011 Fabrice Bellard + */var tb=Object.defineProperty,Hx=Object.getOwnPropertyDescriptor,Px=(e,t)=>{for(var n in t)tb(e,n,{get:t[n],enumerable:!0})},pt=(e,t,n,s)=>{for(var a=s>1?void 0:s?Hx(t,n):t,o=e.length-1,c;o>=0;o--)(c=e[o])&&(a=(s?c(t,n,a):c(a))||a);return s&&a&&tb(t,n,a),a},pe=(e,t)=>(n,s)=>t(n,s,e),lv="Terminal input",Df={get:()=>lv,set:e=>lv=e},av="Too much output to announce, navigate to rows manually to read",Rf={get:()=>av,set:e=>av=e};function Ux(e){return e.replace(/\r?\n/g,"\r")}function Ix(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Fx(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function qx(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let a=e.clipboardData.getData("text/plain");ib(a,t,n,s)}}function ib(e,t,n,s){e=Ux(e),e=Ix(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function nb(e,t,n){let s=n.getBoundingClientRect(),a=e.clientX-s.left-10,o=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${a}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function ov(e,t,n,s,a){nb(e,t,n),a&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function br(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function wu(e,t=0,n=e.length){let s="";for(let a=t;a65535?(o-=65536,s+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):s+=String.fromCharCode(o)}return s}var Wx=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let s=0,a=0;if(this._interim){let o=e.charCodeAt(a++);56320<=o&&o<=57343?t[s++]=(this._interim-55296)*1024+o-56320+65536:(t[s++]=this._interim,t[s++]=o),this._interim=0}for(let o=a;o=n)return this._interim=c,s;let f=e.charCodeAt(o);56320<=f&&f<=57343?t[s++]=(c-55296)*1024+f-56320+65536:(t[s++]=c,t[s++]=f);continue}c!==65279&&(t[s++]=c)}return s}},Yx=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let s=0,a,o,c,f,p=0,h=0;if(this.interim[0]){let b=!1,y=this.interim[0];y&=(y&224)===192?31:(y&240)===224?15:7;let x=0,k;for(;(k=this.interim[++x]&63)&&x<4;)y<<=6,y|=k;let L=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,M=L-x;for(;h=n)return 0;if(k=e[h++],(k&192)!==128){h--,b=!0;break}else this.interim[x++]=k,y<<=6,y|=k&63}b||(L===2?y<128?h--:t[s++]=y:L===3?y<2048||y>=55296&&y<=57343||y===65279||(t[s++]=y):y<65536||y>1114111||(t[s++]=y)),this.interim.fill(0)}let g=n-4,_=h;for(;_=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(p=(a&31)<<6|o&63,p<128){_--;continue}t[s++]=p}else if((a&240)===224){if(_>=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[_++],(c&192)!==128){_--;continue}if(p=(a&15)<<12|(o&63)<<6|c&63,p<2048||p>=55296&&p<=57343||p===65279)continue;t[s++]=p}else if((a&248)===240){if(_>=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[_++],(c&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,this.interim[2]=c,s;if(f=e[_++],(f&192)!==128){_--;continue}if(p=(a&7)<<18|(o&63)<<12|(c&63)<<6|f&63,p<65536||p>1114111)continue;t[s++]=p}}return s}},rb="",xr=" ",Ca=class sb{constructor(){this.fg=0,this.bg=0,this.extended=new du}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new sb;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},du=class lb{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new lb(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ki=class ab extends Ca{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new du,this.combinedData=""}static fromCharData(t){let n=new ab;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?br(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let a=t[1].charCodeAt(1);56320<=a&&a<=57343?this.content=(s-55296)*1024+a-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},uv="di$target",Mf="di$dependencies",$h=new Map;function Vx(e){return e[Mf]||[]}function qt(e){if($h.has(e))return $h.get(e);let t=function(n,s,a){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Kx(t,n,a)};return t._id=e,$h.set(e,t),t}function Kx(e,t,n){t[uv]===t?t[Mf].push({id:e,index:n}):(t[Mf]=[{id:e,index:n}],t[uv]=t)}var ui=qt("BufferService"),ob=qt("CoreMouseService"),ns=qt("CoreService"),Xx=qt("CharsetService"),Cd=qt("InstantiationService"),ub=qt("LogService"),ci=qt("OptionsService"),cb=qt("OscLinkService"),Gx=qt("UnicodeService"),ka=qt("DecorationService"),Bf=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var g;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],a=this._optionsService.rawOptions.linkHandler,o=new Ki,c=n.getTrimmedLength(),f=-1,p=-1,h=!1;for(let _=0;_a?a.activate(k,L,y):$x(k,L),hover:(k,L)=>{var M;return(M=a==null?void 0:a.hover)==null?void 0:M.call(a,k,L,y)},leave:(k,L)=>{var M;return(M=a==null?void 0:a.leave)==null?void 0:M.call(a,k,L,y)}})}h=!1,o.hasExtendedAttrs()&&o.extended.urlId?(p=_,f=o.extended.urlId):(p=-1,f=-1)}}t(s)}};Bf=pt([pe(0,ui),pe(1,ci),pe(2,cb)],Bf);function $x(e,t){if(confirm(`Do you want to navigate to ${t}? + +WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Cu=qt("CharSizeService"),In=qt("CoreBrowserService"),kd=qt("MouseService"),Fn=qt("RenderService"),Zx=qt("SelectionService"),hb=qt("CharacterJoinerService"),Js=qt("ThemeService"),fb=qt("LinkProviderService"),Qx=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?cv.isErrorNoTelemetry(e)?new cv(e.message+` + +`+e.stack):new Error(e.message+` + +`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},Jx=new Qx;function su(e){ew(e)||Jx.onUnexpectedError(e)}var Nf="Canceled";function ew(e){return e instanceof tw?!0:e instanceof Error&&e.name===Nf&&e.message===Nf}var tw=class extends Error{constructor(){super(Nf),this.name=this.message}};function iw(e){return new Error(`Illegal argument: ${e}`)}var cv=class Lf extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Lf)return t;let n=new Lf;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},zf=class db extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,db.prototype)}};function Di(e,t=0){return e[e.length-(1+t)]}var nw;(e=>{function t(o){return o<0}e.isLessThan=t;function n(o){return o<=0}e.isLessThanOrEqual=n;function s(o){return o>0}e.isGreaterThan=s;function a(o){return o===0}e.isNeitherLessOrGreaterThan=a,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(nw||(nw={}));function rw(e,t){let n=this,s=!1,a;return function(){return s||(s=!0,t||(a=e.apply(n,arguments))),a}}var pb;(e=>{function t(Q){return Q&&typeof Q=="object"&&typeof Q[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*a(Q){yield Q}e.single=a;function o(Q){return t(Q)?Q:a(Q)}e.wrap=o;function c(Q){return Q||n}e.from=c;function*f(Q){for(let W=Q.length-1;W>=0;W--)yield Q[W]}e.reverse=f;function p(Q){return!Q||Q[Symbol.iterator]().next().done===!0}e.isEmpty=p;function h(Q){return Q[Symbol.iterator]().next().value}e.first=h;function g(Q,W){let O=0;for(let ie of Q)if(W(ie,O++))return!0;return!1}e.some=g;function _(Q,W){for(let O of Q)if(W(O))return O}e.find=_;function*b(Q,W){for(let O of Q)W(O)&&(yield O)}e.filter=b;function*y(Q,W){let O=0;for(let ie of Q)yield W(ie,O++)}e.map=y;function*x(Q,W){let O=0;for(let ie of Q)yield*W(ie,O++)}e.flatMap=x;function*k(...Q){for(let W of Q)yield*W}e.concat=k;function L(Q,W,O){let ie=O;for(let ue of Q)ie=W(ie,ue);return ie}e.reduce=L;function*M(Q,W,O=Q.length){for(W<0&&(W+=Q.length),O<0?O+=Q.length:O>Q.length&&(O=Q.length);W1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function sw(...e){return lt(()=>es(e))}function lt(e){return{dispose:rw(()=>{e()})}}var mb=class _b{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{es(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?_b.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};mb.DISABLE_DISPOSED_WARNING=!1;var wr=mb,Be=class{constructor(){this._store=new wr,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Be.None=Object.freeze({dispose(){}});var Zs=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Un=typeof window=="object"?window:globalThis,Of=class jf{constructor(t){this.element=t,this.next=jf.Undefined,this.prev=jf.Undefined}};Of.Undefined=new Of(void 0);var at=Of,hv=class{constructor(){this._first=at.Undefined,this._last=at.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===at.Undefined}clear(){let e=this._first;for(;e!==at.Undefined;){let t=e.next;e.prev=at.Undefined,e.next=at.Undefined,e=t}this._first=at.Undefined,this._last=at.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new at(e);if(this._first===at.Undefined)this._first=n,this._last=n;else if(t){let a=this._last;this._last=n,n.prev=a,a.next=n}else{let a=this._first;this._first=n,n.next=a,a.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first!==at.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==at.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==at.Undefined&&e.next!==at.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===at.Undefined&&e.next===at.Undefined?(this._first=at.Undefined,this._last=at.Undefined):e.next===at.Undefined?(this._last=this._last.prev,this._last.next=at.Undefined):e.prev===at.Undefined&&(this._first=this._first.next,this._first.prev=at.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==at.Undefined;)yield e.element,e=e.next}},lw=globalThis.performance&&typeof globalThis.performance.now=="function",aw=class gb{static create(t){return new gb(t)}constructor(t){this._now=lw&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Jt;(e=>{e.None=()=>Be.None;function t(V,B){return _(V,()=>{},0,void 0,!0,void 0,B)}e.defer=t;function n(V){return(B,A=null,R)=>{let T=!1,j;return j=V(H=>{if(!T)return j?j.dispose():T=!0,B.call(A,H)},null,R),T&&j.dispose(),j}}e.once=n;function s(V,B,A){return h((R,T=null,j)=>V(H=>R.call(T,B(H)),null,j),A)}e.map=s;function a(V,B,A){return h((R,T=null,j)=>V(H=>{B(H),R.call(T,H)},null,j),A)}e.forEach=a;function o(V,B,A){return h((R,T=null,j)=>V(H=>B(H)&&R.call(T,H),null,j),A)}e.filter=o;function c(V){return V}e.signal=c;function f(...V){return(B,A=null,R)=>{let T=sw(...V.map(j=>j(H=>B.call(A,H))));return g(T,R)}}e.any=f;function p(V,B,A,R){let T=A;return s(V,j=>(T=B(T,j),T),R)}e.reduce=p;function h(V,B){let A,R={onWillAddFirstListener(){A=V(T.fire,T)},onDidRemoveLastListener(){A==null||A.dispose()}},T=new ce(R);return B==null||B.add(T),T.event}function g(V,B){return B instanceof Array?B.push(V):B&&B.add(V),V}function _(V,B,A=100,R=!1,T=!1,j,H){let oe,E,D,K=0,C,J={leakWarningThreshold:j,onWillAddFirstListener(){oe=V(de=>{K++,E=B(E,de),R&&!D&&(fe.fire(E),E=void 0),C=()=>{let xe=E;E=void 0,D=void 0,(!R||K>1)&&fe.fire(xe),K=0},typeof A=="number"?(clearTimeout(D),D=setTimeout(C,A)):D===void 0&&(D=0,queueMicrotask(C))})},onWillRemoveListener(){T&&K>0&&(C==null||C())},onDidRemoveLastListener(){C=void 0,oe.dispose()}},fe=new ce(J);return H==null||H.add(fe),fe.event}e.debounce=_;function b(V,B=0,A){return e.debounce(V,(R,T)=>R?(R.push(T),R):[T],B,void 0,!0,void 0,A)}e.accumulate=b;function y(V,B=(R,T)=>R===T,A){let R=!0,T;return o(V,j=>{let H=R||!B(j,T);return R=!1,T=j,H},A)}e.latch=y;function x(V,B,A){return[e.filter(V,B,A),e.filter(V,R=>!B(R),A)]}e.split=x;function k(V,B=!1,A=[],R){let T=A.slice(),j=V(E=>{T?T.push(E):oe.fire(E)});R&&R.add(j);let H=()=>{T==null||T.forEach(E=>oe.fire(E)),T=null},oe=new ce({onWillAddFirstListener(){j||(j=V(E=>oe.fire(E)),R&&R.add(j))},onDidAddFirstListener(){T&&(B?setTimeout(H):H())},onDidRemoveLastListener(){j&&j.dispose(),j=null}});return R&&R.add(oe),oe.event}e.buffer=k;function L(V,B){return(A,R,T)=>{let j=B(new Z);return V(function(H){let oe=j.evaluate(H);oe!==M&&A.call(R,oe)},void 0,T)}}e.chain=L;let M=Symbol("HaltChainable");class Z{constructor(){this.steps=[]}map(B){return this.steps.push(B),this}forEach(B){return this.steps.push(A=>(B(A),A)),this}filter(B){return this.steps.push(A=>B(A)?A:M),this}reduce(B,A){let R=A;return this.steps.push(T=>(R=B(R,T),R)),this}latch(B=(A,R)=>A===R){let A=!0,R;return this.steps.push(T=>{let j=A||!B(T,R);return A=!1,R=T,j?T:M}),this}evaluate(B){for(let A of this.steps)if(B=A(B),B===M)break;return B}}function I(V,B,A=R=>R){let R=(...oe)=>H.fire(A(...oe)),T=()=>V.on(B,R),j=()=>V.removeListener(B,R),H=new ce({onWillAddFirstListener:T,onDidRemoveLastListener:j});return H.event}e.fromNodeEventEmitter=I;function Q(V,B,A=R=>R){let R=(...oe)=>H.fire(A(...oe)),T=()=>V.addEventListener(B,R),j=()=>V.removeEventListener(B,R),H=new ce({onWillAddFirstListener:T,onDidRemoveLastListener:j});return H.event}e.fromDOMEventEmitter=Q;function W(V){return new Promise(B=>n(V)(B))}e.toPromise=W;function O(V){let B=new ce;return V.then(A=>{B.fire(A)},()=>{B.fire(void 0)}).finally(()=>{B.dispose()}),B.event}e.fromPromise=O;function ie(V,B){return V(A=>B.fire(A))}e.forward=ie;function ue(V,B,A){return B(A),V(R=>B(R))}e.runAndSubscribe=ue;class me{constructor(B,A){this._observable=B,this._counter=0,this._hasChanged=!1;let R={onWillAddFirstListener:()=>{B.addObserver(this)},onDidRemoveLastListener:()=>{B.removeObserver(this)}};this.emitter=new ce(R),A&&A.add(this.emitter)}beginUpdate(B){this._counter++}handlePossibleChange(B){}handleChange(B,A){this._hasChanged=!0}endUpdate(B){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function U(V,B){return new me(V,B).emitter.event}e.fromObservable=U;function le(V){return(B,A,R)=>{let T=0,j=!1,H={beginUpdate(){T++},endUpdate(){T--,T===0&&(V.reportChanges(),j&&(j=!1,B.call(A)))},handlePossibleChange(){},handleChange(){j=!0}};V.addObserver(H),V.reportChanges();let oe={dispose(){V.removeObserver(H)}};return R instanceof wr?R.add(oe):Array.isArray(R)&&R.push(oe),oe}}e.fromObservableLight=le})(Jt||(Jt={}));var Hf=class Pf{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Pf._idPool++}`,Pf.all.add(this)}start(t){this._stopWatch=new aw,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Hf.all=new Set,Hf._idPool=0;var ow=Hf,uw=-1,vb=class yb{constructor(t,n,s=(yb._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let s=this.threshold;if(s<=0||n{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[s,a]of this._stacks)(!t||n{var f,p,h,g,_;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let b=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(b);let y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],x=new dw(`${b}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((f=this._options)==null?void 0:f.onListenerError)||su)(x),Be.None}if(this._disposed)return Be.None;n&&(t=t.bind(n));let a=new Zh(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(a.stack=hw.create(),o=this._leakageMon.check(a.stack,this._size+1)),this._listeners?this._listeners instanceof Zh?(this._deliveryQueue??(this._deliveryQueue=new gw),this._listeners=[this._listeners,a]):this._listeners.push(a):((h=(p=this._options)==null?void 0:p.onWillAddFirstListener)==null||h.call(p,this),this._listeners=a,(_=(g=this._options)==null?void 0:g.onDidAddFirstListener)==null||_.call(g,this)),this._size++;let c=lt(()=>{o==null||o(),this._removeListener(a)});return s instanceof wr?s.add(c):Array.isArray(s)&&s.push(c),c}),this._event}_removeListener(t){var o,c,f,p;if((c=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||c.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(p=(f=this._options)==null?void 0:f.onDidRemoveLastListener)==null||p.call(f,this),this._size=0;return}let n=this._listeners,s=n.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,n[s]=void 0;let a=this._deliveryQueue.current===this;if(this._size*mw<=n.length){let h=0;for(let g=0;g0}},gw=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Uf=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ce,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ce,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Uf.INSTANCE=new Uf;var Ed=Uf;function vw(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Ed.INSTANCE.onDidChangeZoomLevel;function yw(e){return Ed.INSTANCE.getZoomFactor(e)}Ed.INSTANCE.onDidChangeFullscreen;var el=typeof navigator=="object"?navigator.userAgent:"",If=el.indexOf("Firefox")>=0,bw=el.indexOf("AppleWebKit")>=0,Td=el.indexOf("Chrome")>=0,Sw=!Td&&el.indexOf("Safari")>=0;el.indexOf("Electron/")>=0;el.indexOf("Android")>=0;var Qh=!1;if(typeof Un.matchMedia=="function"){let e=Un.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Un.matchMedia("(display-mode: fullscreen)");Qh=e.matches,vw(Un,e,({matches:n})=>{Qh&&t.matches||(Qh=n)})}var Gs="en",Ff=!1,qf=!1,lu=!1,Sb=!1,Go,au=Gs,fv=Gs,xw,Qi,Jr=globalThis,Qt,Zy;typeof Jr.vscode<"u"&&typeof Jr.vscode.process<"u"?Qt=Jr.vscode.process:typeof process<"u"&&typeof((Zy=process==null?void 0:process.versions)==null?void 0:Zy.node)=="string"&&(Qt=process);var Qy,ww=typeof((Qy=Qt==null?void 0:Qt.versions)==null?void 0:Qy.electron)=="string",Cw=ww&&(Qt==null?void 0:Qt.type)==="renderer",Jy;if(typeof Qt=="object"){Ff=Qt.platform==="win32",qf=Qt.platform==="darwin",lu=Qt.platform==="linux",lu&&Qt.env.SNAP&&Qt.env.SNAP_REVISION,Qt.env.CI||Qt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Go=Gs,au=Gs;let e=Qt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Go=t.userLocale,fv=t.osLocale,au=t.resolvedLanguage||Gs,xw=(Jy=t.languagePack)==null?void 0:Jy.translationsConfigFile}catch{}Sb=!0}else typeof navigator=="object"&&!Cw?(Qi=navigator.userAgent,Ff=Qi.indexOf("Windows")>=0,qf=Qi.indexOf("Macintosh")>=0,(Qi.indexOf("Macintosh")>=0||Qi.indexOf("iPad")>=0||Qi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,lu=Qi.indexOf("Linux")>=0,(Qi==null?void 0:Qi.indexOf("Mobi"))>=0,au=globalThis._VSCODE_NLS_LANGUAGE||Gs,Go=navigator.language.toLowerCase(),fv=Go):console.error("Unable to resolve platform.");var xb=Ff,hn=qf,kw=lu,dv=Sb,fn=Qi,_r=au,Ew;(e=>{function t(){return _r}e.value=t;function n(){return _r.length===2?_r==="en":_r.length>=3?_r[0]==="e"&&_r[1]==="n"&&_r[2]==="-":!1}e.isDefaultVariant=n;function s(){return _r==="en"}e.isDefault=s})(Ew||(Ew={}));var Tw=typeof Jr.postMessage=="function"&&!Jr.importScripts;(()=>{if(Tw){let e=[];Jr.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,a=e.length;s{let s=++t;e.push({id:s,callback:n}),Jr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var Aw=!!(fn&&fn.indexOf("Chrome")>=0);fn&&fn.indexOf("Firefox")>=0;!Aw&&fn&&fn.indexOf("Safari")>=0;fn&&fn.indexOf("Edg/")>=0;fn&&fn.indexOf("Android")>=0;var Ws=typeof navigator=="object"?navigator:{};dv||document.queryCommandSupported&&document.queryCommandSupported("copy")||Ws&&Ws.clipboard&&Ws.clipboard.writeText,dv||Ws&&Ws.clipboard&&Ws.clipboard.readText;var Ad=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Jh=new Ad,pv=new Ad,mv=new Ad,Dw=new Array(230),wb;(e=>{function t(f){return Jh.keyCodeToStr(f)}e.toString=t;function n(f){return Jh.strToKeyCode(f)}e.fromString=n;function s(f){return pv.keyCodeToStr(f)}e.toUserSettingsUS=s;function a(f){return mv.keyCodeToStr(f)}e.toUserSettingsGeneral=a;function o(f){return pv.strToKeyCode(f)||mv.strToKeyCode(f)}e.fromUserSettings=o;function c(f){if(f>=98&&f<=113)return null;switch(f){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Jh.keyCodeToStr(f)}e.toElectronAccelerator=c})(wb||(wb={}));var Rw=class Cb{constructor(t,n,s,a,o){this.ctrlKey=t,this.shiftKey=n,this.altKey=s,this.metaKey=a,this.keyCode=o}equals(t){return t instanceof Cb&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",s=this.altKey?"1":"0",a=this.metaKey?"1":"0";return`K${t}${n}${s}${a}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Mw([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Mw=class{constructor(e){if(e.length===0)throw iw("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t{function t(n){return n===e.None||n===e.Cancelled||n instanceof Uw?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Jt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:kb})})(Pw||(Pw={}));var Uw=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?kb:(this._emitter||(this._emitter=new ce),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Dd=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new zf("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new zf("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Iw=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new zf("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=lt(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Fw;(e=>{async function t(s){let a,o=await Promise.all(s.map(c=>c.then(f=>f,f=>{a||(a=f)})));if(typeof a<"u")throw a;return o}e.settled=t;function n(s){return new Promise(async(a,o)=>{try{await s(a,o)}catch(c){o(c)}})}e.withAsyncBody=n})(Fw||(Fw={}));var yv=class Wi{static fromArray(t){return new Wi(n=>{n.emitMany(t)})}static fromPromise(t){return new Wi(async n=>{n.emitMany(await t)})}static fromPromises(t){return new Wi(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new Wi(async n=>{await Promise.all(t.map(async s=>{for await(let a of s)n.emitOne(a)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new ce,queueMicrotask(async()=>{let s={emitOne:a=>this.emitOne(a),emitMany:a=>this.emitMany(a),reject:a=>this.reject(a)};try{await Promise.resolve(t(s)),this.resolve()}catch(a){this.reject(a)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(t,n){return new Wi(async s=>{for await(let a of t)s.emitOne(n(a))})}map(t){return Wi.map(this,t)}static filter(t,n){return new Wi(async s=>{for await(let a of t)n(a)&&s.emitOne(a)})}filter(t){return Wi.filter(this,t)}static coalesce(t){return Wi.filter(t,n=>!!n)}coalesce(){return Wi.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return Wi.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};yv.EMPTY=yv.fromArray([]);var{getWindow:cn,getWindowId:qw,onDidRegisterWindow:Ww}=(function(){let e=new Map,t={window:Un,disposables:new wr};e.set(Un.vscodeWindowId,t);let n=new ce,s=new ce,a=new ce;function o(c,f){return(typeof c=="number"?e.get(c):void 0)??(f?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:a.event,onDidUnregisterWindow:s.event,registerWindow(c){if(e.has(c.vscodeWindowId))return Be.None;let f=new wr,p={window:c,disposables:f.add(new wr)};return e.set(c.vscodeWindowId,p),f.add(lt(()=>{e.delete(c.vscodeWindowId),s.fire(c)})),f.add(ke(c,Ot.BEFORE_UNLOAD,()=>{a.fire(c)})),n.fire(p),f},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return e.has(c)},getWindowById:o,getWindow(c){var h;let f=c;if((h=f==null?void 0:f.ownerDocument)!=null&&h.defaultView)return f.ownerDocument.defaultView.window;let p=c;return p!=null&&p.view?p.view.window:Un},getDocument(c){return cn(c).document}}})(),Yw=class{constructor(e,t,n,s){this._node=e,this._type=t,this._handler=n,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function ke(e,t,n,s){return new Yw(e,t,n,s)}var bv=function(e,t,n,s){return ke(e,t,n,s)},Rd,Vw=class extends Iw{constructor(e){super(),this.defaultTarget=e&&cn(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Sv=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){su(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,s=new Map,a=o=>{n.set(o,!1);let c=e.get(o)??[];for(t.set(o,c),e.set(o,[]),s.set(o,!0);c.length>0;)c.sort(Sv.sort),c.shift().execute();s.set(o,!1)};Rd=(o,c,f=0)=>{let p=qw(o),h=new Sv(c,f),g=e.get(p);return g||(g=[],e.set(p,g)),g.push(h),n.get(p)||(n.set(p,!0),o.requestAnimationFrame(()=>a(p))),h}})();function Kw(e){let t=e.getBoundingClientRect(),n=cn(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Ot={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Xw=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=yi(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=yi(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=yi(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=yi(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=yi(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=yi(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=yi(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=yi(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=yi(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=yi(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=yi(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=yi(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=yi(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=yi(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function yi(e){return typeof e=="number"?`${e}px`:e}function pa(e){return new Xw(e)}var Eb=class{constructor(){this._hooks=new wr,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,s,a){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=a;let o=e;try{e.setPointerCapture(t),this._hooks.add(lt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=cn(e)}this._hooks.add(ke(o,Ot.POINTER_MOVE,c=>{if(c.buttons!==n){this.stopMonitoring(!0);return}c.preventDefault(),this._pointerMoveCallback(c)})),this._hooks.add(ke(o,Ot.POINTER_UP,c=>this.stopMonitoring(!0)))}};function Gw(e,t,n){let s=null,a=null;if(typeof n.value=="function"?(s="value",a=n.value,a.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",a=n.get),!a)throw new Error("not supported");let o=`$memoize$${t}`;n[s]=function(...c){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:a.apply(this,c)}),this[o]}}var on;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(on||(on={}));var ua=class ti extends Be{constructor(){super(),this.dispatched=!1,this.targets=new hv,this.ignoreTargets=new hv,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Jt.runAndSubscribe(Ww,({window:t,disposables:n})=>{n.add(ke(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(ke(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(ke(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Un,disposables:this._store}))}static addTarget(t){if(!ti.isTouchDevice())return Be.None;ti.INSTANCE||(ti.INSTANCE=new ti);let n=ti.INSTANCE.targets.push(t);return lt(n)}static ignoreTarget(t){if(!ti.isTouchDevice())return Be.None;ti.INSTANCE||(ti.INSTANCE=new ti);let n=ti.INSTANCE.ignoreTargets.push(t);return lt(n)}static isTouchDevice(){return"ontouchstart"in Un||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,a=t.targetTouches.length;s=ti.HOLD_DELAY&&Math.abs(p.initialPageX-Di(p.rollingPageX))<30&&Math.abs(p.initialPageY-Di(p.rollingPageY))<30){let g=this.newGestureEvent(on.Contextmenu,p.initialTarget);g.pageX=Di(p.rollingPageX),g.pageY=Di(p.rollingPageY),this.dispatchEvent(g)}else if(a===1){let g=Di(p.rollingPageX),_=Di(p.rollingPageY),b=Di(p.rollingTimestamps)-p.rollingTimestamps[0],y=g-p.rollingPageX[0],x=_-p.rollingPageY[0],k=[...this.targets].filter(L=>p.initialTarget instanceof Node&&L.contains(p.initialTarget));this.inertia(t,k,s,Math.abs(y)/b,y>0?1:-1,g,Math.abs(x)/b,x>0?1:-1,_)}this.dispatchEvent(this.newGestureEvent(on.End,p.initialTarget)),delete this.activeTouches[f.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(t){if(t.type===on.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>ti.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===on.Change||t.type===on.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let n=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let a=0,o=t.initialTarget;for(;o&&o!==s;)a++,o=o.parentElement;n.push([a,s])}n.sort((s,a)=>s[0]-a[0]);for(let[s,a]of n)a.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,s,a,o,c,f,p,h){this.handle=Rd(t,()=>{let g=Date.now(),_=g-s,b=0,y=0,x=!0;a+=ti.SCROLL_FRICTION*_,f+=ti.SCROLL_FRICTION*_,a>0&&(x=!1,b=o*a*_),f>0&&(x=!1,y=p*f*_);let k=this.newGestureEvent(on.Change);k.translationX=b,k.translationY=y,n.forEach(L=>L.dispatchEvent(k)),x||this.inertia(t,n,g,a,o,c+b,f,p,h+y)})}onTouchMove(t){let n=Date.now();for(let s=0,a=t.changedTouches.length;s3&&(c.rollingPageX.shift(),c.rollingPageY.shift(),c.rollingTimestamps.shift()),c.rollingPageX.push(o.pageX),c.rollingPageY.push(o.pageY),c.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};ua.SCROLL_FRICTION=-.005,ua.HOLD_DELAY=700,ua.CLEAR_TAP_COUNT_TIME=400,pt([Gw],ua,"isTouchDevice",1);var $w=ua,Md=class extends Be{onclick(e,t){this._register(ke(e,Ot.CLICK,n=>t(new $o(cn(e),n))))}onmousedown(e,t){this._register(ke(e,Ot.MOUSE_DOWN,n=>t(new $o(cn(e),n))))}onmouseover(e,t){this._register(ke(e,Ot.MOUSE_OVER,n=>t(new $o(cn(e),n))))}onmouseleave(e,t){this._register(ke(e,Ot.MOUSE_LEAVE,n=>t(new $o(cn(e),n))))}onkeydown(e,t){this._register(ke(e,Ot.KEY_DOWN,n=>t(new _v(n))))}onkeyup(e,t){this._register(ke(e,Ot.KEY_UP,n=>t(new _v(n))))}oninput(e,t){this._register(ke(e,Ot.INPUT,t))}onblur(e,t){this._register(ke(e,Ot.BLUR,t))}onfocus(e,t){this._register(ke(e,Ot.FOCUS,t))}onchange(e,t){this._register(ke(e,Ot.CHANGE,t))}ignoreGesture(e){return $w.ignoreTarget(e)}},xv=11,Zw=class extends Md{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=xv+"px",this.domNode.style.height=xv+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new Eb),this._register(bv(this.bgDomNode,Ot.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(bv(this.domNode,Ot.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Vw),this._pointerdownScheduleRepeatTimer=this._register(new Dd)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,cn(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Qw=class Wf{constructor(t,n,s,a,o,c,f){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,a=a|0,o=o|0,c=c|0,f=f|0),this.rawScrollLeft=a,this.rawScrollTop=f,n<0&&(n=0),a+n>s&&(a=s-n),a<0&&(a=0),o<0&&(o=0),f+o>c&&(f=c-o),f<0&&(f=0),this.width=n,this.scrollWidth=s,this.scrollLeft=a,this.height=o,this.scrollHeight=c,this.scrollTop=f}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new Wf(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Wf(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let s=this.width!==t.width,a=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,c=this.height!==t.height,f=this.scrollHeight!==t.scrollHeight,p=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:a,scrollLeftChanged:o,heightChanged:c,scrollHeightChanged:f,scrollTopChanged:p}}},Jw=class extends Be{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new ce),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Qw(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let s;t?s=new Cv(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=Cv.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},wv=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function ef(e,t){let n=t-e;return function(s){return e+n*iC(s)}}function eC(e,t,n){return function(s){return s2.5*s){let a,o;return t{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},rC=140,Tb=class extends Md{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new nC(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Eb),this._shouldRender=!0,this.domNode=pa(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(ke(this.domNode.domNode,Ot.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Zw(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=pa(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(ke(this.slider.domNode,Ot.POINTER_DOWN,a=>{a.button===0&&(a.preventDefault(),this._sliderPointerDown(a))})),this.onclick(this.slider.domNode,a=>{a.leftButton&&a.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),a=this._sliderPointerPosition(e);n<=a&&a<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let a=Kw(this.domNode.domNode);t=e.pageX-a.left,n=e.pageY-a.top}let s=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,a=>{let o=this._sliderOrthogonalPointerPosition(a),c=Math.abs(o-n);if(xb&&c>rC){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let f=this._sliderPointerPosition(a)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(f))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Ab=class Vf{constructor(t,n,s,a,o,c){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=a,this._scrollSize=o,this._scrollPosition=c,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Vf(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,s,a,o){let c=Math.max(0,s-t),f=Math.max(0,c-2*n),p=a>0&&a>s;if(!p)return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(f),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(s*f/a))),g=(f-h)/(a-s),_=o*g;return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(h),computedSliderRatio:g,computedSliderPosition:Math.round(_)}}_refreshComputedValues(){let t=Vf._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,s=this._scrollPosition;return n0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),n){let a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),c=Math.abs(n.deltaX),f=Math.abs(n.deltaY),p=Math.max(Math.min(a,c),1),h=Math.max(Math.min(o,f),1),g=Math.max(a,c),_=Math.max(o,f);g%p===0&&_%h===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Kf.INSTANCE=new Kf;var uC=Kf,cC=class extends Md{constructor(e,t,n){super(),this._onScroll=this._register(new ce),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new ce),this.onWillScroll=this._onWillScroll.event,this._options=fC(t),this._scrollable=n,this._register(this._scrollable.onScroll(a=>{this._onWillScroll.fire(a),this._onDidScroll(a),this._onScroll.fire(a)}));let s={onMouseWheel:a=>this._onMouseWheel(a),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new lC(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new sC(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=pa(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=pa(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=pa(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,a=>this._onMouseOver(a)),this.onmouseleave(this._listenOnDomNode,a=>this._onMouseLeave(a)),this._hideTimeout=this._register(new Dd),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=es(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,hn&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new vv(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=es(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new vv(n))};this._mouseWheelToDispose.push(ke(this._listenOnDomNode,Ot.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var a;if((a=e.browserEvent)!=null&&a.defaultPrevented)return;let t=uC.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+o===0?c=o=0:Math.abs(o)>=Math.abs(c)?c=0:o=0),this._options.flipAxes&&([o,c]=[c,o]);let f=!hn&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||f)&&!c&&(c=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),h={};if(o){let g=kv*o,_=p.scrollTop-(g<0?Math.floor(g):Math.ceil(g));this._verticalScrollbar.writeScrollPosition(h,_)}if(c){let g=kv*c,_=p.scrollLeft-(g<0?Math.floor(g):Math.ceil(g));this._horizontalScrollbar.writeScrollPosition(h,_)}h=this._scrollable.validateScrollPosition(h),(p.scrollLeft!==h.scrollLeft||p.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),n=!0)}let s=n;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,s=n?" left":"",a=t?" top":"",o=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${a}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${a}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),aC)}},hC=class extends cC{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function fC(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,hn&&(t.className+=" mac"),t}var Xf=class extends Be{constructor(e,t,n,s,a,o,c,f){super(),this._bufferService=n,this._optionsService=c,this._renderService=f,this._onRequestScrollLines=this._register(new ce),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new Jw({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Rd(s.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new hC(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},p)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(a.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Jt.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(lt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(lt(()=>this._styleElement.remove())),this._register(Jt.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(` +`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(h=>this._handleScroll(h)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};Xf=pt([pe(2,ui),pe(3,In),pe(4,ob),pe(5,Js),pe(6,ci),pe(7,Fn)],Xf);var Gf=class extends Be{constructor(e,t,n,s,a){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=s,this._renderService=a,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(lt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Gf=pt([pe(1,ui),pe(2,In),pe(3,ka),pe(4,Fn)],Gf);var dC=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},ln={full:0,left:0,center:0,right:0},gr={full:0,left:0,center:0,right:0},$l={full:0,left:0,center:0,right:0},pu=class extends Be{constructor(e,t,n,s,a,o,c,f){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=a,this._optionsService=o,this._themeService=c,this._coreBrowserService=f,this._colorZoneStore=new dC,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(h=this._viewportElement.parentElement)==null||h.insertBefore(this._canvas,this._viewportElement),this._register(lt(()=>{var g;return(g=this._canvas)==null?void 0:g.remove()}));let p=this._canvas.getContext("2d");if(p)this._ctx=p;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);gr.full=this._canvas.width,gr.left=e,gr.center=t,gr.right=e,this._refreshDrawHeightConstants(),$l.full=1,$l.left=1,$l.center=1+gr.left,$l.right=1+gr.left+gr.center}_refreshDrawHeightConstants(){ln.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);ln.left=t,ln.center=t,ln.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect($l[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ln[e.position||"full"]/2),gr[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ln[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};pu=pt([pe(2,ui),pe(3,ka),pe(4,Fn),pe(5,ci),pe(6,Js),pe(7,In)],pu);var se;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=` +`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(se||(se={}));var ou;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(ou||(ou={}));var Db;(e=>e.ST=`${se.ESC}\\`)(Db||(Db={}));var $f=class{constructor(e,t,n,s,a,o){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=s,this._coreService=a,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.lengththis.updateCompositionElements(!0),0)}}};$f=pt([pe(2,ui),pe(3,ci),pe(4,ns),pe(5,Fn)],$f);var jt=0,Ht=0,Pt=0,ft=0,Ev={css:"#00000000",rgba:0},kt;(e=>{function t(a,o,c,f){return f!==void 0?`#${Vr(a)}${Vr(o)}${Vr(c)}${Vr(f)}`:`#${Vr(a)}${Vr(o)}${Vr(c)}`}e.toCss=t;function n(a,o,c,f=255){return(a<<24|o<<16|c<<8|f)>>>0}e.toRgba=n;function s(a,o,c,f){return{css:e.toCss(a,o,c,f),rgba:e.toRgba(a,o,c,f)}}e.toColor=s})(kt||(kt={}));var nt;(e=>{function t(p,h){if(ft=(h.rgba&255)/255,ft===1)return{css:h.css,rgba:h.rgba};let g=h.rgba>>24&255,_=h.rgba>>16&255,b=h.rgba>>8&255,y=p.rgba>>24&255,x=p.rgba>>16&255,k=p.rgba>>8&255;jt=y+Math.round((g-y)*ft),Ht=x+Math.round((_-x)*ft),Pt=k+Math.round((b-k)*ft);let L=kt.toCss(jt,Ht,Pt),M=kt.toRgba(jt,Ht,Pt);return{css:L,rgba:M}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,h,g){let _=uu.ensureContrastRatio(p.rgba,h.rgba,g);if(_)return kt.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function a(p){let h=(p.rgba|255)>>>0;return[jt,Ht,Pt]=uu.toChannels(h),{css:kt.toCss(jt,Ht,Pt),rgba:h}}e.opaque=a;function o(p,h){return ft=Math.round(h*255),[jt,Ht,Pt]=uu.toChannels(p.rgba),{css:kt.toCss(jt,Ht,Pt,ft),rgba:kt.toRgba(jt,Ht,Pt,ft)}}e.opacity=o;function c(p,h){return ft=p.rgba&255,o(p,ft*h/255)}e.multiplyOpacity=c;function f(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=f})(nt||(nt={}));var ot;(e=>{let t,n;try{let a=document.createElement("canvas");a.width=1,a.height=1;let o=a.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return jt=parseInt(a.slice(1,2).repeat(2),16),Ht=parseInt(a.slice(2,3).repeat(2),16),Pt=parseInt(a.slice(3,4).repeat(2),16),kt.toColor(jt,Ht,Pt);case 5:return jt=parseInt(a.slice(1,2).repeat(2),16),Ht=parseInt(a.slice(2,3).repeat(2),16),Pt=parseInt(a.slice(3,4).repeat(2),16),ft=parseInt(a.slice(4,5).repeat(2),16),kt.toColor(jt,Ht,Pt,ft);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let o=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return jt=parseInt(o[1]),Ht=parseInt(o[2]),Pt=parseInt(o[3]),ft=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),kt.toColor(jt,Ht,Pt,ft);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[jt,Ht,Pt,ft]=t.getImageData(0,0,1,1).data,ft!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:kt.toRgba(jt,Ht,Pt,ft),css:a}}e.toColor=s})(ot||(ot={}));var li;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,a,o){let c=s/255,f=a/255,p=o/255,h=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),_=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return h*.2126+g*.7152+_*.0722}e.relativeLuminance2=n})(li||(li={}));var uu;(e=>{function t(c,f){if(ft=(f&255)/255,ft===1)return f;let p=f>>24&255,h=f>>16&255,g=f>>8&255,_=c>>24&255,b=c>>16&255,y=c>>8&255;return jt=_+Math.round((p-_)*ft),Ht=b+Math.round((h-b)*ft),Pt=y+Math.round((g-y)*ft),kt.toRgba(jt,Ht,Pt)}e.blend=t;function n(c,f,p){let h=li.relativeLuminance(c>>8),g=li.relativeLuminance(f>>8);if(jn(h,g)>8));if(x>8));return x>L?y:k}return y}let _=a(c,f,p),b=jn(h,li.relativeLuminance(_>>8));if(b>8));return b>x?_:y}return _}}e.ensureContrastRatio=n;function s(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=jn(li.relativeLuminance2(b,y,x),li.relativeLuminance2(h,g,_));for(;k0||y>0||x>0);)b-=Math.max(0,Math.ceil(b*.1)),y-=Math.max(0,Math.ceil(y*.1)),x-=Math.max(0,Math.ceil(x*.1)),k=jn(li.relativeLuminance2(b,y,x),li.relativeLuminance2(h,g,_));return(b<<24|y<<16|x<<8|255)>>>0}e.reduceLuminance=s;function a(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=jn(li.relativeLuminance2(b,y,x),li.relativeLuminance2(h,g,_));for(;k>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(uu||(uu={}));function Vr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function jn(e,t){return e1){let g=this._getJoinedRanges(s,c,o,t,a);for(let _=0;_1){let h=this._getJoinedRanges(s,c,o,t,a);for(let g=0;g=U,j=B,H=this._workCell;if(b.length>0&&B===b[0][0]&&T){let we=b.shift(),Et=this._isCellInSelection(we[0],t);for(Z=we[0]+1;Z=we[1]),T?(R=!0,H=new pC(this._workCell,e.translateToString(!0,we[0],we[1]),we[1]-we[0]),j=we[1]-1,A=H.getWidth()):U=we[1]}let oe=this._isCellInSelection(B,t),E=n&&B===o,D=V&&B>=h&&B<=g,K=!1;this._decorationService.forEachDecorationAtCell(B,t,void 0,we=>{K=!0});let C=H.getChars()||xr;if(C===" "&&(H.isUnderline()||H.isOverline())&&(C=" "),me=A*f-p.get(C,H.isBold(),H.isItalic()),!k)k=this._document.createElement("span");else if(L&&(oe&&ue||!oe&&!ue&&H.bg===I)&&(oe&&ue&&y.selectionForeground||H.fg===Q)&&H.extended.ext===W&&D===O&&me===ie&&!E&&!R&&!K&&T){H.isInvisible()?M+=xr:M+=C,L++;continue}else L&&(k.textContent=M),k=this._document.createElement("span"),L=0,M="";if(I=H.bg,Q=H.fg,W=H.extended.ext,O=D,ie=me,ue=oe,R&&o>=B&&o<=j&&(o=B),!this._coreService.isCursorHidden&&E&&this._coreService.isCursorInitialized){if(le.push("xterm-cursor"),this._coreBrowserService.isFocused)c&&le.push("xterm-cursor-blink"),le.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":le.push("xterm-cursor-outline");break;case"block":le.push("xterm-cursor-block");break;case"bar":le.push("xterm-cursor-bar");break;case"underline":le.push("xterm-cursor-underline");break}}if(H.isBold()&&le.push("xterm-bold"),H.isItalic()&&le.push("xterm-italic"),H.isDim()&&le.push("xterm-dim"),H.isInvisible()?M=xr:M=H.getChars()||xr,H.isUnderline()&&(le.push(`xterm-underline-${H.extended.underlineStyle}`),M===" "&&(M=" "),!H.isUnderlineColorDefault()))if(H.isUnderlineColorRGB())k.style.textDecorationColor=`rgb(${Ca.toColorRGB(H.getUnderlineColor()).join(",")})`;else{let we=H.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&H.isBold()&&we<8&&(we+=8),k.style.textDecorationColor=y.ansi[we].css}H.isOverline()&&(le.push("xterm-overline"),M===" "&&(M=" ")),H.isStrikethrough()&&le.push("xterm-strikethrough"),D&&(k.style.textDecoration="underline");let J=H.getFgColor(),fe=H.getFgColorMode(),de=H.getBgColor(),xe=H.getBgColorMode(),Ne=!!H.isInverse();if(Ne){let we=J;J=de,de=we;let Et=fe;fe=xe,xe=Et}let Ce,rt,et=!1;this._decorationService.forEachDecorationAtCell(B,t,void 0,we=>{we.options.layer!=="top"&&et||(we.backgroundColorRGB&&(xe=50331648,de=we.backgroundColorRGB.rgba>>8&16777215,Ce=we.backgroundColorRGB),we.foregroundColorRGB&&(fe=50331648,J=we.foregroundColorRGB.rgba>>8&16777215,rt=we.foregroundColorRGB),et=we.options.layer==="top")}),!et&&oe&&(Ce=this._coreBrowserService.isFocused?y.selectionBackgroundOpaque:y.selectionInactiveBackgroundOpaque,de=Ce.rgba>>8&16777215,xe=50331648,et=!0,y.selectionForeground&&(fe=50331648,J=y.selectionForeground.rgba>>8&16777215,rt=y.selectionForeground)),et&&le.push("xterm-decoration-top");let ut;switch(xe){case 16777216:case 33554432:ut=y.ansi[de],le.push(`xterm-bg-${de}`);break;case 50331648:ut=kt.toColor(de>>16,de>>8&255,de&255),this._addStyle(k,`background-color:#${Tv((de>>>0).toString(16),"0",6)}`);break;case 0:default:Ne?(ut=y.foreground,le.push("xterm-bg-257")):ut=y.background}switch(Ce||H.isDim()&&(Ce=nt.multiplyOpacity(ut,.5)),fe){case 16777216:case 33554432:H.isBold()&&J<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(J+=8),this._applyMinimumContrast(k,ut,y.ansi[J],H,Ce,void 0)||le.push(`xterm-fg-${J}`);break;case 50331648:let we=kt.toColor(J>>16&255,J>>8&255,J&255);this._applyMinimumContrast(k,ut,we,H,Ce,rt)||this._addStyle(k,`color:#${Tv(J.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(k,ut,y.foreground,H,Ce,rt)||Ne&&le.push("xterm-fg-257")}le.length&&(k.className=le.join(" "),le.length=0),!E&&!R&&!K&&T?L++:k.textContent=M,me!==this.defaultSpacing&&(k.style.letterSpacing=`${me}px`),_.push(k),B=j}return k&&L&&(k.textContent=M),_}_applyMinimumContrast(e,t,n,s,a,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||gC(s.getCode()))return!1;let c=this._getContrastCache(s),f;if(!a&&!o&&(f=c.getColor(t.rgba,n.rgba)),f===void 0){let p=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);f=nt.ensureContrastRatio(a||t,o||n,p),c.setColor((a||t).rgba,(o||n).rgba,f??null)}return f?(this._addStyle(e,`color:${f.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t=n[0]&&e=n[0]}};Zf=pt([pe(1,hb),pe(2,ci),pe(3,In),pe(4,ns),pe(5,ka),pe(6,Js)],Zf);function Tv(e,t,n){for(;e.length0&&(this._flat[s]=c),c}let a=e;t&&(a+="B"),n&&(a+="I");let o=this._holey.get(a);if(o===void 0){let c=0;t&&(c|=1),n&&(c|=2),o=this._measure(e,c),o>0&&this._holey.set(a,o)}return o}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},bC=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let a=e.buffers.active.ydisp,o=t[1]-a,c=n[1]-a,f=Math.max(o,0),p=Math.min(c,e.rows-1);if(f>=e.rows||p<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=o,this.viewportEndRow=c,this.viewportCappedStartRow=f,this.viewportCappedEndRow=p,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n=this.startCol&&t=this.startCol):!1}};function SC(){return new bC}var tf="xterm-dom-renderer-owner-",qi="xterm-rows",Qo="xterm-fg-",Av="xterm-bg-",Zl="xterm-focus",Jo="xterm-selection",xC=1,Qf=class extends Be{constructor(e,t,n,s,a,o,c,f,p,h,g,_,b,y){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=a,this._helperContainer=o,this._linkifier2=c,this._charSizeService=p,this._optionsService=h,this._bufferService=g,this._coreService=_,this._coreBrowserService=b,this._themeService=y,this._terminalClass=xC++,this._rowElements=[],this._selectionRenderModel=SC(),this.onRequestRedraw=this._register(new ce).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(qi),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Jo),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=vC(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(x=>this._injectCss(x))),this._injectCss(this._themeService.colors),this._rowFactory=f.createInstance(Zf,document),this._element.classList.add(tf+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(x=>this._handleLinkHover(x))),this._register(this._linkifier2.onHideLinkUnderline(x=>this._handleLinkLeave(x))),this._register(lt(()=>{this._element.classList.remove(tf+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new yC(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${qi} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${qi} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${qi} .xterm-dim { color: ${nt.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,a=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${a} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${qi}.${Zl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${qi}.${Zl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${qi}.${Zl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${qi} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${qi} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${qi} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${qi} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${qi} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Jo} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Jo} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Jo} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,c]of e.ansi.entries())t+=`${this._terminalSelector} .${Qo}${o} { color: ${c.css}; }${this._terminalSelector} .${Qo}${o}.xterm-dim { color: ${nt.multiplyOpacity(c,.5).css}; }${this._terminalSelector} .${Av}${o} { background-color: ${c.css}; }`;t+=`${this._terminalSelector} .${Qo}257 { color: ${nt.opaque(e.background).css}; }${this._terminalSelector} .${Qo}257.xterm-dim { color: ${nt.multiplyOpacity(nt.opaque(e.background),.5).css}; }${this._terminalSelector} .${Av}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Zl),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Zl),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,a=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,c=this._selectionRenderModel.viewportCappedEndRow,f=this._document.createDocumentFragment();if(n){let p=e[0]>t[0];f.appendChild(this._createSelectionElement(o,p?t[0]:e[0],p?e[0]:t[0],c-o+1))}else{let p=s===o?e[0]:0,h=o===a?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(o,p,h));let g=c-o-1;if(f.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,g)),o!==c){let _=a===c?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(c,0,_))}}this._selectionContainer.appendChild(f)}_createSelectionElement(e,t,n,s=1){let a=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,c=this.dimensions.css.cell.width*(n-t);return o+c>this.dimensions.css.canvas.width&&(c=this.dimensions.css.canvas.width-o),a.style.height=`${s*this.dimensions.css.cell.height}px`,a.style.top=`${e*this.dimensions.css.cell.height}px`,a.style.left=`${o}px`,a.style.width=`${c}px`,a}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,s=n.ybase+n.y,a=Math.min(n.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,c=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=e;p<=t;p++){let h=p+n.ydisp,g=this._rowElements[p],_=n.lines.get(h);if(!g||!_)break;g.replaceChildren(...this._rowFactory.createRow(_,h,h===s,c,f,a,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${tf}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,s,a,o){n<0&&(e=0),s<0&&(t=0);let c=this._bufferService.rows-1;n=Math.max(Math.min(n,c),0),s=Math.max(Math.min(s,c),0),a=Math.min(a,this._bufferService.cols);let f=this._bufferService.buffer,p=f.ybase+f.y,h=Math.min(f.x,a-1),g=this._optionsService.rawOptions.cursorBlink,_=this._optionsService.rawOptions.cursorStyle,b=this._optionsService.rawOptions.cursorInactiveStyle;for(let y=n;y<=s;++y){let x=y+f.ydisp,k=this._rowElements[y],L=f.lines.get(x);if(!k||!L)break;k.replaceChildren(...this._rowFactory.createRow(L,x,x===p,_,b,h,g,this.dimensions.css.cell.width,this._widthCache,o?y===n?e:0:-1,o?(y===s?t:a)-1:-1))}}};Qf=pt([pe(7,Cd),pe(8,Cu),pe(9,ci),pe(10,ui),pe(11,ns),pe(12,In),pe(13,Js)],Qf);var Jf=class extends Be{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new ce),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new CC(this._optionsService))}catch{this._measureStrategy=this._register(new wC(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Jf=pt([pe(2,ci)],Jf);var Rb=class extends Be{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},wC=class extends Rb{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},CC=class extends Rb{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},kC=class extends Be{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new EC(this._window)),this._onDprChange=this._register(new ce),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ce),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Jt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(ke(this._textarea,"focus",()=>this._isFocused=!0)),this._register(ke(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},EC=class extends Be{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Zs),this._onDprChange=this._register(new ce),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(lt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=ke(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},TC=class extends Be{constructor(){super(),this.linkProviders=[],this._register(lt(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Bd(e,t,n){let s=n.getBoundingClientRect(),a=e.getComputedStyle(n),o=parseInt(a.getPropertyValue("padding-left")),c=parseInt(a.getPropertyValue("padding-top"));return[t.clientX-s.left-o,t.clientY-s.top-c]}function AC(e,t,n,s,a,o,c,f,p){if(!o)return;let h=Bd(e,t,n);if(h)return h[0]=Math.ceil((h[0]+(p?c/2:0))/c),h[1]=Math.ceil(h[1]/f),h[0]=Math.min(Math.max(h[0],1),s+(p?1:0)),h[1]=Math.min(Math.max(h[1],1),a),h}var ed=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,a){return AC(window,e,t,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,a)}getMouseReportCoords(e,t){let n=Bd(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};ed=pt([pe(0,Fn),pe(1,Cu)],ed);var DC=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Mb={};Px(Mb,{getSafariVersion:()=>MC,isChromeOS:()=>zb,isFirefox:()=>Bb,isIpad:()=>BC,isIphone:()=>NC,isLegacyEdge:()=>RC,isLinux:()=>Nd,isMac:()=>_u,isNode:()=>ku,isSafari:()=>Nb,isWindows:()=>Lb});var ku=typeof process<"u"&&"title"in process,Ea=ku?"node":navigator.userAgent,Ta=ku?"node":navigator.platform,Bb=Ea.includes("Firefox"),RC=Ea.includes("Edge"),Nb=/^((?!chrome|android).)*safari/i.test(Ea);function MC(){if(!Nb)return 0;let e=Ea.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var _u=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Ta),BC=Ta==="iPad",NC=Ta==="iPhone",Lb=["Windows","Win16","Win32","WinCE"].includes(Ta),Nd=Ta.indexOf("Linux")>=0,zb=/\bCrOS\b/.test(Ea),Ob=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._ia){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=a}this.clear()}},LC=class extends Ob{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},zC=class extends Ob{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},gu=!ku&&"requestIdleCallback"in window?zC:LC,OC=class{constructor(){this._queue=new gu}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},td=class extends Be{constructor(e,t,n,s,a,o,c,f,p){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=a,this._coreBrowserService=f,this._renderer=this._register(new Zs),this._pausedResizeTask=new OC,this._observerDisposable=this._register(new Zs),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new ce),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new ce),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new ce),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new ce),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new DC((h,g)=>this._renderRows(h,g),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new jC(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(lt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(c.onResize(()=>this._fullRefresh())),this._register(c.buffers.onBufferActivate(()=>{var h;return(h=this._renderer.value)==null?void 0:h.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(c.cols,c.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(c.buffer.y,c.buffer.y,!0))),this._register(p.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(h=>this._registerIntersectionObserver(h,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=lt(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var n;return(n=this._renderer.value)==null?void 0:n.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,n){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};td=pt([pe(2,ci),pe(3,Cu),pe(4,ns),pe(5,ka),pe(6,ui),pe(7,In),pe(8,Js)],td);var jC=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function HC(e,t,n,s){let a=n.buffer.x,o=n.buffer.y;if(!n.buffer.hasScrollback)return IC(a,o,e,t,n,s)+Eu(o,t,n,s)+FC(a,o,e,t,n,s);let c;if(o===t)return c=a>e?"D":"C",ya(Math.abs(a-e),va(c,s));c=o>t?"D":"C";let f=Math.abs(o-t),p=UC(o>t?e:a,n)+(f-1)*n.cols+1+PC(o>t?a:e);return ya(p,va(c,s))}function PC(e,t){return e-1}function UC(e,t){return t.cols-e}function IC(e,t,n,s,a,o){return Eu(t,s,a,o).length===0?"":ya(Hb(e,t,e,t-ts(t,a),!1,a).length,va("D",o))}function Eu(e,t,n,s){let a=e-ts(e,n),o=t-ts(t,n),c=Math.abs(a-o)-qC(e,t,n);return ya(c,va(jb(e,t),s))}function FC(e,t,n,s,a,o){let c;Eu(t,s,a,o).length>0?c=s-ts(s,a):c=t;let f=s,p=WC(e,t,n,s,a,o);return ya(Hb(e,c,n,f,p==="C",a).length,va(p,o))}function qC(e,t,n){var c;let s=0,a=e-ts(e,n),o=t-ts(t,n);for(let f=0;f=0&&e0?c=s-ts(s,a):c=t,e=n&&ct?"A":"B"}function Hb(e,t,n,s,a,o){let c=e,f=t,p="";for(;(c!==n||f!==s)&&f>=0&&fo.cols-1?(p+=o.buffer.translateBufferLineToString(f,!1,e,c),c=0,e=0,f++):!a&&c<0&&(p+=o.buffer.translateBufferLineToString(f,!1,0,e+1),c=o.cols-1,e=c,f--);return p+o.buffer.translateBufferLineToString(f,!1,e,c)}function va(e,t){let n=t?"O":"[";return se.ESC+n+e}function ya(e,t){e=Math.floor(e);let n="";for(let s=0;sthis._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Dv(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var nf=50,VC=15,KC=50,XC=500,GC=" ",$C=new RegExp(GC,"g"),id=class extends Be{constructor(e,t,n,s,a,o,c,f,p){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=a,this._mouseService=o,this._optionsService=c,this._renderService=f,this._coreBrowserService=p,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Ki,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new ce),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new ce),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new ce),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new ce),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=h=>this._handleMouseMove(h),this._mouseUpListener=h=>this._handleMouseUp(h),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(h=>this._handleTrim(h)),this._register(this._bufferService.buffers.onBufferActivate(h=>this._handleBufferActivate(h))),this.enable(),this._model=new YC(this._bufferService),this._activeSelectionMode=0,this._register(lt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(h=>{h.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let a=e[0]a.replace($C," ")).join(Lb?`\r +`:` +`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Nd&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s||!t?!1:this._areCoordsInSelection(t,n,s)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,t],n,s)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){var a,o;let n=(o=(a=this._linkifier.currentLink)==null?void 0:a.link)==null?void 0:o.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=Dv(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Bd(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-nf),nf),t/=nf,t/Math.abs(t)+Math.round(t*(VC-1)))}shouldForceSelection(e){return _u?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),KC)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(_u&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&tthis._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let s=0;t>=s;s++){let a=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:a>1&&t!==s&&(n+=a-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let a=this._bufferService.buffer,o=a.lines.get(e[1]);if(!o)return;let c=a.translateBufferLineToString(e[1],!1),f=this._convertViewportColToCharacterIndex(o,e[0]),p=f,h=e[0]-f,g=0,_=0,b=0,y=0;if(c.charAt(f)===" "){for(;f>0&&c.charAt(f-1)===" ";)f--;for(;p1&&(y+=Z-1,p+=Z-1);L>0&&f>0&&!this._isCharWordSeparator(o.loadCell(L-1,this._workCell));){o.loadCell(L-1,this._workCell);let I=this._workCell.getChars().length;this._workCell.getWidth()===0?(g++,L--):I>1&&(b+=I-1,f-=I-1),f--,L--}for(;M1&&(y+=I-1,p+=I-1),p++,M++}}p++;let x=f+h-g+b,k=Math.min(this._bufferService.cols,p-f+g+_-b-y);if(!(!t&&c.slice(f,p).trim()==="")){if(n&&x===0&&o.getCodePoint(0)!==32){let L=a.lines.get(e[1]-1);if(L&&o.isWrapped&&L.getCodePoint(this._bufferService.cols-1)!==32){let M=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(M){let Z=this._bufferService.cols-M.start;x-=Z,k+=Z}}}if(s&&x+k===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let L=a.lines.get(e[1]+1);if(L!=null&&L.isWrapped&&L.getCodePoint(0)!==32){let M=this._getWordAt([0,e[1]+1],!1,!1,!0);M&&(k+=M.length)}}return{start:x,length:k}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Dv(n,this._bufferService.cols)}};id=pt([pe(3,ui),pe(4,ns),pe(5,kd),pe(6,ci),pe(7,Fn),pe(8,In)],id);var Rv=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Mv=class{constructor(){this._color=new Rv,this._css=new Rv}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Rt=Object.freeze((()=>{let e=[ot.toColor("#2e3436"),ot.toColor("#cc0000"),ot.toColor("#4e9a06"),ot.toColor("#c4a000"),ot.toColor("#3465a4"),ot.toColor("#75507b"),ot.toColor("#06989a"),ot.toColor("#d3d7cf"),ot.toColor("#555753"),ot.toColor("#ef2929"),ot.toColor("#8ae234"),ot.toColor("#fce94f"),ot.toColor("#729fcf"),ot.toColor("#ad7fa8"),ot.toColor("#34e2e2"),ot.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],a=t[n/6%6|0],o=t[n%6];e.push({css:kt.toCss(s,a,o),rgba:kt.toRgba(s,a,o)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:kt.toCss(s,s,s),rgba:kt.toRgba(s,s,s)})}return e})()),$r=ot.toColor("#ffffff"),ca=ot.toColor("#000000"),Bv=ot.toColor("#ffffff"),Nv=ca,Ql={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},ZC=$r,nd=class extends Be{constructor(e){super(),this._optionsService=e,this._contrastCache=new Mv,this._halfContrastCache=new Mv,this._onChangeColors=this._register(new ce),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:$r,background:ca,cursor:Bv,cursorAccent:Nv,selectionForeground:void 0,selectionBackgroundTransparent:Ql,selectionBackgroundOpaque:nt.blend(ca,Ql),selectionInactiveBackgroundTransparent:Ql,selectionInactiveBackgroundOpaque:nt.blend(ca,Ql),scrollbarSliderBackground:nt.opacity($r,.2),scrollbarSliderHoverBackground:nt.opacity($r,.4),scrollbarSliderActiveBackground:nt.opacity($r,.5),overviewRulerBorder:$r,ansi:Rt.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=Ge(e.foreground,$r),t.background=Ge(e.background,ca),t.cursor=nt.blend(t.background,Ge(e.cursor,Bv)),t.cursorAccent=nt.blend(t.background,Ge(e.cursorAccent,Nv)),t.selectionBackgroundTransparent=Ge(e.selectionBackground,Ql),t.selectionBackgroundOpaque=nt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Ge(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=nt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Ge(e.selectionForeground,Ev):void 0,t.selectionForeground===Ev&&(t.selectionForeground=void 0),nt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=nt.opacity(t.selectionBackgroundTransparent,.3)),nt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=nt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Ge(e.scrollbarSliderBackground,nt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Ge(e.scrollbarSliderHoverBackground,nt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Ge(e.scrollbarSliderActiveBackground,nt.opacity(t.foreground,.5)),t.overviewRulerBorder=Ge(e.overviewRulerBorder,ZC),t.ansi=Rt.slice(),t.ansi[0]=Ge(e.black,Rt[0]),t.ansi[1]=Ge(e.red,Rt[1]),t.ansi[2]=Ge(e.green,Rt[2]),t.ansi[3]=Ge(e.yellow,Rt[3]),t.ansi[4]=Ge(e.blue,Rt[4]),t.ansi[5]=Ge(e.magenta,Rt[5]),t.ansi[6]=Ge(e.cyan,Rt[6]),t.ansi[7]=Ge(e.white,Rt[7]),t.ansi[8]=Ge(e.brightBlack,Rt[8]),t.ansi[9]=Ge(e.brightRed,Rt[9]),t.ansi[10]=Ge(e.brightGreen,Rt[10]),t.ansi[11]=Ge(e.brightYellow,Rt[11]),t.ansi[12]=Ge(e.brightBlue,Rt[12]),t.ansi[13]=Ge(e.brightMagenta,Rt[13]),t.ansi[14]=Ge(e.brightCyan,Rt[14]),t.ansi[15]=Ge(e.brightWhite,Rt[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;so.index-c.index),s=[];for(let o of n){let c=this._services.get(o.id);if(!c)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);s.push(c)}let a=n.length>0?n[0].index:t.length;if(t.length!==a)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${a+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},e2={trace:0,debug:1,info:2,warn:3,error:4,off:5},t2="xterm.js: ",rd=class extends Be{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=e2[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;s--)this._array[this._getCyclicIndex(s+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;sthis._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let a=t-1;a>=0;a--)this.set(e+a+n,this.get(e+a));let s=e+t+n-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*Me+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Me+0]=t|2097152|n[2]<<22):this._data[t*Me+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Me+0]>>22}hasWidth(t){return this._data[t*Me+0]&12582912}getFg(t){return this._data[t*Me+1]}getBg(t){return this._data[t*Me+2]}hasContent(t){return this._data[t*Me+0]&4194303}getCodePoint(t){let n=this._data[t*Me+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Me+0]&2097152}getString(t){let n=this._data[t*Me+0];return n&2097152?this._combined[t]:n&2097151?br(n&2097151):""}isProtected(t){return this._data[t*Me+2]&536870912}loadCell(t,n){return eu=t*Me,n.content=this._data[eu+0],n.fg=this._data[eu+1],n.bg=this._data[eu+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*Me+0]=n.content,this._data[t*Me+1]=n.fg,this._data[t*Me+2]=n.bg}setCellFromCodepoint(t,n,s,a){a.bg&268435456&&(this._extendedAttrs[t]=a.extended),this._data[t*Me+0]=n|s<<22,this._data[t*Me+1]=a.fg,this._data[t*Me+2]=a.bg}addCodepointToCell(t,n,s){let a=this._data[t*Me+0];a&2097152?this._combined[t]+=br(n):a&2097151?(this._combined[t]=br(a&2097151)+br(n),a&=-2097152,a|=2097152):a=n|1<<22,s&&(a&=-12582913,a|=s<<22),this._data[t*Me+0]=a}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n=0;--o)this.setCell(t+n+o,this.loadCell(t+o,a));for(let o=0;othis.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let a=new Uint32Array(s);a.set(this._data),this._data=a}for(let a=this.length;a=t&&delete this._combined[f]}let o=Object.keys(this._extendedAttrs);for(let c=0;c=t&&delete this._extendedAttrs[f]}}return this.length=t,s*4*rf=0;--t)if(this._data[t*Me+0]&4194303)return t+(this._data[t*Me+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Me+0]&4194303||this._data[t*Me+2]&50331648)return t+(this._data[t*Me+0]>>22);return 0}copyCellsFrom(t,n,s,a,o){let c=t._data;if(o)for(let p=a-1;p>=0;p--){for(let h=0;h=n&&(this._combined[h-n+s]=t._combined[h])}}translateToString(t,n,s,a){n=n??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),a&&(a.length=0);let o="";for(;n>22||1}return a&&a.push(n),o}};function i2(e,t,n,s,a,o){let c=[];for(let f=0;f=f&&s0&&(L>_||g[L].getTrimmedLength()===0);L--)k++;k>0&&(c.push(f+g.length-k),c.push(k)),f+=g.length-1}return c}function n2(e,t){let n=[],s=0,a=t[s],o=0;for(let c=0;cba(e,h,t)).reduce((p,h)=>p+h),o=0,c=0,f=0;for(;fp&&(o-=p,c++);let h=e[c].getWidth(o-1)===2;h&&o--;let g=h?n-1:n;s.push(g),f+=g}return s}function ba(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,a=e[t+1].getWidth(0)===2;return s&&a?n-1:n}var Ub=class Ib{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Ib._nextId++,this._onDispose=this.register(new ce),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),es(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Ub._nextId=1;var l2=Ub,Nt={},Zr=Nt.B;Nt[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Nt.A={"#":"£"};Nt.B=void 0;Nt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Nt.C=Nt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Nt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Nt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Nt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Nt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Nt.E=Nt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Nt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Nt.H=Nt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Nt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var zv=4294967295,Ov=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Ct.clone(),this.savedCharset=Zr,this.markers=[],this._nullCell=Ki.fromCharData([0,rb,1,0]),this._whitespaceCell=Ki.fromCharData([0,xr,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new gu,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Lv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new du),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new du),this._whitespaceCell}getBlankLine(e,t){return new ha(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&ezv?zv:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ct);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Lv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Ct),s=0,a=this._getCorrectBufferLength(t);if(a>this.lines.maxLength&&(this.lines.maxLength=a),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new ha(e,n)));else for(let c=this._rows;c>t;c--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(a0&&(this.lines.trimStart(c),this.ybase=Math.max(this.ybase-c,0),this.ydisp=Math.max(this.ydisp-c,0),this.savedY=Math.max(this.savedY-c,0)),this.lines.maxLength=a}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let o=0;o.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=i2(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ct),n);if(s.length>0){let a=n2(this.lines,s);r2(this.lines,a.layout),this._reflowLargerAdjustViewport(e,t,a.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(Ct),a=n;for(;a-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;c--){let f=this.lines.get(c);if(!f||!f.isWrapped&&f.getTrimmedLength()<=e)continue;let p=[f];for(;f.isWrapped&&c>0;)f=this.lines.get(--c),p.unshift(f);if(!n){let I=this.ybase+this.y;if(I>=c&&I0&&(a.push({start:c+p.length+o,newLines:y}),o+=y.length),p.push(...y);let x=g.length-1,k=g[x];k===0&&(x--,k=g[x]);let L=p.length-_-1,M=h;for(;L>=0;){let I=Math.min(M,k);if(p[x]===void 0)break;if(p[x].copyCellsFrom(p[L],M-I,k-I,I,!0),k-=I,k===0&&(x--,k=g[x]),M-=I,M===0){L--;let Q=Math.max(L,0);M=ba(p,Q,this._cols)}}for(let I=0;I0;)this.ybase===0?this.y0){let c=[],f=[];for(let k=0;k=0;k--)if(_&&_.start>h+b){for(let L=_.newLines.length-1;L>=0;L--)this.lines.set(k--,_.newLines[L]);k++,c.push({index:h+1,amount:_.newLines.length}),b+=_.newLines.length,_=a[++g]}else this.lines.set(k,f[h--]);let y=0;for(let k=c.length-1;k>=0;k--)c[k].index+=y,this.lines.onInsertEmitter.fire(c[k]),y+=c[k].amount;let x=Math.max(0,p+o-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(e,t,n=0,s){let a=this.lines.get(e);return a?a.translateToString(t,n,s):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+10;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.linen.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},a2=class extends Be{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new ce),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new Ov(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Ov(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},Fb=2,qb=1,sd=class extends Be{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new ce),this.onResize=this._onResize.event,this._onScroll=this._register(new ce),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Fb),this.rows=Math.max(e.rawOptions.rows||0,qb),this.buffers=this._register(new a2(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=n.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let a=n.ybase+n.scrollTop,o=n.ybase+n.scrollBottom;if(n.scrollTop===0){let c=n.lines.isFull;o===n.lines.length-1?c?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(o+1,0,s.clone()),c?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let c=o-a+1;n.lines.shiftElements(a+1,c-1,-1),n.lines.set(o,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),s!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};sd=pt([pe(0,ci)],sd);var Ys={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:_u,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},o2=["normal","bold","100","200","300","400","500","600","700","800","900"],u2=class extends Be{constructor(e){super(),this._onOptionChange=this._register(new ce),this.onOptionChange=this._onOptionChange.event;let t={...Ys};for(let n in e)if(n in t)try{let s=e[n];t[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(lt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in Ys))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in Ys))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Ys[e]),!c2(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Ys[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=o2.includes(t)?t:Ys[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function c2(e){return e==="block"||e==="underline"||e==="bar"}function fa(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let s in e)n[s]=t<=1?e[s]:e[s]&&fa(e[s],t-1);return n}var jv=Object.freeze({insertMode:!1}),Hv=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),ld=class extends Be{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new ce),this.onData=this._onData.event,this._onUserInput=this._register(new ce),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ce),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ce),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=fa(jv),this.decPrivateModes=fa(Hv)}reset(){this.modes=fa(jv),this.decPrivateModes=fa(Hv)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};ld=pt([pe(0,ui),pe(1,ub),pe(2,ci)],ld);var Pv={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function sf(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var lf=String.fromCharCode,Uv={DEFAULT:e=>{let t=[sf(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${lf(t[0])}${lf(t[1])}${lf(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${sf(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${sf(e,!0)};${e.x};${e.y}${t}`}},ad=class extends Be{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new ce),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Pv))this.addProtocol(s,Pv[s]);for(let s of Object.keys(Uv))this.addEncoding(s,Uv[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let s=t/n,a=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(a/=s+0,Math.abs(e.deltaY)<50&&(a*=.3),this._wheelPartialScroll+=a,a=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(a*=this._bufferService.rows),a}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};ad=pt([pe(0,ui),pe(1,ns),pe(2,ci)],ad);var af=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],h2=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Mt;function f2(e,t){let n=0,s=t.length-1,a;if(et[s][1])return!1;for(;s>=n;)if(a=n+s>>1,e>t[a][1])n=a+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let a=Qr.extractWidth(t);a===0?s=!1:a>n&&(n=a)}return Qr.createPropertyValue(0,n,s)}},Qr=class cu{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ce,this.onChange=this._onChange.event;let t=new d2;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,s=!1){return(t&16777215)<<3|(n&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,s=0,a=t.length;for(let o=0;o=a)return n+this.wcwidth(c);let h=t.charCodeAt(o);56320<=h&&h<=57343?c=(c-55296)*1024+h-56320+65536:n+=this.wcwidth(h)}let f=this.charProperties(c,s),p=cu.extractWidth(f);cu.extractShouldJoin(f)&&(p-=cu.extractWidth(s)),n+=p,s=f}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},p2=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Iv(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var Jl=2147483647,m2=256,Wb=class od{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>m2)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new od;if(!t.length)return n;for(let s=Array.isArray(t[0])?1:0;s>8,a=this._subParamsIdx[n]&255;a-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,a))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Jl?Jl:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Jl?Jl:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let t={};for(let n=0;n>8,a=this._subParamsIdx[n]&255;a-s>0&&(t[n]=this._subParams.slice(s,a))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,a=s[n-1];s[n-1]=~a?Math.min(a*10+t,Jl):t}},ea=[],_2=class{constructor(){this._state=0,this._active=ea,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ea}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=ea,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ea,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",wu(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=ea,this._id=-1,this._state=0}}},Ri=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=wu(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},ta=[],g2=class{constructor(){this._handlers=Object.create(null),this._active=ta,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ta}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=ta,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||ta,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",wu(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=ta,this._ident=0}},da=new Wb;da.addParam(0);var Fv=class{constructor(e){this._handler=e,this._data="",this._params=da,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():da,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=wu(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=da,this._data="",this._hitLimit=!1,n));return this._params=da,this._data="",this._hitLimit=!1,t}},v2=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let a=0;ap),n=(f,p)=>t.slice(f,p),s=n(32,127),a=n(0,24);a.push(25),a.push.apply(a,n(28,32));let o=n(0,14),c;e.setDefault(1,0),e.addMany(s,0,2,0);for(c in o)e.addMany([24,26,153,154],c,3,0),e.addMany(n(128,144),c,3,0),e.addMany(n(144,152),c,3,0),e.add(156,c,0,0),e.add(27,c,11,1),e.add(157,c,4,8),e.addMany([152,158,159],c,0,7),e.add(155,c,11,3),e.add(144,c,11,9);return e.addMany(a,0,3,0),e.addMany(a,1,3,1),e.add(127,1,0,1),e.addMany(a,8,0,8),e.addMany(a,3,3,3),e.add(127,3,0,3),e.addMany(a,4,3,4),e.add(127,4,0,4),e.addMany(a,6,3,6),e.addMany(a,5,3,5),e.add(127,5,0,5),e.addMany(a,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(a,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(a,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(a,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(a,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(a,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(a,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Yi,0,2,0),e.add(Yi,8,5,8),e.add(Yi,6,0,6),e.add(Yi,11,0,11),e.add(Yi,13,13,13),e})(),b2=class extends Be{constructor(e=y2){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Wb,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(lt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new _2),this._dcsParser=this._register(new g2),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let a=0;ao||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=s,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];return s.push(t),{dispose:()=>{let a=s.indexOf(t);a!==-1&&s.splice(a,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];return s.push(t),{dispose:()=>{let a=s.indexOf(t);a!==-1&&s.splice(a,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,s,a){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=a}parse(e,t,n){let s=0,a=0,o=0,c;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let f=this._parseStack.handlers,p=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&p>-1){for(;p>=0&&(c=f[p](this._params),c!==!0);p--)if(c instanceof Promise)return this._parseStack.handlerPos=p,c}this._parseStack.handlers=[];break;case 4:if(n===!1&&p>-1){for(;p>=0&&(c=f[p](),c!==!0);p--)if(c instanceof Promise)return this._parseStack.handlerPos=p,c}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],c=this._dcsParser.unhook(s!==24&&s!==26,n),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],c=this._oscParser.end(s!==24&&s!==26,n),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let f=o;f>4){case 2:for(let b=f+1;;++b){if(b>=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=0&&(c=p[h](this._params),c!==!0);h--)if(c instanceof Promise)return this._preserveStack(3,p,h,a,f),c;h<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++f47&&s<60);f--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let g=this._escHandlers[this._collect<<8|s],_=g?g.length-1:-1;for(;_>=0&&(c=g[_](),c!==!0);_--)if(c instanceof Promise)return this._preserveStack(4,g,_,a,f),c;_<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let b=f+1;;++b)if(b>=t||(s=e[b])===24||s===26||s===27||s>127&&s=t||(s=e[b])<32||s>127&&s>4:o>>8}return s}}function of(e,t){let n=e.toString(16),s=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function w2(e,t=16){let[n,s,a]=e;return`rgb:${of(n,t)}/${of(s,t)}/${of(a,t)}`}var C2={"(":0,")":1,"*":2,"+":3,"-":1,".":2},vr=131072,Wv=10;function Yv(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Vv=5e3,Kv=0,k2=class extends Be{constructor(e,t,n,s,a,o,c,f,p=new b2){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=a,this._oscLinkService=o,this._coreMouseService=c,this._unicodeService=f,this._parser=p,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Wx,this._utf8Decoder=new Yx,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ct.clone(),this._eraseAttrDataInternal=Ct.clone(),this._onRequestBell=this._register(new ce),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ce),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ce),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ce),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ce),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ce),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ce),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ce),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ce),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ce),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ce),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ce),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ce),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new ud(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,g)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:g.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,g,_)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:g,data:_})}),this._parser.setDcsHandlerFallback((h,g,_)=>{g==="HOOK"&&(_=_.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:g,payload:_})}),this._parser.setPrintHandler((h,g,_)=>this.print(h,g,_)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler(se.BEL,()=>this.bell()),this._parser.setExecuteHandler(se.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(se.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(se.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(se.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(se.BS,()=>this.backspace()),this._parser.setExecuteHandler(se.HT,()=>this.tab()),this._parser.setExecuteHandler(se.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(se.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ou.IND,()=>this.index()),this._parser.setExecuteHandler(ou.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ou.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ri(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new Ri(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new Ri(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new Ri(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new Ri(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new Ri(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new Ri(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new Ri(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new Ri(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new Ri(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new Ri(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new Ri(h=>this.restoreCursorColor(h))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let h in Nt)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Fv((h,g)=>this.requestStatusString(h,g)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),Vv))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Vv} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,a=this._activeBuffer.y,o=0,c=this._parseStack.paused;if(c){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,a=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>vr&&(o=this._parseStack.position+vr)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(h=>h.charCodeAt(0)):e),this._parseBuffer.lengthvr)for(let h=o;h0&&_.getWidth(this._activeBuffer.x-1)===2&&_.setCellFromCodepoint(this._activeBuffer.x-1,0,1,g);let b=this._parser.precedingJoinState;for(let y=t;yf){if(p){let M=_,Z=this._activeBuffer.x-L;for(this._activeBuffer.x=L,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),_=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),L>0&&_ instanceof ha&&_.copyCellsFrom(M,Z,0,L,!1);Z=0;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,g);continue}if(h&&(_.insertCells(this._activeBuffer.x,a-L,this._activeBuffer.getNullCell(g)),_.getWidth(f-1)===2&&_.setCellFromCodepoint(f-1,0,1,g)),_.setCellFromCodepoint(this._activeBuffer.x++,s,a,g),a>0)for(;--a;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,g)}this._parser.precedingJoinState=b,this._activeBuffer.x0&&_.getWidth(this._activeBuffer.x)===0&&!_.hasContent(this._activeBuffer.x)&&_.setCellFromCodepoint(this._activeBuffer.x,0,1,g),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>Yv(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Fv(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ri(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,s=!1,a=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),a),s&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&s.getTrimmedLength()););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let a=this._activeBuffer.lines.length-this._bufferService.rows;a>0&&(this._activeBuffer.lines.trimStart(a),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-a,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-a,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y65535?2:1}let p=f;for(let h=1;h0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(se.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(se.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(se.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(se.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(se.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t(k[k.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",k[k.SET=1]="SET",k[k.RESET=2]="RESET",k[k.PERMANENTLY_SET=3]="PERMANENTLY_SET",k[k.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:a,activeEncoding:o}=this._coreMouseService,c=this._coreService,{buffers:f,cols:p}=this._bufferService,{active:h,alt:g}=f,_=this._optionsService.rawOptions,b=(k,L)=>(c.triggerDataEvent(`${se.ESC}[${t?"":"?"}${k};${L}$y`),!0),y=k=>k?1:2,x=e.params[0];return t?x===2?b(x,4):x===4?b(x,y(c.modes.insertMode)):x===12?b(x,3):x===20?b(x,y(_.convertEol)):b(x,0):x===1?b(x,y(s.applicationCursorKeys)):x===3?b(x,_.windowOptions.setWinLines?p===80?2:p===132?1:0:0):x===6?b(x,y(s.origin)):x===7?b(x,y(s.wraparound)):x===8?b(x,3):x===9?b(x,y(a==="X10")):x===12?b(x,y(_.cursorBlink)):x===25?b(x,y(!c.isCursorHidden)):x===45?b(x,y(s.reverseWraparound)):x===66?b(x,y(s.applicationKeypad)):x===67?b(x,4):x===1e3?b(x,y(a==="VT200")):x===1002?b(x,y(a==="DRAG")):x===1003?b(x,y(a==="ANY")):x===1004?b(x,y(s.sendFocus)):x===1005?b(x,4):x===1006?b(x,y(o==="SGR")):x===1015?b(x,4):x===1016?b(x,y(o==="SGR_PIXELS")):x===1048?b(x,1):x===47||x===1047||x===1049?b(x,y(h===g)):x===2004?b(x,y(s.bracketedPasteMode)):x===2026?b(x,y(s.synchronizedOutput)):b(x,0)}_updateAttrColor(e,t,n,s,a){return t===2?(e|=50331648,e&=-16777216,e|=Ca.fromColorRGB([n,s,a])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let s=[0,0,-1,0,0,0],a=0,o=0;do{if(s[o+a]=e.params[t+o],e.hasSubParams(t+o)){let c=e.getSubParams(t+o),f=0;do s[1]===5&&(a=1),s[o+f+1+a]=c[f];while(++f=2||s[1]===2&&o+a>=5)break;s[1]&&(a=1)}while(++o+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Ct.fg,e.bg=Ct.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,s=this._curAttrData;for(let a=0;a=30&&n<=37?(s.fg&=-50331904,s.fg|=16777216|n-30):n>=40&&n<=47?(s.bg&=-50331904,s.bg|=16777216|n-40):n>=90&&n<=97?(s.fg&=-50331904,s.fg|=16777216|n-90|8):n>=100&&n<=107?(s.bg&=-50331904,s.bg|=16777216|n-100|8):n===0?this._processSGR0(s):n===1?s.fg|=134217728:n===3?s.bg|=67108864:n===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(a)?e.getSubParams(a)[0]:1,s)):n===5?s.fg|=536870912:n===7?s.fg|=67108864:n===8?s.fg|=1073741824:n===9?s.fg|=2147483648:n===2?s.bg|=134217728:n===21?this._processUnderline(2,s):n===22?(s.fg&=-134217729,s.bg&=-134217729):n===23?s.bg&=-67108865:n===24?(s.fg&=-268435457,this._processUnderline(0,s)):n===25?s.fg&=-536870913:n===27?s.fg&=-67108865:n===28?s.fg&=-1073741825:n===29?s.fg&=2147483647:n===39?(s.fg&=-67108864,s.fg|=Ct.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=Ct.bg&16777215):n===38||n===48||n===58?a+=this._extractColor(e,a,s):n===53?s.bg|=1073741824:n===55?s.bg&=-1073741825:n===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):n===100?(s.fg&=-67108864,s.fg|=Ct.fg&16777215,s.bg&=-67108864,s.bg|=Ct.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${se.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${se.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${se.ESC}[?${t};${n}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Ct.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Yv(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${se.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Wv&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Wv&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let s=n.shift(),a=n.shift();if(/^\d+$/.exec(s)){let o=parseInt(s);if(Xv(o))if(a==="?")t.push({type:0,index:o});else{let c=qv(a);c&&t.push({type:1,index:o,color:c})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),s,a=n.findIndex(o=>o.startsWith("id="));return a!==-1&&(s=n[a].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let s=0;s=this._specialColors.length);++s,++t)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let a=qv(n[s]);a&&this._onColor.fire([{type:1,index:this._specialColors[t],color:a}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let s=0;s=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Ct.clone(),this._eraseAttrDataInternal=Ct.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Ki;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t(this._coreService.triggerDataEvent(`${se.ESC}${c}${se.ESC}\\`),!0),s=this._bufferService.buffer,a=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[a.cursorStyle]-(a.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},ud=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){ethis.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Kv=e,e=t,t=Kv),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};ud=pt([pe(0,ui)],ud);function Xv(e){return 0<=e&&e<256}var E2=5e7,Gv=12,T2=50,A2=class extends Be{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new ce),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>E2)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],a=this._action(s,t);if(a){let c=f=>performance.now()-n>=Gv?setTimeout(()=>this._innerWrite(0,f)):this._innerWrite(n,f);a.catch(f=>(queueMicrotask(()=>{throw f}),Promise.resolve(!1))).then(c);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=Gv)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>T2&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},cd=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let f=t.addMarker(t.ybase+t.y),p={data:e,id:this._nextId++,lines:[f]};return f.onDispose(()=>this._removeMarkerFromLink(p,f)),this._dataByLinkId.set(p.id,p),p.id}let n=e,s=this._getEntryIdKey(n),a=this._entriesWithId.get(s);if(a)return this.addLineToLink(a.id,t.ybase+t.y),a.id;let o=t.addMarker(t.ybase+t.y),c={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(c,o)),this._entriesWithId.set(c.key,c),this._dataByLinkId.set(c.id,c),c.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};cd=pt([pe(0,ui)],cd);var $v=!1,D2=class extends Be{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Zs),this._onBinary=this._register(new ce),this.onBinary=this._onBinary.event,this._onData=this._register(new ce),this.onData=this._onData.event,this._onLineFeed=this._register(new ce),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ce),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ce),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ce),this._instantiationService=new JC,this.optionsService=this._register(new u2(e)),this._instantiationService.setService(ci,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(sd)),this._instantiationService.setService(ui,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(rd)),this._instantiationService.setService(ub,this._logService),this.coreService=this._register(this._instantiationService.createInstance(ld)),this._instantiationService.setService(ns,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(ad)),this._instantiationService.setService(ob,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Qr)),this._instantiationService.setService(Gx,this.unicodeService),this._charsetService=this._instantiationService.createInstance(p2),this._instantiationService.setService(Xx,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(cd),this._instantiationService.setService(cb,this._oscLinkService),this._inputHandler=this._register(new k2(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Jt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Jt.forward(this._bufferService.onResize,this._onResize)),this._register(Jt.forward(this.coreService.onData,this._onData)),this._register(Jt.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new A2((t,n)=>this._inputHandler.parse(t,n))),this._register(Jt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ce),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!$v&&(this._logService.warn("writeSync is unreliable and will be removed soon."),$v=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,Fb),t=Math.max(t,qb),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Iv.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Iv(this._bufferService),!1))),this._windowsWrappingHeuristics.value=lt(()=>{for(let t of e)t.dispose()})}}},R2={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function M2(e,t,n,s){var c;let a={type:0,cancel:!1,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?a.key=se.ESC+"OA":a.key=se.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?a.key=se.ESC+"OD":a.key=se.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?a.key=se.ESC+"OC":a.key=se.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?a.key=se.ESC+"OB":a.key=se.ESC+"[B");break;case 8:a.key=e.ctrlKey?"\b":se.DEL,e.altKey&&(a.key=se.ESC+a.key);break;case 9:if(e.shiftKey){a.key=se.ESC+"[Z";break}a.key=se.HT,a.cancel=!0;break;case 13:a.key=e.altKey?se.ESC+se.CR:se.CR,a.cancel=!0;break;case 27:a.key=se.ESC,e.altKey&&(a.key=se.ESC+se.ESC),a.cancel=!0;break;case 37:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"D":t?a.key=se.ESC+"OD":a.key=se.ESC+"[D";break;case 39:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"C":t?a.key=se.ESC+"OC":a.key=se.ESC+"[C";break;case 38:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"A":t?a.key=se.ESC+"OA":a.key=se.ESC+"[A";break;case 40:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"B":t?a.key=se.ESC+"OB":a.key=se.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(a.key=se.ESC+"[2~");break;case 46:o?a.key=se.ESC+"[3;"+(o+1)+"~":a.key=se.ESC+"[3~";break;case 36:o?a.key=se.ESC+"[1;"+(o+1)+"H":t?a.key=se.ESC+"OH":a.key=se.ESC+"[H";break;case 35:o?a.key=se.ESC+"[1;"+(o+1)+"F":t?a.key=se.ESC+"OF":a.key=se.ESC+"[F";break;case 33:e.shiftKey?a.type=2:e.ctrlKey?a.key=se.ESC+"[5;"+(o+1)+"~":a.key=se.ESC+"[5~";break;case 34:e.shiftKey?a.type=3:e.ctrlKey?a.key=se.ESC+"[6;"+(o+1)+"~":a.key=se.ESC+"[6~";break;case 112:o?a.key=se.ESC+"[1;"+(o+1)+"P":a.key=se.ESC+"OP";break;case 113:o?a.key=se.ESC+"[1;"+(o+1)+"Q":a.key=se.ESC+"OQ";break;case 114:o?a.key=se.ESC+"[1;"+(o+1)+"R":a.key=se.ESC+"OR";break;case 115:o?a.key=se.ESC+"[1;"+(o+1)+"S":a.key=se.ESC+"OS";break;case 116:o?a.key=se.ESC+"[15;"+(o+1)+"~":a.key=se.ESC+"[15~";break;case 117:o?a.key=se.ESC+"[17;"+(o+1)+"~":a.key=se.ESC+"[17~";break;case 118:o?a.key=se.ESC+"[18;"+(o+1)+"~":a.key=se.ESC+"[18~";break;case 119:o?a.key=se.ESC+"[19;"+(o+1)+"~":a.key=se.ESC+"[19~";break;case 120:o?a.key=se.ESC+"[20;"+(o+1)+"~":a.key=se.ESC+"[20~";break;case 121:o?a.key=se.ESC+"[21;"+(o+1)+"~":a.key=se.ESC+"[21~";break;case 122:o?a.key=se.ESC+"[23;"+(o+1)+"~":a.key=se.ESC+"[23~";break;case 123:o?a.key=se.ESC+"[24;"+(o+1)+"~":a.key=se.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?a.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?a.key=se.NUL:e.keyCode>=51&&e.keyCode<=55?a.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?a.key=se.DEL:e.keyCode===219?a.key=se.ESC:e.keyCode===220?a.key=se.FS:e.keyCode===221&&(a.key=se.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let f=(c=R2[e.keyCode])==null?void 0:c[e.shiftKey?1:0];if(f)a.key=se.ESC+f;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,h=String.fromCharCode(p);e.shiftKey&&(h=h.toUpperCase()),a.key=se.ESC+h}else if(e.keyCode===32)a.key=se.ESC+(e.ctrlKey?se.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),a.key=se.ESC+p,a.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(a.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?a.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(a.key=se.US),e.key==="@"&&(a.key=se.NUL));break}return a}var gt=0,B2=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new gu,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new gu,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((a,o)=>this._getKey(a)-this._getKey(o)),t=0,n=0,s=new Array(this._array.length+this._insertedValues.length);for(let a=0;a=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(s[a]=e[t],t++):s[a]=this._array[n++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(gt=this._search(t),gt===-1)||this._getKey(this._array[gt])!==t)return!1;do if(this._array[gt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(gt),!0;while(++gta-o),t=0,n=new Array(this._array.length-e.length),s=0;for(let a=0;a0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(gt=this._search(e),!(gt<0||gt>=this._array.length)&&this._getKey(this._array[gt])===e))do yield this._array[gt];while(++gt=this._array.length)&&this._getKey(this._array[gt])===e))do t(this._array[gt]);while(++gt=t;){let s=t+n>>1,a=this._getKey(this._array[s]);if(a>e)n=s-1;else if(a0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},uf=0,Zv=0,N2=class extends Be{constructor(){super(),this._decorations=new B2(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new ce),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ce),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(lt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new L2(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let s=0,a=0;for(let o of this._decorations.getKeyIterator(t))s=o.options.x??0,a=s+(o.options.width??1),e>=s&&e{uf=a.options.x??0,Zv=uf+(a.options.width??1),e>=uf&&e=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let a=s-this._lastRefreshMs,o=this._debounceThresholdMS-a;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Qv=20,vu=class extends Be{constructor(e,t,n,s){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let a=this._coreBrowserService.mainDocument;this._accessibilityContainer=a.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=a.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;othis._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=a.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new O2(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(` +`))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(ke(a,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(lt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===` +`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Qv+1&&(this._liveRegion.textContent+=Rf.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,s=n.lines.length.toString();for(let a=e;a<=t;a++){let o=n.lines.get(n.ydisp+a),c=[],f=(o==null?void 0:o.translateToString(!0,void 0,void 0,c))||"",p=(n.ydisp+a+1).toString(),h=this._rowElements[a];h&&(f.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=f,this._rowColumns.set(h,c)),h.setAttribute("aria-posinset",p),h.setAttribute("aria-setsize",s),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],a=n.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(a===o||e.relatedTarget!==s)return;let c,f;if(t===0?(c=n,f=this._rowElements.pop(),this._rowContainer.removeChild(f)):(c=this._rowElements.shift(),f=n,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),f.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let p=this._createAccessibilityTreeNode();this._rowElements.unshift(p),this._rowContainer.insertAdjacentElement("afterbegin",p)}else{let p=this._createAccessibilityTreeNode();this._rowElements.push(p),this._rowContainer.appendChild(p)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var f;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:s,offset:((f=s.textContent)==null?void 0:f.length)??0}),!this._rowContainer.contains(n.node))return;let a=({node:p,offset:h})=>{let g=p instanceof Text?p.parentNode:p,_=parseInt(g==null?void 0:g.getAttribute("aria-posinset"),10)-1;if(isNaN(_))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(g);if(!b)return console.warn("columns is null. Race condition?"),null;let y=h=this._terminal.cols&&(++_,y=0),{row:_,column:y}},o=a(t),c=a(n);if(!(!o||!c)){if(o.row>c.row||o.row===c.row&&o.column>=c.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(c.row-o.row)*this._terminal.cols-o.column+c.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;te;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e{var o;es(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(o=this._activeProviderReplies)==null||o.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(ke(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(ke(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(ke(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(ke(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let s=0;s{o==null||o.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[o,c]of this._linkProviderService.linkProviders.entries())t?(a=this._activeProviderReplies)!=null&&a.get(o)&&(n=this._checkLinkProviderResult(o,e,n)):c.provideLinks(e.y,f=>{var h,g;if(this._isMouseOut)return;let p=f==null?void 0:f.map(_=>({link:_}));(h=this._activeProviderReplies)==null||h.set(o,p),n=this._checkLinkProviderResult(o,e,n),((g=this._activeProviderReplies)==null?void 0:g.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;se?this._bufferService.cols:c.link.range.end.x;for(let h=f;h<=p;h++){if(n.has(h)){a.splice(o--,1);break}n.add(h)}}}}_checkLinkProviderResult(e,t,n){var o;if(!this._activeProviderReplies)return n;let s=this._activeProviderReplies.get(e),a=!1;for(let c=0;cthis._linkAtPosition(f.link,t));c&&(n=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let c=0;cthis._linkAtPosition(p.link,t));if(f){n=!0,this._handleNewLink(f);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&j2(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,es(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.pointerCursor},set:n=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.underline},set:n=>{var s,a,o;(s=this._currentLink)!=null&&s.state&&((o=(a=this._currentLink)==null?void 0:a.state)==null?void 0:o.decorations.underline)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let s=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,a=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=a&&(this._clearCurrentLink(s,a),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,s=this._bufferService.buffer.ydisp,a=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(a)}_linkLeave(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,a=t.y*this._bufferService.cols+t.x;return n<=a&&a<=s}_positionFromMouseEvent(e,t,n){let s=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,s,a){return{x1:e,y1:t,x2:n,y2:s,cols:this._bufferService.cols,fg:a}}};hd=pt([pe(1,kd),pe(2,Fn),pe(3,ui),pe(4,fb)],hd);function j2(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var H2=class extends D2{constructor(e={}){super(e),this._linkifier=this._register(new Zs),this.browser=Mb,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Zs),this._onCursorMove=this._register(new ce),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ce),this.onKey=this._onKey.event,this._onRender=this._register(new ce),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ce),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ce),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ce),this.onBell=this._onBell.event,this._onFocus=this._register(new ce),this._onBlur=this._register(new ce),this._onA11yCharEmitter=this._register(new ce),this._onA11yTabEmitter=this._register(new ce),this._onWillOpen=this._register(new ce),this._setup(),this._decorationService=this._instantiationService.createInstance(N2),this._instantiationService.setService(ka,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(TC),this._instantiationService.setService(fb,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Bf)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Jt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Jt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Jt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Jt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(lt(()=>{var t,n;this._customKeyEventHandler=void 0,(n=(t=this.element)==null?void 0:t.parentNode)==null||n.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,s="";switch(t.index){case 256:n="foreground",s="10";break;case 257:n="background",s="11";break;case 258:n="cursor",s="12";break;default:n="ansi",s="4;"+t.index}switch(t.type){case 0:let a=nt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${se.ESC}]${s};${w2(a)}${Db.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=kt.toColor(...t.color));else{let o=n;this._themeService.modifyColors(c=>c[o]=kt.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(vu,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(se.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(se.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,a=t.getWidth(n),o=this._renderService.dimensions.css.cell.width*a,c=this.buffer.y*this._renderService.dimensions.css.cell.height,f=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=f+"px",this.textarea.style.top=c+"px",this.textarea.style.width=o+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(ke(this.element,"copy",t=>{this.hasSelection()&&Fx(t,this._selectionService)}));let e=t=>qx(t,this.textarea,this.coreService,this.optionsService);this._register(ke(this.textarea,"paste",e)),this._register(ke(this.element,"paste",e)),Bb?this._register(ke(this.element,"mousedown",t=>{t.button===2&&ov(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(ke(this.element,"contextmenu",t=>{ov(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Nd&&this._register(ke(this.element,"auxclick",t=>{t.button===1&&nb(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(ke(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(ke(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(ke(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(ke(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(ke(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(ke(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(ke(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var a;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((a=this.element)==null?void 0:a.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(ke(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Df.get()),zb||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(kC,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(In,this._coreBrowserService),this._register(ke(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(ke(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Jf,this._document,this._helperContainer),this._instantiationService.setService(Cu,this._charSizeService),this._themeService=this._instantiationService.createInstance(nd),this._instantiationService.setService(Js,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(mu),this._instantiationService.setService(hb,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(td,this.rows,this.screenElement)),this._instantiationService.setService(Fn,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance($f,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(ed),this._instantiationService.setService(kd,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(hd,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Xf,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(id,this.element,this.screenElement,s)),this._instantiationService.setService(Zx,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register(Jt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(Gf,this.screenElement)),this._register(ke(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(vu,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(pu,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(pu,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Qf,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(o){var h,g,_,b,y;let c=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!c)return!1;let f,p;switch(o.overrideType||o.type){case"mousemove":p=32,o.buttons===void 0?(f=3,o.button!==void 0&&(f=o.button<3?o.button:3)):f=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":p=0,f=o.button<3?o.button:3;break;case"mousedown":p=1,f=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let x=o.deltaY;if(x===0||e.coreMouseService.consumeWheelEvent(o,(b=(_=(g=(h=e._renderService)==null?void 0:h.dimensions)==null?void 0:g.device)==null?void 0:_.cell)==null?void 0:b.height,(y=e._coreBrowserService)==null?void 0:y.dpr)===0)return!1;p=x<0?0:1,f=4;break;default:return!1}return p===void 0||f===void 0||f>4?!1:e.coreMouseService.triggerMouseEvent({col:c.col,row:c.row,x:c.x,y:c.y,button:f,action:p,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:o=>(n(o),o.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(o)),wheel:o=>(n(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&n(o)},mousemove:o=>{o.buttons||n(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?s.mousemove||(t.addEventListener("mousemove",a.mousemove),s.mousemove=a.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),o&16?s.wheel||(t.addEventListener("wheel",a.wheel,{passive:!1}),s.wheel=a.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),o&2?s.mouseup||(s.mouseup=a.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),o&4?s.mousedrag||(s.mousedrag=a.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(ke(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return n(o),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(o)})),this._register(ke(t,"wheel",o=>{var c,f,p,h,g;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,(h=(p=(f=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:f.device)==null?void 0:p.cell)==null?void 0:h.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return this.cancel(o,!0);let _=se.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(_,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var n;(n=this._renderService)==null||n.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){ib(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var n;(n=this._selectionService)==null||n.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=M2(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let s=this.rows-1;return this.scrollLines(n.type===2?-s:s),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===se.ETX||n.key===se.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(P2(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var n;(n=this._charSizeService)==null||n.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Ki)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Jv=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new I2(t)}getNullCell(){return new Ki}},F2=class extends Be{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ce),this.onBufferChange=this._onBufferChange.event,this._normal=new Jv(this._core.buffers.normal,"normal"),this._alternate=new Jv(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},q2=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,s)=>t(n,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},W2=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},Y2=["cols","rows"],an=0,V2=class extends Be{constructor(e){super(),this._core=this._register(new H2(e)),this._addonManager=this._register(new U2),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],n=(s,a)=>{this._checkReadonlyOptions(s),this._core.options[s]=a};for(let s in this._core.options){let a={get:t.bind(this,s),set:n.bind(this,s)};Object.defineProperty(this._publicOptions,s,a)}}_checkReadonlyOptions(e){if(Y2.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new q2(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new W2(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new F2(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r +`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Df.get()},set promptLabel(e){Df.set(e)},get tooMuchOutput(){return Rf.get()},set tooMuchOutput(e){Rf.set(e)}}}_verifyIntegers(...e){for(an of e)if(an===1/0||isNaN(an)||an%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(an of e)if(an&&(an===1/0||isNaN(an)||an%1!==0||an<0))throw new Error("This API only accepts positive integers")}};/** + * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. + * @license MIT + * + * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) + * @license MIT + * + * Originally forked from (with the author's permission): + * Fabrice Bellard's javascript vt100 for jslinux: + * http://bellard.org/jslinux/ + * Copyright (c) 2011 Fabrice Bellard + */var K2=2,X2=1,G2=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var _;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((_=this._terminal.options.overviewRuler)==null?void 0:_.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),a=Math.max(0,parseInt(n.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),c={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},f=c.top+c.bottom,p=c.right+c.left,h=s-f,g=a-p-t;return{cols:Math.max(K2,Math.floor(g/e.css.cell.width)),rows:Math.max(X2,Math.floor(h/e.css.cell.height))}}};/** + * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. + * @license MIT + * + * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) + * @license MIT + * + * Originally forked from (with the author's permission): + * Fabrice Bellard's javascript vt100 for jslinux: + * http://bellard.org/jslinux/ + * Copyright (c) 2011 Fabrice Bellard + */var Ut=0,It=0,Ft=0,dt=0,ii;(e=>{function t(a,o,c,f){return f!==void 0?`#${Kr(a)}${Kr(o)}${Kr(c)}${Kr(f)}`:`#${Kr(a)}${Kr(o)}${Kr(c)}`}e.toCss=t;function n(a,o,c,f=255){return(a<<24|o<<16|c<<8|f)>>>0}e.toRgba=n;function s(a,o,c,f){return{css:e.toCss(a,o,c,f),rgba:e.toRgba(a,o,c,f)}}e.toColor=s})(ii||(ii={}));var $2;(e=>{function t(p,h){if(dt=(h.rgba&255)/255,dt===1)return{css:h.css,rgba:h.rgba};let g=h.rgba>>24&255,_=h.rgba>>16&255,b=h.rgba>>8&255,y=p.rgba>>24&255,x=p.rgba>>16&255,k=p.rgba>>8&255;Ut=y+Math.round((g-y)*dt),It=x+Math.round((_-x)*dt),Ft=k+Math.round((b-k)*dt);let L=ii.toCss(Ut,It,Ft),M=ii.toRgba(Ut,It,Ft);return{css:L,rgba:M}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,h,g){let _=hu.ensureContrastRatio(p.rgba,h.rgba,g);if(_)return ii.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function a(p){let h=(p.rgba|255)>>>0;return[Ut,It,Ft]=hu.toChannels(h),{css:ii.toCss(Ut,It,Ft),rgba:h}}e.opaque=a;function o(p,h){return dt=Math.round(h*255),[Ut,It,Ft]=hu.toChannels(p.rgba),{css:ii.toCss(Ut,It,Ft,dt),rgba:ii.toRgba(Ut,It,Ft,dt)}}e.opacity=o;function c(p,h){return dt=p.rgba&255,o(p,dt*h/255)}e.multiplyOpacity=c;function f(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=f})($2||($2={}));var Zt;(e=>{let t,n;try{let a=document.createElement("canvas");a.width=1,a.height=1;let o=a.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return Ut=parseInt(a.slice(1,2).repeat(2),16),It=parseInt(a.slice(2,3).repeat(2),16),Ft=parseInt(a.slice(3,4).repeat(2),16),ii.toColor(Ut,It,Ft);case 5:return Ut=parseInt(a.slice(1,2).repeat(2),16),It=parseInt(a.slice(2,3).repeat(2),16),Ft=parseInt(a.slice(3,4).repeat(2),16),dt=parseInt(a.slice(4,5).repeat(2),16),ii.toColor(Ut,It,Ft,dt);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let o=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Ut=parseInt(o[1]),It=parseInt(o[2]),Ft=parseInt(o[3]),dt=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),ii.toColor(Ut,It,Ft,dt);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ut,It,Ft,dt]=t.getImageData(0,0,1,1).data,dt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ii.toRgba(Ut,It,Ft,dt),css:a}}e.toColor=s})(Zt||(Zt={}));var ai;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,a,o){let c=s/255,f=a/255,p=o/255,h=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),_=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return h*.2126+g*.7152+_*.0722}e.relativeLuminance2=n})(ai||(ai={}));var hu;(e=>{function t(c,f){if(dt=(f&255)/255,dt===1)return f;let p=f>>24&255,h=f>>16&255,g=f>>8&255,_=c>>24&255,b=c>>16&255,y=c>>8&255;return Ut=_+Math.round((p-_)*dt),It=b+Math.round((h-b)*dt),Ft=y+Math.round((g-y)*dt),ii.toRgba(Ut,It,Ft)}e.blend=t;function n(c,f,p){let h=ai.relativeLuminance(c>>8),g=ai.relativeLuminance(f>>8);if(Hn(h,g)>8));if(x>8));return x>L?y:k}return y}let _=a(c,f,p),b=Hn(h,ai.relativeLuminance(_>>8));if(b>8));return b>x?_:y}return _}}e.ensureContrastRatio=n;function s(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=Hn(ai.relativeLuminance2(b,y,x),ai.relativeLuminance2(h,g,_));for(;k0||y>0||x>0);)b-=Math.max(0,Math.ceil(b*.1)),y-=Math.max(0,Math.ceil(y*.1)),x-=Math.max(0,Math.ceil(x*.1)),k=Hn(ai.relativeLuminance2(b,y,x),ai.relativeLuminance2(h,g,_));return(b<<24|y<<16|x<<8|255)>>>0}e.reduceLuminance=s;function a(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=Hn(ai.relativeLuminance2(b,y,x),ai.relativeLuminance2(h,g,_));for(;k>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(hu||(hu={}));function Kr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Hn(e,t){return e{let e=[Zt.toColor("#2e3436"),Zt.toColor("#cc0000"),Zt.toColor("#4e9a06"),Zt.toColor("#c4a000"),Zt.toColor("#3465a4"),Zt.toColor("#75507b"),Zt.toColor("#06989a"),Zt.toColor("#d3d7cf"),Zt.toColor("#555753"),Zt.toColor("#ef2929"),Zt.toColor("#8ae234"),Zt.toColor("#fce94f"),Zt.toColor("#729fcf"),Zt.toColor("#ad7fa8"),Zt.toColor("#34e2e2"),Zt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],a=t[n/6%6|0],o=t[n%6];e.push({css:ii.toCss(s,a,o),rgba:ii.toRgba(s,a,o)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:ii.toCss(s,s,s),rgba:ii.toRgba(s,s,s)})}return e})());function ey(e,t,n){return Math.max(t,Math.min(e,n))}function Q2(e){switch(e){case"&":return"&";case"<":return"<"}return e}var Yb=class{constructor(e){this._buffer=e}serialize(e,t){let n=this._buffer.getNullCell(),s=this._buffer.getNullCell(),a=n,o=e.start.y,c=e.end.y,f=e.start.x,p=e.end.x;this._beforeSerialize(c-o,o,c);for(let h=o;h<=c;h++){let g=this._buffer.getLine(h);if(g){let _=h===e.start.y?f:0,b=h===e.end.y?p:g.length;for(let y=_;y0&&!Pn(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let n="";if(!t){e-this._firstRow>=this._terminal.rows&&((s=this._buffer.getLine(this._cursorStyleRow))==null||s.getCell(this._cursorStyleCol,this._backgroundCell));let a=this._buffer.getLine(e),o=this._buffer.getLine(e+1);if(!o.isWrapped)n=`\r +`,this._lastCursorRow=e+1,this._lastCursorCol=0;else{n="";let c=a.getCell(a.length-1,this._thisRowLastChar),f=a.getCell(a.length-2,this._thisRowLastSecondChar),p=o.getCell(0,this._nextRowFirstChar),h=p.getWidth()>1,g=!1;(p.getChars()&&h?this._nullCellCount<=1:this._nullCellCount<=0)&&((c.getChars()||c.getWidth()===0)&&Pn(c,p)&&(g=!0),h&&(f.getChars()||f.getWidth()===0)&&Pn(c,p)&&Pn(f,p)&&(g=!0)),g||(n="-".repeat(this._nullCellCount+1),n+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(n+="\x1B[A",n+=`\x1B[${a.length-this._nullCellCount}C`,n+=`\x1B[${this._nullCellCount}X`,n+=`\x1B[${a.length-this._nullCellCount}D`,n+="\x1B[B"),this._lastContentCursorRow=e+1,this._lastContentCursorCol=0,this._lastCursorRow=e+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=n,this._currentRow="",this._nullCellCount=0}_diffStyle(e,t){let n=[],s=!Vb(e,t),a=!Pn(e,t),o=!Kb(e,t);if(s||a||o)if(e.isAttributeDefault())t.isAttributeDefault()||n.push(0);else{if(s){let c=e.getFgColor();e.isFgRGB()?n.push(38,2,c>>>16&255,c>>>8&255,c&255):e.isFgPalette()?c>=16?n.push(38,5,c):n.push(c&8?90+(c&7):30+(c&7)):n.push(39)}if(a){let c=e.getBgColor();e.isBgRGB()?n.push(48,2,c>>>16&255,c>>>8&255,c&255):e.isBgPalette()?c>=16?n.push(48,5,c):n.push(c&8?100+(c&7):40+(c&7)):n.push(49)}o&&(e.isInverse()!==t.isInverse()&&n.push(e.isInverse()?7:27),e.isBold()!==t.isBold()&&n.push(e.isBold()?1:22),e.isUnderline()!==t.isUnderline()&&n.push(e.isUnderline()?4:24),e.isOverline()!==t.isOverline()&&n.push(e.isOverline()?53:55),e.isBlink()!==t.isBlink()&&n.push(e.isBlink()?5:25),e.isInvisible()!==t.isInvisible()&&n.push(e.isInvisible()?8:28),e.isItalic()!==t.isItalic()&&n.push(e.isItalic()?3:23),e.isDim()!==t.isDim()&&n.push(e.isDim()?2:22),e.isStrikethrough()!==t.isStrikethrough()&&n.push(e.isStrikethrough()?9:29))}return n}_nextCell(e,t,n,s){if(e.getWidth()===0)return;let a=e.getChars()==="",o=this._diffStyle(e,this._cursorStyle);if(a?!Pn(this._cursorStyle,e):o.length>0){this._nullCellCount>0&&(Pn(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=s,this._currentRow+=`\x1B[${o.join(";")}m`;let c=this._buffer.getLine(n);c!==void 0&&(c.getCell(s,this._cursorStyle),this._cursorStyleRow=n,this._cursorStyleCol=s)}a?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(Pn(this._cursorStyle,this._backgroundCell)?this._currentRow+=`\x1B[${this._nullCellCount}C`:(this._currentRow+=`\x1B[${this._nullCellCount}X`,this._currentRow+=`\x1B[${this._nullCellCount}C`),this._nullCellCount=0),this._currentRow+=e.getChars(),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=s+e.getWidth())}_serializeString(e){let t=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(t=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let n="";for(let o=0;o{h>0?n+=`\x1B[${h}C`:h<0&&(n+=`\x1B[${-h}D`)};f&&((h=>{h>0?n+=`\x1B[${h}B`:h<0&&(n+=`\x1B[${-h}A`)})(o-this._lastCursorRow),p(c-this._lastCursorCol))}let s=this._terminal._core._inputHandler._curAttrData,a=this._diffStyle(s,this._cursorStyle);return a.length>0&&(n+=`\x1B[${a.join(";")}m`),n}},ek=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,n){let s=t.length,a=n===void 0?s:ey(n+e.rows,0,s);return this._serializeBufferByRange(e,t,{start:s-a,end:s-1},!1)}_serializeBufferByRange(e,t,n,s){return new J2(t,e).serialize({start:{x:0,y:typeof n.start=="number"?n.start:n.start.line},end:{x:e.cols,y:typeof n.end=="number"?n.end:n.end.line}},s)}_serializeBufferAsHTML(e,t){var f;let n=e.buffer.active,s=new tk(n,e,t),a=t.onlySelection??!1,o=t.range;if(o)return s.serialize({start:{x:o.startCol,y:(o.startLine,o.startLine)},end:{x:e.cols,y:(o.endLine,o.endLine)}});if(!a){let p=n.length,h=t.scrollback,g=h===void 0?p:ey(h+e.rows,0,p);return s.serialize({start:{x:0,y:p-g},end:{x:e.cols,y:p-1}})}let c=(f=this._terminal)==null?void 0:f.getSelectionPosition();return c!==void 0?s.serialize({start:{x:c.start.x,y:c.start.y},end:{x:c.end.x,y:c.end.y}}):""}_serializeModes(e){let t="",n=e.modes;if(n.applicationCursorKeysMode&&(t+="\x1B[?1h"),n.applicationKeypadMode&&(t+="\x1B[?66h"),n.bracketedPasteMode&&(t+="\x1B[?2004h"),n.insertMode&&(t+="\x1B[4h"),n.originMode&&(t+="\x1B[?6h"),n.reverseWraparoundMode&&(t+="\x1B[?45h"),n.sendFocusMode&&(t+="\x1B[?1004h"),n.wraparoundMode===!1&&(t+="\x1B[?7l"),n.mouseTrackingMode!=="none")switch(n.mouseTrackingMode){case"x10":t+="\x1B[?9h";break;case"vt200":t+="\x1B[?1000h";break;case"drag":t+="\x1B[?1002h";break;case"any":t+="\x1B[?1003h";break}return t}serialize(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let t=e!=null&&e.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,e.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,e==null?void 0:e.scrollback);if(!(e!=null&&e.excludeAltBuffer)&&this._terminal.buffer.active.type==="alternate"){let n=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);t+=`\x1B[?1049h\x1B[H${n}`}return e!=null&&e.excludeModes||(t+=this._serializeModes(this._terminal)),t}serializeAsHTML(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,e||{})}dispose(){}},tk=class extends Yb{constructor(e,t,n){super(e),this._terminal=t,this._options=n,this._currentRow="",this._htmlContent="",t._core._themeService?this._ansiColors=t._core._themeService.colors.ansi:this._ansiColors=Z2}_padStart(e,t,n){return t=t>>0,n=n??" ",e.length>t?e:(t-=e.length,t>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}_beforeSerialize(e,t,n){var c,f;this._htmlContent+="
";let s="#000000",a="#ffffff";(this._options.includeGlobalBackground??!1)&&(s=((c=this._terminal.options.theme)==null?void 0:c.foreground)??"#ffffff",a=((f=this._terminal.options.theme)==null?void 0:f.background)??"#000000");let o=[];o.push("color: "+s+";"),o.push("background-color: "+a+";"),o.push("font-family: "+this._terminal.options.fontFamily+";"),o.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="
"}_afterSerialize(){this._htmlContent+="
",this._htmlContent+="
"}_rowEnd(e,t){this._htmlContent+="
"+this._currentRow+"
",this._currentRow=""}_getHexColor(e,t){let n=t?e.getFgColor():e.getBgColor();if(t?e.isFgRGB():e.isBgRGB())return"#"+[n>>16&255,n>>8&255,n&255].map(s=>this._padStart(s.toString(16),2,"0")).join("");if(t?e.isFgPalette():e.isBgPalette())return this._ansiColors[n].css}_diffStyle(e,t){let n=[],s=!Vb(e,t),a=!Pn(e,t),o=!Kb(e,t);if(s||a||o){let c=this._getHexColor(e,!0);c&&n.push("color: "+c+";");let f=this._getHexColor(e,!1);return f&&n.push("background-color: "+f+";"),e.isInverse()&&n.push("color: #000000; background-color: #BFBFBF;"),e.isBold()&&n.push("font-weight: bold;"),e.isUnderline()&&e.isOverline()?n.push("text-decoration: overline underline;"):e.isUnderline()?n.push("text-decoration: underline;"):e.isOverline()&&n.push("text-decoration: overline;"),e.isBlink()&&n.push("text-decoration: blink;"),e.isInvisible()&&n.push("visibility: hidden;"),e.isItalic()&&n.push("font-style: italic;"),e.isDim()&&n.push("opacity: 0.5;"),e.isStrikethrough()&&n.push("text-decoration: line-through;"),n}}_nextCell(e,t,n,s){if(e.getWidth()===0)return;let a=e.getChars()==="",o=this._diffStyle(e,t);o&&(this._currentRow+=o.length===0?"":""),a?this._currentRow+=" ":this._currentRow+=Q2(e.getChars())}_serializeString(){return this._htmlContent}};const ik={background:"#F0EBE1",foreground:"#2C1810",cursor:"#8B4513",cursorAccent:"#F0EBE1",selectionBackground:"#D4C5B0",selectionForeground:"#2C1810",black:"#2C1810",red:"#A63D40",green:"#4A7A4A",yellow:"#8B6914",blue:"#4A6FA5",magenta:"#7B4B8A",cyan:"#3D7A7A",white:"#E6DDD0",brightBlack:"#8B7355",brightRed:"#B85C5C",brightGreen:"#5A8A5A",brightYellow:"#A07D1C",brightBlue:"#5A82BA",brightMagenta:"#8E5D9F",brightCyan:"#5A8F8F",brightWhite:"#4A3728"},nk="plotlink-terminal",rk=1,Cr="scrollback",ty=10*1024*1024;function Ld(){return new Promise((e,t)=>{const n=indexedDB.open(nk,rk);n.onupgradeneeded=()=>{const s=n.result;s.objectStoreNames.contains(Cr)||s.createObjectStore(Cr)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function ia(e,t){const n=t.length>ty?t.slice(-ty):t,s=await Ld();return new Promise((a,o)=>{const c=s.transaction(Cr,"readwrite");c.objectStore(Cr).put(n,e),c.oncomplete=()=>{s.close(),a()},c.onerror=()=>{s.close(),o(c.error)}})}async function sk(e){const t=await Ld();return new Promise((n,s)=>{const o=t.transaction(Cr,"readonly").objectStore(Cr).get(e);o.onsuccess=()=>{t.close(),n(o.result??null)},o.onerror=()=>{t.close(),s(o.error)}})}async function iy(e){const t=await Ld();return new Promise((n,s)=>{const a=t.transaction(Cr,"readwrite");a.objectStore(Cr).delete(e),a.oncomplete=()=>{t.close(),n()},a.onerror=()=>{t.close(),s(a.error)}})}const Bt=new Map;function lk({token:e,storyName:t,authFetch:n,onSelectStory:s,onDestroySession:a,onArchiveStory:o,confirmedStories:c,renameRef:f}){const p=$.useRef(null),h=$.useRef(n),[g,_]=$.useState([]),[b,y]=$.useState(new Set),[x,k]=$.useState(null),[L,M]=$.useState(null),Z=$.useRef(()=>{});$.useEffect(()=>{h.current=n},[n]);const I=$.useCallback(B=>{var R;const{width:A}=B.container.getBoundingClientRect();if(!(A<50))try{B.fit.fit(),((R=B.ws)==null?void 0:R.readyState)===WebSocket.OPEN&&B.ws.send(JSON.stringify({type:"resize",cols:B.term.cols,rows:B.term.rows}))}catch{}},[]),Q=$.useCallback(B=>{for(const[A,R]of Bt)R.container.style.display=A===B?"block":"none";if(B){const A=Bt.get(B);A&&setTimeout(()=>I(A),50)}},[I]),W=$.useCallback((B,A,R)=>{const T=window.location.protocol==="https:"?"wss:":"ws:",j=new WebSocket(`${T}//${window.location.host}/ws/terminal?story=${encodeURIComponent(B)}&token=${e}&resume=${R}`);j.onopen=()=>{A.connected=!0,A._retried=!1,y(H=>{const oe=new Set(H);return oe.delete(B),oe}),j.send(JSON.stringify({type:"resize",cols:A.term.cols,rows:A.term.rows}))},j.onmessage=H=>{A.term.write(H.data)},j.onclose=H=>{if(A.connected=!1,A.ws===j){A.ws=null;try{const oe=A.serialize.serialize();ia(B,oe).catch(()=>{})}catch{}if(H.code===4e3&&!A._retried){A._retried=!0,A.term.write(`\r +\x1B[33m[Resume failed — starting fresh session...]\x1B[0m\r +`),Z.current(B,A,!1);return}y(oe=>new Set(oe).add(B))}},A.term.onData(H=>{j.readyState===WebSocket.OPEN&&j.send(H)}),A.ws=j},[e]);$.useEffect(()=>{Z.current=W},[W]);const O=$.useCallback(async(B,A)=>{if(!p.current||Bt.has(B))return;const{resume:R=!1,autoConnect:T=!0}=A??{},j=document.createElement("div");j.style.width="100%",j.style.height="100%",j.style.display="none",j.style.paddingLeft="10px",j.style.boxSizing="border-box",p.current.appendChild(j);const H=new V2({cols:80,scrollback:5e3,fontSize:13,fontFamily:'"Geist Mono", ui-monospace, monospace',lineHeight:1.05,letterSpacing:0,cursorBlink:!0,cursorStyle:"block",theme:ik,allowTransparency:!1,drawBoldTextInBrightColors:!1,minimumContrastRatio:7}),oe=new G2,E=new ek;H.loadAddon(oe),H.loadAddon(E),H.open(j);const D={term:H,fit:oe,serialize:E,ws:null,container:j,observer:null,connected:!1},K=new ResizeObserver(()=>{var J;const{width:C}=j.getBoundingClientRect();if(!(C<50))try{oe.fit(),((J=D.ws)==null?void 0:J.readyState)===WebSocket.OPEN&&D.ws.send(JSON.stringify({type:"resize",cols:H.cols,rows:H.rows}))}catch{}});K.observe(j),D.observer=K,Bt.set(B,D),_(C=>[...C,B]);try{const C=await sk(B);C&&H.write(C)}catch{}T?W(B,D,R):y(C=>new Set(C).add(B)),setTimeout(()=>I(D),50)},[W,I]),ie=$.useCallback(async(B,A)=>{const R=Bt.get(B);R&&(R.ws&&(R.ws.close(),R.ws=null),A||(await h.current(`/api/terminal/${encodeURIComponent(B)}`,{method:"DELETE"}).catch(()=>{}),R.term.clear()),W(B,R,A))},[W]),ue=$.useCallback(B=>{const A=Bt.get(B);if(A){try{const R=A.serialize.serialize();ia(B,R).catch(()=>{})}catch{}A.observer.disconnect(),A.ws&&A.ws.close(),A.term.dispose(),A.container.remove(),Bt.delete(B),_(R=>R.filter(T=>T!==B)),y(R=>{const T=new Set(R);return T.delete(B),T}),n(`/api/terminal/${encodeURIComponent(B)}`,{method:"DELETE"}).catch(()=>{}),a==null||a(B)}},[n,a]),me=$.useCallback(B=>{var R;const A=Bt.get(B);A&&(((R=A.ws)==null?void 0:R.readyState)===WebSocket.OPEN&&A.ws.send(`exit +`),iy(B).catch(()=>{}),A.observer.disconnect(),A.ws&&A.ws.close(),A.term.dispose(),A.container.remove(),Bt.delete(B),_(T=>T.filter(j=>j!==B)),y(T=>{const j=new Set(T);return j.delete(B),j}),n(`/api/terminal/${encodeURIComponent(B)}/discard`,{method:"DELETE"}).catch(()=>{}),a==null||a(B))},[n,a]),U=$.useCallback(async(B,A)=>{const R=Bt.get(B);if(!R||Bt.has(A)||!(await h.current("/api/terminal/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldName:B,newName:A})})).ok)return!1;Bt.delete(B),Bt.set(A,R);try{const j=R.serialize.serialize();await iy(B),await ia(A,j)}catch{}return _(j=>j.map(H=>H===B?A:H)),y(j=>{if(!j.has(B))return j;const H=new Set(j);return H.delete(B),H.add(A),H}),!0},[]);$.useEffect(()=>(f&&(f.current=U),()=>{f&&(f.current=null)}),[f,U]),$.useEffect(()=>{t&&(Bt.has(t)?Q(t):h.current(`/api/terminal/session/${encodeURIComponent(t)}`).then(B=>B.ok?B.json():null).then(B=>{if(!Bt.has(t)){const A=(B==null?void 0:B.sessionId)&&!(B!=null&&B.running);O(t,{autoConnect:!A}),Q(t)}}).catch(()=>{Bt.has(t)||(O(t),Q(t))}))},[t,O,Q]),$.useEffect(()=>{const B=setInterval(()=>{for(const[A,R]of Bt)if(R.connected)try{const T=R.serialize.serialize();ia(A,T).catch(()=>{})}catch{}},3e4);return()=>clearInterval(B)},[]),$.useEffect(()=>()=>{for(const[B,A]of Bt){try{const R=A.serialize.serialize();ia(B,R).catch(()=>{})}catch{}A.observer.disconnect(),A.ws&&A.ws.close(),A.term.dispose(),A.container.remove(),h.current(`/api/terminal/${encodeURIComponent(B)}`,{method:"DELETE"}).catch(()=>{})}Bt.clear()},[]);const le=t?b.has(t):!1,V=g.length===0;return S.jsxs("div",{className:"h-full flex flex-col",children:[!V&&S.jsxs("div",{className:"px-2 py-1 border-b border-border flex items-center gap-1 overflow-x-auto",children:[g.map(B=>S.jsxs("div",{onClick:()=>s==null?void 0:s(B),className:`flex items-center gap-1 px-2 py-0.5 rounded text-xs font-mono cursor-pointer ${B===t?"bg-accent/10 text-accent":"text-muted hover:text-foreground"}`,children:[S.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${b.has(B)?"bg-amber-500":B===t?"bg-green-600":"bg-muted/50"}`}),S.jsx("span",{className:`truncate max-w-[120px] ${B.startsWith("_new_")?"italic":""}`,children:B.startsWith("_new_")?"Untitled":B}),S.jsx("button",{onClick:A=>{A.stopPropagation(),B.startsWith("_new_")?k(B):ue(B)},className:"ml-0.5 text-muted hover:text-error text-[10px] leading-none",title:"Close terminal",children:"×"})]},B)),t!=null&&t.startsWith("_new_")?S.jsx("button",{onClick:()=>k(t),className:"ml-auto px-2 py-0.5 text-xs text-error hover:bg-surface rounded flex items-center gap-1 flex-shrink-0",children:"Cancel ×"}):t&&o&&(c!=null&&c.has(t))?S.jsx("button",{onClick:()=>M(t),className:"ml-auto px-2 py-0.5 text-xs text-muted hover:text-foreground hover:bg-surface rounded flex items-center gap-1 flex-shrink-0",children:"Archive"}):null]}),S.jsxs("div",{className:"relative flex-1 min-h-0",children:[S.jsx("div",{ref:p,className:"h-full"}),V&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-muted",children:S.jsxs("div",{className:"text-center",children:[S.jsx("p",{className:"text-lg font-serif",children:"Select a story on the left menu"}),S.jsx("p",{className:"text-sm mt-1",children:"to start an AI Writer session"})]})}),x&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[S.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Discard this session?"}),S.jsx("p",{className:"text-xs text-muted",children:"This session will be lost — your AI hasn't created a story structure yet."}),S.jsxs("div",{className:"flex items-center justify-center gap-2",children:[S.jsx("button",{onClick:()=>k(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),S.jsx("button",{onClick:()=>{const B=x;k(null),me(B)},className:"px-4 py-1.5 bg-error text-white text-sm rounded hover:opacity-80",children:"Discard"})]})]})}),L&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[S.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Archive this story?"}),S.jsx("p",{className:"text-xs text-muted",children:"You can restore it later from the Archives view."}),S.jsxs("div",{className:"flex items-center justify-center gap-2",children:[S.jsx("button",{onClick:()=>M(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),S.jsx("button",{onClick:async()=>{const B=L;M(null);try{(await h.current("/api/stories/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B})})).ok&&(ue(B),o==null||o(B))}catch{}},className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Archive"})]})]})}),le&&t&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3",children:[S.jsx("p",{className:"text-sm font-serif text-foreground",children:"Terminal disconnected"}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("button",{onClick:()=>ie(t,!0),className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Resume Session"}),S.jsx("button",{onClick:()=>ie(t,!1),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Start Fresh"})]}),S.jsx("p",{className:"text-xs text-muted",children:"Resume continues your previous Claude conversation"})]})})]})]})}function ak(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const ok=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,uk=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ck={};function ny(e,t){return(ck.jsx?uk:ok).test(e)}const hk=/[ \t\n\f\r]/g;function fk(e){return typeof e=="object"?e.type==="text"?ry(e.value):!1:ry(e)}function ry(e){return e.replace(hk,"")===""}class Aa{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}}Aa.prototype.normal={};Aa.prototype.property={};Aa.prototype.space=void 0;function Xb(e,t){const n={},s={};for(const a of e)Object.assign(n,a.property),Object.assign(s,a.normal);return new Aa(n,s,t)}function fd(e){return e.toLowerCase()}class Si{constructor(t,n){this.attribute=n,this.property=t}}Si.prototype.attribute="";Si.prototype.booleanish=!1;Si.prototype.boolean=!1;Si.prototype.commaOrSpaceSeparated=!1;Si.prototype.commaSeparated=!1;Si.prototype.defined=!1;Si.prototype.mustUseProperty=!1;Si.prototype.number=!1;Si.prototype.overloadedBoolean=!1;Si.prototype.property="";Si.prototype.spaceSeparated=!1;Si.prototype.space=void 0;let dk=0;const Re=rs(),wt=rs(),dd=rs(),ae=rs(),Je=rs(),$s=rs(),Mi=rs();function rs(){return 2**++dk}const pd=Object.freeze(Object.defineProperty({__proto__:null,boolean:Re,booleanish:wt,commaOrSpaceSeparated:Mi,commaSeparated:$s,number:ae,overloadedBoolean:dd,spaceSeparated:Je},Symbol.toStringTag,{value:"Module"})),cf=Object.keys(pd);class zd extends Si{constructor(t,n,s,a){let o=-1;if(super(t,n),sy(this,"space",a),typeof s=="number")for(;++o4&&n.slice(0,4)==="data"&&vk.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(ly,Sk);s="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!ly.test(o)){let c=o.replace(gk,bk);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=zd}return new a(s,t)}function bk(e){return"-"+e.toLowerCase()}function Sk(e){return e.charAt(1).toUpperCase()}const xk=Xb([Gb,pk,Qb,Jb,eS],"html"),Od=Xb([Gb,mk,Qb,Jb,eS],"svg");function wk(e){return e.join(" ").trim()}var Vs={},hf,ay;function Ck(){if(ay)return hf;ay=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,f=/^\s+|\s+$/g,p=` +`,h="/",g="*",_="",b="comment",y="declaration";function x(L,M){if(typeof L!="string")throw new TypeError("First argument must be a string");if(!L)return[];M=M||{};var Z=1,I=1;function Q(A){var R=A.match(t);R&&(Z+=R.length);var T=A.lastIndexOf(p);I=~T?A.length-T:I+A.length}function W(){var A={line:Z,column:I};return function(R){return R.position=new O(A),me(),R}}function O(A){this.start=A,this.end={line:Z,column:I},this.source=M.source}O.prototype.content=L;function ie(A){var R=new Error(M.source+":"+Z+":"+I+": "+A);if(R.reason=A,R.filename=M.source,R.line=Z,R.column=I,R.source=L,!M.silent)throw R}function ue(A){var R=A.exec(L);if(R){var T=R[0];return Q(T),L=L.slice(T.length),R}}function me(){ue(n)}function U(A){var R;for(A=A||[];R=le();)R!==!1&&A.push(R);return A}function le(){var A=W();if(!(h!=L.charAt(0)||g!=L.charAt(1))){for(var R=2;_!=L.charAt(R)&&(g!=L.charAt(R)||h!=L.charAt(R+1));)++R;if(R+=2,_===L.charAt(R-1))return ie("End of comment missing");var T=L.slice(2,R-2);return I+=2,Q(T),L=L.slice(R),I+=2,A({type:b,comment:T})}}function V(){var A=W(),R=ue(s);if(R){if(le(),!ue(a))return ie("property missing ':'");var T=ue(o),j=A({type:y,property:k(R[0].replace(e,_)),value:T?k(T[0].replace(e,_)):_});return ue(c),j}}function B(){var A=[];U(A);for(var R;R=V();)R!==!1&&(A.push(R),U(A));return A}return me(),B()}function k(L){return L?L.replace(f,_):_}return hf=x,hf}var oy;function kk(){if(oy)return Vs;oy=1;var e=Vs&&Vs.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Vs,"__esModule",{value:!0}),Vs.default=n;const t=e(Ck());function n(s,a){let o=null;if(!s||typeof s!="string")return o;const c=(0,t.default)(s),f=typeof a=="function";return c.forEach(p=>{if(p.type!=="declaration")return;const{property:h,value:g}=p;f?a(h,g,p):g&&(o=o||{},o[h]=g)}),o}return Vs}var na={},uy;function Ek(){if(uy)return na;uy=1,Object.defineProperty(na,"__esModule",{value:!0}),na.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(h){return!h||n.test(h)||e.test(h)},c=function(h,g){return g.toUpperCase()},f=function(h,g){return"".concat(g,"-")},p=function(h,g){return g===void 0&&(g={}),o(h)?h:(h=h.toLowerCase(),g.reactCompat?h=h.replace(a,f):h=h.replace(s,f),h.replace(t,c))};return na.camelCase=p,na}var ra,cy;function Tk(){if(cy)return ra;cy=1;var e=ra&&ra.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(kk()),n=Ek();function s(a,o){var c={};return!a||typeof a!="string"||(0,t.default)(a,function(f,p){f&&p&&(c[(0,n.camelCase)(f,o)]=p)}),c}return s.default=s,ra=s,ra}var Ak=Tk();const Dk=xu(Ak),tS=iS("end"),jd=iS("start");function iS(e){return t;function t(n){const s=n&&n.position&&n.position[e]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function nS(e){const t=jd(e),n=tS(e);if(t&&n)return{start:t,end:n}}function ma(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?hy(e.position):"start"in e||"end"in e?hy(e):"line"in e||"column"in e?md(e):""}function md(e){return fy(e&&e.line)+":"+fy(e&&e.column)}function hy(e){return md(e&&e.start)+"-"+md(e&&e.end)}function fy(e){return e&&typeof e=="number"?e:1}class ri extends Error{constructor(t,n,s){super(),typeof n=="string"&&(s=n,n=void 0);let a="",o={},c=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?a=t:!o.cause&&t&&(c=!0,a=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof s=="string"){const p=s.indexOf(":");p===-1?o.ruleId=s:(o.source=s.slice(0,p),o.ruleId=s.slice(p+1))}if(!o.place&&o.ancestors&&o.ancestors){const p=o.ancestors[o.ancestors.length-1];p&&(o.place=p.position)}const f=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=f?f.line:void 0,this.name=ma(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=c&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ri.prototype.file="";ri.prototype.name="";ri.prototype.reason="";ri.prototype.message="";ri.prototype.stack="";ri.prototype.column=void 0;ri.prototype.line=void 0;ri.prototype.ancestors=void 0;ri.prototype.cause=void 0;ri.prototype.fatal=void 0;ri.prototype.place=void 0;ri.prototype.ruleId=void 0;ri.prototype.source=void 0;const Hd={}.hasOwnProperty,Rk=new Map,Mk=/[A-Z]/g,Bk=new Set(["table","tbody","thead","tfoot","tr"]),Nk=new Set(["td","th"]),rS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Lk(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let s;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=Fk(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");s=Ik(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Od:xk,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=sS(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function sS(e,t,n){if(t.type==="element")return zk(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Ok(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Hk(e,t,n);if(t.type==="mdxjsEsm")return jk(e,t);if(t.type==="root")return Pk(e,t,n);if(t.type==="text")return Uk(e,t)}function zk(e,t,n){const s=e.schema;let a=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(a=Od,e.schema=a),e.ancestors.push(t);const o=aS(e,t.tagName,!1),c=qk(e,t);let f=Ud(e,t);return Bk.has(t.tagName)&&(f=f.filter(function(p){return typeof p=="string"?!fk(p):!0})),lS(e,c,o,t),Pd(c,f),e.ancestors.pop(),e.schema=s,e.create(t,o,c,n)}function Ok(e,t){if(t.data&&t.data.estree&&e.evaluater){const s=t.data.estree.body[0];return s.type,e.evaluater.evaluateExpression(s.expression)}Sa(e,t.position)}function jk(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Sa(e,t.position)}function Hk(e,t,n){const s=e.schema;let a=s;t.name==="svg"&&s.space==="html"&&(a=Od,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:aS(e,t.name,!0),c=Wk(e,t),f=Ud(e,t);return lS(e,c,o,t),Pd(c,f),e.ancestors.pop(),e.schema=s,e.create(t,o,c,n)}function Pk(e,t,n){const s={};return Pd(s,Ud(e,t)),e.create(t,e.Fragment,s,n)}function Uk(e,t){return t.value}function lS(e,t,n,s){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=s)}function Pd(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Ik(e,t,n){return s;function s(a,o,c,f){const h=Array.isArray(c.children)?n:t;return f?h(o,c,f):h(o,c)}}function Fk(e,t){return n;function n(s,a,o,c){const f=Array.isArray(o.children),p=jd(s);return t(a,o,c,f,{columnNumber:p?p.column-1:void 0,fileName:e,lineNumber:p?p.line:void 0},void 0)}}function qk(e,t){const n={};let s,a;for(a in t.properties)if(a!=="children"&&Hd.call(t.properties,a)){const o=Yk(e,a,t.properties[a]);if(o){const[c,f]=o;e.tableCellAlignToStyle&&c==="align"&&typeof f=="string"&&Nk.has(t.tagName)?s=f:n[c]=f}}if(s){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return n}function Wk(e,t){const n={};for(const s of t.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&e.evaluater){const o=s.data.estree.body[0];o.type;const c=o.expression;c.type;const f=c.properties[0];f.type,Object.assign(n,e.evaluater.evaluateExpression(f.argument))}else Sa(e,t.position);else{const a=s.name;let o;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&e.evaluater){const f=s.value.data.estree.body[0];f.type,o=e.evaluater.evaluateExpression(f.expression)}else Sa(e,t.position);else o=s.value===null?!0:s.value;n[a]=o}return n}function Ud(e,t){const n=[];let s=-1;const a=e.passKeys?new Map:Rk;for(;++sa?0:a+t:t=t>a?a:t,n=n>0?n:0,s.length<1e4)c=Array.from(s),c.unshift(t,n),e.splice(...c);else for(n&&e.splice(t,n);o0?(Bi(e,e.length,0,t),e):t}const my={}.hasOwnProperty;function uS(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ji(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const oi=kr(/[A-Za-z]/),ni=kr(/[\dA-Za-z]/),eE=kr(/[#-'*+\--9=?A-Z^-~]/);function yu(e){return e!==null&&(e<32||e===127)}const _d=kr(/\d/),tE=kr(/[\dA-Fa-f]/),iE=kr(/[!-/:-@[-`{-~]/);function be(e){return e!==null&&e<-2}function Qe(e){return e!==null&&(e<0||e===32)}function Oe(e){return e===-2||e===-1||e===32}const Tu=kr(new RegExp("\\p{P}|\\p{S}","u")),is=kr(/\s/);function kr(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function il(e){const t=[];let n=-1,s=0,a=0;for(;++n55295&&o<57344){const f=e.charCodeAt(n+1);o<56320&&f>56319&&f<57344?(c=String.fromCharCode(o,f),a=1):c="�"}else c=String.fromCharCode(o);c&&(t.push(e.slice(s,n),encodeURIComponent(c)),s=n+a+1,c=""),a&&(n+=a,a=0)}return t.join("")+e.slice(s)}function Ue(e,t,n,s){const a=s?s-1:Number.POSITIVE_INFINITY;let o=0;return c;function c(p){return Oe(p)?(e.enter(n),f(p)):t(p)}function f(p){return Oe(p)&&o++c))return;const ie=t.events.length;let ue=ie,me,U;for(;ue--;)if(t.events[ue][0]==="exit"&&t.events[ue][1].type==="chunkFlow"){if(me){U=t.events[ue][1].end;break}me=!0}for(M(s),O=ie;OI;){const W=n[Q];t.containerState=W[1],W[0].exit.call(t,e)}n.length=I}function Z(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function aE(e,t,n){return Ue(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Qs(e){if(e===null||Qe(e)||is(e))return 1;if(Tu(e))return 2}function Au(e,t,n){const s=[];let a=-1;for(;++a1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const _={...e[s][1].end},b={...e[n][1].start};gy(_,-p),gy(b,p),c={type:p>1?"strongSequence":"emphasisSequence",start:_,end:{...e[s][1].end}},f={type:p>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:b},o={type:p>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[n][1].start}},a={type:p>1?"strong":"emphasis",start:{...c.start},end:{...f.end}},e[s][1].end={...c.start},e[n][1].start={...f.end},h=[],e[s][1].end.offset-e[s][1].start.offset&&(h=Vi(h,[["enter",e[s][1],t],["exit",e[s][1],t]])),h=Vi(h,[["enter",a,t],["enter",c,t],["exit",c,t],["enter",o,t]]),h=Vi(h,Au(t.parser.constructs.insideSpan.null,e.slice(s+1,n),t)),h=Vi(h,[["exit",o,t],["enter",f,t],["exit",f,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(g=2,h=Vi(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):g=0,Bi(e,s-1,n-s+3,h),n=s+h.length-g-2;break}}for(n=-1;++n0&&Oe(O)?Ue(e,Z,"linePrefix",o+1)(O):Z(O)}function Z(O){return O===null||be(O)?e.check(vy,k,Q)(O):(e.enter("codeFlowValue"),I(O))}function I(O){return O===null||be(O)?(e.exit("codeFlowValue"),Z(O)):(e.consume(O),I)}function Q(O){return e.exit("codeFenced"),t(O)}function W(O,ie,ue){let me=0;return U;function U(R){return O.enter("lineEnding"),O.consume(R),O.exit("lineEnding"),le}function le(R){return O.enter("codeFencedFence"),Oe(R)?Ue(O,V,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):V(R)}function V(R){return R===f?(O.enter("codeFencedFenceSequence"),B(R)):ue(R)}function B(R){return R===f?(me++,O.consume(R),B):me>=c?(O.exit("codeFencedFenceSequence"),Oe(R)?Ue(O,A,"whitespace")(R):A(R)):ue(R)}function A(R){return R===null||be(R)?(O.exit("codeFencedFence"),ie(R)):ue(R)}}}function yE(e,t,n){const s=this;return a;function a(c){return c===null?n(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o)}function o(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}const df={name:"codeIndented",tokenize:SE},bE={partial:!0,tokenize:xE};function SE(e,t,n){const s=this;return a;function a(h){return e.enter("codeIndented"),Ue(e,o,"linePrefix",5)(h)}function o(h){const g=s.events[s.events.length-1];return g&&g[1].type==="linePrefix"&&g[2].sliceSerialize(g[1],!0).length>=4?c(h):n(h)}function c(h){return h===null?p(h):be(h)?e.attempt(bE,c,p)(h):(e.enter("codeFlowValue"),f(h))}function f(h){return h===null||be(h)?(e.exit("codeFlowValue"),c(h)):(e.consume(h),f)}function p(h){return e.exit("codeIndented"),t(h)}}function xE(e,t,n){const s=this;return a;function a(c){return s.parser.lazy[s.now().line]?n(c):be(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):Ue(e,o,"linePrefix",5)(c)}function o(c){const f=s.events[s.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?t(c):be(c)?a(c):n(c)}}const wE={name:"codeText",previous:kE,resolve:CE,tokenize:EE};function CE(e){let t=e.length-4,n=3,s,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(s=n;++s=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(t,n,s){const a=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return s&&sa(this.left,s),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),sa(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),sa(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(c):e.interrupt(s.parser.constructs.flow,n,t)(c)}}function mS(e,t,n,s,a,o,c,f,p){const h=p||Number.POSITIVE_INFINITY;let g=0;return _;function _(M){return M===60?(e.enter(s),e.enter(a),e.enter(o),e.consume(M),e.exit(o),b):M===null||M===32||M===41||yu(M)?n(M):(e.enter(s),e.enter(c),e.enter(f),e.enter("chunkString",{contentType:"string"}),k(M))}function b(M){return M===62?(e.enter(o),e.consume(M),e.exit(o),e.exit(a),e.exit(s),t):(e.enter(f),e.enter("chunkString",{contentType:"string"}),y(M))}function y(M){return M===62?(e.exit("chunkString"),e.exit(f),b(M)):M===null||M===60||be(M)?n(M):(e.consume(M),M===92?x:y)}function x(M){return M===60||M===62||M===92?(e.consume(M),y):y(M)}function k(M){return!g&&(M===null||M===41||Qe(M))?(e.exit("chunkString"),e.exit(f),e.exit(c),e.exit(s),t(M)):g999||y===null||y===91||y===93&&!p||y===94&&!f&&"_hiddenFootnoteSupport"in c.parser.constructs?n(y):y===93?(e.exit(o),e.enter(a),e.consume(y),e.exit(a),e.exit(s),t):be(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),g):(e.enter("chunkString",{contentType:"string"}),_(y))}function _(y){return y===null||y===91||y===93||be(y)||f++>999?(e.exit("chunkString"),g(y)):(e.consume(y),p||(p=!Oe(y)),y===92?b:_)}function b(y){return y===91||y===92||y===93?(e.consume(y),f++,_):_(y)}}function gS(e,t,n,s,a,o){let c;return f;function f(b){return b===34||b===39||b===40?(e.enter(s),e.enter(a),e.consume(b),e.exit(a),c=b===40?41:b,p):n(b)}function p(b){return b===c?(e.enter(a),e.consume(b),e.exit(a),e.exit(s),t):(e.enter(o),h(b))}function h(b){return b===c?(e.exit(o),p(c)):b===null?n(b):be(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),Ue(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),g(b))}function g(b){return b===c||b===null||be(b)?(e.exit("chunkString"),h(b)):(e.consume(b),b===92?_:g)}function _(b){return b===c||b===92?(e.consume(b),g):g(b)}}function _a(e,t){let n;return s;function s(a){return be(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,s):Oe(a)?Ue(e,s,n?"linePrefix":"lineSuffix")(a):t(a)}}const LE={name:"definition",tokenize:OE},zE={partial:!0,tokenize:jE};function OE(e,t,n){const s=this;let a;return o;function o(y){return e.enter("definition"),c(y)}function c(y){return _S.call(s,e,f,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function f(y){return a=Ji(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),p):n(y)}function p(y){return Qe(y)?_a(e,h)(y):h(y)}function h(y){return mS(e,g,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function g(y){return e.attempt(zE,_,_)(y)}function _(y){return Oe(y)?Ue(e,b,"whitespace")(y):b(y)}function b(y){return y===null||be(y)?(e.exit("definition"),s.parser.defined.push(a),t(y)):n(y)}}function jE(e,t,n){return s;function s(f){return Qe(f)?_a(e,a)(f):n(f)}function a(f){return gS(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function o(f){return Oe(f)?Ue(e,c,"whitespace")(f):c(f)}function c(f){return f===null||be(f)?t(f):n(f)}}const HE={name:"hardBreakEscape",tokenize:PE};function PE(e,t,n){return s;function s(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return be(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const UE={name:"headingAtx",resolve:IE,tokenize:FE};function IE(e,t){let n=e.length-2,s=3,a,o;return e[s][1].type==="whitespace"&&(s+=2),n-2>s&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(s===n-1||n-4>s&&e[n-2][1].type==="whitespace")&&(n-=s+1===n?2:4),n>s&&(a={type:"atxHeadingText",start:e[s][1].start,end:e[n][1].end},o={type:"chunkText",start:e[s][1].start,end:e[n][1].end,contentType:"text"},Bi(e,s,n-s+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function FE(e,t,n){let s=0;return a;function a(g){return e.enter("atxHeading"),o(g)}function o(g){return e.enter("atxHeadingSequence"),c(g)}function c(g){return g===35&&s++<6?(e.consume(g),c):g===null||Qe(g)?(e.exit("atxHeadingSequence"),f(g)):n(g)}function f(g){return g===35?(e.enter("atxHeadingSequence"),p(g)):g===null||be(g)?(e.exit("atxHeading"),t(g)):Oe(g)?Ue(e,f,"whitespace")(g):(e.enter("atxHeadingText"),h(g))}function p(g){return g===35?(e.consume(g),p):(e.exit("atxHeadingSequence"),f(g))}function h(g){return g===null||g===35||Qe(g)?(e.exit("atxHeadingText"),f(g)):(e.consume(g),h)}}const qE=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],by=["pre","script","style","textarea"],WE={concrete:!0,name:"htmlFlow",resolveTo:KE,tokenize:XE},YE={partial:!0,tokenize:$E},VE={partial:!0,tokenize:GE};function KE(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function XE(e,t,n){const s=this;let a,o,c,f,p;return h;function h(C){return g(C)}function g(C){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(C),_}function _(C){return C===33?(e.consume(C),b):C===47?(e.consume(C),o=!0,k):C===63?(e.consume(C),a=3,s.interrupt?t:E):oi(C)?(e.consume(C),c=String.fromCharCode(C),L):n(C)}function b(C){return C===45?(e.consume(C),a=2,y):C===91?(e.consume(C),a=5,f=0,x):oi(C)?(e.consume(C),a=4,s.interrupt?t:E):n(C)}function y(C){return C===45?(e.consume(C),s.interrupt?t:E):n(C)}function x(C){const J="CDATA[";return C===J.charCodeAt(f++)?(e.consume(C),f===J.length?s.interrupt?t:V:x):n(C)}function k(C){return oi(C)?(e.consume(C),c=String.fromCharCode(C),L):n(C)}function L(C){if(C===null||C===47||C===62||Qe(C)){const J=C===47,fe=c.toLowerCase();return!J&&!o&&by.includes(fe)?(a=1,s.interrupt?t(C):V(C)):qE.includes(c.toLowerCase())?(a=6,J?(e.consume(C),M):s.interrupt?t(C):V(C)):(a=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(C):o?Z(C):I(C))}return C===45||ni(C)?(e.consume(C),c+=String.fromCharCode(C),L):n(C)}function M(C){return C===62?(e.consume(C),s.interrupt?t:V):n(C)}function Z(C){return Oe(C)?(e.consume(C),Z):U(C)}function I(C){return C===47?(e.consume(C),U):C===58||C===95||oi(C)?(e.consume(C),Q):Oe(C)?(e.consume(C),I):U(C)}function Q(C){return C===45||C===46||C===58||C===95||ni(C)?(e.consume(C),Q):W(C)}function W(C){return C===61?(e.consume(C),O):Oe(C)?(e.consume(C),W):I(C)}function O(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(e.consume(C),p=C,ie):Oe(C)?(e.consume(C),O):ue(C)}function ie(C){return C===p?(e.consume(C),p=null,me):C===null||be(C)?n(C):(e.consume(C),ie)}function ue(C){return C===null||C===34||C===39||C===47||C===60||C===61||C===62||C===96||Qe(C)?W(C):(e.consume(C),ue)}function me(C){return C===47||C===62||Oe(C)?I(C):n(C)}function U(C){return C===62?(e.consume(C),le):n(C)}function le(C){return C===null||be(C)?V(C):Oe(C)?(e.consume(C),le):n(C)}function V(C){return C===45&&a===2?(e.consume(C),T):C===60&&a===1?(e.consume(C),j):C===62&&a===4?(e.consume(C),D):C===63&&a===3?(e.consume(C),E):C===93&&a===5?(e.consume(C),oe):be(C)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(YE,K,B)(C)):C===null||be(C)?(e.exit("htmlFlowData"),B(C)):(e.consume(C),V)}function B(C){return e.check(VE,A,K)(C)}function A(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),R}function R(C){return C===null||be(C)?B(C):(e.enter("htmlFlowData"),V(C))}function T(C){return C===45?(e.consume(C),E):V(C)}function j(C){return C===47?(e.consume(C),c="",H):V(C)}function H(C){if(C===62){const J=c.toLowerCase();return by.includes(J)?(e.consume(C),D):V(C)}return oi(C)&&c.length<8?(e.consume(C),c+=String.fromCharCode(C),H):V(C)}function oe(C){return C===93?(e.consume(C),E):V(C)}function E(C){return C===62?(e.consume(C),D):C===45&&a===2?(e.consume(C),E):V(C)}function D(C){return C===null||be(C)?(e.exit("htmlFlowData"),K(C)):(e.consume(C),D)}function K(C){return e.exit("htmlFlow"),t(C)}}function GE(e,t,n){const s=this;return a;function a(c){return be(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):n(c)}function o(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}function $E(e,t,n){return s;function s(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Da,t,n)}}const ZE={name:"htmlText",tokenize:QE};function QE(e,t,n){const s=this;let a,o,c;return f;function f(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),p}function p(E){return E===33?(e.consume(E),h):E===47?(e.consume(E),W):E===63?(e.consume(E),I):oi(E)?(e.consume(E),ue):n(E)}function h(E){return E===45?(e.consume(E),g):E===91?(e.consume(E),o=0,x):oi(E)?(e.consume(E),Z):n(E)}function g(E){return E===45?(e.consume(E),y):n(E)}function _(E){return E===null?n(E):E===45?(e.consume(E),b):be(E)?(c=_,j(E)):(e.consume(E),_)}function b(E){return E===45?(e.consume(E),y):_(E)}function y(E){return E===62?T(E):E===45?b(E):_(E)}function x(E){const D="CDATA[";return E===D.charCodeAt(o++)?(e.consume(E),o===D.length?k:x):n(E)}function k(E){return E===null?n(E):E===93?(e.consume(E),L):be(E)?(c=k,j(E)):(e.consume(E),k)}function L(E){return E===93?(e.consume(E),M):k(E)}function M(E){return E===62?T(E):E===93?(e.consume(E),M):k(E)}function Z(E){return E===null||E===62?T(E):be(E)?(c=Z,j(E)):(e.consume(E),Z)}function I(E){return E===null?n(E):E===63?(e.consume(E),Q):be(E)?(c=I,j(E)):(e.consume(E),I)}function Q(E){return E===62?T(E):I(E)}function W(E){return oi(E)?(e.consume(E),O):n(E)}function O(E){return E===45||ni(E)?(e.consume(E),O):ie(E)}function ie(E){return be(E)?(c=ie,j(E)):Oe(E)?(e.consume(E),ie):T(E)}function ue(E){return E===45||ni(E)?(e.consume(E),ue):E===47||E===62||Qe(E)?me(E):n(E)}function me(E){return E===47?(e.consume(E),T):E===58||E===95||oi(E)?(e.consume(E),U):be(E)?(c=me,j(E)):Oe(E)?(e.consume(E),me):T(E)}function U(E){return E===45||E===46||E===58||E===95||ni(E)?(e.consume(E),U):le(E)}function le(E){return E===61?(e.consume(E),V):be(E)?(c=le,j(E)):Oe(E)?(e.consume(E),le):me(E)}function V(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),a=E,B):be(E)?(c=V,j(E)):Oe(E)?(e.consume(E),V):(e.consume(E),A)}function B(E){return E===a?(e.consume(E),a=void 0,R):E===null?n(E):be(E)?(c=B,j(E)):(e.consume(E),B)}function A(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||Qe(E)?me(E):(e.consume(E),A)}function R(E){return E===47||E===62||Qe(E)?me(E):n(E)}function T(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function j(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),H}function H(E){return Oe(E)?Ue(e,oe,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):oe(E)}function oe(E){return e.enter("htmlTextData"),c(E)}}const qd={name:"labelEnd",resolveAll:i5,resolveTo:n5,tokenize:r5},JE={tokenize:s5},e5={tokenize:l5},t5={tokenize:a5};function i5(e){let t=-1;const n=[];for(;++t=3&&(h===null||be(h))?(e.exit("thematicBreak"),t(h)):n(h)}function p(h){return h===a?(e.consume(h),s++,p):(e.exit("thematicBreakSequence"),Oe(h)?Ue(e,f,"whitespace")(h):f(h))}}const bi={continuation:{tokenize:g5},exit:y5,name:"list",tokenize:_5},p5={partial:!0,tokenize:b5},m5={partial:!0,tokenize:v5};function _5(e,t,n){const s=this,a=s.events[s.events.length-1];let o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,c=0;return f;function f(y){const x=s.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(x==="listUnordered"?!s.containerState.marker||y===s.containerState.marker:_d(y)){if(s.containerState.type||(s.containerState.type=x,e.enter(x,{_container:!0})),x==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(fu,n,h)(y):h(y);if(!s.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),p(y)}return n(y)}function p(y){return _d(y)&&++c<10?(e.consume(y),p):(!s.interrupt||c<2)&&(s.containerState.marker?y===s.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),h(y)):n(y)}function h(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||y,e.check(Da,s.interrupt?n:g,e.attempt(p5,b,_))}function g(y){return s.containerState.initialBlankLine=!0,o++,b(y)}function _(y){return Oe(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),b):n(y)}function b(y){return s.containerState.size=o+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function g5(e,t,n){const s=this;return s.containerState._closeFlow=void 0,e.check(Da,a,o);function a(f){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,Ue(e,t,"listItemIndent",s.containerState.size+1)(f)}function o(f){return s.containerState.furtherBlankLines||!Oe(f)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,c(f)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(m5,t,c)(f))}function c(f){return s.containerState._closeFlow=!0,s.interrupt=void 0,Ue(e,e.attempt(bi,t,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function v5(e,t,n){const s=this;return Ue(e,a,"listItemIndent",s.containerState.size+1);function a(o){const c=s.events[s.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===s.containerState.size?t(o):n(o)}}function y5(e){e.exit(this.containerState.type)}function b5(e,t,n){const s=this;return Ue(e,a,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(o){const c=s.events[s.events.length-1];return!Oe(o)&&c&&c[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const Sy={name:"setextUnderline",resolveTo:S5,tokenize:x5};function S5(e,t){let n=e.length,s,a,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){s=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const c={type:"setextHeading",start:{...e[s][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",o?(e.splice(a,0,["enter",c,t]),e.splice(o+1,0,["exit",e[s][1],t]),e[s][1].end={...e[o][1].end}):e[s][1]=c,e.push(["exit",c,t]),e}function x5(e,t,n){const s=this;let a;return o;function o(h){let g=s.events.length,_;for(;g--;)if(s.events[g][1].type!=="lineEnding"&&s.events[g][1].type!=="linePrefix"&&s.events[g][1].type!=="content"){_=s.events[g][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||_)?(e.enter("setextHeadingLine"),a=h,c(h)):n(h)}function c(h){return e.enter("setextHeadingLineSequence"),f(h)}function f(h){return h===a?(e.consume(h),f):(e.exit("setextHeadingLineSequence"),Oe(h)?Ue(e,p,"lineSuffix")(h):p(h))}function p(h){return h===null||be(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const w5={tokenize:C5};function C5(e){const t=this,n=e.attempt(Da,s,e.attempt(this.parser.constructs.flowInitial,a,Ue(e,e.attempt(this.parser.constructs.flow,a,e.attempt(DE,a)),"linePrefix")));return n;function s(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const k5={resolveAll:yS()},E5=vS("string"),T5=vS("text");function vS(e){return{resolveAll:yS(e==="text"?A5:void 0),tokenize:t};function t(n){const s=this,a=this.parser.constructs[e],o=n.attempt(a,c,f);return c;function c(g){return h(g)?o(g):f(g)}function f(g){if(g===null){n.consume(g);return}return n.enter("data"),n.consume(g),p}function p(g){return h(g)?(n.exit("data"),o(g)):(n.consume(g),p)}function h(g){if(g===null)return!0;const _=a[g];let b=-1;if(_)for(;++b<_.length;){const y=_[b];if(!y.previous||y.previous.call(s,s.previous))return!0}return!1}}}function yS(e){return t;function t(n,s){let a=-1,o;for(;++a<=n.length;)o===void 0?n[a]&&n[a][1].type==="data"&&(o=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==o+2&&(n[o][1].end=n[a-1][1].end,n.splice(o+2,a-o-2),a=o+2),o=void 0);return e?e(n,s):n}}function A5(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const s=e[n-1][1],a=t.sliceStream(s);let o=a.length,c=-1,f=0,p;for(;o--;){const h=a[o];if(typeof h=="string"){for(c=h.length;h.charCodeAt(c-1)===32;)f++,c--;if(c)break;c=-1}else if(h===-2)p=!0,f++;else if(h!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(f=0),f){const h={type:n===e.length||p||f<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?c:s.start._bufferIndex+c,_index:s.start._index+o,line:s.end.line,column:s.end.column-f,offset:s.end.offset-f},end:{...s.end}};s.end={...h.start},s.start.offset===s.end.offset?Object.assign(s,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const D5={42:bi,43:bi,45:bi,48:bi,49:bi,50:bi,51:bi,52:bi,53:bi,54:bi,55:bi,56:bi,57:bi,62:hS},R5={91:LE},M5={[-2]:df,[-1]:df,32:df},B5={35:UE,42:fu,45:[Sy,fu],60:WE,61:Sy,95:fu,96:yy,126:yy},N5={38:dS,92:fS},L5={[-5]:pf,[-4]:pf,[-3]:pf,33:o5,38:dS,42:gd,60:[cE,ZE],91:c5,92:[HE,fS],93:qd,95:gd,96:wE},z5={null:[gd,k5]},O5={null:[42,95]},j5={null:[]},H5=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:O5,contentInitial:R5,disable:j5,document:D5,flow:B5,flowInitial:M5,insideSpan:z5,string:N5,text:L5},Symbol.toStringTag,{value:"Module"}));function P5(e,t,n){let s={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},o=[];let c=[],f=[];const p={attempt:ie(W),check:ie(O),consume:Z,enter:I,exit:Q,interrupt:ie(O,{interrupt:!0})},h={code:null,containerState:{},defineSkip:k,events:[],now:x,parser:e,previous:null,sliceSerialize:b,sliceStream:y,write:_};let g=t.tokenize.call(h,p);return t.resolveAll&&o.push(t),h;function _(le){return c=Vi(c,le),L(),c[c.length-1]!==null?[]:(ue(t,0),h.events=Au(o,h.events,h),h.events)}function b(le,V){return I5(y(le),V)}function y(le){return U5(c,le)}function x(){const{_bufferIndex:le,_index:V,line:B,column:A,offset:R}=s;return{_bufferIndex:le,_index:V,line:B,column:A,offset:R}}function k(le){a[le.line]=le.column,U()}function L(){let le;for(;s._index-1){const f=c[0];typeof f=="string"?c[0]=f.slice(s):c.shift()}o>0&&c.push(e[a].slice(0,o))}return c}function I5(e,t){let n=-1;const s=[];let a;for(;++n0){const vt=he.tokenStack[he.tokenStack.length-1];(vt[1]||wy).call(he,void 0,vt[0])}for(X.position={start:yr(te.length>0?te[0][1].start:{line:1,column:1,offset:0}),end:yr(te.length>0?te[te.length-2][1].end:{line:1,column:1,offset:0})},Te=-1;++Te0&&(s.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:s,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function tT(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function iT(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nT(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),a=il(s.toLowerCase()),o=e.footnoteOrder.indexOf(s);let c,f=e.footnoteCounts.get(s);f===void 0?(f=0,e.footnoteOrder.push(s),c=e.footnoteOrder.length):c=o+1,f+=1,e.footnoteCounts.set(s,f);const p={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(f>1?"-"+f:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};e.patch(t,p);const h={type:"element",tagName:"sup",properties:{},children:[p]};return e.patch(t,h),e.applyData(t,h)}function rT(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function sT(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function xS(e,t){const n=t.referenceType;let s="]";if(n==="collapsed"?s+="[]":n==="full"&&(s+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+s}];const a=e.all(t),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const c=a[a.length-1];return c&&c.type==="text"?c.value+=s:a.push({type:"text",value:s}),a}function lT(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return xS(e,t);const a={src:il(s.url||""),alt:t.alt};s.title!==null&&s.title!==void 0&&(a.title=s.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)}function aT(e,t){const n={src:il(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,s),e.applyData(t,s)}function oT(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const s={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,s),e.applyData(t,s)}function uT(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return xS(e,t);const a={href:il(s.url||"")};s.title!==null&&s.title!==void 0&&(a.title=s.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function cT(e,t){const n={href:il(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function hT(e,t,n){const s=e.all(t),a=n?fT(n):wS(t),o={},c=[];if(typeof t.checked=="boolean"){const g=s[0];let _;g&&g.type==="element"&&g.tagName==="p"?_=g:(_={type:"element",tagName:"p",properties:{},children:[]},s.unshift(_)),_.children.length>0&&_.children.unshift({type:"text",value:" "}),_.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let f=-1;for(;++f1}function dT(e,t){const n={},s=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++a0){const c={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},f=jd(t.children[1]),p=tS(t.children[t.children.length-1]);f&&p&&(c.position={start:f,end:p}),a.push(c)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,o),e.applyData(t,o)}function vT(e,t,n){const s=n?n.children:void 0,o=(s?s.indexOf(t):1)===0?"th":"td",c=n&&n.type==="table"?n.align:void 0,f=c?c.length:t.children.length;let p=-1;const h=[];for(;++p0,!0),s[0]),a=s.index+s[0].length,s=n.exec(t);return o.push(Ey(t.slice(a),a>0,!1)),o.join("")}function Ey(e,t,n){let s=0,a=e.length;if(t){let o=e.codePointAt(s);for(;o===Cy||o===ky;)s++,o=e.codePointAt(s)}if(n){let o=e.codePointAt(a-1);for(;o===Cy||o===ky;)a--,o=e.codePointAt(a-1)}return a>s?e.slice(s,a):""}function ST(e,t){const n={type:"text",value:bT(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function xT(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const wT={blockquote:Q5,break:J5,code:eT,delete:tT,emphasis:iT,footnoteReference:nT,heading:rT,html:sT,imageReference:lT,image:aT,inlineCode:oT,linkReference:uT,link:cT,listItem:hT,list:dT,paragraph:pT,root:mT,strong:_T,table:gT,tableCell:yT,tableRow:vT,text:ST,thematicBreak:xT,toml:tu,yaml:tu,definition:tu,footnoteDefinition:tu};function tu(){}const CS=-1,Du=0,ga=1,bu=2,Wd=3,Yd=4,Vd=5,Kd=6,kS=7,ES=8,Ty=typeof self=="object"?self:globalThis,CT=(e,t)=>{const n=(a,o)=>(e.set(o,a),a),s=a=>{if(e.has(a))return e.get(a);const[o,c]=t[a];switch(o){case Du:case CS:return n(c,a);case ga:{const f=n([],a);for(const p of c)f.push(s(p));return f}case bu:{const f=n({},a);for(const[p,h]of c)f[s(p)]=s(h);return f}case Wd:return n(new Date(c),a);case Yd:{const{source:f,flags:p}=c;return n(new RegExp(f,p),a)}case Vd:{const f=n(new Map,a);for(const[p,h]of c)f.set(s(p),s(h));return f}case Kd:{const f=n(new Set,a);for(const p of c)f.add(s(p));return f}case kS:{const{name:f,message:p}=c;return n(new Ty[f](p),a)}case ES:return n(BigInt(c),a);case"BigInt":return n(Object(BigInt(c)),a);case"ArrayBuffer":return n(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:f}=new Uint8Array(c);return n(new DataView(f),c)}}return n(new Ty[o](c),a)};return s},Ay=e=>CT(new Map,e)(0),Ks="",{toString:kT}={},{keys:ET}=Object,la=e=>{const t=typeof e;if(t!=="object"||!e)return[Du,t];const n=kT.call(e).slice(8,-1);switch(n){case"Array":return[ga,Ks];case"Object":return[bu,Ks];case"Date":return[Wd,Ks];case"RegExp":return[Yd,Ks];case"Map":return[Vd,Ks];case"Set":return[Kd,Ks];case"DataView":return[ga,n]}return n.includes("Array")?[ga,n]:n.includes("Error")?[kS,n]:[bu,n]},iu=([e,t])=>e===Du&&(t==="function"||t==="symbol"),TT=(e,t,n,s)=>{const a=(c,f)=>{const p=s.push(c)-1;return n.set(f,p),p},o=c=>{if(n.has(c))return n.get(c);let[f,p]=la(c);switch(f){case Du:{let g=c;switch(p){case"bigint":f=ES,g=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+p);g=null;break;case"undefined":return a([CS],c)}return a([f,g],c)}case ga:{if(p){let b=c;return p==="DataView"?b=new Uint8Array(c.buffer):p==="ArrayBuffer"&&(b=new Uint8Array(c)),a([p,[...b]],c)}const g=[],_=a([f,g],c);for(const b of c)g.push(o(b));return _}case bu:{if(p)switch(p){case"BigInt":return a([p,c.toString()],c);case"Boolean":case"Number":case"String":return a([p,c.valueOf()],c)}if(t&&"toJSON"in c)return o(c.toJSON());const g=[],_=a([f,g],c);for(const b of ET(c))(e||!iu(la(c[b])))&&g.push([o(b),o(c[b])]);return _}case Wd:return a([f,c.toISOString()],c);case Yd:{const{source:g,flags:_}=c;return a([f,{source:g,flags:_}],c)}case Vd:{const g=[],_=a([f,g],c);for(const[b,y]of c)(e||!(iu(la(b))||iu(la(y))))&&g.push([o(b),o(y)]);return _}case Kd:{const g=[],_=a([f,g],c);for(const b of c)(e||!iu(la(b)))&&g.push(o(b));return _}}const{message:h}=c;return a([f,{name:p,message:h}],c)};return o},Dy=(e,{json:t,lossy:n}={})=>{const s=[];return TT(!(t||n),!!t,new Map,s)(e),s},xa=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Ay(Dy(e,t)):structuredClone(e):(e,t)=>Ay(Dy(e,t));function AT(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function DT(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function RT(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||AT,s=e.options.footnoteBackLabel||DT,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",c=e.options.footnoteLabelProperties||{className:["sr-only"]},f=[];let p=-1;for(;++p0&&x.push({type:"text",value:" "});let Z=typeof n=="string"?n:n(p,y);typeof Z=="string"&&(Z={type:"text",value:Z}),x.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+b+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof s=="string"?s:s(p,y),className:["data-footnote-backref"]},children:Array.isArray(Z)?Z:[Z]})}const L=g[g.length-1];if(L&&L.type==="element"&&L.tagName==="p"){const Z=L.children[L.children.length-1];Z&&Z.type==="text"?Z.value+=" ":L.children.push({type:"text",value:" "}),L.children.push(...x)}else g.push(...x);const M={type:"element",tagName:"li",properties:{id:t+"fn-"+b},children:e.wrap(g,!0)};e.patch(h,M),f.push(M)}if(f.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...xa(c),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:` +`},{type:"element",tagName:"ol",properties:{},children:e.wrap(f,!0)},{type:"text",value:` +`}]}}const Ru=(function(e){if(e==null)return LT;if(typeof e=="function")return Mu(e);if(typeof e=="object")return Array.isArray(e)?MT(e):BT(e);if(typeof e=="string")return NT(e);throw new Error("Expected function, string, or object as test")});function MT(e){const t=[];let n=-1;for(;++n":""))+")"})}return b;function b(){let y=TS,x,k,L;if((!t||o(p,h,g[g.length-1]||void 0))&&(y=HT(n(p,g)),y[0]===vd))return y;if("children"in p&&p.children){const M=p;if(M.children&&y[0]!==jT)for(k=(s?M.children.length:-1)+c,L=g.concat(M);k>-1&&k0&&n.push({type:"text",value:` +`}),n}function Ry(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function My(e,t){const n=UT(e,t),s=n.one(e,void 0),a=RT(n),o=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return a&&o.children.push({type:"text",value:` +`},a),o}function YT(e,t){return e&&"run"in e?async function(n,s){const a=My(n,{file:s,...t});await e.run(a,s)}:function(n,s){return My(n,{file:s,...e||t})}}function By(e){if(e)throw e}var mf,Ny;function VT(){if(Ny)return mf;Ny=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},o=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var g=e.call(h,"constructor"),_=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!g&&!_)return!1;var b;for(b in h);return typeof b>"u"||e.call(h,b)},c=function(h,g){n&&g.name==="__proto__"?n(h,g.name,{enumerable:!0,configurable:!0,value:g.newValue,writable:!0}):h[g.name]=g.newValue},f=function(h,g){if(g==="__proto__")if(e.call(h,g)){if(s)return s(h,g).value}else return;return h[g]};return mf=function p(){var h,g,_,b,y,x,k=arguments[0],L=1,M=arguments.length,Z=!1;for(typeof k=="boolean"&&(Z=k,k=arguments[1]||{},L=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});Lc.length;let p;f&&c.push(a);try{p=e.apply(this,c)}catch(h){const g=h;if(f&&n)throw g;return a(g)}f||(p&&p.then&&typeof p.then=="function"?p.then(o,a):p instanceof Error?a(p):o(p))}function a(c,...f){n||(n=!0,t(c,...f))}function o(c){a(null,c)}}const un={basename:$T,dirname:ZT,extname:QT,join:JT,sep:"/"};function $T(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Ra(e);let n=0,s=-1,a=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else s<0&&(o=!0,s=a+1);return s<0?"":e.slice(n,s)}if(t===e)return"";let c=-1,f=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else c<0&&(o=!0,c=a+1),f>-1&&(e.codePointAt(a)===t.codePointAt(f--)?f<0&&(s=a):(f=-1,s=c));return n===s?s=c:s<0&&(s=e.length),e.slice(n,s)}function ZT(e){if(Ra(e),e.length===0)return".";let t=-1,n=e.length,s;for(;--n;)if(e.codePointAt(n)===47){if(s){t=n;break}}else s||(s=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function QT(e){Ra(e);let t=e.length,n=-1,s=0,a=-1,o=0,c;for(;t--;){const f=e.codePointAt(t);if(f===47){if(c){s=t+1;break}continue}n<0&&(c=!0,n=t+1),f===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||n<0||o===0||o===1&&a===n-1&&a===s+1?"":e.slice(a,n)}function JT(...e){let t=-1,n;for(;++t0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function t3(e,t){let n="",s=0,a=-1,o=0,c=-1,f,p;for(;++c<=e.length;){if(c2){if(p=n.lastIndexOf("/"),p!==n.length-1){p<0?(n="",s=0):(n=n.slice(0,p),s=n.length-1-n.lastIndexOf("/")),a=c,o=0;continue}}else if(n.length>0){n="",s=0,a=c,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",s=2)}else n.length>0?n+="/"+e.slice(a+1,c):n=e.slice(a+1,c),s=c-a-1;a=c,o=0}else f===46&&o>-1?o++:o=-1}return n}function Ra(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const i3={cwd:n3};function n3(){return"/"}function Sd(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function r3(e){if(typeof e=="string")e=new URL(e);else if(!Sd(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return s3(e)}function s3(e){if(e.hostname!==""){const s=new TypeError('File URL host must be "localhost" or empty on darwin');throw s.code="ERR_INVALID_FILE_URL_HOST",s}const t=e.pathname;let n=-1;for(;++n0){let[y,...x]=g;const k=s[b][1];bd(k)&&bd(y)&&(y=_f(!0,k,y)),s[b]=[h,y,...x]}}}}const u3=new Gd().freeze();function bf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Sf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function xf(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function zy(e){if(!bd(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Oy(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function nu(e){return c3(e)?e:new DS(e)}function c3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function h3(e){return typeof e=="string"||f3(e)}function f3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const d3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",jy=[],Hy={allowDangerousHtml:!0},p3=/^(https?|ircs?|mailto|xmpp)$/i,m3=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function _3(e){const t=g3(e),n=v3(e);return y3(t.runSync(t.parse(n),n),e)}function g3(e){const t=e.rehypePlugins||jy,n=e.remarkPlugins||jy,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Hy}:Hy;return u3().use(Z5).use(n).use(YT,s).use(t)}function v3(e){const t=e.children||"",n=new DS;return typeof t=="string"&&(n.value=t),n}function y3(e,t){const n=t.allowedElements,s=t.allowElement,a=t.components,o=t.disallowedElements,c=t.skipHtml,f=t.unwrapDisallowed,p=t.urlTransform||b3;for(const g of m3)Object.hasOwn(t,g.from)&&(""+g.from+(g.to?"use `"+g.to+"` instead":"remove it")+d3+g.id,void 0);return Xd(e,h),Lk(e,{Fragment:S.Fragment,components:a,ignoreInvalidStyle:!0,jsx:S.jsx,jsxs:S.jsxs,passKeys:!0,passNode:!0});function h(g,_,b){if(g.type==="raw"&&b&&typeof _=="number")return c?b.children.splice(_,1):b.children[_]={type:"text",value:g.value},_;if(g.type==="element"){let y;for(y in ff)if(Object.hasOwn(ff,y)&&Object.hasOwn(g.properties,y)){const x=g.properties[y],k=ff[y];(k===null||k.includes(g.tagName))&&(g.properties[y]=p(String(x||""),y,g))}}if(g.type==="element"){let y=n?!n.includes(g.tagName):o?o.includes(g.tagName):!1;if(!y&&s&&typeof _=="number"&&(y=!s(g,_,b)),y&&b&&typeof _=="number")return f&&g.children?b.children.splice(_,1,...g.children):b.children.splice(_,1),_}}}function b3(e){const t=e.indexOf(":"),n=e.indexOf("?"),s=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||s!==-1&&t>s||p3.test(e.slice(0,t))?e:""}function S3(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function RS(e,t,n){const a=Ru((n||{}).ignore||[]),o=x3(t);let c=-1;for(;++c0?{type:"text",value:O}:void 0),O===!1?b.lastIndex=Q+1:(x!==Q&&Z.push({type:"text",value:h.value.slice(x,Q)}),Array.isArray(O)?Z.push(...O):O&&Z.push(O),x=Q+I[0].length,M=!0),!b.global)break;I=b.exec(h.value)}return M?(x?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],s=n.indexOf(")");const a=Py(e,"(");let o=Py(e,")");for(;s!==-1&&a>o;)e+=n.slice(0,s+1),n=n.slice(s+1),s=n.indexOf(")"),o++;return[e,n]}function MS(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||is(n)||Tu(n))&&(!t||n!==47)}BS.peek=X3;function U3(){this.buffer()}function I3(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function F3(){this.buffer()}function q3(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function W3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ji(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Y3(e){this.exit(e)}function V3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ji(this.sliceSerialize(e)).toLowerCase(),n.label=t}function K3(e){this.exit(e)}function X3(){return"["}function BS(e,t,n,s){const a=n.createTracker(s);let o=a.move("[^");const c=n.enter("footnoteReference"),f=n.enter("reference");return o+=a.move(n.safe(n.associationId(e),{after:"]",before:o})),f(),c(),o+=a.move("]"),o}function G3(){return{enter:{gfmFootnoteCallString:U3,gfmFootnoteCall:I3,gfmFootnoteDefinitionLabelString:F3,gfmFootnoteDefinition:q3},exit:{gfmFootnoteCallString:W3,gfmFootnoteCall:Y3,gfmFootnoteDefinitionLabelString:V3,gfmFootnoteDefinition:K3}}}function $3(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:BS},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(s,a,o,c){const f=o.createTracker(c);let p=f.move("[^");const h=o.enter("footnoteDefinition"),g=o.enter("label");return p+=f.move(o.safe(o.associationId(s),{before:p,after:"]"})),g(),p+=f.move("]:"),s.children&&s.children.length>0&&(f.shift(4),p+=f.move((t?` +`:" ")+o.indentLines(o.containerFlow(s,f.current()),t?NS:Z3))),h(),p}}function Z3(e,t,n){return t===0?e:NS(e,t,n)}function NS(e,t,n){return(n?"":" ")+e}const Q3=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];LS.peek=nA;function J3(){return{canContainEols:["delete"],enter:{strikethrough:tA},exit:{strikethrough:iA}}}function eA(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Q3}],handlers:{delete:LS}}}function tA(e){this.enter({type:"delete",children:[]},e)}function iA(e){this.exit(e)}function LS(e,t,n,s){const a=n.createTracker(s),o=n.enter("strikethrough");let c=a.move("~~");return c+=n.containerPhrasing(e,{...a.current(),before:c,after:"~"}),c+=a.move("~~"),o(),c}function nA(){return"~"}function rA(e){return e.length}function sA(e,t){const n=t||{},s=(n.align||[]).concat(),a=n.stringLength||rA,o=[],c=[],f=[],p=[];let h=0,g=-1;for(;++gh&&(h=e[g].length);++Mp[M])&&(p[M]=I)}k.push(Z)}c[g]=k,f[g]=L}let _=-1;if(typeof s=="object"&&"length"in s)for(;++_p[_]&&(p[_]=Z),y[_]=Z),b[_]=I}c.splice(1,0,b),f.splice(1,0,y),g=-1;const x=[];for(;++g "),o.shift(2);const c=n.indentLines(n.containerFlow(e,o.current()),oA);return a(),c}function oA(e,t,n){return">"+(n?"":" ")+e}function uA(e,t){return Iy(e,t.inConstruct,!0)&&!Iy(e,t.notInConstruct,!1)}function Iy(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let s=-1;for(;++sc&&(c=o):o=1,a=s+t.length,s=n.indexOf(t,a);return c}function hA(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function fA(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function dA(e,t,n,s){const a=fA(n),o=e.value||"",c=a==="`"?"GraveAccent":"Tilde";if(hA(e,n)){const _=n.enter("codeIndented"),b=n.indentLines(o,pA);return _(),b}const f=n.createTracker(s),p=a.repeat(Math.max(cA(o,a)+1,3)),h=n.enter("codeFenced");let g=f.move(p);if(e.lang){const _=n.enter(`codeFencedLang${c}`);g+=f.move(n.safe(e.lang,{before:g,after:" ",encode:["`"],...f.current()})),_()}if(e.lang&&e.meta){const _=n.enter(`codeFencedMeta${c}`);g+=f.move(" "),g+=f.move(n.safe(e.meta,{before:g,after:` +`,encode:["`"],...f.current()})),_()}return g+=f.move(` +`),o&&(g+=f.move(o+` +`)),g+=f.move(p),h(),g}function pA(e,t,n){return(n?"":" ")+e}function $d(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function mA(e,t,n,s){const a=$d(n),o=a==='"'?"Quote":"Apostrophe",c=n.enter("definition");let f=n.enter("label");const p=n.createTracker(s);let h=p.move("[");return h+=p.move(n.safe(n.associationId(e),{before:h,after:"]",...p.current()})),h+=p.move("]: "),f(),!e.url||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(n.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(f=n.enter("destinationRaw"),h+=p.move(n.safe(e.url,{before:h,after:e.title?" ":` +`,...p.current()}))),f(),e.title&&(f=n.enter(`title${o}`),h+=p.move(" "+a),h+=p.move(n.safe(e.title,{before:h,after:a,...p.current()})),h+=p.move(a),f()),c(),h}function _A(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function wa(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Su(e,t,n){const s=Qs(e),a=Qs(t);return s===void 0?a===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:s===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}zS.peek=gA;function zS(e,t,n,s){const a=_A(n),o=n.enter("emphasis"),c=n.createTracker(s),f=c.move(a);let p=c.move(n.containerPhrasing(e,{after:a,before:f,...c.current()}));const h=p.charCodeAt(0),g=Su(s.before.charCodeAt(s.before.length-1),h,a);g.inside&&(p=wa(h)+p.slice(1));const _=p.charCodeAt(p.length-1),b=Su(s.after.charCodeAt(0),_,a);b.inside&&(p=p.slice(0,-1)+wa(_));const y=c.move(a);return o(),n.attentionEncodeSurroundingInfo={after:b.outside,before:g.outside},f+p+y}function gA(e,t,n){return n.options.emphasis||"*"}function vA(e,t){let n=!1;return Xd(e,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return n=!0,vd}),!!((!e.depth||e.depth<3)&&Id(e)&&(t.options.setext||n))}function yA(e,t,n,s){const a=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(s);if(vA(e,n)){const g=n.enter("headingSetext"),_=n.enter("phrasing"),b=n.containerPhrasing(e,{...o.current(),before:` +`,after:` +`});return _(),g(),b+` +`+(a===1?"=":"-").repeat(b.length-(Math.max(b.lastIndexOf("\r"),b.lastIndexOf(` +`))+1))}const c="#".repeat(a),f=n.enter("headingAtx"),p=n.enter("phrasing");o.move(c+" ");let h=n.containerPhrasing(e,{before:"# ",after:` +`,...o.current()});return/^[\t ]/.test(h)&&(h=wa(h.charCodeAt(0))+h.slice(1)),h=h?c+" "+h:c,n.options.closeAtx&&(h+=" "+c),p(),f(),h}OS.peek=bA;function OS(e){return e.value||""}function bA(){return"<"}jS.peek=SA;function jS(e,t,n,s){const a=$d(n),o=a==='"'?"Quote":"Apostrophe",c=n.enter("image");let f=n.enter("label");const p=n.createTracker(s);let h=p.move("![");return h+=p.move(n.safe(e.alt,{before:h,after:"]",...p.current()})),h+=p.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(n.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(f=n.enter("destinationRaw"),h+=p.move(n.safe(e.url,{before:h,after:e.title?" ":")",...p.current()}))),f(),e.title&&(f=n.enter(`title${o}`),h+=p.move(" "+a),h+=p.move(n.safe(e.title,{before:h,after:a,...p.current()})),h+=p.move(a),f()),h+=p.move(")"),c(),h}function SA(){return"!"}HS.peek=xA;function HS(e,t,n,s){const a=e.referenceType,o=n.enter("imageReference");let c=n.enter("label");const f=n.createTracker(s);let p=f.move("![");const h=n.safe(e.alt,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),c();const g=n.stack;n.stack=[],c=n.enter("reference");const _=n.safe(n.associationId(e),{before:p,after:"]",...f.current()});return c(),n.stack=g,o(),a==="full"||!h||h!==_?p+=f.move(_+"]"):a==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function xA(){return"!"}PS.peek=wA;function PS(e,t,n){let s=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(s);)a+="`";for(/[^ \r\n]/.test(s)&&(/^[ \r\n]/.test(s)&&/[ \r\n]$/.test(s)||/^`|`$/.test(s))&&(s=" "+s+" ");++o\u007F]/.test(e.url))}IS.peek=CA;function IS(e,t,n,s){const a=$d(n),o=a==='"'?"Quote":"Apostrophe",c=n.createTracker(s);let f,p;if(US(e,n)){const g=n.stack;n.stack=[],f=n.enter("autolink");let _=c.move("<");return _+=c.move(n.containerPhrasing(e,{before:_,after:">",...c.current()})),_+=c.move(">"),f(),n.stack=g,_}f=n.enter("link"),p=n.enter("label");let h=c.move("[");return h+=c.move(n.containerPhrasing(e,{before:h,after:"](",...c.current()})),h+=c.move("]("),p(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(p=n.enter("destinationLiteral"),h+=c.move("<"),h+=c.move(n.safe(e.url,{before:h,after:">",...c.current()})),h+=c.move(">")):(p=n.enter("destinationRaw"),h+=c.move(n.safe(e.url,{before:h,after:e.title?" ":")",...c.current()}))),p(),e.title&&(p=n.enter(`title${o}`),h+=c.move(" "+a),h+=c.move(n.safe(e.title,{before:h,after:a,...c.current()})),h+=c.move(a),p()),h+=c.move(")"),f(),h}function CA(e,t,n){return US(e,n)?"<":"["}FS.peek=kA;function FS(e,t,n,s){const a=e.referenceType,o=n.enter("linkReference");let c=n.enter("label");const f=n.createTracker(s);let p=f.move("[");const h=n.containerPhrasing(e,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),c();const g=n.stack;n.stack=[],c=n.enter("reference");const _=n.safe(n.associationId(e),{before:p,after:"]",...f.current()});return c(),n.stack=g,o(),a==="full"||!h||h!==_?p+=f.move(_+"]"):a==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function kA(){return"["}function Zd(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function EA(e){const t=Zd(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function TA(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function qS(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function AA(e,t,n,s){const a=n.enter("list"),o=n.bulletCurrent;let c=e.ordered?TA(n):Zd(n);const f=e.ordered?c==="."?")":".":EA(n);let p=t&&n.bulletLastUsed?c===n.bulletLastUsed:!1;if(!e.ordered){const g=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&g&&(!g.children||!g.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(p=!0),qS(n)===c&&g){let _=-1;for(;++_-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let c=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(c=Math.ceil(c/4)*4);const f=n.createTracker(s);f.move(o+" ".repeat(c-o.length)),f.shift(c);const p=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,f.current()),g);return p(),h;function g(_,b,y){return b?(y?"":" ".repeat(c))+_:(y?o:o+" ".repeat(c-o.length))+_}}function MA(e,t,n,s){const a=n.enter("paragraph"),o=n.enter("phrasing"),c=n.containerPhrasing(e,s);return o(),a(),c}const BA=Ru(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function NA(e,t,n,s){return(e.children.some(function(c){return BA(c)})?n.containerPhrasing:n.containerFlow).call(n,e,s)}function LA(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}WS.peek=zA;function WS(e,t,n,s){const a=LA(n),o=n.enter("strong"),c=n.createTracker(s),f=c.move(a+a);let p=c.move(n.containerPhrasing(e,{after:a,before:f,...c.current()}));const h=p.charCodeAt(0),g=Su(s.before.charCodeAt(s.before.length-1),h,a);g.inside&&(p=wa(h)+p.slice(1));const _=p.charCodeAt(p.length-1),b=Su(s.after.charCodeAt(0),_,a);b.inside&&(p=p.slice(0,-1)+wa(_));const y=c.move(a+a);return o(),n.attentionEncodeSurroundingInfo={after:b.outside,before:g.outside},f+p+y}function zA(e,t,n){return n.options.strong||"*"}function OA(e,t,n,s){return n.safe(e.value,s)}function jA(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function HA(e,t,n){const s=(qS(n)+(n.options.ruleSpaces?" ":"")).repeat(jA(n));return n.options.ruleSpaces?s.slice(0,-1):s}const YS={blockquote:aA,break:Fy,code:dA,definition:mA,emphasis:zS,hardBreak:Fy,heading:yA,html:OS,image:jS,imageReference:HS,inlineCode:PS,link:IS,linkReference:FS,list:AA,listItem:RA,paragraph:MA,root:NA,strong:WS,text:OA,thematicBreak:HA};function PA(){return{enter:{table:UA,tableData:qy,tableHeader:qy,tableRow:FA},exit:{codeText:qA,table:IA,tableData:Ef,tableHeader:Ef,tableRow:Ef}}}function UA(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function IA(e){this.exit(e),this.data.inTable=void 0}function FA(e){this.enter({type:"tableRow",children:[]},e)}function Ef(e){this.exit(e)}function qy(e){this.enter({type:"tableCell",children:[]},e)}function qA(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,WA));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function WA(e,t){return t==="|"?t:e}function YA(e){const t=e||{},n=t.tableCellPadding,s=t.tablePipeAlign,a=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` +`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:b,table:c,tableCell:p,tableRow:f}};function c(y,x,k,L){return h(g(y,k,L),y.align)}function f(y,x,k,L){const M=_(y,k,L),Z=h([M]);return Z.slice(0,Z.indexOf(` +`))}function p(y,x,k,L){const M=k.enter("tableCell"),Z=k.enter("phrasing"),I=k.containerPhrasing(y,{...L,before:o,after:o});return Z(),M(),I}function h(y,x){return sA(y,{align:x,alignDelimiters:s,padding:n,stringLength:a})}function g(y,x,k){const L=y.children;let M=-1;const Z=[],I=x.enter("table");for(;++M0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const uD={tokenize:gD,partial:!0};function cD(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:pD,continuation:{tokenize:mD},exit:_D}},text:{91:{name:"gfmFootnoteCall",tokenize:dD},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:hD,resolveTo:fD}}}}function hD(e,t,n){const s=this;let a=s.events.length;const o=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let c;for(;a--;){const p=s.events[a][1];if(p.type==="labelImage"){c=p;break}if(p.type==="gfmFootnoteCall"||p.type==="labelLink"||p.type==="label"||p.type==="image"||p.type==="link")break}return f;function f(p){if(!c||!c._balanced)return n(p);const h=Ji(s.sliceSerialize({start:c.end,end:s.now()}));return h.codePointAt(0)!==94||!o.includes(h.slice(1))?n(p):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),t(p))}}function fD(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const s={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},f=[e[n+1],e[n+2],["enter",s,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",c,t],["exit",c,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",s,t]];return e.splice(n,e.length-n+1,...f),e}function dD(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o=0,c;return f;function f(_){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(_),e.exit("gfmFootnoteCallLabelMarker"),p}function p(_){return _!==94?n(_):(e.enter("gfmFootnoteCallMarker"),e.consume(_),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(_){if(o>999||_===93&&!c||_===null||_===91||Qe(_))return n(_);if(_===93){e.exit("chunkString");const b=e.exit("gfmFootnoteCallString");return a.includes(Ji(s.sliceSerialize(b)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(_),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(_)}return Qe(_)||(c=!0),o++,e.consume(_),_===92?g:h}function g(_){return _===91||_===92||_===93?(e.consume(_),o++,h):h(_)}}function pD(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o,c=0,f;return p;function p(x){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(x){return x===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",g):n(x)}function g(x){if(c>999||x===93&&!f||x===null||x===91||Qe(x))return n(x);if(x===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return o=Ji(s.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),b}return Qe(x)||(f=!0),c++,e.consume(x),x===92?_:g}function _(x){return x===91||x===92||x===93?(e.consume(x),c++,g):g(x)}function b(x){return x===58?(e.enter("definitionMarker"),e.consume(x),e.exit("definitionMarker"),a.includes(o)||a.push(o),Ue(e,y,"gfmFootnoteDefinitionWhitespace")):n(x)}function y(x){return t(x)}}function mD(e,t,n){return e.check(Da,t,e.attempt(uD,t,n))}function _D(e){e.exit("gfmFootnoteDefinition")}function gD(e,t,n){const s=this;return Ue(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const c=s.events[s.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?t(o):n(o)}}function vD(e){let n=(e||{}).singleTilde;const s={name:"strikethrough",tokenize:o,resolveAll:a};return n==null&&(n=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function a(c,f){let p=-1;for(;++p1?p(x):(c.consume(x),_++,y);if(_<2&&!n)return p(x);const L=c.exit("strikethroughSequenceTemporary"),M=Qs(x);return L._open=!M||M===2&&!!k,L._close=!k||k===2&&!!M,f(x)}}}class yD{constructor(){this.map=[]}add(t,n,s){bD(this,t,n,s)}consume(t){if(this.map.sort(function(o,c){return o[0]-c[0]}),this.map.length===0)return;let n=this.map.length;const s=[];for(;n>0;)n-=1,s.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];s.push(t.slice()),t.length=0;let a=s.pop();for(;a;){for(const o of a)t.push(o);a=s.pop()}this.map.length=0}}function bD(e,t,n,s){let a=0;if(!(n===0&&s.length===0)){for(;a-1;){const A=s.events[le][1].type;if(A==="lineEnding"||A==="linePrefix")le--;else break}const V=le>-1?s.events[le][1].type:null,B=V==="tableHead"||V==="tableRow"?O:p;return B===O&&s.parser.lazy[s.now().line]?n(U):B(U)}function p(U){return e.enter("tableHead"),e.enter("tableRow"),h(U)}function h(U){return U===124||(c=!0,o+=1),g(U)}function g(U){return U===null?n(U):be(U)?o>1?(o=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(U),e.exit("lineEnding"),y):n(U):Oe(U)?Ue(e,g,"whitespace")(U):(o+=1,c&&(c=!1,a+=1),U===124?(e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),c=!0,g):(e.enter("data"),_(U)))}function _(U){return U===null||U===124||Qe(U)?(e.exit("data"),g(U)):(e.consume(U),U===92?b:_)}function b(U){return U===92||U===124?(e.consume(U),_):_(U)}function y(U){return s.interrupt=!1,s.parser.lazy[s.now().line]?n(U):(e.enter("tableDelimiterRow"),c=!1,Oe(U)?Ue(e,x,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(U):x(U))}function x(U){return U===45||U===58?L(U):U===124?(c=!0,e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),k):W(U)}function k(U){return Oe(U)?Ue(e,L,"whitespace")(U):L(U)}function L(U){return U===58?(o+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(U),e.exit("tableDelimiterMarker"),M):U===45?(o+=1,M(U)):U===null||be(U)?Q(U):W(U)}function M(U){return U===45?(e.enter("tableDelimiterFiller"),Z(U)):W(U)}function Z(U){return U===45?(e.consume(U),Z):U===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(U),e.exit("tableDelimiterMarker"),I):(e.exit("tableDelimiterFiller"),I(U))}function I(U){return Oe(U)?Ue(e,Q,"whitespace")(U):Q(U)}function Q(U){return U===124?x(U):U===null||be(U)?!c||a!==o?W(U):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(U)):W(U)}function W(U){return n(U)}function O(U){return e.enter("tableRow"),ie(U)}function ie(U){return U===124?(e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),ie):U===null||be(U)?(e.exit("tableRow"),t(U)):Oe(U)?Ue(e,ie,"whitespace")(U):(e.enter("data"),ue(U))}function ue(U){return U===null||U===124||Qe(U)?(e.exit("data"),ie(U)):(e.consume(U),U===92?me:ue)}function me(U){return U===92||U===124?(e.consume(U),ue):ue(U)}}function CD(e,t){let n=-1,s=!0,a=0,o=[0,0,0,0],c=[0,0,0,0],f=!1,p=0,h,g,_;const b=new yD;for(;++nn[2]+1){const x=n[2]+1,k=n[3]-n[2]-1;e.add(x,k,[])}}e.add(n[3]+1,0,[["exit",_,t]])}return a!==void 0&&(o.end=Object.assign({},Xs(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function Yy(e,t,n,s,a){const o=[],c=Xs(t.events,n);a&&(a.end=Object.assign({},c),o.push(["exit",a,t])),s.end=Object.assign({},c),o.push(["exit",s,t]),e.add(n+1,0,o)}function Xs(e,t){const n=e[t],s=n[0]==="enter"?"start":"end";return n[1][s]}const kD={name:"tasklistCheck",tokenize:TD};function ED(){return{text:{91:kD}}}function TD(e,t,n){const s=this;return a;function a(p){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?n(p):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),o)}function o(p){return Qe(p)?(e.enter("taskListCheckValueUnchecked"),e.consume(p),e.exit("taskListCheckValueUnchecked"),c):p===88||p===120?(e.enter("taskListCheckValueChecked"),e.consume(p),e.exit("taskListCheckValueChecked"),c):n(p)}function c(p){return p===93?(e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):n(p)}function f(p){return be(p)?t(p):Oe(p)?e.check({tokenize:AD},t,n)(p):n(p)}}function AD(e,t,n){return Ue(e,s,"whitespace");function s(a){return a===null?n(a):t(a)}}function DD(e){return uS([eD(),cD(),vD(e),xD(),ED()])}const RD={};function MD(e){const t=this,n=e||RD,s=t.data(),a=s.micromarkExtensions||(s.micromarkExtensions=[]),o=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),c=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);a.push(DD(n)),o.push($A()),c.push(ZA(n))}const Gr=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],Vy={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...Gr,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...Gr],h2:[["className","sr-only"]],img:[...Gr,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...Gr,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...Gr],table:[...Gr],ul:[...Gr,["className","contains-task-list"]],"*":["abbr","accept","acceptCharset","accessKey","action","align","alt","axis","border","cellPadding","cellSpacing","char","charOff","charSet","checked","clear","colSpan","color","cols","compact","coords","dateTime","dir","encType","frame","hSpace","headers","height","hrefLang","htmlFor","id","isMap","itemProp","label","lang","maxLength","media","method","multiple","name","noHref","noShade","noWrap","open","prompt","readOnly","rev","rowSpan","rows","rules","scope","selected","shape","size","span","start","summary","tabIndex","title","useMap","vAlign","value","width"]},clobber:["ariaDescribedBy","ariaLabelledBy","id","name"],clobberPrefix:"user-content-",protocols:{cite:["http","https"],href:["http","https","irc","ircs","mailto","xmpp"],longDesc:["http","https"],src:["http","https"]},required:{input:{disabled:!0,type:"checkbox"}},strip:["script"],tagNames:["a","b","blockquote","br","code","dd","del","details","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","i","img","input","ins","kbd","li","ol","p","picture","pre","q","rp","rt","ruby","s","samp","section","source","span","strike","strong","sub","summary","sup","table","tbody","td","tfoot","th","thead","tr","tt","ul","var"]},Sr={}.hasOwnProperty;function BD(e,t){let n={type:"root",children:[]};const s={schema:t?{...Vy,...t}:Vy,stack:[]},a=e0(s,e);return a&&(Array.isArray(a)?a.length===1?n=a[0]:n.children=a:n=a),n}function e0(e,t){if(t&&typeof t=="object"){const n=t;switch(typeof n.type=="string"?n.type:""){case"comment":return ND(e,n);case"doctype":return LD(e,n);case"element":return zD(e,n);case"root":return OD(e,n);case"text":return jD(e,n)}}}function ND(e,t){if(e.schema.allowComments){const n=typeof t.value=="string"?t.value:"",s=n.indexOf("-->"),o={type:"comment",value:s<0?n:n.slice(0,s)};return Ma(o,t),o}}function LD(e,t){if(e.schema.allowDoctypes){const n={type:"doctype"};return Ma(n,t),n}}function zD(e,t){const n=typeof t.tagName=="string"?t.tagName:"";e.stack.push(n);const s=t0(e,t.children),a=HD(e,t.properties);e.stack.pop();let o=!1;if(n&&n!=="*"&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(o=!0,e.schema.ancestors&&Sr.call(e.schema.ancestors,n))){const f=e.schema.ancestors[n];let p=-1;for(o=!1;++p1){let a=!1,o=0;for(;++o-1&&o>p||c>-1&&o>c||f>-1&&o>f)return!0;let h=-1;for(;++h4&&t.slice(0,4).toLowerCase()==="data")return n}function ID(e){return function(t){return BD(t,e)}}const aa=["Romance","Fantasy","Science Fiction","Mystery","Thriller","Horror","Adventure","Historical Fiction","Contemporary Lit","Humor","Poetry","Non-Fiction","Fanfiction","Short Story","Paranormal","Werewolf","LGBTQ+","New Adult","Teen Fiction","Diverse Lit","Others"],oa=["English","Chinese","Korean","Japanese","Spanish","French","Hindi","Arabic","Portuguese","Russian","Others"];function FD({storyName:e,fileName:t,authFetch:n,onPublish:s,publishingFile:a,walletAddress:o}){const[c,f]=$.useState(null),[p,h]=$.useState(!1),[g,_]=$.useState("preview"),[b,y]=$.useState(""),[x,k]=$.useState(!1),[L,M]=$.useState(!1),[Z,I]=$.useState(!1),[Q,W]=$.useState(null),[O,ie]=$.useState(aa[0]),[ue,me]=$.useState(oa[0]),[U,le]=$.useState(!1),V=$.useRef(null),B=$.useRef(!1),[A,R]=$.useState(!1),[T,j]=$.useState(aa[0]),[H,oe]=$.useState(oa[0]),[E,D]=$.useState(!1),[K,C]=$.useState(null),[J,fe]=$.useState(null),[de,xe]=$.useState(!1),[Ne,Ce]=$.useState(null),[rt,et]=$.useState(!1),ut=$.useRef(null),we=$.useRef(null),Et=$.useCallback(async()=>{if(!e||!t){f(null);return}const X=`${e}/${t}`,he=we.current!==X;he&&(we.current=X);try{const ve=await n(`/api/stories/${e}/${t}`);if(ve.ok){const Te=await ve.json();f(Te),(he||!B.current)&&(y(Te.content??""),he&&(M(!1),B.current=!1))}}catch{}},[e,t,n]);$.useEffect(()=>{h(!0),Et().finally(()=>h(!1))},[Et]),$.useEffect(()=>{if(!e||!t||g==="edit"&&L)return;const X=setInterval(Et,3e3);return()=>clearInterval(X)},[e,t,Et,g,L]),$.useEffect(()=>{if(!e)return;let X=!1;return n(`/api/stories/${e}/structure.md`).then(he=>he.ok?he.json():null).then(he=>{if(X||!(he!=null&&he.content))return;const ve=he.content.match(/\*{0,2}genre\*{0,2}[:\s]+(.+)/i);if(ve){const vt=ve[1].replace(/\*+/g,"").trim(),Yt=aa.find(Tt=>Tt.toLowerCase()===vt.toLowerCase());Yt&&ie(Yt)}const Te=he.content.match(/\*{0,2}language\*{0,2}[:\s]+(.+)/i);if(Te){const vt=Te[1].replace(/\*+/g,"").trim(),Yt=oa.find(Tt=>Tt.toLowerCase()===vt.toLowerCase());Yt&&me(Yt)}}).catch(()=>{}),()=>{X=!0}},[e,n]);const en=$.useCallback(async()=>{if(!(!e||!t)){k(!0);try{(await n(`/api/stories/${e}/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:b})})).ok&&(M(!1),B.current=!1,f(he=>he&&{...he,content:b}))}catch{}k(!1)}},[e,t,n,b]),Wn=$.useCallback(X=>{var ve;const he=(ve=X.target.files)==null?void 0:ve[0];if(he){if(he.size>500*1024){Ce("Image exceeds 500KB limit");return}if(!he.type.startsWith("image/")){Ce("File must be an image");return}C(he),fe(URL.createObjectURL(he)),Ce(null)}},[]),ss=$.useCallback(async()=>{if(c!=null&&c.storylineId){xe(!0),Ce(null),et(!1);try{let X;if(K){const ve=new FormData;ve.append("file",K);const Te=await n("/api/publish/upload-cover",{method:"POST",body:ve});if(!Te.ok){const Yt=await Te.json();throw new Error(Yt.error||"Cover upload failed")}X=(await Te.json()).cid}const he=await n("/api/publish/update-storyline",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storylineId:c.storylineId,...X!==void 0&&{coverCid:X},genre:T,language:H,isNsfw:E})});if(!he.ok){const ve=await he.json();throw new Error(ve.error||"Update failed")}et(!0),C(null),setTimeout(()=>et(!1),3e3)}catch(X){Ce(X instanceof Error?X.message:"Update failed")}finally{xe(!1)}}},[c==null?void 0:c.storylineId,K,T,H,E,n]);$.useEffect(()=>{R(!1),C(null),fe(null),Ce(null),et(!1)},[e,t]),$.useEffect(()=>{if(g!=="edit")return;const X=he=>{(he.metaKey||he.ctrlKey)&&he.key==="s"&&(he.preventDefault(),en())};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[g,en]),$.useEffect(()=>{if((c==null?void 0:c.status)!=="published-not-indexed"||!c.publishedAt)return;const X=new Date(c.publishedAt).getTime(),he=300*1e3,ve=()=>{const vt=Math.max(0,he-(Date.now()-X));W(vt)};ve();const Te=setInterval(ve,1e3);return()=>clearInterval(Te)},[c==null?void 0:c.status,c==null?void 0:c.publishedAt]);const Er=Q!==null&&Q<=0,pn=Q!==null&&Q>0?`${Math.floor(Q/6e4)}:${String(Math.floor(Q%6e4/1e3)).padStart(2,"0")}`:null;if(!e||!t)return S.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:S.jsxs("div",{className:"text-center",children:[S.jsx("p",{className:"text-lg font-serif",children:"Select a file to preview"}),S.jsx("p",{className:"text-sm mt-1",children:"Click a story file in the sidebar"})]})});if(p&&!c)return S.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:"Loading..."});const mn=(g==="edit"?b:(c==null?void 0:c.content)??"").length,_n=t==="genesis.md",gn=t?/^plot-\d+\.md$/.test(t):!1,Wt=(c==null?void 0:c.status)==="published"||(c==null?void 0:c.status)==="published-not-indexed",vn=_n||gn?1e4:null,te=!Wt&&vn!==null&&mn>vn;return S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"border-b border-border",children:[S.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[S.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono text-muted",children:[S.jsxs("span",{children:[e,"/",t]}),(c==null?void 0:c.status)==="published"&&S.jsx("span",{className:"text-green-700 font-medium",children:"Published"}),(c==null?void 0:c.status)==="published-not-indexed"&&S.jsx("span",{className:"text-amber-700 font-medium",title:c.indexError,children:"Published (not indexed)"}),(c==null?void 0:c.status)==="pending"&&S.jsx("span",{className:"text-amber-700 font-medium",children:"Pending"})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsxs("span",{className:`text-xs font-mono ${te?"text-error font-medium":"text-muted"}`,children:[mn.toLocaleString(),vn!==null?`/${vn.toLocaleString()}`:" chars"]}),te&&S.jsxs("span",{className:"text-error text-xs font-medium",children:[(mn-vn).toLocaleString()," over limit"]})]})]}),S.jsxs("div",{className:"flex px-3 gap-1",children:[S.jsx("button",{onClick:()=>_("preview"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${g==="preview"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:"Preview"}),S.jsxs("button",{onClick:()=>_("edit"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${g==="edit"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:["Edit",L&&S.jsx("span",{className:"ml-1 text-amber-600",children:"*"})]})]})]}),g==="preview"?S.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-6 py-4",style:{background:"var(--paper-bg)"},children:c!=null&&c.content?S.jsx("div",{className:"prose max-w-none",children:S.jsx(_3,{remarkPlugins:[T3,MD],rehypePlugins:[ID],children:c.content})}):S.jsx("p",{className:"text-muted italic",children:"No content"})}):S.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",style:{background:"var(--paper-bg)"},children:[S.jsx("textarea",{ref:V,value:b,onChange:X=>{y(X.target.value),M(!0),B.current=!0},className:"flex-1 min-h-0 w-full resize-none px-4 py-3 text-sm leading-relaxed focus:outline-none",style:{fontFamily:'"Geist Mono", ui-monospace, monospace',background:"var(--paper-bg)",color:"var(--text)"},spellCheck:!1}),S.jsxs("div",{className:"px-3 py-1.5 border-t border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs text-muted",children:L?"Unsaved changes":"No changes"}),S.jsx("button",{onClick:en,disabled:!L||x,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:x?"Saving...":"Save"})]})]}),S.jsx("div",{className:"px-3 py-2 border-t border-border flex items-center justify-between",children:t==="structure.md"?S.jsx("p",{className:"text-muted text-xs italic",children:"This is your story outline — not publishable. Ask AI to write the genesis next."}):(c==null?void 0:c.status)==="published-not-indexed"?S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[S.jsx("span",{className:"text-amber-700",children:"Published on-chain but not indexed on PlotLink"}),!Er&&S.jsx("button",{onClick:async()=>{if(!(!e||!t||!c.txHash)){I(!0);try{(await(await n("/api/publish/retry-index",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:e,fileName:t,txHash:c.txHash,content:c.content,storylineId:c.storylineId})})).json()).ok&&(await n(`/api/stories/${e}/${t}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:c.txHash,storylineId:c.storylineId,contentCid:"",gasCost:""})}),Et())}catch{}I(!1)}},disabled:Z,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:Z?"Retrying...":`Retry Index${pn?` (${pn})`:""}`}),gn&&S.jsx("button",{onClick:()=>e&&t&&(s==null?void 0:s(e,t,O,ue,U)),disabled:!!a,className:"px-3 py-1 border border-border text-xs rounded hover:bg-surface disabled:opacity-50",children:a===t?"Publishing...":"Retry Publish"}),c.txHash&&S.jsx("a",{href:`https://basescan.org/tx/${c.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"})]}),S.jsx("p",{className:"text-muted text-xs",children:Er?gn?"Index window expired. Use Retry Publish to create a new on-chain tx.":"Index window expired. Contact support or re-publish manually.":gn?"Try Retry Index first (available for 5 min after publish). If that fails, Retry Publish creates a new on-chain tx.":"Retry Index is available for 5 min after publish."}),c.indexError&&S.jsx("p",{className:"text-error text-xs",children:c.indexError})]}):(c==null?void 0:c.status)==="published"?S.jsxs("div",{className:"flex flex-col gap-2",children:[S.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[S.jsx("span",{className:"text-green-700",children:"Published"}),c.storylineId&&S.jsx("a",{href:(()=>{var ve;const X=`https://plotlink.xyz/story/${c.storylineId}`;if(!gn)return X;const he=c.plotIndex!=null&&c.plotIndex>0?c.plotIndex:parseInt(((ve=t==null?void 0:t.match(/^plot-(\d+)\.md$/))==null?void 0:ve[1])??"1");return`${X}/${he}`})(),target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"}),c.txHash&&S.jsx("a",{href:`https://basescan.org/tx/${c.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"}),_n&&o&&c.storylineId&&S.jsx("button",{onClick:()=>R(X=>!X),className:"px-2 py-0.5 border border-border text-xs rounded hover:bg-surface",children:A?"Close Edit":"Edit Story"})]}),A&&_n&&c.storylineId&&S.jsxs("div",{className:"border border-border rounded p-3 flex flex-col gap-3 bg-surface",children:[S.jsxs("div",{className:"flex flex-col gap-1.5",children:[S.jsx("span",{className:"text-xs font-medium text-foreground",children:"Cover Image"}),S.jsxs("div",{className:"flex items-start gap-3",children:[J&&S.jsxs("div",{className:"relative",children:[S.jsx("img",{src:J,alt:"Cover preview",className:"w-16 h-24 object-cover rounded border border-border"}),S.jsx("button",{onClick:()=>{C(null),fe(null),ut.current&&(ut.current.value="")},className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-error text-white rounded-full text-xs flex items-center justify-center",children:"x"})]}),S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsx("input",{ref:ut,type:"file",accept:"image/webp,image/jpeg,image/png",onChange:Wn,className:"text-xs"}),S.jsx("span",{className:"text-xs text-muted",children:"WebP/JPEG, max 500KB, 600x900px recommended"})]})]})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("select",{value:T,onChange:X=>j(X.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:aa.map(X=>S.jsx("option",{value:X,children:X},X))}),S.jsx("select",{value:H,onChange:X=>oe(X.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:oa.map(X=>S.jsx("option",{value:X,children:X},X))})]}),S.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[S.jsx("input",{type:"checkbox",checked:E,onChange:X=>D(X.target.checked),className:"rounded border-border"}),"This story contains adult content (18+)"]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("button",{onClick:ss,disabled:de,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:de?"Saving...":"Save Changes"}),rt&&S.jsx("span",{className:"text-green-700 text-xs",children:"Updated!"}),Ne&&S.jsx("span",{className:"text-error text-xs",children:Ne})]})]})]}):S.jsxs("div",{className:"flex flex-col gap-2",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[_n&&S.jsxs(S.Fragment,{children:[S.jsx("select",{value:O,onChange:X=>ie(X.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:aa.map(X=>S.jsx("option",{value:X,children:X},X))}),S.jsx("select",{value:ue,onChange:X=>me(X.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:oa.map(X=>S.jsx("option",{value:X,children:X},X))})]}),S.jsx("button",{onClick:()=>e&&t&&(s==null?void 0:s(e,t,O,ue,U)),disabled:!!a||te,className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:a===t?"Publishing...":"Publish to PlotLink"}),te&&S.jsx("span",{className:"text-error text-xs",children:"Reduce content to publish"})]}),_n&&S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[S.jsx("input",{type:"checkbox",checked:U,onChange:X=>le(X.target.checked),className:"rounded border-border"}),"This story contains adult content (18+)"]}),U&&S.jsx("span",{className:"text-xs text-amber-600",children:"Adult content will be hidden from the default browse view."})]})]})})]})}const n0="plotlink-panel-ratio",qD=.6,Gy=300,Tf=224,Af=6;function WD(){try{const e=localStorage.getItem(n0);if(e){const t=parseFloat(e);if(t>0&&t<1)return t}}catch{}return qD}function $y(e,t){if(t<=0)return e;const n=Gy/t,s=1-Gy/t;return n>=s?.5:Math.min(s,Math.max(n,e))}function YD({token:e,authFetch:t}){const[n,s]=$.useState(null),[a,o]=$.useState(null),[c,f]=$.useState(null),[p,h]=$.useState(""),[g,_]=$.useState(null),[b,y]=$.useState(WD),[x,k]=$.useState([]),L=$.useRef(new Set),M=$.useRef(null),Z=$.useRef(null),I=$.useRef(!1);$.useEffect(()=>{t("/api/wallet").then(A=>A.ok?A.json():null).then(A=>{A!=null&&A.address&&_(A.address)}).catch(()=>{})},[t]),$.useEffect(()=>{try{localStorage.setItem(n0,String(b))}catch{}},[b]),$.useEffect(()=>{const A=()=>{if(!Z.current)return;const R=Z.current.getBoundingClientRect().width-Tf-Af;y(T=>$y(T,R))};return window.addEventListener("resize",A),A(),()=>window.removeEventListener("resize",A)},[]);const Q=$.useCallback(()=>{const A=`_new_${Date.now()}`;k(R=>[...R,A]),s(A),o(null)},[]);$.useEffect(()=>{if(x.length===0)return;const A=setInterval(async()=>{try{const R=await t("/api/stories");if(!R.ok)return;const T=await R.json(),j=new Set(T.stories.filter(H=>H.name!=="_example").map(H=>H.name));for(const H of j)if(!L.current.has(H)&&x.length>0){const oe=x[0];let E=!1;M.current&&(E=await M.current(oe,H).catch(()=>!1)),E&&k(D=>D.slice(1)),s(H),o(null)}L.current=j}catch{}},3e3);return()=>clearInterval(A)},[t,x]),$.useEffect(()=>{t("/api/stories").then(A=>{if(A.ok)return A.json()}).then(A=>{A!=null&&A.stories&&(L.current=new Set(A.stories.filter(R=>R.name!=="_example").map(R=>R.name)))}).catch(()=>{})},[t]);const W=$.useCallback((A,R)=>{s(A),o(R)},[]),O=$.useRef(null),ie=$.useCallback(async A=>{var R,T,j,H;O.current=A,s(A),o(null);try{const oe=await t(`/api/stories/${A}`);if(oe.ok&&O.current===A){const D=(await oe.json()).files||[],C=((R=D.map(J=>{var fe;return{file:J.file,num:(fe=J.file.match(/^plot-(\d+)\.md$/))==null?void 0:fe[1]}}).filter(J=>J.num!=null).sort((J,fe)=>parseInt(fe.num)-parseInt(J.num))[0])==null?void 0:R.file)??((T=D.find(J=>J.file==="genesis.md"))==null?void 0:T.file)??((j=D.find(J=>J.file==="structure.md"))==null?void 0:j.file)??((H=D[0])==null?void 0:H.file);C&&O.current===A&&o(C)}}catch{}},[t]),ue=$.useCallback(A=>{A.preventDefault(),I.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";const R=j=>{if(!I.current||!Z.current)return;const H=Z.current.getBoundingClientRect(),oe=H.width-Tf-Af,E=j.clientX-H.left-Tf;y($y(E/oe,oe))},T=()=>{I.current=!1,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",R),window.removeEventListener("mouseup",T)};window.addEventListener("mousemove",R),window.addEventListener("mouseup",T)},[]),me=$.useCallback(async(A,R,T,j,H)=>{var oe;f(R),h("Reading file...");try{const E=await t(`/api/stories/${A}/${R}`);if(!E.ok)throw new Error("Failed to read file");const D=await E.json(),K=D.content.match(/^#\s+(.+)$/m),C=K?K[1].slice(0,60):R.replace(".md","");let J;if(R.match(/^plot-\d+\.md$/)){try{const Ne=await t(`/api/stories/${A}`);if(Ne.ok){const rt=(await Ne.json()).files.find(et=>et.file==="genesis.md"&&et.storylineId);J=rt==null?void 0:rt.storylineId}}catch{}if(!J){h("Error: Publish genesis first to create the storyline"),setTimeout(()=>{f(null),h("")},3e3);return}}h("Publishing...");const fe=await t("/api/publish/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:A,fileName:R,title:C,content:D.content,genre:T,language:j,isNsfw:H,storylineId:J})});if(!fe.ok){const Ne=await fe.json();throw new Error(Ne.error||"Publish failed")}const de=(oe=fe.body)==null?void 0:oe.getReader(),xe=new TextDecoder;if(de)for(;;){const{done:Ne,value:Ce}=await de.read();if(Ne)break;const et=xe.decode(Ce).split(` +`).filter(ut=>ut.startsWith("data: "));for(const ut of et)try{const we=JSON.parse(ut.slice(6));we.step&&h(we.message||we.step),we.step==="done"&&we.txHash&&await t(`/api/stories/${A}/${R}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:we.txHash,storylineId:we.storylineId,plotIndex:we.plotIndex,contentCid:we.contentCid,gasCost:we.gasCost,indexError:we.indexError})})}catch{}}h("Published!")}catch(E){const D=E instanceof Error?E.message:"Publish failed";h(`Error: ${D}`)}finally{setTimeout(()=>{f(null),h("")},3e3)}},[t]),U=$.useCallback(A=>{A.startsWith("_new_")&&k(R=>R.filter(T=>T!==A))},[]),[le,V]=$.useState(new Set);$.useEffect(()=>{t("/api/stories").then(R=>R.ok?R.json():null).then(R=>{R!=null&&R.stories&&V(new Set(R.stories.filter(T=>T.hasStructure).map(T=>T.name)))}).catch(()=>{});const A=setInterval(async()=>{try{const R=await t("/api/stories");if(R.ok){const T=await R.json();V(new Set(T.stories.filter(j=>j.hasStructure).map(j=>j.name)))}}catch{}},5e3);return()=>clearInterval(A)},[t]);const B=$.useCallback(A=>{n===A&&(s(null),o(null))},[n]);return S.jsxs("div",{ref:Z,className:"h-[calc(100vh-3.5rem)] flex",children:[S.jsx("div",{className:"w-56 border-r border-border flex-shrink-0",children:S.jsx(jx,{authFetch:t,selectedStory:n,selectedFile:a,onSelectFile:W,onNewStory:Q,untitledSessions:x})}),S.jsx("div",{className:"min-w-0 border-r border-border",style:{flex:`${b} 0 0`},children:S.jsx(lk,{token:e,storyName:n,authFetch:t,onSelectStory:ie,onDestroySession:U,onArchiveStory:B,confirmedStories:le,renameRef:M})}),S.jsx("div",{onMouseDown:ue,className:"flex-shrink-0 flex items-center justify-center hover:bg-border/50 transition-colors",style:{width:Af,cursor:"col-resize",background:"var(--border)"},children:S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}})]})}),S.jsxs("div",{className:"min-w-0 flex flex-col",style:{flex:`${1-b} 0 0`},children:[S.jsx(FD,{storyName:n,fileName:a,authFetch:t,onPublish:me,publishingFile:c,walletAddress:g}),p&&S.jsx("div",{className:"px-3 py-1.5 bg-surface border-t border-border text-xs text-muted",children:p})]})]})}function VD({token:e,onComplete:t}){const[n,s]=$.useState(!1),[a,o]=$.useState(null),[c,f]=$.useState(!1),p=async()=>{s(!0),o(null);try{const h=await fetch("/api/wallet/create",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),g=await h.json();if(!h.ok)throw new Error(g.error||"Wallet creation failed");f(!0)}catch(h){o(h instanceof Error?h.message:"Wallet creation failed")}s(!1)};return $.useEffect(()=>{p()},[]),S.jsxs("div",{className:"mx-auto max-w-sm p-6 text-center",children:[S.jsx("h2",{className:"text-accent mb-1 text-lg font-bold",children:"Wallet Setup"}),S.jsx("p",{className:"text-muted mb-6 text-xs",children:"creating your OWS wallet for on-chain publishing"}),n&&S.jsx("p",{className:"text-accent text-sm",children:"creating wallet..."}),a&&S.jsxs("div",{className:"space-y-4",children:[S.jsx("div",{className:"rounded border border-red-700/30 p-3 text-xs text-red-700",children:a}),S.jsx("button",{onClick:p,className:"border-accent text-accent hover:bg-accent/10 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:"retry"})]}),c&&S.jsxs("div",{className:"space-y-4",children:[S.jsx("div",{className:"text-accent text-2xl",children:"✓"}),S.jsx("p",{className:"text-foreground text-sm font-medium",children:"wallet created"}),S.jsx("button",{onClick:t,className:"border-accent text-accent hover:bg-accent/10 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:"continue"})]})]})}function KD({token:e,onLogout:t}){const[n,s]=$.useState("home"),[a,o]=$.useState(0),c=$.useCallback(async(f,p)=>fetch(f,{...p,headers:{...(p==null?void 0:p.headers)||{},Authorization:`Bearer ${e}`}}),[e]);return $.useEffect(()=>{async function f(){try{if(!(await(await c("/api/wallet")).json()).exists){s("wallet-setup");return}const g=await c("/api/stories");if(g.ok){const _=await g.json();o(_.stories.filter(b=>b.name!=="_example").length)}}catch{}}f()},[e]),S.jsxs("div",{className:"flex h-screen flex-col",children:[S.jsxs("header",{className:"border-border flex h-14 items-center justify-between border-b px-4 flex-shrink-0",children:[S.jsxs("div",{className:"flex items-center gap-3",children:[S.jsx("button",{onClick:()=>{n!=="wallet-setup"&&s("home")},className:"flex items-center gap-2 hover:opacity-80",children:S.jsx("span",{className:"text-accent text-sm font-bold tracking-tight",children:"PlotLink OWS"})}),S.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"writer"})]}),n!=="wallet-setup"&&S.jsxs("nav",{className:"flex items-center gap-4",children:[S.jsx("button",{onClick:()=>s("stories"),className:`text-xs transition-colors ${n==="stories"?"text-accent":"text-muted hover:text-foreground"}`,children:"stories"}),S.jsx("button",{onClick:()=>s("dashboard"),className:`text-xs transition-colors ${n==="dashboard"?"text-accent":"text-muted hover:text-foreground"}`,children:"dashboard"}),S.jsx("button",{onClick:()=>s("settings"),className:`text-xs transition-colors ${n==="settings"?"text-accent":"text-muted hover:text-foreground"}`,children:"settings"}),S.jsx("button",{onClick:t,className:"text-muted hover:text-foreground text-xs transition-colors",children:"logout"})]})]}),S.jsxs("main",{className:"flex-1 min-h-0",children:[n==="home"&&S.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-8",children:[S.jsxs("div",{className:"text-center space-y-2",children:[S.jsx("h1",{className:"text-2xl font-serif text-foreground",children:"Write. Publish. Earn."}),S.jsx("p",{className:"text-muted text-sm",children:"Claude CLI writes stories. You publish them on-chain."})]}),S.jsxs("div",{className:"text-center space-y-3",children:[S.jsx("button",{onClick:()=>s("stories"),className:"bg-accent text-white hover:bg-accent-dim px-6 py-2.5 rounded text-sm font-medium transition-colors",children:"Start Writing"}),a>0&&S.jsxs("p",{className:"text-muted text-xs",children:[a," ",a===1?"story":"stories"," in progress"]})]}),S.jsxs("div",{className:"rounded border border-border p-4 space-y-2 text-xs text-muted",children:[S.jsx("p",{className:"font-medium text-foreground text-sm",children:"How it works"}),S.jsxs("ol",{className:"space-y-1.5 list-decimal list-inside",children:[S.jsxs("li",{children:["Open the ",S.jsx("strong",{children:"Stories"})," tab — Claude CLI launches in the terminal"]}),S.jsx("li",{children:"Tell Claude your story idea — it brainstorms, outlines, and writes"}),S.jsx("li",{children:"Review the live preview as Claude creates files"}),S.jsxs("li",{children:["Click ",S.jsx("strong",{children:"Publish"})," to put your story on-chain"]}),S.jsxs("li",{children:["Earn 5% royalties on every trade at ",S.jsx("a",{href:"https://plotlink.xyz",target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"plotlink.xyz"})]})]})]}),S.jsx("div",{className:"text-center",children:S.jsx("a",{href:"https://github.com/realproject7/plotlink-ows#-wallet-setup",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted hover:text-accent underline transition-colors",children:"Wallet Setup Guide"})}),S.jsx(eb,{token:e})]}),n==="stories"&&S.jsx(YD,{token:e,authFetch:c}),n==="dashboard"&&S.jsx(Lx,{token:e}),n==="wallet-setup"&&S.jsx(VD,{token:e,onComplete:()=>s("home")}),n==="settings"&&S.jsx(Bx,{token:e,onLogout:t})]})]})}function XD(){const[e,t]=$.useState(()=>localStorage.getItem("ows-token")),[n,s]=$.useState(null),[a,o]=$.useState(!0);$.useEffect(()=>{fetch("/api/auth/status").then(h=>h.json()).then(h=>s(h.configured)).catch(()=>s(null))},[]),$.useEffect(()=>{if(!e){o(!1);return}fetch("/api/auth/verify",{headers:{Authorization:`Bearer ${e}`}}).then(h=>{h.ok||(localStorage.removeItem("ows-token"),t(null))}).catch(()=>{localStorage.removeItem("ows-token"),t(null)}).finally(()=>o(!1))},[e]);const c=async h=>{try{const g=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:h})}),_=await g.json();return g.ok?(localStorage.setItem("ows-token",_.token),t(_.token),null):_.error||"Login failed"}catch{return"Cannot connect to server"}},f=async h=>{try{const g=await fetch("/api/auth/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:h})}),_=await g.json();return g.ok?(localStorage.setItem("ows-token",_.token),t(_.token),s(!0),null):_.error||"Setup failed"}catch{return"Cannot connect to server"}},p=()=>{localStorage.removeItem("ows-token"),t(null)};return a||n===null?S.jsx("div",{className:"flex h-screen items-center justify-center",children:S.jsx("span",{className:"text-muted text-sm",children:"connecting..."})}):n?e?S.jsx(KD,{token:e,onLogout:p}):S.jsx(Rx,{onLogin:c}):S.jsx(Mx,{onSetup:f})}Dx.createRoot(document.getElementById("root")).render(S.jsx(Sx.StrictMode,{children:S.jsx(XD,{})})); diff --git a/app/web/dist/assets/index-DHjiVVCV.css b/app/web/dist/assets/index-DHjiVVCV.css deleted file mode 100644 index 56036a5..0000000 --- a/app/web/dist/assets/index-DHjiVVCV.css +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2014 The xterm.js authors. All rights reserved. - * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) - * https://github.com/chjj/term.js - * @license MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * Originally forked from (with the author's permission): - * Fabrice Bellard's javascript vt100 for jslinux: - * http://bellard.org/jslinux/ - * Copyright (c) 2011 Fabrice Bellard - * The original design remains. The terminal itself - * has been extended to include xterm CSI codes, among - * other features. - */.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{font-family:monospace;-webkit-user-select:text;user-select:text;white-space:pre}.xterm .xterm-accessibility-tree>div{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px!important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:#0000;transition:opacity .1s linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity .8s linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}/*! tailwindcss v4.2.2 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial}}}@layer theme{:root,:host{--font-serif:ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-700:oklch(50.5% .213 27.518);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-amber-700:oklch(55.5% .163 48.998);--color-green-600:oklch(62.7% .194 149.214);--color-green-700:oklch(52.7% .154 150.069);--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--container-lg:32rem;--container-2xl:42rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--font-weight-medium:500;--font-weight-bold:700;--tracking-tight:-.025em;--tracking-wider:.05em;--leading-relaxed:1.625;--radius-lg:.5rem;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent;font-family:Inter,system-ui,-apple-system,sans-serif;line-height:1.5}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.invisible{visibility:hidden}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.relative{position:relative}.static{position:static}.inset-0{inset:calc(var(--spacing) * 0)}.start{inset-inline-start:var(--spacing)}.start\!{inset-inline-start:var(--spacing)!important}.end{inset-inline-end:var(--spacing)}.top-1{top:calc(var(--spacing) * 1)}.right-1{right:calc(var(--spacing) * 1)}.z-10{z-index:10}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.mx-auto{margin-inline:auto}.prose{color:var(--tw-prose-body);max-width:65ch}.prose :where(p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em}.prose :where([class~=lead]):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-lead);margin-top:1.2em;margin-bottom:1.2em;font-size:1.25em;line-height:1.6}.prose :where(a):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-links);font-weight:500;text-decoration:underline}.prose :where(strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-bold);font-weight:600}.prose :where(a strong):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(blockquote strong):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(thead th strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em;padding-inline-start:1.625em;list-style-type:decimal}.prose :where(ol[type=A]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-alpha}.prose :where(ol[type=a]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-alpha}.prose :where(ol[type=A s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-alpha}.prose :where(ol[type=a s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-alpha}.prose :where(ol[type=I]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-roman}.prose :where(ol[type=i]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-roman}.prose :where(ol[type=I s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-roman}.prose :where(ol[type=i s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-roman}.prose :where(ol[type="1"]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:decimal}.prose :where(ul):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em;padding-inline-start:1.625em;list-style-type:disc}.prose :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *))::marker{color:var(--tw-prose-counters);font-weight:400}.prose :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *))::marker{color:var(--tw-prose-bullets)}.prose :where(dt):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:1.25em;font-weight:600}.prose :where(hr):not(:where([class~=not-prose],[class~=not-prose] *)){border-color:var(--tw-prose-hr);border-top-width:1px;margin-top:3em;margin-bottom:3em}.prose :where(blockquote):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-quotes);border-inline-start-width:.25rem;border-inline-start-color:var(--tw-prose-quote-borders);quotes:"“""”""‘""’";margin-top:1.6em;margin-bottom:1.6em;padding-inline-start:1em;font-style:italic;font-weight:500}.prose :where(blockquote p:first-of-type):not(:where([class~=not-prose],[class~=not-prose] *)):before{content:open-quote}.prose :where(blockquote p:last-of-type):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:close-quote}.prose :where(h1):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:0;margin-bottom:.888889em;font-size:2.25em;font-weight:800;line-height:1.11111}.prose :where(h1 strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-weight:900}.prose :where(h2):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:2em;margin-bottom:1em;font-size:1.5em;font-weight:700;line-height:1.33333}.prose :where(h2 strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-weight:800}.prose :where(h3):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:1.6em;margin-bottom:.6em;font-size:1.25em;font-weight:600;line-height:1.6}.prose :where(h3 strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-weight:700}.prose :where(h4):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);margin-top:1.5em;margin-bottom:.5em;font-weight:600;line-height:1.5}.prose :where(h4 strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-weight:700}.prose :where(img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(picture):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em;display:block}.prose :where(video):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(kbd):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-kbd);box-shadow:0 0 0 1px var(--tw-prose-kbd-shadows),0 3px 0 var(--tw-prose-kbd-shadows);padding-top:.1875em;padding-inline-end:.375em;padding-bottom:.1875em;border-radius:.3125rem;padding-inline-start:.375em;font-family:inherit;font-size:.875em;font-weight:500}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-code);font-size:.875em;font-weight:600}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)):before,.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:"`"}.prose :where(a code):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(h1 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(h2 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-size:.875em}.prose :where(h3 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-size:.9em}.prose :where(h4 code):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(blockquote code):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(thead th code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(pre):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-pre-code);background-color:var(--tw-prose-pre-bg);padding-top:.857143em;padding-inline-end:1.14286em;padding-bottom:.857143em;border-radius:.375rem;margin-top:1.71429em;margin-bottom:1.71429em;padding-inline-start:1.14286em;font-size:.875em;font-weight:400;line-height:1.71429;overflow-x:auto}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:inherit;color:inherit;font-size:inherit;font-family:inherit;line-height:inherit;background-color:#0000;border-width:0;border-radius:0;padding:0}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)):before,.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:none}.prose :where(table):not(:where([class~=not-prose],[class~=not-prose] *)){table-layout:auto;width:100%;margin-top:2em;margin-bottom:2em;font-size:.875em;line-height:1.71429}.prose :where(thead):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-th-borders)}.prose :where(thead th):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);vertical-align:bottom;padding-inline-end:.571429em;padding-bottom:.571429em;padding-inline-start:.571429em;font-weight:600}.prose :where(tbody tr):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-td-borders)}.prose :where(tbody tr:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:0}.prose :where(tbody td):not(:where([class~=not-prose],[class~=not-prose] *)){vertical-align:baseline}.prose :where(tfoot):not(:where([class~=not-prose],[class~=not-prose] *)){border-top-width:1px;border-top-color:var(--tw-prose-th-borders)}.prose :where(tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){vertical-align:top}.prose :where(th,td):not(:where([class~=not-prose],[class~=not-prose] *)){text-align:start}.prose :where(figure>*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose :where(figcaption):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-captions);margin-top:.857143em;font-size:.875em;line-height:1.42857}.prose{--tw-prose-body:oklch(37.3% .034 259.733);--tw-prose-headings:oklch(21% .034 264.665);--tw-prose-lead:oklch(44.6% .03 256.802);--tw-prose-links:oklch(21% .034 264.665);--tw-prose-bold:oklch(21% .034 264.665);--tw-prose-counters:oklch(55.1% .027 264.364);--tw-prose-bullets:oklch(87.2% .01 258.338);--tw-prose-hr:oklch(92.8% .006 264.531);--tw-prose-quotes:oklch(21% .034 264.665);--tw-prose-quote-borders:oklch(92.8% .006 264.531);--tw-prose-captions:oklch(55.1% .027 264.364);--tw-prose-kbd:oklch(21% .034 264.665);--tw-prose-kbd-shadows:oklab(21% -.00316127 -.0338527/.1);--tw-prose-code:oklch(21% .034 264.665);--tw-prose-pre-code:oklch(92.8% .006 264.531);--tw-prose-pre-bg:oklch(27.8% .033 256.848);--tw-prose-th-borders:oklch(87.2% .01 258.338);--tw-prose-td-borders:oklch(92.8% .006 264.531);--tw-prose-invert-body:oklch(87.2% .01 258.338);--tw-prose-invert-headings:#fff;--tw-prose-invert-lead:oklch(70.7% .022 261.325);--tw-prose-invert-links:#fff;--tw-prose-invert-bold:#fff;--tw-prose-invert-counters:oklch(70.7% .022 261.325);--tw-prose-invert-bullets:oklch(44.6% .03 256.802);--tw-prose-invert-hr:oklch(37.3% .034 259.733);--tw-prose-invert-quotes:oklch(96.7% .003 264.542);--tw-prose-invert-quote-borders:oklch(37.3% .034 259.733);--tw-prose-invert-captions:oklch(70.7% .022 261.325);--tw-prose-invert-kbd:#fff;--tw-prose-invert-kbd-shadows:#ffffff1a;--tw-prose-invert-code:#fff;--tw-prose-invert-pre-code:oklch(87.2% .01 258.338);--tw-prose-invert-pre-bg:#00000080;--tw-prose-invert-th-borders:oklch(44.6% .03 256.802);--tw-prose-invert-td-borders:oklch(37.3% .034 259.733);font-size:1rem;line-height:1.75}.prose :where(picture>img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose :where(li):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5em;margin-bottom:.5em}.prose :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.375em}.prose :where(.prose>ul>li p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.prose :where(.prose>ul>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em}.prose :where(.prose>ul>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.25em}.prose :where(.prose>ol>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em}.prose :where(.prose>ol>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.25em}.prose :where(ul ul,ul ol,ol ul,ol ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.prose :where(dl):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em}.prose :where(dd):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5em;padding-inline-start:1.625em}.prose :where(hr+*):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(h2+*):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(h3+*):not(:where([class~=not-prose],[class~=not-prose] *)),.prose :where(h4+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(thead th:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose :where(thead th:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose :where(tbody td,tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){padding-top:.571429em;padding-inline-end:.571429em;padding-bottom:.571429em;padding-inline-start:.571429em}.prose :where(tbody td:first-child,tfoot td:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose :where(tbody td:last-child,tfoot td:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose :where(figure):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(.prose>:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(.prose>:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:0}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-1\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.mb-6{margin-bottom:calc(var(--spacing) * 6)}.ml-0\.5{margin-left:calc(var(--spacing) * .5)}.ml-1{margin-left:calc(var(--spacing) * 1)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-auto{margin-left:auto}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.table{display:table}.h-0\.5{height:calc(var(--spacing) * .5)}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-14{height:calc(var(--spacing) * 14)}.h-\[calc\(100vh-3\.5rem\)\]{height:calc(100vh - 3.5rem)}.h-full{height:100%}.h-screen{height:100vh}.min-h-0{min-height:calc(var(--spacing) * 0)}.w-0\.5{width:calc(var(--spacing) * .5)}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-56{width:calc(var(--spacing) * 56)}.w-full{width:100%}.max-w-2xl{max-width:var(--container-2xl)}.max-w-\[120px\]{max-width:120px}.max-w-lg{max-width:var(--container-lg)}.max-w-none{max-width:none}.max-w-sm{max-width:var(--container-sm)}.min-w-0{min-width:calc(var(--spacing) * 0)}.flex-1{flex:1}.flex-shrink-0{flex-shrink:0}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.cursor-pointer{cursor:pointer}.resize{resize:both}.resize-none{resize:none}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1.5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1.5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 6) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)))}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-accent{border-color:#8b4513}.border-accent-dim\/30{border-color:#6b34104d}.border-accent\/30{border-color:#8b45134d}.border-amber-600\/30{border-color:#dd74004d}@supports (color:color-mix(in lab,red,red)){.border-amber-600\/30{border-color:color-mix(in oklab,var(--color-amber-600) 30%,transparent)}}.border-border{border-color:#d4c5b0}.border-green-700\/30{border-color:#0081384d}@supports (color:color-mix(in lab,red,red)){.border-green-700\/30{border-color:color-mix(in oklab,var(--color-green-700) 30%,transparent)}}.border-red-700\/30{border-color:#bf000f4d}@supports (color:color-mix(in lab,red,red)){.border-red-700\/30{border-color:color-mix(in oklab,var(--color-red-700) 30%,transparent)}}.border-transparent{border-color:#0000}.bg-accent{background-color:#8b4513}.bg-accent\/10{background-color:#8b45131a}.bg-amber-500{background-color:var(--color-amber-500)}.bg-background{background-color:#e8dfd0}.bg-error{background-color:#c33}.bg-green-600{background-color:var(--color-green-600)}.bg-muted\/50{background-color:#8b735580}.bg-surface{background-color:#f0ebe1}.p-1\.5{padding:calc(var(--spacing) * 1.5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.p-8{padding:calc(var(--spacing) * 8)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-6{padding-inline:calc(var(--spacing) * 6)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.pt-1\.5{padding-top:calc(var(--spacing) * 1.5)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pr-16{padding-right:calc(var(--spacing) * 16)}.pl-3{padding-left:calc(var(--spacing) * 3)}.pl-4{padding-left:calc(var(--spacing) * 4)}.text-center{text-align:center}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.font-serif{font-family:var(--font-serif)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.break-all{word-break:break-all}.text-accent{color:#8b4513}.text-accent-dim{color:#6b3410}.text-amber-600{color:var(--color-amber-600)}.text-amber-700{color:var(--color-amber-700)}.text-error{color:#c33}.text-foreground{color:#2c1810}.text-green-700{color:var(--color-green-700)}.text-muted{color:#8b7355}.text-red-700{color:var(--color-red-700)}.text-white{color:var(--color-white)}.uppercase{text-transform:uppercase}.italic{font-style:italic}.overline{text-decoration-line:overline}.underline{text-decoration-line:underline}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.outline-none{--tw-outline-style:none;outline-style:none}.placeholder\:text-muted\/50::placeholder{color:#8b735580}@media(hover:hover){.hover\:border-accent:hover{border-color:#8b4513}.hover\:border-error:hover{border-color:#c33}.hover\:bg-accent-dim:hover{background-color:#6b3410}.hover\:bg-accent\/10:hover{background-color:#8b45131a}.hover\:bg-border\/50:hover{background-color:#d4c5b080}.hover\:bg-surface:hover{background-color:#f0ebe1}.hover\:text-accent:hover{color:#8b4513}.hover\:text-accent-dim:hover{color:#6b3410}.hover\:text-error:hover{color:#c33}.hover\:text-foreground:hover{color:#2c1810}.hover\:opacity-80:hover{opacity:.8}}.focus\:border-accent:focus{border-color:#8b4513}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}}:root{--bg:#e8dfd0;--bg-surface:#f0ebe1;--bg-shelf:#ddd3c2;--text:#2c1810;--text-muted:#8b7355;--accent:#8b4513;--accent-dim:#6b3410;--border:#d4c5b0;--error:#c33;--paper-bg:#f5f0e8}body{background:var(--bg);color:var(--text);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,system-ui,-apple-system,sans-serif}::selection{background:var(--accent);color:#fff}h1,h2,h3,h4{font-family:Lora,Georgia,Times New Roman,serif}.prose{--tw-prose-body:var(--text);--tw-prose-headings:var(--text);--tw-prose-links:var(--accent);--tw-prose-bold:var(--text);--tw-prose-quotes:var(--text-muted);--tw-prose-quote-borders:var(--border);--tw-prose-code:var(--text);--tw-prose-hr:var(--border)}.prose,.prose p,.prose li,.prose blockquote{font-family:Lora,Georgia,Times New Roman,serif}code,pre{font-family:Geist Mono,ui-monospace,monospace}.xterm .xterm-dim{opacity:1!important;color:#8b7355!important}.xterm,.xterm-viewport{border:none!important;outline:none!important}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false} diff --git a/app/web/dist/assets/index-DWqOuJeA.js b/app/web/dist/assets/index-DWqOuJeA.js deleted file mode 100644 index 9d5f7ec..0000000 --- a/app/web/dist/assets/index-DWqOuJeA.js +++ /dev/null @@ -1,130 +0,0 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();function gu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Fh={exports:{}},ql={};/** - * @license React - * react-jsx-runtime.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var $g;function vx(){if($g)return ql;$g=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,a,o){var c=null;if(o!==void 0&&(c=""+o),a.key!==void 0&&(c=""+a.key),"key"in a){o={};for(var f in a)f!=="key"&&(o[f]=a[f])}else o=a;return a=o.ref,{$$typeof:e,type:s,key:c,ref:a!==void 0?a:null,props:o}}return ql.Fragment=t,ql.jsx=n,ql.jsxs=n,ql}var Gg;function yx(){return Gg||(Gg=1,Fh.exports=vx()),Fh.exports}var S=yx(),qh={exports:{}},Ce={};/** - * @license React - * react.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Zg;function bx(){if(Zg)return Ce;Zg=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),b=Symbol.iterator;function y(D){return D===null||typeof D!="object"?null:(D=b&&D[b]||D["@@iterator"],typeof D=="function"?D:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,L={};function R(D,V,w){this.props=D,this.context=V,this.refs=L,this.updater=w||x}R.prototype.isReactComponent={},R.prototype.setState=function(D,V){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,V,"setState")},R.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function $(){}$.prototype=R.prototype;function I(D,V,w){this.props=D,this.context=V,this.refs=L,this.updater=w||x}var Z=I.prototype=new $;Z.constructor=I,k(Z,R.prototype),Z.isPureReactComponent=!0;var Y=Array.isArray;function O(){}var J={H:null,A:null,T:null,S:null},ce=Object.prototype.hasOwnProperty;function pe(D,V,w){var ie=w.ref;return{$$typeof:e,type:D,key:V,ref:ie!==void 0?ie:null,props:w}}function F(D,V){return pe(D.type,V,D.props)}function se(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function H(D){var V={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(w){return V[w]})}var E=/\/+/g;function B(D,V){return typeof D=="object"&&D!==null&&D.key!=null?H(""+D.key):V.toString(36)}function N(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(O,O):(D.status="pending",D.then(function(V){D.status==="pending"&&(D.status="fulfilled",D.value=V)},function(V){D.status==="pending"&&(D.status="rejected",D.reason=V)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function A(D,V,w,ie,ae){var le=typeof D;(le==="undefined"||le==="boolean")&&(D=null);var ge=!1;if(D===null)ge=!0;else switch(le){case"bigint":case"string":case"number":ge=!0;break;case"object":switch(D.$$typeof){case e:case t:ge=!0;break;case g:return ge=D._init,A(ge(D._payload),V,w,ie,ae)}}if(ge)return ae=ae(D),ge=ie===""?"."+B(D,0):ie,Y(ae)?(w="",ge!=null&&(w=ge.replace(E,"$&/")+"/"),A(ae,V,w,"",function(Ze){return Ze})):ae!=null&&(se(ae)&&(ae=F(ae,w+(ae.key==null||D&&D.key===ae.key?"":(""+ae.key).replace(E,"$&/")+"/")+ge)),V.push(ae)),1;ge=0;var Ee=ie===""?".":ie+":";if(Y(D))for(var Se=0;Se>>1,T=A[oe];if(0>>1;oea(w,P))iea(ae,w)?(A[oe]=ae,A[ie]=P,oe=ie):(A[oe]=w,A[V]=P,oe=V);else if(iea(ae,P))A[oe]=ae,A[ie]=P,oe=ie;else break e}}return j}function a(A,j){var P=A.sortIndex-j.sortIndex;return P!==0?P:A.id-j.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,f=c.now();e.unstable_now=function(){return c.now()-f}}var p=[],h=[],g=1,_=null,b=3,y=!1,x=!1,k=!1,L=!1,R=typeof setTimeout=="function"?setTimeout:null,$=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;function Z(A){for(var j=n(h);j!==null;){if(j.callback===null)s(h);else if(j.startTime<=A)s(h),j.sortIndex=j.expirationTime,t(p,j);else break;j=n(h)}}function Y(A){if(k=!1,Z(A),!x)if(n(p)!==null)x=!0,O||(O=!0,H());else{var j=n(h);j!==null&&N(Y,j.startTime-A)}}var O=!1,J=-1,ce=5,pe=-1;function F(){return L?!0:!(e.unstable_now()-peA&&F());){var oe=_.callback;if(typeof oe=="function"){_.callback=null,b=_.priorityLevel;var T=oe(_.expirationTime<=A);if(A=e.unstable_now(),typeof T=="function"){_.callback=T,Z(A),j=!0;break t}_===n(p)&&s(p),Z(A)}else s(p);_=n(p)}if(_!==null)j=!0;else{var D=n(h);D!==null&&N(Y,D.startTime-A),j=!1}}break e}finally{_=null,b=P,y=!1}j=void 0}}finally{j?H():O=!1}}}var H;if(typeof I=="function")H=function(){I(se)};else if(typeof MessageChannel<"u"){var E=new MessageChannel,B=E.port2;E.port1.onmessage=se,H=function(){B.postMessage(null)}}else H=function(){R(se,0)};function N(A,j){J=R(function(){A(e.unstable_now())},j)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(A){A.callback=null},e.unstable_forceFrameRate=function(A){0>A||125oe?(A.sortIndex=P,t(h,A),n(p)===null&&A===n(h)&&(k?($(J),J=-1):k=!0,N(Y,P-oe))):(A.sortIndex=T,t(p,A),x||y||(x=!0,O||(O=!0,H()))),A},e.unstable_shouldYield=F,e.unstable_wrapCallback=function(A){var j=b;return function(){var P=b;b=j;try{return A.apply(this,arguments)}finally{b=P}}}})(Vh)),Vh}var ev;function wx(){return ev||(ev=1,Yh.exports=xx()),Yh.exports}var Kh={exports:{}},Xt={};/** - * @license React - * react-dom.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var tv;function Cx(){if(tv)return Xt;tv=1;var e=wd();function t(p){var h="https://react.dev/errors/"+p;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Kh.exports=Cx(),Kh.exports}/** - * @license React - * react-dom-client.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var nv;function Ex(){if(nv)return Wl;nv=1;var e=wx(),t=wd(),n=kx();function s(i){var r="https://react.dev/errors/"+i;if(1T||(i.current=oe[T],oe[T]=null,T--)}function w(i,r){T++,oe[T]=i.current,i.current=r}var ie=D(null),ae=D(null),le=D(null),ge=D(null);function Ee(i,r){switch(w(le,r),w(ae,i),w(ie,null),r.nodeType){case 9:case 11:i=(i=r.documentElement)&&(i=i.namespaceURI)?vg(i):0;break;default:if(i=r.tagName,r=r.namespaceURI)r=vg(r),i=yg(r,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}V(ie),w(ie,i)}function Se(){V(ie),V(ae),V(le)}function Ze(i){i.memoizedState!==null&&w(ge,i);var r=ie.current,l=yg(r,i.type);r!==l&&(w(ae,i),w(ie,l))}function Fe(i){ae.current===i&&(V(ie),V(ae)),ge.current===i&&(V(ge),Ul._currentValue=P)}var ai,He;function yi(i){if(ai===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);ai=r&&r[1]||"",He=-1)":-1d||M[u]!==W[d]){var G=` -`+M[u].replace(" at new "," at ");return i.displayName&&G.includes("")&&(G=G.replace("",i.displayName)),G}while(1<=u&&0<=d);break}}}finally{Gr=!1,Error.prepareStackTrace=l}return(l=i?i.displayName||i.name:"")?yi(l):""}function ka(i,r){switch(i.tag){case 26:case 27:case 5:return yi(i.type);case 16:return yi("Lazy");case 13:return i.child!==r&&r!==null?yi("Suspense Fallback"):yi("Suspense");case 19:return yi("SuspenseList");case 0:case 15:return Zr(i.type,!1);case 11:return Zr(i.type.render,!1);case 1:return Zr(i.type,!0);case 31:return yi("Activity");default:return""}}function Ea(i){try{var r="",l=null;do r+=ka(i,l),l=i,i=i.return;while(i);return r}catch(u){return` -Error generating stack: `+u.message+` -`+u.stack}}var Qr=Object.prototype.hasOwnProperty,Jr=e.unstable_scheduleCallback,Zs=e.unstable_cancelCallback,Tu=e.unstable_shouldYield,Au=e.unstable_requestPaint,Jt=e.unstable_now,Du=e.unstable_getCurrentPriorityLevel,ee=e.unstable_ImmediatePriority,fe=e.unstable_UserBlockingPriority,xe=e.unstable_NormalPriority,Me=e.unstable_LowPriority,We=e.unstable_IdlePriority,bi=e.log,fn=e.unstable_setDisableYieldValue,ei=null,Ct=null;function oi(i){if(typeof bi=="function"&&fn(i),Ct&&typeof Ct.setStrictMode=="function")try{Ct.setStrictMode(ei,i)}catch{}}var Qe=Math.clz32?Math.clz32:r0,Hn=Math.log,Ki=Math.LN2;function r0(i){return i>>>=0,i===0?32:31-(Hn(i)/Ki|0)|0}var Ta=256,Aa=262144,Da=4194304;function yr(i){var r=i&42;if(r!==0)return r;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Ra(i,r,l){var u=i.pendingLanes;if(u===0)return 0;var d=0,m=i.suspendedLanes,v=i.pingedLanes;i=i.warmLanes;var C=u&134217727;return C!==0?(u=C&~m,u!==0?d=yr(u):(v&=C,v!==0?d=yr(v):l||(l=C&~i,l!==0&&(d=yr(l))))):(C=u&~m,C!==0?d=yr(C):v!==0?d=yr(v):l||(l=u&~i,l!==0&&(d=yr(l)))),d===0?0:r!==0&&r!==d&&(r&m)===0&&(m=d&-d,l=r&-r,m>=l||m===32&&(l&4194048)!==0)?r:d}function Qs(i,r){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&r)===0}function s0(i,r){switch(i){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Jd(){var i=Da;return Da<<=1,(Da&62914560)===0&&(Da=4194304),i}function Ru(i){for(var r=[],l=0;31>l;l++)r.push(i);return r}function Js(i,r){i.pendingLanes|=r,r!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function l0(i,r,l,u,d,m){var v=i.pendingLanes;i.pendingLanes=l,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=l,i.entangledLanes&=l,i.errorRecoveryDisabledLanes&=l,i.shellSuspendCounter=0;var C=i.entanglements,M=i.expirationTimes,W=i.hiddenUpdates;for(l=v&~l;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var f0=/[\n"\\]/g;function Ni(i){return i.replace(f0,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Ou(i,r,l,u,d,m,v,C){i.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?i.type=v:i.removeAttribute("type"),r!=null?v==="number"?(r===0&&i.value===""||i.value!=r)&&(i.value=""+Bi(r)):i.value!==""+Bi(r)&&(i.value=""+Bi(r)):v!=="submit"&&v!=="reset"||i.removeAttribute("value"),r!=null?ju(i,v,Bi(r)):l!=null?ju(i,v,Bi(l)):u!=null&&i.removeAttribute("value"),d==null&&m!=null&&(i.defaultChecked=!!m),d!=null&&(i.checked=d&&typeof d!="function"&&typeof d!="symbol"),C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?i.name=""+Bi(C):i.removeAttribute("name")}function fp(i,r,l,u,d,m,v,C){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(i.type=m),r!=null||l!=null){if(!(m!=="submit"&&m!=="reset"||r!=null)){zu(i);return}l=l!=null?""+Bi(l):"",r=r!=null?""+Bi(r):l,C||r===i.value||(i.value=r),i.defaultValue=r}u=u??d,u=typeof u!="function"&&typeof u!="symbol"&&!!u,i.checked=C?i.checked:!!u,i.defaultChecked=!!u,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(i.name=v),zu(i)}function ju(i,r,l){r==="number"&&Na(i.ownerDocument)===i||i.defaultValue===""+l||(i.defaultValue=""+l)}function ss(i,r,l,u){if(i=i.options,r){r={};for(var d=0;d"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Fu=!1;if(mn)try{var nl={};Object.defineProperty(nl,"passive",{get:function(){Fu=!0}}),window.addEventListener("test",nl,nl),window.removeEventListener("test",nl,nl)}catch{Fu=!1}var Pn=null,qu=null,za=null;function yp(){if(za)return za;var i,r=qu,l=r.length,u,d="value"in Pn?Pn.value:Pn.textContent,m=d.length;for(i=0;i=ll),kp=" ",Ep=!1;function Tp(i,r){switch(i){case"keyup":return P0.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ap(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var us=!1;function F0(i,r){switch(i){case"compositionend":return Ap(r);case"keypress":return r.which!==32?null:(Ep=!0,kp);case"textInput":return i=r.data,i===kp&&Ep?null:i;default:return null}}function q0(i,r){if(us)return i==="compositionend"||!Xu&&Tp(i,r)?(i=yp(),za=qu=Pn=null,us=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1=r)return{node:l,offset:r-i};i=u}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Op(l)}}function Hp(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?Hp(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function Up(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var r=Na(i.document);r instanceof i.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)i=r.contentWindow;else break;r=Na(i.document)}return r}function Zu(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}var Z0=mn&&"documentMode"in document&&11>=document.documentMode,cs=null,Qu=null,cl=null,Ju=!1;function Pp(i,r,l){var u=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Ju||cs==null||cs!==Na(u)||(u=cs,"selectionStart"in u&&Zu(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),cl&&ul(cl,u)||(cl=u,u=Do(Qu,"onSelect"),0>=v,d-=v,Ji=1<<32-Qe(r)+d|l<Te?(Oe=_e,_e=null):Oe=_e.sibling;var Ie=K(U,_e,q[Te],te);if(Ie===null){_e===null&&(_e=Oe);break}i&&_e&&Ie.alternate===null&&r(U,_e),z=m(Ie,z,Te),Pe===null?ve=Ie:Pe.sibling=Ie,Pe=Ie,_e=Oe}if(Te===q.length)return l(U,_e),je&&gn(U,Te),ve;if(_e===null){for(;TeTe?(Oe=_e,_e=null):Oe=_e.sibling;var or=K(U,_e,Ie.value,te);if(or===null){_e===null&&(_e=Oe);break}i&&_e&&or.alternate===null&&r(U,_e),z=m(or,z,Te),Pe===null?ve=or:Pe.sibling=or,Pe=or,_e=Oe}if(Ie.done)return l(U,_e),je&&gn(U,Te),ve;if(_e===null){for(;!Ie.done;Te++,Ie=q.next())Ie=ne(U,Ie.value,te),Ie!==null&&(z=m(Ie,z,Te),Pe===null?ve=Ie:Pe.sibling=Ie,Pe=Ie);return je&&gn(U,Te),ve}for(_e=u(_e);!Ie.done;Te++,Ie=q.next())Ie=X(_e,U,Te,Ie.value,te),Ie!==null&&(i&&Ie.alternate!==null&&_e.delete(Ie.key===null?Te:Ie.key),z=m(Ie,z,Te),Pe===null?ve=Ie:Pe.sibling=Ie,Pe=Ie);return i&&_e.forEach(function(gx){return r(U,gx)}),je&&gn(U,Te),ve}function $e(U,z,q,te){if(typeof q=="object"&&q!==null&&q.type===k&&q.key===null&&(q=q.props.children),typeof q=="object"&&q!==null){switch(q.$$typeof){case y:e:{for(var ve=q.key;z!==null;){if(z.key===ve){if(ve=q.type,ve===k){if(z.tag===7){l(U,z.sibling),te=d(z,q.props.children),te.return=U,U=te;break e}}else if(z.elementType===ve||typeof ve=="object"&&ve!==null&&ve.$$typeof===ce&&Rr(ve)===z.type){l(U,z.sibling),te=d(z,q.props),_l(te,q),te.return=U,U=te;break e}l(U,z);break}else r(U,z);z=z.sibling}q.type===k?(te=kr(q.props.children,U.mode,te,q.key),te.return=U,U=te):(te=Ya(q.type,q.key,q.props,null,U.mode,te),_l(te,q),te.return=U,U=te)}return v(U);case x:e:{for(ve=q.key;z!==null;){if(z.key===ve)if(z.tag===4&&z.stateNode.containerInfo===q.containerInfo&&z.stateNode.implementation===q.implementation){l(U,z.sibling),te=d(z,q.children||[]),te.return=U,U=te;break e}else{l(U,z);break}else r(U,z);z=z.sibling}te=lc(q,U.mode,te),te.return=U,U=te}return v(U);case ce:return q=Rr(q),$e(U,z,q,te)}if(N(q))return me(U,z,q,te);if(H(q)){if(ve=H(q),typeof ve!="function")throw Error(s(150));return q=ve.call(q),be(U,z,q,te)}if(typeof q.then=="function")return $e(U,z,Qa(q),te);if(q.$$typeof===I)return $e(U,z,Xa(U,q),te);Ja(U,q)}return typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint"?(q=""+q,z!==null&&z.tag===6?(l(U,z.sibling),te=d(z,q),te.return=U,U=te):(l(U,z),te=sc(q,U.mode,te),te.return=U,U=te),v(U)):l(U,z)}return function(U,z,q,te){try{ml=0;var ve=$e(U,z,q,te);return Ss=null,ve}catch(_e){if(_e===bs||_e===Ga)throw _e;var Pe=xi(29,_e,null,U.mode);return Pe.lanes=te,Pe.return=U,Pe}finally{}}}var Br=um(!0),cm=um(!1),Yn=!1;function vc(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function yc(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function Vn(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function Kn(i,r,l){var u=i.updateQueue;if(u===null)return null;if(u=u.shared,(qe&2)!==0){var d=u.pending;return d===null?r.next=r:(r.next=d.next,d.next=r),u.pending=r,r=Wa(i),Kp(i,null,l),r}return qa(i,u,r,l),Wa(i)}function gl(i,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194048)!==0)){var u=r.lanes;u&=i.pendingLanes,l|=u,r.lanes=l,tp(i,l)}}function bc(i,r){var l=i.updateQueue,u=i.alternate;if(u!==null&&(u=u.updateQueue,l===u)){var d=null,m=null;if(l=l.firstBaseUpdate,l!==null){do{var v={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};m===null?d=m=v:m=m.next=v,l=l.next}while(l!==null);m===null?d=m=r:m=m.next=r}else d=m=r;l={baseState:u.baseState,firstBaseUpdate:d,lastBaseUpdate:m,shared:u.shared,callbacks:u.callbacks},i.updateQueue=l;return}i=l.lastBaseUpdate,i===null?l.firstBaseUpdate=r:i.next=r,l.lastBaseUpdate=r}var Sc=!1;function vl(){if(Sc){var i=ys;if(i!==null)throw i}}function yl(i,r,l,u){Sc=!1;var d=i.updateQueue;Yn=!1;var m=d.firstBaseUpdate,v=d.lastBaseUpdate,C=d.shared.pending;if(C!==null){d.shared.pending=null;var M=C,W=M.next;M.next=null,v===null?m=W:v.next=W,v=M;var G=i.alternate;G!==null&&(G=G.updateQueue,C=G.lastBaseUpdate,C!==v&&(C===null?G.firstBaseUpdate=W:C.next=W,G.lastBaseUpdate=M))}if(m!==null){var ne=d.baseState;v=0,G=W=M=null,C=m;do{var K=C.lane&-536870913,X=K!==C.lane;if(X?(ze&K)===K:(u&K)===K){K!==0&&K===vs&&(Sc=!0),G!==null&&(G=G.next={lane:0,tag:C.tag,payload:C.payload,callback:null,next:null});e:{var me=i,be=C;K=r;var $e=l;switch(be.tag){case 1:if(me=be.payload,typeof me=="function"){ne=me.call($e,ne,K);break e}ne=me;break e;case 3:me.flags=me.flags&-65537|128;case 0:if(me=be.payload,K=typeof me=="function"?me.call($e,ne,K):me,K==null)break e;ne=_({},ne,K);break e;case 2:Yn=!0}}K=C.callback,K!==null&&(i.flags|=64,X&&(i.flags|=8192),X=d.callbacks,X===null?d.callbacks=[K]:X.push(K))}else X={lane:K,tag:C.tag,payload:C.payload,callback:C.callback,next:null},G===null?(W=G=X,M=ne):G=G.next=X,v|=K;if(C=C.next,C===null){if(C=d.shared.pending,C===null)break;X=C,C=X.next,X.next=null,d.lastBaseUpdate=X,d.shared.pending=null}}while(!0);G===null&&(M=ne),d.baseState=M,d.firstBaseUpdate=W,d.lastBaseUpdate=G,m===null&&(d.shared.lanes=0),Qn|=v,i.lanes=v,i.memoizedState=ne}}function hm(i,r){if(typeof i!="function")throw Error(s(191,i));i.call(r)}function fm(i,r){var l=i.callbacks;if(l!==null)for(i.callbacks=null,i=0;im?m:8;var v=A.T,C={};A.T=C,Pc(i,!1,r,l);try{var M=d(),W=A.S;if(W!==null&&W(C,M),M!==null&&typeof M=="object"&&typeof M.then=="function"){var G=l1(M,u);xl(i,r,G,Ti(i))}else xl(i,r,u,Ti(i))}catch(ne){xl(i,r,{then:function(){},status:"rejected",reason:ne},Ti())}finally{j.p=m,v!==null&&C.types!==null&&(v.types=C.types),A.T=v}}function f1(){}function Hc(i,r,l,u){if(i.tag!==5)throw Error(s(476));var d=Wm(i).queue;qm(i,d,r,P,l===null?f1:function(){return Ym(i),l(u)})}function Wm(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:P,baseState:P,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sn,lastRenderedState:P},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sn,lastRenderedState:l},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function Ym(i){var r=Wm(i);r.next===null&&(r=i.alternate.memoizedState),xl(i,r.next.queue,{},Ti())}function Uc(){return Ft(Ul)}function Vm(){return mt().memoizedState}function Km(){return mt().memoizedState}function d1(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var l=Ti();i=Vn(l);var u=Kn(r,i,l);u!==null&&(mi(u,r,l),gl(u,r,l)),r={cache:pc()},i.payload=r;return}r=r.return}}function p1(i,r,l){var u=Ti();l={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},uo(i)?$m(r,l):(l=nc(i,r,l,u),l!==null&&(mi(l,i,u),Gm(l,r,u)))}function Xm(i,r,l){var u=Ti();xl(i,r,l,u)}function xl(i,r,l,u){var d={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(uo(i))$m(r,d);else{var m=i.alternate;if(i.lanes===0&&(m===null||m.lanes===0)&&(m=r.lastRenderedReducer,m!==null))try{var v=r.lastRenderedState,C=m(v,l);if(d.hasEagerState=!0,d.eagerState=C,Si(C,v))return qa(i,r,d,0),Je===null&&Fa(),!1}catch{}finally{}if(l=nc(i,r,d,u),l!==null)return mi(l,i,u),Gm(l,r,u),!0}return!1}function Pc(i,r,l,u){if(u={lane:2,revertLane:vh(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},uo(i)){if(r)throw Error(s(479))}else r=nc(i,l,u,2),r!==null&&mi(r,i,2)}function uo(i){var r=i.alternate;return i===ke||r!==null&&r===ke}function $m(i,r){ws=io=!0;var l=i.pending;l===null?r.next=r:(r.next=l.next,l.next=r),i.pending=r}function Gm(i,r,l){if((l&4194048)!==0){var u=r.lanes;u&=i.pendingLanes,l|=u,r.lanes=l,tp(i,l)}}var wl={readContext:Ft,use:so,useCallback:ut,useContext:ut,useEffect:ut,useImperativeHandle:ut,useLayoutEffect:ut,useInsertionEffect:ut,useMemo:ut,useReducer:ut,useRef:ut,useState:ut,useDebugValue:ut,useDeferredValue:ut,useTransition:ut,useSyncExternalStore:ut,useId:ut,useHostTransitionStatus:ut,useFormState:ut,useActionState:ut,useOptimistic:ut,useMemoCache:ut,useCacheRefresh:ut};wl.useEffectEvent=ut;var Zm={readContext:Ft,use:so,useCallback:function(i,r){return ti().memoizedState=[i,r===void 0?null:r],i},useContext:Ft,useEffect:Lm,useImperativeHandle:function(i,r,l){l=l!=null?l.concat([i]):null,ao(4194308,4,Hm.bind(null,r,i),l)},useLayoutEffect:function(i,r){return ao(4194308,4,i,r)},useInsertionEffect:function(i,r){ao(4,2,i,r)},useMemo:function(i,r){var l=ti();r=r===void 0?null:r;var u=i();if(Nr){oi(!0);try{i()}finally{oi(!1)}}return l.memoizedState=[u,r],u},useReducer:function(i,r,l){var u=ti();if(l!==void 0){var d=l(r);if(Nr){oi(!0);try{l(r)}finally{oi(!1)}}}else d=r;return u.memoizedState=u.baseState=d,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:d},u.queue=i,i=i.dispatch=p1.bind(null,ke,i),[u.memoizedState,i]},useRef:function(i){var r=ti();return i={current:i},r.memoizedState=i},useState:function(i){i=Nc(i);var r=i.queue,l=Xm.bind(null,ke,r);return r.dispatch=l,[i.memoizedState,l]},useDebugValue:Oc,useDeferredValue:function(i,r){var l=ti();return jc(l,i,r)},useTransition:function(){var i=Nc(!1);return i=qm.bind(null,ke,i.queue,!0,!1),ti().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,l){var u=ke,d=ti();if(je){if(l===void 0)throw Error(s(407));l=l()}else{if(l=r(),Je===null)throw Error(s(349));(ze&127)!==0||vm(u,r,l)}d.memoizedState=l;var m={value:l,getSnapshot:r};return d.queue=m,Lm(bm.bind(null,u,m,i),[i]),u.flags|=2048,ks(9,{destroy:void 0},ym.bind(null,u,m,l,r),null),l},useId:function(){var i=ti(),r=Je.identifierPrefix;if(je){var l=en,u=Ji;l=(u&~(1<<32-Qe(u)-1)).toString(32)+l,r="_"+r+"R_"+l,l=no++,0<\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof u.is=="string"?v.createElement("select",{is:u.is}):v.createElement("select"),u.multiple?m.multiple=!0:u.size&&(m.size=u.size);break;default:m=typeof u.is=="string"?v.createElement(d,{is:u.is}):v.createElement(d)}}m[Pt]=r,m[ui]=u;e:for(v=r.child;v!==null;){if(v.tag===5||v.tag===6)m.appendChild(v.stateNode);else if(v.tag!==4&&v.tag!==27&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===r)break e;for(;v.sibling===null;){if(v.return===null||v.return===r)break e;v=v.return}v.sibling.return=v.return,v=v.sibling}r.stateNode=m;e:switch(Wt(m,d,u),d){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&wn(r)}}return nt(r),eh(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,l),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==u&&wn(r);else{if(typeof u!="string"&&r.stateNode===null)throw Error(s(166));if(i=le.current,_s(r)){if(i=r.stateNode,l=r.memoizedProps,u=null,d=It,d!==null)switch(d.tag){case 27:case 5:u=d.memoizedProps}i[Pt]=r,i=!!(i.nodeValue===l||u!==null&&u.suppressHydrationWarning===!0||_g(i.nodeValue,l)),i||qn(r,!0)}else i=Ro(i).createTextNode(u),i[Pt]=r,r.stateNode=i}return nt(r),null;case 31:if(l=r.memoizedState,i===null||i.memoizedState!==null){if(u=_s(r),l!==null){if(i===null){if(!u)throw Error(s(318));if(i=r.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[Pt]=r}else Er(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;nt(r),i=!1}else l=cc(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=l),i=!0;if(!i)return r.flags&256?(Ci(r),r):(Ci(r),null);if((r.flags&128)!==0)throw Error(s(558))}return nt(r),null;case 13:if(u=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(d=_s(r),u!==null&&u.dehydrated!==null){if(i===null){if(!d)throw Error(s(318));if(d=r.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(s(317));d[Pt]=r}else Er(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;nt(r),d=!1}else d=cc(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=d),d=!0;if(!d)return r.flags&256?(Ci(r),r):(Ci(r),null)}return Ci(r),(r.flags&128)!==0?(r.lanes=l,r):(l=u!==null,i=i!==null&&i.memoizedState!==null,l&&(u=r.child,d=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(d=u.alternate.memoizedState.cachePool.pool),m=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(m=u.memoizedState.cachePool.pool),m!==d&&(u.flags|=2048)),l!==i&&l&&(r.child.flags|=8192),mo(r,r.updateQueue),nt(r),null);case 4:return Se(),i===null&&xh(r.stateNode.containerInfo),nt(r),null;case 10:return yn(r.type),nt(r),null;case 19:if(V(pt),u=r.memoizedState,u===null)return nt(r),null;if(d=(r.flags&128)!==0,m=u.rendering,m===null)if(d)kl(u,!1);else{if(ct!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(m=to(i),m!==null){for(r.flags|=128,kl(u,!1),i=m.updateQueue,r.updateQueue=i,mo(r,i),r.subtreeFlags=0,i=l,l=r.child;l!==null;)Xp(l,i),l=l.sibling;return w(pt,pt.current&1|2),je&&gn(r,u.treeForkCount),r.child}i=i.sibling}u.tail!==null&&Jt()>bo&&(r.flags|=128,d=!0,kl(u,!1),r.lanes=4194304)}else{if(!d)if(i=to(m),i!==null){if(r.flags|=128,d=!0,i=i.updateQueue,r.updateQueue=i,mo(r,i),kl(u,!0),u.tail===null&&u.tailMode==="hidden"&&!m.alternate&&!je)return nt(r),null}else 2*Jt()-u.renderingStartTime>bo&&l!==536870912&&(r.flags|=128,d=!0,kl(u,!1),r.lanes=4194304);u.isBackwards?(m.sibling=r.child,r.child=m):(i=u.last,i!==null?i.sibling=m:r.child=m,u.last=m)}return u.tail!==null?(i=u.tail,u.rendering=i,u.tail=i.sibling,u.renderingStartTime=Jt(),i.sibling=null,l=pt.current,w(pt,d?l&1|2:l&1),je&&gn(r,u.treeForkCount),i):(nt(r),null);case 22:case 23:return Ci(r),wc(),u=r.memoizedState!==null,i!==null?i.memoizedState!==null!==u&&(r.flags|=8192):u&&(r.flags|=8192),u?(l&536870912)!==0&&(r.flags&128)===0&&(nt(r),r.subtreeFlags&6&&(r.flags|=8192)):nt(r),l=r.updateQueue,l!==null&&mo(r,l.retryQueue),l=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(l=i.memoizedState.cachePool.pool),u=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),u!==l&&(r.flags|=2048),i!==null&&V(Dr),null;case 24:return l=null,i!==null&&(l=i.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),yn(gt),nt(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function y1(i,r){switch(oc(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return yn(gt),Se(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return Fe(r),null;case 31:if(r.memoizedState!==null){if(Ci(r),r.alternate===null)throw Error(s(340));Er()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(Ci(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(s(340));Er()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return V(pt),null;case 4:return Se(),null;case 10:return yn(r.type),null;case 22:case 23:return Ci(r),wc(),i!==null&&V(Dr),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return yn(gt),null;case 25:return null;default:return null}}function S_(i,r){switch(oc(r),r.tag){case 3:yn(gt),Se();break;case 26:case 27:case 5:Fe(r);break;case 4:Se();break;case 31:r.memoizedState!==null&&Ci(r);break;case 13:Ci(r);break;case 19:V(pt);break;case 10:yn(r.type);break;case 22:case 23:Ci(r),wc(),i!==null&&V(Dr);break;case 24:yn(gt)}}function El(i,r){try{var l=r.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var d=u.next;l=d;do{if((l.tag&i)===i){u=void 0;var m=l.create,v=l.inst;u=m(),v.destroy=u}l=l.next}while(l!==d)}}catch(C){Ve(r,r.return,C)}}function Gn(i,r,l){try{var u=r.updateQueue,d=u!==null?u.lastEffect:null;if(d!==null){var m=d.next;u=m;do{if((u.tag&i)===i){var v=u.inst,C=v.destroy;if(C!==void 0){v.destroy=void 0,d=r;var M=l,W=C;try{W()}catch(G){Ve(d,M,G)}}}u=u.next}while(u!==m)}}catch(G){Ve(r,r.return,G)}}function x_(i){var r=i.updateQueue;if(r!==null){var l=i.stateNode;try{fm(r,l)}catch(u){Ve(i,i.return,u)}}}function w_(i,r,l){l.props=Lr(i.type,i.memoizedProps),l.state=i.memoizedState;try{l.componentWillUnmount()}catch(u){Ve(i,r,u)}}function Tl(i,r){try{var l=i.ref;if(l!==null){switch(i.tag){case 26:case 27:case 5:var u=i.stateNode;break;case 30:u=i.stateNode;break;default:u=i.stateNode}typeof l=="function"?i.refCleanup=l(u):l.current=u}}catch(d){Ve(i,r,d)}}function tn(i,r){var l=i.ref,u=i.refCleanup;if(l!==null)if(typeof u=="function")try{u()}catch(d){Ve(i,r,d)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(d){Ve(i,r,d)}else l.current=null}function C_(i){var r=i.type,l=i.memoizedProps,u=i.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":l.autoFocus&&u.focus();break e;case"img":l.src?u.src=l.src:l.srcSet&&(u.srcset=l.srcSet)}}catch(d){Ve(i,i.return,d)}}function th(i,r,l){try{var u=i.stateNode;I1(u,i.type,l,r),u[ui]=r}catch(d){Ve(i,i.return,d)}}function k_(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&nr(i.type)||i.tag===4}function ih(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||k_(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&nr(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function nh(i,r,l){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(i,r):(r=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,r.appendChild(i),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=pn));else if(u!==4&&(u===27&&nr(i.type)&&(l=i.stateNode,r=null),i=i.child,i!==null))for(nh(i,r,l),i=i.sibling;i!==null;)nh(i,r,l),i=i.sibling}function _o(i,r,l){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?l.insertBefore(i,r):l.appendChild(i);else if(u!==4&&(u===27&&nr(i.type)&&(l=i.stateNode),i=i.child,i!==null))for(_o(i,r,l),i=i.sibling;i!==null;)_o(i,r,l),i=i.sibling}function E_(i){var r=i.stateNode,l=i.memoizedProps;try{for(var u=i.type,d=r.attributes;d.length;)r.removeAttributeNode(d[0]);Wt(r,u,l),r[Pt]=i,r[ui]=l}catch(m){Ve(i,i.return,m)}}var Cn=!1,bt=!1,rh=!1,T_=typeof WeakSet=="function"?WeakSet:Set,Mt=null;function b1(i,r){if(i=i.containerInfo,kh=jo,i=Up(i),Zu(i)){if("selectionStart"in i)var l={start:i.selectionStart,end:i.selectionEnd};else e:{l=(l=i.ownerDocument)&&l.defaultView||window;var u=l.getSelection&&l.getSelection();if(u&&u.rangeCount!==0){l=u.anchorNode;var d=u.anchorOffset,m=u.focusNode;u=u.focusOffset;try{l.nodeType,m.nodeType}catch{l=null;break e}var v=0,C=-1,M=-1,W=0,G=0,ne=i,K=null;t:for(;;){for(var X;ne!==l||d!==0&&ne.nodeType!==3||(C=v+d),ne!==m||u!==0&&ne.nodeType!==3||(M=v+u),ne.nodeType===3&&(v+=ne.nodeValue.length),(X=ne.firstChild)!==null;)K=ne,ne=X;for(;;){if(ne===i)break t;if(K===l&&++W===d&&(C=v),K===m&&++G===u&&(M=v),(X=ne.nextSibling)!==null)break;ne=K,K=ne.parentNode}ne=X}l=C===-1||M===-1?null:{start:C,end:M}}else l=null}l=l||{start:0,end:0}}else l=null;for(Eh={focusedElem:i,selectionRange:l},jo=!1,Mt=r;Mt!==null;)if(r=Mt,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,Mt=i;else for(;Mt!==null;){switch(r=Mt,m=r.alternate,i=r.flags,r.tag){case 0:if((i&4)!==0&&(i=r.updateQueue,i=i!==null?i.events:null,i!==null))for(l=0;l title"))),Wt(m,u,l),m[Pt]=i,Rt(m),u=m;break e;case"link":var v=Ng("link","href",d).get(u+(l.href||""));if(v){for(var C=0;C$e&&(v=$e,$e=be,be=v);var U=jp(C,be),z=jp(C,$e);if(U&&z&&(X.rangeCount!==1||X.anchorNode!==U.node||X.anchorOffset!==U.offset||X.focusNode!==z.node||X.focusOffset!==z.offset)){var q=ne.createRange();q.setStart(U.node,U.offset),X.removeAllRanges(),be>$e?(X.addRange(q),X.extend(z.node,z.offset)):(q.setEnd(z.node,z.offset),X.addRange(q))}}}}for(ne=[],X=C;X=X.parentNode;)X.nodeType===1&&ne.push({element:X,left:X.scrollLeft,top:X.scrollTop});for(typeof C.focus=="function"&&C.focus(),C=0;Cl?32:l,A.T=null,l=hh,hh=null;var m=er,v=Dn;if(kt=0,Rs=er=null,Dn=0,(qe&6)!==0)throw Error(s(331));var C=qe;if(qe|=4,H_(m.current),z_(m,m.current,v,l),qe=C,Nl(0,!1),Ct&&typeof Ct.onPostCommitFiberRoot=="function")try{Ct.onPostCommitFiberRoot(ei,m)}catch{}return!0}finally{j.p=d,A.T=u,ig(i,r)}}function rg(i,r,l){r=zi(l,r),r=Wc(i.stateNode,r,2),i=Kn(i,r,2),i!==null&&(Js(i,2),nn(i))}function Ve(i,r,l){if(i.tag===3)rg(i,i,l);else for(;r!==null;){if(r.tag===3){rg(r,i,l);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Jn===null||!Jn.has(u))){i=zi(l,i),l=s_(2),u=Kn(r,l,2),u!==null&&(l_(l,u,r,i),Js(u,2),nn(u));break}}r=r.return}}function mh(i,r,l){var u=i.pingCache;if(u===null){u=i.pingCache=new w1;var d=new Set;u.set(r,d)}else d=u.get(r),d===void 0&&(d=new Set,u.set(r,d));d.has(l)||(ah=!0,d.add(l),i=A1.bind(null,i,r,l),r.then(i,i))}function A1(i,r,l){var u=i.pingCache;u!==null&&u.delete(r),i.pingedLanes|=i.suspendedLanes&l,i.warmLanes&=~l,Je===i&&(ze&l)===l&&(ct===4||ct===3&&(ze&62914560)===ze&&300>Jt()-yo?(qe&2)===0&&Ms(i,0):oh|=l,Ds===ze&&(Ds=0)),nn(i)}function sg(i,r){r===0&&(r=Jd()),i=Cr(i,r),i!==null&&(Js(i,r),nn(i))}function D1(i){var r=i.memoizedState,l=0;r!==null&&(l=r.retryLane),sg(i,l)}function R1(i,r){var l=0;switch(i.tag){case 31:case 13:var u=i.stateNode,d=i.memoizedState;d!==null&&(l=d.retryLane);break;case 19:u=i.stateNode;break;case 22:u=i.stateNode._retryCache;break;default:throw Error(s(314))}u!==null&&u.delete(r),sg(i,l)}function M1(i,r){return Jr(i,r)}var Eo=null,Ns=null,_h=!1,To=!1,gh=!1,ir=0;function nn(i){i!==Ns&&i.next===null&&(Ns===null?Eo=Ns=i:Ns=Ns.next=i),To=!0,_h||(_h=!0,N1())}function Nl(i,r){if(!gh&&To){gh=!0;do for(var l=!1,u=Eo;u!==null;){if(i!==0){var d=u.pendingLanes;if(d===0)var m=0;else{var v=u.suspendedLanes,C=u.pingedLanes;m=(1<<31-Qe(42|i)+1)-1,m&=d&~(v&~C),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(l=!0,ug(u,m))}else m=ze,m=Ra(u,u===Je?m:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(m&3)===0||Qs(u,m)||(l=!0,ug(u,m));u=u.next}while(l);gh=!1}}function B1(){lg()}function lg(){To=_h=!1;var i=0;ir!==0&&q1()&&(i=ir);for(var r=Jt(),l=null,u=Eo;u!==null;){var d=u.next,m=ag(u,r);m===0?(u.next=null,l===null?Eo=d:l.next=d,d===null&&(Ns=l)):(l=u,(i!==0||(m&3)!==0)&&(To=!0)),u=d}kt!==0&&kt!==5||Nl(i),ir!==0&&(ir=0)}function ag(i,r){for(var l=i.suspendedLanes,u=i.pingedLanes,d=i.expirationTimes,m=i.pendingLanes&-62914561;0C)break;var G=M.transferSize,ne=M.initiatorType;G&&gg(ne)&&(M=M.responseEnd,v+=G*(M"u"?null:document;function Dg(i,r,l){var u=Ls;if(u&&typeof r=="string"&&r){var d=Ni(r);d='link[rel="'+i+'"][href="'+d+'"]',typeof l=="string"&&(d+='[crossorigin="'+l+'"]'),Ag.has(d)||(Ag.add(d),i={rel:i,crossOrigin:l,href:r},u.querySelector(d)===null&&(r=u.createElement("link"),Wt(r,"link",i),Rt(r),u.head.appendChild(r)))}}function Q1(i){Rn.D(i),Dg("dns-prefetch",i,null)}function J1(i,r){Rn.C(i,r),Dg("preconnect",i,r)}function ex(i,r,l){Rn.L(i,r,l);var u=Ls;if(u&&i&&r){var d='link[rel="preload"][as="'+Ni(r)+'"]';r==="image"&&l&&l.imageSrcSet?(d+='[imagesrcset="'+Ni(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(d+='[imagesizes="'+Ni(l.imageSizes)+'"]')):d+='[href="'+Ni(i)+'"]';var m=d;switch(r){case"style":m=zs(i);break;case"script":m=Os(i)}Ii.has(m)||(i=_({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:i,as:r},l),Ii.set(m,i),u.querySelector(d)!==null||r==="style"&&u.querySelector(jl(m))||r==="script"&&u.querySelector(Hl(m))||(r=u.createElement("link"),Wt(r,"link",i),Rt(r),u.head.appendChild(r)))}}function tx(i,r){Rn.m(i,r);var l=Ls;if(l&&i){var u=r&&typeof r.as=="string"?r.as:"script",d='link[rel="modulepreload"][as="'+Ni(u)+'"][href="'+Ni(i)+'"]',m=d;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=Os(i)}if(!Ii.has(m)&&(i=_({rel:"modulepreload",href:i},r),Ii.set(m,i),l.querySelector(d)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Hl(m)))return}u=l.createElement("link"),Wt(u,"link",i),Rt(u),l.head.appendChild(u)}}}function ix(i,r,l){Rn.S(i,r,l);var u=Ls;if(u&&i){var d=ns(u).hoistableStyles,m=zs(i);r=r||"default";var v=d.get(m);if(!v){var C={loading:0,preload:null};if(v=u.querySelector(jl(m)))C.loading=5;else{i=_({rel:"stylesheet",href:i,"data-precedence":r},l),(l=Ii.get(m))&&Nh(i,l);var M=v=u.createElement("link");Rt(M),Wt(M,"link",i),M._p=new Promise(function(W,G){M.onload=W,M.onerror=G}),M.addEventListener("load",function(){C.loading|=1}),M.addEventListener("error",function(){C.loading|=2}),C.loading|=4,Bo(v,r,u)}v={type:"stylesheet",instance:v,count:1,state:C},d.set(m,v)}}}function nx(i,r){Rn.X(i,r);var l=Ls;if(l&&i){var u=ns(l).hoistableScripts,d=Os(i),m=u.get(d);m||(m=l.querySelector(Hl(d)),m||(i=_({src:i,async:!0},r),(r=Ii.get(d))&&Lh(i,r),m=l.createElement("script"),Rt(m),Wt(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(d,m))}}function rx(i,r){Rn.M(i,r);var l=Ls;if(l&&i){var u=ns(l).hoistableScripts,d=Os(i),m=u.get(d);m||(m=l.querySelector(Hl(d)),m||(i=_({src:i,async:!0,type:"module"},r),(r=Ii.get(d))&&Lh(i,r),m=l.createElement("script"),Rt(m),Wt(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(d,m))}}function Rg(i,r,l,u){var d=(d=le.current)?Mo(d):null;if(!d)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(r=zs(l.href),l=ns(d).hoistableStyles,u=l.get(r),u||(u={type:"style",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){i=zs(l.href);var m=ns(d).hoistableStyles,v=m.get(i);if(v||(d=d.ownerDocument||d,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(i,v),(m=d.querySelector(jl(i)))&&!m._p&&(v.instance=m,v.state.loading=5),Ii.has(i)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Ii.set(i,l),m||sx(d,i,l,v.state))),r&&u===null)throw Error(s(528,""));return v}if(r&&u!==null)throw Error(s(529,""));return null;case"script":return r=l.async,l=l.src,typeof l=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Os(l),l=ns(d).hoistableScripts,u=l.get(r),u||(u={type:"script",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,i))}}function zs(i){return'href="'+Ni(i)+'"'}function jl(i){return'link[rel="stylesheet"]['+i+"]"}function Mg(i){return _({},i,{"data-precedence":i.precedence,precedence:null})}function sx(i,r,l,u){i.querySelector('link[rel="preload"][as="style"]['+r+"]")?u.loading=1:(r=i.createElement("link"),u.preload=r,r.addEventListener("load",function(){return u.loading|=1}),r.addEventListener("error",function(){return u.loading|=2}),Wt(r,"link",l),Rt(r),i.head.appendChild(r))}function Os(i){return'[src="'+Ni(i)+'"]'}function Hl(i){return"script[async]"+i}function Bg(i,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var u=i.querySelector('style[data-href~="'+Ni(l.href)+'"]');if(u)return r.instance=u,Rt(u),u;var d=_({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return u=(i.ownerDocument||i).createElement("style"),Rt(u),Wt(u,"style",d),Bo(u,l.precedence,i),r.instance=u;case"stylesheet":d=zs(l.href);var m=i.querySelector(jl(d));if(m)return r.state.loading|=4,r.instance=m,Rt(m),m;u=Mg(l),(d=Ii.get(d))&&Nh(u,d),m=(i.ownerDocument||i).createElement("link"),Rt(m);var v=m;return v._p=new Promise(function(C,M){v.onload=C,v.onerror=M}),Wt(m,"link",u),r.state.loading|=4,Bo(m,l.precedence,i),r.instance=m;case"script":return m=Os(l.src),(d=i.querySelector(Hl(m)))?(r.instance=d,Rt(d),d):(u=l,(d=Ii.get(m))&&(u=_({},l),Lh(u,d)),i=i.ownerDocument||i,d=i.createElement("script"),Rt(d),Wt(d,"link",u),i.head.appendChild(d),r.instance=d);case"void":return null;default:throw Error(s(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(u=r.instance,r.state.loading|=4,Bo(u,l.precedence,i));return r.instance}function Bo(i,r,l){for(var u=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=u.length?u[u.length-1]:null,m=d,v=0;v title"):null)}function lx(i,r,l){if(l===1||r.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return i=r.disabled,typeof r.precedence=="string"&&i==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function zg(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function ax(i,r,l,u){if(l.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var d=zs(u.href),m=r.querySelector(jl(d));if(m){r=m._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=Lo.bind(i),r.then(i,i)),l.state.loading|=4,l.instance=m,Rt(m);return}m=r.ownerDocument||r,u=Mg(u),(d=Ii.get(d))&&Nh(u,d),m=m.createElement("link"),Rt(m);var v=m;v._p=new Promise(function(C,M){v.onload=C,v.onerror=M}),Wt(m,"link",u),l.instance=m}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(l,r),(r=l.state.preload)&&(l.state.loading&3)===0&&(i.count++,l=Lo.bind(i),r.addEventListener("load",l),r.addEventListener("error",l))}}var zh=0;function ox(i,r){return i.stylesheets&&i.count===0&&Oo(i,i.stylesheets),0zh?50:800)+r);return i.unsuspend=l,function(){i.unsuspend=null,clearTimeout(u),clearTimeout(d)}}:null}function Lo(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Oo(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var zo=null;function Oo(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,zo=new Map,r.forEach(ux,i),zo=null,Lo.call(i))}function ux(i,r){if(!(r.state.loading&4)){var l=zo.get(i);if(l)var u=l.get(null);else{l=new Map,zo.set(i,l);for(var d=i.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Wh.exports=Ex(),Wh.exports}var Ax=Tx();const Dx=gu(Ax);function Rx({onLogin:e}){const[t,n]=Q.useState(""),[s,a]=Q.useState(null),[o,c]=Q.useState(!1),f=async p=>{if(p.preventDefault(),!t.trim())return;c(!0),a(null);const h=await e(t);h&&a(h),c(!1)};return S.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:S.jsxs("div",{className:"w-full max-w-sm",children:[S.jsxs("div",{className:"border-border rounded border p-6",children:[S.jsxs("div",{className:"mb-6 text-center",children:[S.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),S.jsx("p",{className:"text-muted mt-1 text-xs",children:"local writer agent"})]}),S.jsxs("form",{onSubmit:f,className:"space-y-4",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),S.jsx("input",{type:"password",value:t,onChange:p=>n(p.target.value),placeholder:"enter your passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),s&&S.jsx("p",{className:"text-error text-xs",children:s}),S.jsx("button",{type:"submit",disabled:o||!t.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:o?"authenticating...":"unlock"})]})]}),S.jsx("p",{className:"text-muted mt-4 text-center text-[10px]",children:"enter your passphrase to unlock"})]})})}function Mx({onSetup:e}){const[t,n]=Q.useState(""),[s,a]=Q.useState(""),[o,c]=Q.useState(null),[f,p]=Q.useState(!1),h=async g=>{if(g.preventDefault(),!t.trim()||t.length<4){c("Passphrase must be at least 4 characters");return}if(t!==s){c("Passphrases do not match");return}p(!0),c(null);const _=await e(t);_&&c(_),p(!1)};return S.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:S.jsx("div",{className:"w-full max-w-sm",children:S.jsxs("div",{className:"border-border rounded border p-6",children:[S.jsxs("div",{className:"mb-6 text-center",children:[S.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),S.jsx("p",{className:"text-muted mt-1 text-xs",children:"first-time setup"})]}),S.jsx("p",{className:"text-muted mb-4 text-xs leading-relaxed",children:"Choose a passphrase to protect your local writer agent. This will be used to unlock the app and secure your OWS wallet."}),S.jsxs("form",{onSubmit:h,className:"space-y-4",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),S.jsx("input",{type:"password",value:t,onChange:g=>n(g.target.value),placeholder:"choose a passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Confirm"}),S.jsx("input",{type:"password",value:s,onChange:g=>a(g.target.value),placeholder:"repeat passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),o&&S.jsx("p",{className:"text-error text-xs",children:o}),S.jsx("button",{type:"submit",disabled:f||!t.trim()||!s.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:f?"setting up...":"create passphrase"})]})]})})})}const sv="http://localhost:7777";function eb({token:e}){const[t,n]=Q.useState(null),[s,a]=Q.useState(!1),[o,c]=Q.useState(!1),[f,p]=Q.useState(null),h=(x,k)=>fetch(x,{...k,headers:{...k==null?void 0:k.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),g=()=>{h(`${sv}/api/wallet`).then(x=>x.json()).then(x=>n(x)).catch(()=>n({exists:!1,error:"Failed to load wallet"}))};Q.useEffect(()=>{g()},[]);const _=async()=>{a(!0),p(null);try{const x=await h(`${sv}/api/wallet/create`,{method:"POST"}),k=await x.json();if(!x.ok)throw new Error(k.error||"Creation failed");g()}catch(x){p(x instanceof Error?x.message:"Failed to create wallet")}a(!1)},b=()=>{t!=null&&t.address&&(navigator.clipboard.writeText(t.address),c(!0),setTimeout(()=>c(!1),2e3))},y=x=>`${x.slice(0,6)}...${x.slice(-4)}`;return S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"OWS Wallet"}),!t&&S.jsx("p",{className:"text-muted text-xs",children:"loading..."}),t&&!t.exists&&S.jsxs("div",{className:"space-y-3",children:[S.jsx("p",{className:"text-muted text-xs",children:"No wallet created yet. Create one to enable autonomous transactions."}),f&&S.jsx("p",{className:"text-error text-xs",children:f}),S.jsx("button",{onClick:_,disabled:s,className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 rounded border px-4 py-2 text-xs font-medium transition-colors",children:s?"creating...":"create wallet"})]}),t&&t.exists&&t.address&&S.jsxs("div",{className:"space-y-3",children:[S.jsxs("div",{className:"flex items-center justify-between",children:[S.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"Address (Base)"}),S.jsx("span",{className:`rounded border px-1.5 py-0.5 text-[9px] ${t.ethBalance&&parseFloat(t.ethBalance)>0?"border-accent/30 text-accent":"border-accent-dim/30 text-accent-dim"}`,children:t.ethBalance&&parseFloat(t.ethBalance)>0?"active":"no balance"})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("code",{className:"text-foreground bg-surface rounded px-2 py-1 text-xs font-mono",children:y(t.address)}),S.jsx("button",{onClick:b,className:"text-muted hover:text-accent text-xs transition-colors",children:o?"copied":"copy"})]}),S.jsxs("div",{className:"border-border space-y-1 border-t pt-3",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"ETH"}),S.jsxs("span",{className:"text-foreground font-medium",children:[t.ethBalance||"0.000000"," ETH"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"USDC"}),S.jsxs("span",{className:"text-foreground font-medium",children:["$",t.usdcBalance||"0.00"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"PLOT"}),S.jsxs("span",{className:"text-foreground font-medium",children:[t.plotBalance||"0.0000"," PLOT"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Network"}),S.jsx("span",{className:"text-foreground",children:"Base"})]})]}),S.jsxs("div",{className:"border-border border-t pt-3",children:[S.jsx("p",{className:"text-muted mb-2 text-[10px] font-medium uppercase tracking-wider",children:"Fund Wallet"}),S.jsx("p",{className:"text-muted text-[10px]",children:"Send ETH on Base for gas (~$0.01 per publish):"}),S.jsx("code",{className:"text-foreground bg-surface mt-1 block break-all rounded px-2 py-1.5 text-[10px] font-mono",children:t.address})]})]})]})}function Bx({token:e,onLogout:t}){const[n,s]=Q.useState(""),[a,o]=Q.useState(""),[c,f]=Q.useState(null),[p,h]=Q.useState(!1),[g,_]=Q.useState(!1),[b,y]=Q.useState(null),[x,k]=Q.useState("AI Writer"),[L,R]=Q.useState(""),[$,I]=Q.useState(""),[Z,Y]=Q.useState(!1),[O,J]=Q.useState(null),[ce,pe]=Q.useState(""),[F,se]=Q.useState(null),[H,E]=Q.useState(!1),[B,N]=Q.useState(null),[A,j]=Q.useState(null),P=Q.useCallback((w,ie)=>fetch(w,{...ie,headers:{...ie==null?void 0:ie.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]);Q.useEffect(()=>{P("/api/settings/link-status").then(w=>w.json()).then(w=>y(w)).catch(()=>y({linked:!1}))},[]);const oe=async()=>{if(!x.trim()){J("Agent name is required");return}if(!L.trim()){J("Description is required");return}Y(!0),J(null);try{const w=await P("/api/settings/register-agent",{method:"POST",body:JSON.stringify({name:x,description:L,...$.trim()&&{genre:$}})}),ie=await w.json();if(!w.ok)throw new Error(ie.error||"Registration failed");y({linked:!0,agentId:ie.agentId,owsWallet:ie.owsWallet,txHash:ie.txHash})}catch(w){J(w instanceof Error?w.message:"Registration failed")}Y(!1)},T=async()=>{if(!ce.trim()||!/^0x[a-fA-F0-9]{40}$/.test(ce)){N("Enter a valid wallet address (0x...)");return}E(!0),N(null),se(null);try{const w=await P("/api/settings/generate-binding",{method:"POST",body:JSON.stringify({humanWallet:ce})}),ie=await w.json();if(!w.ok)throw new Error(ie.error||"Failed to generate binding code");se(ie)}catch(w){N(w instanceof Error?w.message:"Failed to generate binding code")}E(!1)},D=async(w,ie)=>{await navigator.clipboard.writeText(w),j(ie),setTimeout(()=>j(null),2e3)},V=async()=>{if(f(null),h(!1),!n||n.length<4){f("Passphrase must be at least 4 characters");return}if(n!==a){f("Passphrases do not match");return}_(!0);try{const w=await P("/api/auth/reset-passphrase",{method:"POST",body:JSON.stringify({passphrase:n})});if(!w.ok){const ie=await w.json();throw new Error(ie.error||"Reset failed")}h(!0),s(""),o(""),setTimeout(()=>h(!1),3e3)}catch(w){f(w instanceof Error?w.message:"Reset failed")}_(!1)};return S.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-6",children:[S.jsx("h2",{className:"text-accent text-lg font-bold",children:"Settings"}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Identity"}),b!=null&&b.linked?S.jsxs("div",{className:"space-y-2",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"text-sm font-medium text-accent",children:"Registered"}),S.jsxs("span",{className:"text-muted text-xs",children:["Agent #",b.agentId]})]}),b.owsWallet&&S.jsxs("p",{className:"text-muted text-xs font-mono",children:["Wallet: ",b.owsWallet.slice(0,6),"...",b.owsWallet.slice(-4)]}),b.owner&&S.jsxs("p",{className:"text-muted text-xs font-mono",children:["Owner: ",b.owner.slice(0,6),"...",b.owner.slice(-4)]}),b.txHash&&S.jsx("p",{className:"text-muted text-xs",children:S.jsx("a",{href:`https://basescan.org/tx/${b.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View transaction on BaseScan"})}),S.jsx("p",{className:"text-muted text-xs",children:S.jsx("a",{href:`https://plotlink.xyz/profile/${b.owsWallet}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View agent profile on plotlink.xyz"})})]}):S.jsxs("div",{className:"space-y-3",children:[S.jsx("p",{className:"text-muted text-xs",children:"Register this AI writer on-chain via ERC-8004. Uses your OWS wallet's existing ETH balance for gas."}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Name"}),S.jsx("input",{value:x,onChange:w=>k(w.target.value),placeholder:"AI Writer",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Description"}),S.jsx("input",{value:L,onChange:w=>R(w.target.value),placeholder:"An AI writing assistant for fiction stories",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Genre (optional)"}),S.jsx("input",{value:$,onChange:w=>I(w.target.value),placeholder:"e.g. Fiction, Sci-Fi, Fantasy",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),O&&S.jsx("p",{className:"text-error text-xs",children:O}),S.jsx("button",{onClick:oe,disabled:Z||!x.trim()||!L.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:Z?"Registering...":"Register Agent Identity"})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Link to PlotLink"}),b!=null&&b.owner?S.jsxs("p",{className:"text-muted text-xs",children:["Linked to owner ",S.jsxs("span",{className:"font-mono",children:[b.owner.slice(0,6),"...",b.owner.slice(-4)]})]}):S.jsxs("div",{className:"space-y-3",children:[S.jsx("p",{className:"text-muted text-xs",children:"Link this OWS wallet to your PlotLink account so your stories appear under your profile on plotlink.xyz."}),S.jsxs("div",{className:"text-muted text-xs space-y-1 pl-3",children:[S.jsx("p",{children:"1. Enter your PlotLink wallet address below"}),S.jsx("p",{children:'2. Click "Generate Binding Code"'}),S.jsx("p",{children:"3. Copy the code and paste it on plotlink.xyz → Agents → Link AI Writer"})]}),S.jsx("input",{value:ce,onChange:w=>pe(w.target.value),placeholder:"Your PlotLink wallet address (0x...)",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent font-mono"}),B&&S.jsx("p",{className:"text-error text-xs",children:B}),S.jsx("button",{onClick:T,disabled:H||!ce.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:H?"Generating...":"Generate Binding Code"}),F&&S.jsxs("div",{className:"space-y-3 mt-3",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Binding Code (signature)"}),S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:F.signature}),S.jsx("button",{onClick:()=>D(F.signature,"signature"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:A==="signature"?"Copied!":"Copy"})]})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"OWS Wallet Address"}),S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:F.owsWallet}),S.jsx("button",{onClick:()=>D(F.owsWallet,"wallet"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:A==="wallet"?"Copied!":"Copy"})]})]}),F.agentId&&S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Agent ID"}),S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono text-foreground pr-16",children:F.agentId}),S.jsx("button",{onClick:()=>D(String(F.agentId),"agentId"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:A==="agentId"?"Copied!":"Copy"})]})]}),S.jsx("p",{className:"text-xs text-accent",children:'Now go to plotlink.xyz/agents and paste the values in the "Link AI Writer" section.'})]})]})]}),S.jsx(eb,{token:e}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Reset Passphrase"}),S.jsxs("div",{className:"space-y-3",children:[S.jsx("input",{type:"password",value:n,onChange:w=>s(w.target.value),placeholder:"new passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),S.jsx("input",{type:"password",value:a,onChange:w=>o(w.target.value),placeholder:"confirm passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),c&&S.jsx("p",{className:"text-error text-xs",children:c}),p&&S.jsx("p",{className:"text-xs text-accent",children:"passphrase updated"}),S.jsx("button",{onClick:V,disabled:g||!n.trim(),className:"border-border text-muted hover:border-accent hover:text-accent disabled:opacity-40 w-full rounded border px-4 py-2 text-xs font-medium transition-colors",children:g?"updating...":"update passphrase"})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Session"}),S.jsx("button",{onClick:t,className:"border-border text-muted hover:border-error hover:text-error rounded border px-4 py-2 text-xs font-medium transition-colors",children:"logout"})]})]})}const Nx="http://localhost:7777";function Lx({token:e}){const[t,n]=Q.useState(null),s=(f,p)=>fetch(f,{...p,headers:{...p==null?void 0:p.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),a=()=>{s(`${Nx}/api/dashboard`).then(f=>f.json()).then(n)};Q.useEffect(()=>{a()},[]);const o=f=>`${f.slice(0,6)}...${f.slice(-4)}`,c=f=>{if(!f)return"Unknown date";const p=new Date(f);return isNaN(p.getTime())?"Unknown date":p.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})};return t?S.jsxs("div",{className:"mx-auto max-w-2xl space-y-6 p-6",children:[S.jsx("h2",{className:"text-accent text-lg font-bold",children:"Writer Dashboard"}),S.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-accent text-lg font-bold",children:t.stories.totalPublished}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"published"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.pendingFiles}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"pending"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalStories}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"stories"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalFiles}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"files"})]})]}),t.wallet&&S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Wallet"}),S.jsxs("div",{className:"space-y-1.5",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Address"}),S.jsx("code",{className:"text-foreground font-mono text-[10px]",children:o(t.wallet.address)})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"ETH Balance"}),S.jsxs("span",{className:"text-foreground",children:[t.wallet.ethFormatted," ETH"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"USDC Balance"}),S.jsxs("span",{className:"text-foreground",children:["$",t.wallet.usdcBalance]})]})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Profit & Loss"}),S.jsxs("div",{className:"space-y-1.5",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Total costs (gas)"}),S.jsxs("span",{className:"text-error",children:["-",t.pnl.totalCostsEth," ETH (~$",t.pnl.totalCostsUsd,")"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Royalties earned"}),S.jsxs("span",{className:"text-accent",children:["+",t.pnl.totalRoyaltiesPlot," PLOT"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Unclaimed royalties"}),S.jsxs("span",{className:"text-foreground",children:[t.royalties.unclaimed," PLOT"]})]}),S.jsxs("div",{className:"border-border flex justify-between border-t pt-1.5 text-xs font-medium",children:[S.jsx("span",{className:"text-muted",children:"Net P&L (USD)"}),S.jsxs("span",{className:parseFloat(t.pnl.netPnlUsd)>=0?"text-accent":"text-error",children:[parseFloat(t.pnl.netPnlUsd)>=0?"+":"","$",t.pnl.netPnlUsd]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Stories published"}),S.jsx("span",{className:"text-foreground",children:t.costs.storiesPublished})]})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Published Stories"}),t.stories.published.length===0?S.jsx("p",{className:"text-muted text-xs",children:"no published stories yet"}):S.jsx("div",{className:"space-y-3",children:t.stories.published.map(f=>S.jsxs("div",{className:"bg-surface rounded border border-border p-4",children:[S.jsxs("div",{className:"flex items-start justify-between",children:[S.jsxs("div",{children:[f.genre&&S.jsx("span",{className:"bg-accent/10 text-accent rounded px-2 py-0.5 text-[10px] font-medium",children:f.genre}),S.jsx("h4",{className:"text-foreground mt-1 text-sm font-serif font-medium",children:f.title}),S.jsx("p",{className:"text-muted mt-0.5 text-[10px] font-mono",children:f.storyName})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[f.hasNotIndexed&&S.jsx("span",{className:"rounded border border-amber-600/30 px-1.5 py-0.5 text-[9px] text-amber-700",children:"not indexed"}),S.jsxs("span",{className:"rounded border border-green-700/30 px-1.5 py-0.5 text-[9px] text-green-700",children:[f.publishedFiles," published"]})]})]}),S.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-center",children:[S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium",children:f.plotCount}),S.jsx("div",{className:"text-muted text-[9px]",children:"Plots"})]}),S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium font-mono",children:f.storylineId?`#${f.storylineId}`:"—"}),S.jsx("div",{className:"text-muted text-[9px]",children:"Storyline"})]}),S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium",children:f.totalGasCostEth??"—"}),S.jsx("div",{className:"text-muted text-[9px]",children:"Gas (ETH)"})]})]}),S.jsx("div",{className:"mt-2 space-y-1",children:f.files.map(p=>S.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[S.jsxs("div",{className:"flex items-center gap-1.5",children:[S.jsx("span",{className:p.status==="published-not-indexed"?"text-amber-700":"text-green-700",children:p.status==="published-not-indexed"?"⚠":"✓"}),S.jsx("span",{className:"text-muted font-mono",children:p.file})]}),p.txHash&&S.jsxs("a",{href:`https://basescan.org/tx/${p.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-accent font-mono",children:["tx:",p.txHash.slice(0,8),"..."]})]},p.file))}),S.jsxs("div",{className:"mt-2 flex items-center justify-between text-[10px]",children:[S.jsx("span",{className:"text-muted",children:c(f.latestPublishedAt)}),f.storylineId&&S.jsx("a",{href:`https://plotlink.xyz/story/${f.storylineId}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"})]})]},f.id))})]}),t.stories.pendingFiles>0&&S.jsx("div",{className:"border-border rounded border p-4",children:S.jsxs("p",{className:"text-muted text-xs",children:[t.stories.pendingFiles," file(s) pending publish — go to Stories to publish them."]})})]}):S.jsx("div",{className:"flex h-full items-center justify-center",children:S.jsx("span",{className:"text-muted text-sm",children:"loading dashboard..."})})}const zx={published:"✓","published-not-indexed":"⚠",pending:"⏳",draft:"📝"},Ox={published:"text-green-700","published-not-indexed":"text-amber-700",pending:"text-amber-700",draft:"text-muted"};function jx({authFetch:e,selectedStory:t,selectedFile:n,onSelectFile:s,onNewStory:a,untitledSessions:o=[]}){const[c,f]=Q.useState([]),[p,h]=Q.useState([]),[g,_]=Q.useState(new Set),[b,y]=Q.useState(!1),x=Q.useCallback(async()=>{try{const Y=await e("/api/stories");if(Y.ok){const O=await Y.json();f(O.stories)}}catch{}},[e]),k=Q.useCallback(async()=>{try{const Y=await e("/api/stories/archived");if(Y.ok){const O=await Y.json();h(O.stories)}}catch{}},[e]),L=Q.useCallback(async Y=>{try{(await e("/api/stories/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Y})})).ok&&(k(),x())}catch{}},[e,k,x]);Q.useEffect(()=>{x();const Y=setInterval(x,5e3);return()=>clearInterval(Y)},[x]),Q.useEffect(()=>{b&&k()},[b,k]),Q.useEffect(()=>{t&&_(Y=>new Set(Y).add(t))},[t]);const R=Y=>{var J;const O=Y.map(ce=>{var pe;return{file:ce.file,num:(pe=ce.file.match(/^plot-(\d+)\.md$/))==null?void 0:pe[1]}}).filter(ce=>ce.num!=null).sort((ce,pe)=>parseInt(pe.num)-parseInt(ce.num));return O.length>0?O[0].file:Y.some(ce=>ce.file==="genesis.md")?"genesis.md":Y.some(ce=>ce.file==="structure.md")?"structure.md":((J=Y[0])==null?void 0:J.file)??null},$=Y=>{_(O=>{const J=new Set(O);return J.has(Y)?J.delete(Y):J.add(Y),J})},I=Y=>{if($(Y.name),!g.has(Y.name)){const O=R(Y.files);O&&s(Y.name,O)}},Z=Y=>{const O=J=>{if(J==="structure.md")return 0;if(J==="genesis.md")return 1;const ce=J.match(/^plot-(\d+)\.md$/);return ce?2+parseInt(ce[1]):100};return[...Y].sort((J,ce)=>O(J.file)-O(ce.file))};return b?S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs font-mono text-muted",children:"Archives"}),S.jsx("span",{className:"text-xs text-muted",children:p.length})]}),S.jsx("div",{className:"px-3 py-2 border-b border-border",children:S.jsxs("button",{onClick:()=>y(!1),className:"w-full px-3 py-1.5 text-sm text-muted hover:text-foreground hover:bg-surface rounded flex items-center gap-1.5",children:[S.jsx("span",{children:"←"}),S.jsx("span",{children:"Back"})]})}),S.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:p.length===0?S.jsx("div",{className:"p-3 text-sm text-muted",children:S.jsx("p",{children:"No archived stories."})}):p.map(Y=>S.jsxs("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-surface",children:[S.jsx("span",{className:"text-sm font-medium truncate",title:Y.name,children:Y.title||Y.name}),S.jsx("button",{onClick:()=>L(Y.name),className:"text-xs text-accent hover:text-accent-dim flex-shrink-0 ml-2",children:"Restore"})]},Y.name))})]}):S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs font-mono text-muted",children:"Stories"}),S.jsx("span",{className:"text-xs text-muted",children:c.length})]}),a&&S.jsx("div",{className:"px-3 py-2 border-b border-border",children:S.jsxs("button",{onClick:a,className:"w-full px-3 py-1.5 text-sm bg-accent text-white rounded hover:bg-accent-dim flex items-center justify-center gap-1.5",children:[S.jsx("span",{children:"+"}),S.jsx("span",{children:"New Story"})]})}),S.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[o.map(Y=>S.jsx("div",{children:S.jsxs("button",{onClick:()=>s(Y,""),className:`w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm ${t===Y?"bg-surface":""}`,children:[S.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-600 flex-shrink-0"}),S.jsx("span",{className:"font-medium italic text-muted",children:"Untitled"})]})},Y)),c.length===0&&o.length===0?S.jsxs("div",{className:"p-3 text-sm text-muted",children:[S.jsx("p",{children:"No stories yet."}),S.jsx("p",{className:"mt-1 text-xs",children:'Click "+ New Story" above to start writing.'})]}):c.filter(Y=>Y.name!=="_example").map(Y=>S.jsxs("div",{children:[S.jsxs("button",{onClick:()=>I(Y),className:"w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm",children:[S.jsx("span",{className:"text-xs text-muted",children:g.has(Y.name)?"▼":"▶"}),S.jsx("span",{className:"font-medium truncate",title:Y.name,children:Y.title||Y.name}),S.jsxs("span",{className:"ml-auto text-xs text-muted",children:[Y.publishedCount,"/",Y.files.length]})]}),g.has(Y.name)&&S.jsx("div",{className:"pl-4",children:Z(Y.files).map(O=>{const J=t===Y.name&&n===O.file;return S.jsxs("button",{onClick:()=>s(Y.name,O.file),className:`w-full px-3 py-1.5 text-left flex items-center gap-2 text-xs hover:bg-surface ${J?"bg-surface font-medium":""}`,children:[S.jsx("span",{className:Ox[O.status],children:zx[O.status]}),S.jsx("span",{className:"truncate font-mono",children:O.file})]},O.file)})})]},Y.name))]}),S.jsx("div",{className:"px-3 py-2 border-t border-border",children:S.jsx("button",{onClick:()=>y(!0),className:"w-full px-3 py-1.5 text-xs text-muted hover:text-foreground hover:bg-surface rounded flex items-center justify-center gap-1.5",children:S.jsx("span",{children:"Archives"})})})]})}/** - * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. - * @license MIT - * - * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) - * @license MIT - * - * Originally forked from (with the author's permission): - * Fabrice Bellard's javascript vt100 for jslinux: - * http://bellard.org/jslinux/ - * Copyright (c) 2011 Fabrice Bellard - */var tb=Object.defineProperty,Hx=Object.getOwnPropertyDescriptor,Ux=(e,t)=>{for(var n in t)tb(e,n,{get:t[n],enumerable:!0})},dt=(e,t,n,s)=>{for(var a=s>1?void 0:s?Hx(t,n):t,o=e.length-1,c;o>=0;o--)(c=e[o])&&(a=(s?c(t,n,a):c(a))||a);return s&&a&&tb(t,n,a),a},de=(e,t)=>(n,s)=>t(n,s,e),lv="Terminal input",Df={get:()=>lv,set:e=>lv=e},av="Too much output to announce, navigate to rows manually to read",Rf={get:()=>av,set:e=>av=e};function Px(e){return e.replace(/\r?\n/g,"\r")}function Ix(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Fx(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function qx(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let a=e.clipboardData.getData("text/plain");ib(a,t,n,s)}}function ib(e,t,n,s){e=Px(e),e=Ix(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function nb(e,t,n){let s=n.getBoundingClientRect(),a=e.clientX-s.left-10,o=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${a}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function ov(e,t,n,s,a){nb(e,t,n),a&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function dr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function vu(e,t=0,n=e.length){let s="";for(let a=t;a65535?(o-=65536,s+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):s+=String.fromCharCode(o)}return s}var Wx=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let s=0,a=0;if(this._interim){let o=e.charCodeAt(a++);56320<=o&&o<=57343?t[s++]=(this._interim-55296)*1024+o-56320+65536:(t[s++]=this._interim,t[s++]=o),this._interim=0}for(let o=a;o=n)return this._interim=c,s;let f=e.charCodeAt(o);56320<=f&&f<=57343?t[s++]=(c-55296)*1024+f-56320+65536:(t[s++]=c,t[s++]=f);continue}c!==65279&&(t[s++]=c)}return s}},Yx=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let s=0,a,o,c,f,p=0,h=0;if(this.interim[0]){let b=!1,y=this.interim[0];y&=(y&224)===192?31:(y&240)===224?15:7;let x=0,k;for(;(k=this.interim[++x]&63)&&x<4;)y<<=6,y|=k;let L=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,R=L-x;for(;h=n)return 0;if(k=e[h++],(k&192)!==128){h--,b=!0;break}else this.interim[x++]=k,y<<=6,y|=k&63}b||(L===2?y<128?h--:t[s++]=y:L===3?y<2048||y>=55296&&y<=57343||y===65279||(t[s++]=y):y<65536||y>1114111||(t[s++]=y)),this.interim.fill(0)}let g=n-4,_=h;for(;_=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(p=(a&31)<<6|o&63,p<128){_--;continue}t[s++]=p}else if((a&240)===224){if(_>=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[_++],(c&192)!==128){_--;continue}if(p=(a&15)<<12|(o&63)<<6|c&63,p<2048||p>=55296&&p<=57343||p===65279)continue;t[s++]=p}else if((a&248)===240){if(_>=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[_++],(c&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,this.interim[2]=c,s;if(f=e[_++],(f&192)!==128){_--;continue}if(p=(a&7)<<18|(o&63)<<12|(c&63)<<6|f&63,p<65536||p>1114111)continue;t[s++]=p}}return s}},rb="",mr=" ",ga=class sb{constructor(){this.fg=0,this.bg=0,this.extended=new ou}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new sb;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ou=class lb{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new lb(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Vi=class ab extends ga{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ou,this.combinedData=""}static fromCharData(t){let n=new ab;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?dr(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let a=t[1].charCodeAt(1);56320<=a&&a<=57343?this.content=(s-55296)*1024+a-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},uv="di$target",Mf="di$dependencies",Xh=new Map;function Vx(e){return e[Mf]||[]}function Ut(e){if(Xh.has(e))return Xh.get(e);let t=function(n,s,a){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Kx(t,n,a)};return t._id=e,Xh.set(e,t),t}function Kx(e,t,n){t[uv]===t?t[Mf].push({id:e,index:n}):(t[Mf]=[{id:e,index:n}],t[uv]=t)}var si=Ut("BufferService"),ob=Ut("CoreMouseService"),Xr=Ut("CoreService"),Xx=Ut("CharsetService"),Cd=Ut("InstantiationService"),ub=Ut("LogService"),li=Ut("OptionsService"),cb=Ut("OscLinkService"),$x=Ut("UnicodeService"),va=Ut("DecorationService"),Bf=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var g;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],a=this._optionsService.rawOptions.linkHandler,o=new Vi,c=n.getTrimmedLength(),f=-1,p=-1,h=!1;for(let _=0;_a?a.activate(k,L,y):Gx(k,L),hover:(k,L)=>{var R;return(R=a==null?void 0:a.hover)==null?void 0:R.call(a,k,L,y)},leave:(k,L)=>{var R;return(R=a==null?void 0:a.leave)==null?void 0:R.call(a,k,L,y)}})}h=!1,o.hasExtendedAttrs()&&o.extended.urlId?(p=_,f=o.extended.urlId):(p=-1,f=-1)}}t(s)}};Bf=dt([de(0,si),de(1,li),de(2,cb)],Bf);function Gx(e,t){if(confirm(`Do you want to navigate to ${t}? - -WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var yu=Ut("CharSizeService"),zn=Ut("CoreBrowserService"),kd=Ut("MouseService"),On=Ut("RenderService"),Zx=Ut("SelectionService"),hb=Ut("CharacterJoinerService"),Ks=Ut("ThemeService"),fb=Ut("LinkProviderService"),Qx=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?cv.isErrorNoTelemetry(e)?new cv(e.message+` - -`+e.stack):new Error(e.message+` - -`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},Jx=new Qx;function eu(e){ew(e)||Jx.onUnexpectedError(e)}var Nf="Canceled";function ew(e){return e instanceof tw?!0:e instanceof Error&&e.name===Nf&&e.message===Nf}var tw=class extends Error{constructor(){super(Nf),this.name=this.message}};function iw(e){return new Error(`Illegal argument: ${e}`)}var cv=class Lf extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Lf)return t;let n=new Lf;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},zf=class db extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,db.prototype)}};function Ai(e,t=0){return e[e.length-(1+t)]}var nw;(e=>{function t(o){return o<0}e.isLessThan=t;function n(o){return o<=0}e.isLessThanOrEqual=n;function s(o){return o>0}e.isGreaterThan=s;function a(o){return o===0}e.isNeitherLessOrGreaterThan=a,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(nw||(nw={}));function rw(e,t){let n=this,s=!1,a;return function(){return s||(s=!0,t||(a=e.apply(n,arguments))),a}}var pb;(e=>{function t(Z){return Z&&typeof Z=="object"&&typeof Z[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*a(Z){yield Z}e.single=a;function o(Z){return t(Z)?Z:a(Z)}e.wrap=o;function c(Z){return Z||n}e.from=c;function*f(Z){for(let Y=Z.length-1;Y>=0;Y--)yield Z[Y]}e.reverse=f;function p(Z){return!Z||Z[Symbol.iterator]().next().done===!0}e.isEmpty=p;function h(Z){return Z[Symbol.iterator]().next().value}e.first=h;function g(Z,Y){let O=0;for(let J of Z)if(Y(J,O++))return!0;return!1}e.some=g;function _(Z,Y){for(let O of Z)if(Y(O))return O}e.find=_;function*b(Z,Y){for(let O of Z)Y(O)&&(yield O)}e.filter=b;function*y(Z,Y){let O=0;for(let J of Z)yield Y(J,O++)}e.map=y;function*x(Z,Y){let O=0;for(let J of Z)yield*Y(J,O++)}e.flatMap=x;function*k(...Z){for(let Y of Z)yield*Y}e.concat=k;function L(Z,Y,O){let J=O;for(let ce of Z)J=Y(J,ce);return J}e.reduce=L;function*R(Z,Y,O=Z.length){for(Y<0&&(Y+=Z.length),O<0?O+=Z.length:O>Z.length&&(O=Z.length);Y1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function sw(...e){return lt(()=>Yr(e))}function lt(e){return{dispose:rw(()=>{e()})}}var mb=class _b{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Yr(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?_b.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};mb.DISABLE_DISPOSED_WARNING=!1;var _r=mb,Re=class{constructor(){this._store=new _r,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Re.None=Object.freeze({dispose(){}});var Ys=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Ln=typeof window=="object"?window:globalThis,Of=class jf{constructor(t){this.element=t,this.next=jf.Undefined,this.prev=jf.Undefined}};Of.Undefined=new Of(void 0);var at=Of,hv=class{constructor(){this._first=at.Undefined,this._last=at.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===at.Undefined}clear(){let e=this._first;for(;e!==at.Undefined;){let t=e.next;e.prev=at.Undefined,e.next=at.Undefined,e=t}this._first=at.Undefined,this._last=at.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new at(e);if(this._first===at.Undefined)this._first=n,this._last=n;else if(t){let a=this._last;this._last=n,n.prev=a,a.next=n}else{let a=this._first;this._first=n,n.next=a,a.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first!==at.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==at.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==at.Undefined&&e.next!==at.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===at.Undefined&&e.next===at.Undefined?(this._first=at.Undefined,this._last=at.Undefined):e.next===at.Undefined?(this._last=this._last.prev,this._last.next=at.Undefined):e.prev===at.Undefined&&(this._first=this._first.next,this._first.prev=at.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==at.Undefined;)yield e.element,e=e.next}},lw=globalThis.performance&&typeof globalThis.performance.now=="function",aw=class gb{static create(t){return new gb(t)}constructor(t){this._now=lw&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Kt;(e=>{e.None=()=>Re.None;function t(H,E){return _(H,()=>{},0,void 0,!0,void 0,E)}e.defer=t;function n(H){return(E,B=null,N)=>{let A=!1,j;return j=H(P=>{if(!A)return j?j.dispose():A=!0,E.call(B,P)},null,N),A&&j.dispose(),j}}e.once=n;function s(H,E,B){return h((N,A=null,j)=>H(P=>N.call(A,E(P)),null,j),B)}e.map=s;function a(H,E,B){return h((N,A=null,j)=>H(P=>{E(P),N.call(A,P)},null,j),B)}e.forEach=a;function o(H,E,B){return h((N,A=null,j)=>H(P=>E(P)&&N.call(A,P),null,j),B)}e.filter=o;function c(H){return H}e.signal=c;function f(...H){return(E,B=null,N)=>{let A=sw(...H.map(j=>j(P=>E.call(B,P))));return g(A,N)}}e.any=f;function p(H,E,B,N){let A=B;return s(H,j=>(A=E(A,j),A),N)}e.reduce=p;function h(H,E){let B,N={onWillAddFirstListener(){B=H(A.fire,A)},onDidRemoveLastListener(){B==null||B.dispose()}},A=new he(N);return E==null||E.add(A),A.event}function g(H,E){return E instanceof Array?E.push(H):E&&E.add(H),H}function _(H,E,B=100,N=!1,A=!1,j,P){let oe,T,D,V=0,w,ie={leakWarningThreshold:j,onWillAddFirstListener(){oe=H(le=>{V++,T=E(T,le),N&&!D&&(ae.fire(T),T=void 0),w=()=>{let ge=T;T=void 0,D=void 0,(!N||V>1)&&ae.fire(ge),V=0},typeof B=="number"?(clearTimeout(D),D=setTimeout(w,B)):D===void 0&&(D=0,queueMicrotask(w))})},onWillRemoveListener(){A&&V>0&&(w==null||w())},onDidRemoveLastListener(){w=void 0,oe.dispose()}},ae=new he(ie);return P==null||P.add(ae),ae.event}e.debounce=_;function b(H,E=0,B){return e.debounce(H,(N,A)=>N?(N.push(A),N):[A],E,void 0,!0,void 0,B)}e.accumulate=b;function y(H,E=(N,A)=>N===A,B){let N=!0,A;return o(H,j=>{let P=N||!E(j,A);return N=!1,A=j,P},B)}e.latch=y;function x(H,E,B){return[e.filter(H,E,B),e.filter(H,N=>!E(N),B)]}e.split=x;function k(H,E=!1,B=[],N){let A=B.slice(),j=H(T=>{A?A.push(T):oe.fire(T)});N&&N.add(j);let P=()=>{A==null||A.forEach(T=>oe.fire(T)),A=null},oe=new he({onWillAddFirstListener(){j||(j=H(T=>oe.fire(T)),N&&N.add(j))},onDidAddFirstListener(){A&&(E?setTimeout(P):P())},onDidRemoveLastListener(){j&&j.dispose(),j=null}});return N&&N.add(oe),oe.event}e.buffer=k;function L(H,E){return(B,N,A)=>{let j=E(new $);return H(function(P){let oe=j.evaluate(P);oe!==R&&B.call(N,oe)},void 0,A)}}e.chain=L;let R=Symbol("HaltChainable");class ${constructor(){this.steps=[]}map(E){return this.steps.push(E),this}forEach(E){return this.steps.push(B=>(E(B),B)),this}filter(E){return this.steps.push(B=>E(B)?B:R),this}reduce(E,B){let N=B;return this.steps.push(A=>(N=E(N,A),N)),this}latch(E=(B,N)=>B===N){let B=!0,N;return this.steps.push(A=>{let j=B||!E(A,N);return B=!1,N=A,j?A:R}),this}evaluate(E){for(let B of this.steps)if(E=B(E),E===R)break;return E}}function I(H,E,B=N=>N){let N=(...oe)=>P.fire(B(...oe)),A=()=>H.on(E,N),j=()=>H.removeListener(E,N),P=new he({onWillAddFirstListener:A,onDidRemoveLastListener:j});return P.event}e.fromNodeEventEmitter=I;function Z(H,E,B=N=>N){let N=(...oe)=>P.fire(B(...oe)),A=()=>H.addEventListener(E,N),j=()=>H.removeEventListener(E,N),P=new he({onWillAddFirstListener:A,onDidRemoveLastListener:j});return P.event}e.fromDOMEventEmitter=Z;function Y(H){return new Promise(E=>n(H)(E))}e.toPromise=Y;function O(H){let E=new he;return H.then(B=>{E.fire(B)},()=>{E.fire(void 0)}).finally(()=>{E.dispose()}),E.event}e.fromPromise=O;function J(H,E){return H(B=>E.fire(B))}e.forward=J;function ce(H,E,B){return E(B),H(N=>E(N))}e.runAndSubscribe=ce;class pe{constructor(E,B){this._observable=E,this._counter=0,this._hasChanged=!1;let N={onWillAddFirstListener:()=>{E.addObserver(this)},onDidRemoveLastListener:()=>{E.removeObserver(this)}};this.emitter=new he(N),B&&B.add(this.emitter)}beginUpdate(E){this._counter++}handlePossibleChange(E){}handleChange(E,B){this._hasChanged=!0}endUpdate(E){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function F(H,E){return new pe(H,E).emitter.event}e.fromObservable=F;function se(H){return(E,B,N)=>{let A=0,j=!1,P={beginUpdate(){A++},endUpdate(){A--,A===0&&(H.reportChanges(),j&&(j=!1,E.call(B)))},handlePossibleChange(){},handleChange(){j=!0}};H.addObserver(P),H.reportChanges();let oe={dispose(){H.removeObserver(P)}};return N instanceof _r?N.add(oe):Array.isArray(N)&&N.push(oe),oe}}e.fromObservableLight=se})(Kt||(Kt={}));var Hf=class Uf{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Uf._idPool++}`,Uf.all.add(this)}start(t){this._stopWatch=new aw,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Hf.all=new Set,Hf._idPool=0;var ow=Hf,uw=-1,vb=class yb{constructor(t,n,s=(yb._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let s=this.threshold;if(s<=0||n{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[s,a]of this._stacks)(!t||n{var f,p,h,g,_;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let b=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(b);let y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],x=new dw(`${b}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((f=this._options)==null?void 0:f.onListenerError)||eu)(x),Re.None}if(this._disposed)return Re.None;n&&(t=t.bind(n));let a=new $h(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(a.stack=hw.create(),o=this._leakageMon.check(a.stack,this._size+1)),this._listeners?this._listeners instanceof $h?(this._deliveryQueue??(this._deliveryQueue=new gw),this._listeners=[this._listeners,a]):this._listeners.push(a):((h=(p=this._options)==null?void 0:p.onWillAddFirstListener)==null||h.call(p,this),this._listeners=a,(_=(g=this._options)==null?void 0:g.onDidAddFirstListener)==null||_.call(g,this)),this._size++;let c=lt(()=>{o==null||o(),this._removeListener(a)});return s instanceof _r?s.add(c):Array.isArray(s)&&s.push(c),c}),this._event}_removeListener(t){var o,c,f,p;if((c=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||c.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(p=(f=this._options)==null?void 0:f.onDidRemoveLastListener)==null||p.call(f,this),this._size=0;return}let n=this._listeners,s=n.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,n[s]=void 0;let a=this._deliveryQueue.current===this;if(this._size*mw<=n.length){let h=0;for(let g=0;g0}},gw=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Pf=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new he,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new he,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Pf.INSTANCE=new Pf;var Ed=Pf;function vw(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Ed.INSTANCE.onDidChangeZoomLevel;function yw(e){return Ed.INSTANCE.getZoomFactor(e)}Ed.INSTANCE.onDidChangeFullscreen;var Xs=typeof navigator=="object"?navigator.userAgent:"",If=Xs.indexOf("Firefox")>=0,bw=Xs.indexOf("AppleWebKit")>=0,Td=Xs.indexOf("Chrome")>=0,Sw=!Td&&Xs.indexOf("Safari")>=0;Xs.indexOf("Electron/")>=0;Xs.indexOf("Android")>=0;var Gh=!1;if(typeof Ln.matchMedia=="function"){let e=Ln.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Ln.matchMedia("(display-mode: fullscreen)");Gh=e.matches,vw(Ln,e,({matches:n})=>{Gh&&t.matches||(Gh=n)})}var qs="en",Ff=!1,qf=!1,tu=!1,Sb=!1,Wo,iu=qs,fv=qs,xw,Zi,Wr=globalThis,Vt,Zy;typeof Wr.vscode<"u"&&typeof Wr.vscode.process<"u"?Vt=Wr.vscode.process:typeof process<"u"&&typeof((Zy=process==null?void 0:process.versions)==null?void 0:Zy.node)=="string"&&(Vt=process);var Qy,ww=typeof((Qy=Vt==null?void 0:Vt.versions)==null?void 0:Qy.electron)=="string",Cw=ww&&(Vt==null?void 0:Vt.type)==="renderer",Jy;if(typeof Vt=="object"){Ff=Vt.platform==="win32",qf=Vt.platform==="darwin",tu=Vt.platform==="linux",tu&&Vt.env.SNAP&&Vt.env.SNAP_REVISION,Vt.env.CI||Vt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Wo=qs,iu=qs;let e=Vt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Wo=t.userLocale,fv=t.osLocale,iu=t.resolvedLanguage||qs,xw=(Jy=t.languagePack)==null?void 0:Jy.translationsConfigFile}catch{}Sb=!0}else typeof navigator=="object"&&!Cw?(Zi=navigator.userAgent,Ff=Zi.indexOf("Windows")>=0,qf=Zi.indexOf("Macintosh")>=0,(Zi.indexOf("Macintosh")>=0||Zi.indexOf("iPad")>=0||Zi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,tu=Zi.indexOf("Linux")>=0,(Zi==null?void 0:Zi.indexOf("Mobi"))>=0,iu=globalThis._VSCODE_NLS_LANGUAGE||qs,Wo=navigator.language.toLowerCase(),fv=Wo):console.error("Unable to resolve platform.");var xb=Ff,un=qf,kw=tu,dv=Sb,cn=Zi,ur=iu,Ew;(e=>{function t(){return ur}e.value=t;function n(){return ur.length===2?ur==="en":ur.length>=3?ur[0]==="e"&&ur[1]==="n"&&ur[2]==="-":!1}e.isDefaultVariant=n;function s(){return ur==="en"}e.isDefault=s})(Ew||(Ew={}));var Tw=typeof Wr.postMessage=="function"&&!Wr.importScripts;(()=>{if(Tw){let e=[];Wr.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,a=e.length;s{let s=++t;e.push({id:s,callback:n}),Wr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var Aw=!!(cn&&cn.indexOf("Chrome")>=0);cn&&cn.indexOf("Firefox")>=0;!Aw&&cn&&cn.indexOf("Safari")>=0;cn&&cn.indexOf("Edg/")>=0;cn&&cn.indexOf("Android")>=0;var Hs=typeof navigator=="object"?navigator:{};dv||document.queryCommandSupported&&document.queryCommandSupported("copy")||Hs&&Hs.clipboard&&Hs.clipboard.writeText,dv||Hs&&Hs.clipboard&&Hs.clipboard.readText;var Ad=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Zh=new Ad,pv=new Ad,mv=new Ad,Dw=new Array(230),wb;(e=>{function t(f){return Zh.keyCodeToStr(f)}e.toString=t;function n(f){return Zh.strToKeyCode(f)}e.fromString=n;function s(f){return pv.keyCodeToStr(f)}e.toUserSettingsUS=s;function a(f){return mv.keyCodeToStr(f)}e.toUserSettingsGeneral=a;function o(f){return pv.strToKeyCode(f)||mv.strToKeyCode(f)}e.fromUserSettings=o;function c(f){if(f>=98&&f<=113)return null;switch(f){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Zh.keyCodeToStr(f)}e.toElectronAccelerator=c})(wb||(wb={}));var Rw=class Cb{constructor(t,n,s,a,o){this.ctrlKey=t,this.shiftKey=n,this.altKey=s,this.metaKey=a,this.keyCode=o}equals(t){return t instanceof Cb&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",s=this.altKey?"1":"0",a=this.metaKey?"1":"0";return`K${t}${n}${s}${a}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Mw([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Mw=class{constructor(e){if(e.length===0)throw iw("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t{function t(n){return n===e.None||n===e.Cancelled||n instanceof Pw?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Kt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:kb})})(Uw||(Uw={}));var Pw=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?kb:(this._emitter||(this._emitter=new he),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Dd=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new zf("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new zf("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Iw=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new zf("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=lt(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Fw;(e=>{async function t(s){let a,o=await Promise.all(s.map(c=>c.then(f=>f,f=>{a||(a=f)})));if(typeof a<"u")throw a;return o}e.settled=t;function n(s){return new Promise(async(a,o)=>{try{await s(a,o)}catch(c){o(c)}})}e.withAsyncBody=n})(Fw||(Fw={}));var yv=class qi{static fromArray(t){return new qi(n=>{n.emitMany(t)})}static fromPromise(t){return new qi(async n=>{n.emitMany(await t)})}static fromPromises(t){return new qi(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new qi(async n=>{await Promise.all(t.map(async s=>{for await(let a of s)n.emitOne(a)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new he,queueMicrotask(async()=>{let s={emitOne:a=>this.emitOne(a),emitMany:a=>this.emitMany(a),reject:a=>this.reject(a)};try{await Promise.resolve(t(s)),this.resolve()}catch(a){this.reject(a)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(t,n){return new qi(async s=>{for await(let a of t)s.emitOne(n(a))})}map(t){return qi.map(this,t)}static filter(t,n){return new qi(async s=>{for await(let a of t)n(a)&&s.emitOne(a)})}filter(t){return qi.filter(this,t)}static coalesce(t){return qi.filter(t,n=>!!n)}coalesce(){return qi.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return qi.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};yv.EMPTY=yv.fromArray([]);var{getWindow:on,getWindowId:qw,onDidRegisterWindow:Ww}=(function(){let e=new Map,t={window:Ln,disposables:new _r};e.set(Ln.vscodeWindowId,t);let n=new he,s=new he,a=new he;function o(c,f){return(typeof c=="number"?e.get(c):void 0)??(f?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:a.event,onDidUnregisterWindow:s.event,registerWindow(c){if(e.has(c.vscodeWindowId))return Re.None;let f=new _r,p={window:c,disposables:f.add(new _r)};return e.set(c.vscodeWindowId,p),f.add(lt(()=>{e.delete(c.vscodeWindowId),s.fire(c)})),f.add(we(c,Bt.BEFORE_UNLOAD,()=>{a.fire(c)})),n.fire(p),f},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return e.has(c)},getWindowById:o,getWindow(c){var h;let f=c;if((h=f==null?void 0:f.ownerDocument)!=null&&h.defaultView)return f.ownerDocument.defaultView.window;let p=c;return p!=null&&p.view?p.view.window:Ln},getDocument(c){return on(c).document}}})(),Yw=class{constructor(e,t,n,s){this._node=e,this._type=t,this._handler=n,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function we(e,t,n,s){return new Yw(e,t,n,s)}var bv=function(e,t,n,s){return we(e,t,n,s)},Rd,Vw=class extends Iw{constructor(e){super(),this.defaultTarget=e&&on(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Sv=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){eu(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,s=new Map,a=o=>{n.set(o,!1);let c=e.get(o)??[];for(t.set(o,c),e.set(o,[]),s.set(o,!0);c.length>0;)c.sort(Sv.sort),c.shift().execute();s.set(o,!1)};Rd=(o,c,f=0)=>{let p=qw(o),h=new Sv(c,f),g=e.get(p);return g||(g=[],e.set(p,g)),g.push(h),n.get(p)||(n.set(p,!0),o.requestAnimationFrame(()=>a(p))),h}})();function Kw(e){let t=e.getBoundingClientRect(),n=on(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Bt={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Xw=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=_i(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=_i(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=_i(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=_i(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=_i(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=_i(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=_i(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=_i(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=_i(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=_i(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=_i(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=_i(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=_i(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=_i(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function _i(e){return typeof e=="number"?`${e}px`:e}function aa(e){return new Xw(e)}var Eb=class{constructor(){this._hooks=new _r,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,s,a){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=a;let o=e;try{e.setPointerCapture(t),this._hooks.add(lt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=on(e)}this._hooks.add(we(o,Bt.POINTER_MOVE,c=>{if(c.buttons!==n){this.stopMonitoring(!0);return}c.preventDefault(),this._pointerMoveCallback(c)})),this._hooks.add(we(o,Bt.POINTER_UP,c=>this.stopMonitoring(!0)))}};function $w(e,t,n){let s=null,a=null;if(typeof n.value=="function"?(s="value",a=n.value,a.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",a=n.get),!a)throw new Error("not supported");let o=`$memoize$${t}`;n[s]=function(...c){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:a.apply(this,c)}),this[o]}}var ln;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(ln||(ln={}));var ia=class $t extends Re{constructor(){super(),this.dispatched=!1,this.targets=new hv,this.ignoreTargets=new hv,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Kt.runAndSubscribe(Ww,({window:t,disposables:n})=>{n.add(we(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(we(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(we(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Ln,disposables:this._store}))}static addTarget(t){if(!$t.isTouchDevice())return Re.None;$t.INSTANCE||($t.INSTANCE=new $t);let n=$t.INSTANCE.targets.push(t);return lt(n)}static ignoreTarget(t){if(!$t.isTouchDevice())return Re.None;$t.INSTANCE||($t.INSTANCE=new $t);let n=$t.INSTANCE.ignoreTargets.push(t);return lt(n)}static isTouchDevice(){return"ontouchstart"in Ln||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,a=t.targetTouches.length;s=$t.HOLD_DELAY&&Math.abs(p.initialPageX-Ai(p.rollingPageX))<30&&Math.abs(p.initialPageY-Ai(p.rollingPageY))<30){let g=this.newGestureEvent(ln.Contextmenu,p.initialTarget);g.pageX=Ai(p.rollingPageX),g.pageY=Ai(p.rollingPageY),this.dispatchEvent(g)}else if(a===1){let g=Ai(p.rollingPageX),_=Ai(p.rollingPageY),b=Ai(p.rollingTimestamps)-p.rollingTimestamps[0],y=g-p.rollingPageX[0],x=_-p.rollingPageY[0],k=[...this.targets].filter(L=>p.initialTarget instanceof Node&&L.contains(p.initialTarget));this.inertia(t,k,s,Math.abs(y)/b,y>0?1:-1,g,Math.abs(x)/b,x>0?1:-1,_)}this.dispatchEvent(this.newGestureEvent(ln.End,p.initialTarget)),delete this.activeTouches[f.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(t){if(t.type===ln.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>$t.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===ln.Change||t.type===ln.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let n=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let a=0,o=t.initialTarget;for(;o&&o!==s;)a++,o=o.parentElement;n.push([a,s])}n.sort((s,a)=>s[0]-a[0]);for(let[s,a]of n)a.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,s,a,o,c,f,p,h){this.handle=Rd(t,()=>{let g=Date.now(),_=g-s,b=0,y=0,x=!0;a+=$t.SCROLL_FRICTION*_,f+=$t.SCROLL_FRICTION*_,a>0&&(x=!1,b=o*a*_),f>0&&(x=!1,y=p*f*_);let k=this.newGestureEvent(ln.Change);k.translationX=b,k.translationY=y,n.forEach(L=>L.dispatchEvent(k)),x||this.inertia(t,n,g,a,o,c+b,f,p,h+y)})}onTouchMove(t){let n=Date.now();for(let s=0,a=t.changedTouches.length;s3&&(c.rollingPageX.shift(),c.rollingPageY.shift(),c.rollingTimestamps.shift()),c.rollingPageX.push(o.pageX),c.rollingPageY.push(o.pageY),c.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};ia.SCROLL_FRICTION=-.005,ia.HOLD_DELAY=700,ia.CLEAR_TAP_COUNT_TIME=400,dt([$w],ia,"isTouchDevice",1);var Gw=ia,Md=class extends Re{onclick(e,t){this._register(we(e,Bt.CLICK,n=>t(new Yo(on(e),n))))}onmousedown(e,t){this._register(we(e,Bt.MOUSE_DOWN,n=>t(new Yo(on(e),n))))}onmouseover(e,t){this._register(we(e,Bt.MOUSE_OVER,n=>t(new Yo(on(e),n))))}onmouseleave(e,t){this._register(we(e,Bt.MOUSE_LEAVE,n=>t(new Yo(on(e),n))))}onkeydown(e,t){this._register(we(e,Bt.KEY_DOWN,n=>t(new _v(n))))}onkeyup(e,t){this._register(we(e,Bt.KEY_UP,n=>t(new _v(n))))}oninput(e,t){this._register(we(e,Bt.INPUT,t))}onblur(e,t){this._register(we(e,Bt.BLUR,t))}onfocus(e,t){this._register(we(e,Bt.FOCUS,t))}onchange(e,t){this._register(we(e,Bt.CHANGE,t))}ignoreGesture(e){return Gw.ignoreTarget(e)}},xv=11,Zw=class extends Md{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=xv+"px",this.domNode.style.height=xv+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new Eb),this._register(bv(this.bgDomNode,Bt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(bv(this.domNode,Bt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Vw),this._pointerdownScheduleRepeatTimer=this._register(new Dd)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,on(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Qw=class Wf{constructor(t,n,s,a,o,c,f){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,a=a|0,o=o|0,c=c|0,f=f|0),this.rawScrollLeft=a,this.rawScrollTop=f,n<0&&(n=0),a+n>s&&(a=s-n),a<0&&(a=0),o<0&&(o=0),f+o>c&&(f=c-o),f<0&&(f=0),this.width=n,this.scrollWidth=s,this.scrollLeft=a,this.height=o,this.scrollHeight=c,this.scrollTop=f}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new Wf(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Wf(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let s=this.width!==t.width,a=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,c=this.height!==t.height,f=this.scrollHeight!==t.scrollHeight,p=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:a,scrollLeftChanged:o,heightChanged:c,scrollHeightChanged:f,scrollTopChanged:p}}},Jw=class extends Re{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new he),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Qw(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let s;t?s=new Cv(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=Cv.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},wv=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Qh(e,t){let n=t-e;return function(s){return e+n*iC(s)}}function eC(e,t,n){return function(s){return s2.5*s){let a,o;return t{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},rC=140,Tb=class extends Md{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new nC(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Eb),this._shouldRender=!0,this.domNode=aa(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(we(this.domNode.domNode,Bt.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Zw(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=aa(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(we(this.slider.domNode,Bt.POINTER_DOWN,a=>{a.button===0&&(a.preventDefault(),this._sliderPointerDown(a))})),this.onclick(this.slider.domNode,a=>{a.leftButton&&a.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),a=this._sliderPointerPosition(e);n<=a&&a<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let a=Kw(this.domNode.domNode);t=e.pageX-a.left,n=e.pageY-a.top}let s=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,a=>{let o=this._sliderOrthogonalPointerPosition(a),c=Math.abs(o-n);if(xb&&c>rC){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let f=this._sliderPointerPosition(a)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(f))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Ab=class Vf{constructor(t,n,s,a,o,c){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=a,this._scrollSize=o,this._scrollPosition=c,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Vf(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,s,a,o){let c=Math.max(0,s-t),f=Math.max(0,c-2*n),p=a>0&&a>s;if(!p)return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(f),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(s*f/a))),g=(f-h)/(a-s),_=o*g;return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(h),computedSliderRatio:g,computedSliderPosition:Math.round(_)}}_refreshComputedValues(){let t=Vf._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,s=this._scrollPosition;return n0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),n){let a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),c=Math.abs(n.deltaX),f=Math.abs(n.deltaY),p=Math.max(Math.min(a,c),1),h=Math.max(Math.min(o,f),1),g=Math.max(a,c),_=Math.max(o,f);g%p===0&&_%h===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Kf.INSTANCE=new Kf;var uC=Kf,cC=class extends Md{constructor(e,t,n){super(),this._onScroll=this._register(new he),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new he),this.onWillScroll=this._onWillScroll.event,this._options=fC(t),this._scrollable=n,this._register(this._scrollable.onScroll(a=>{this._onWillScroll.fire(a),this._onDidScroll(a),this._onScroll.fire(a)}));let s={onMouseWheel:a=>this._onMouseWheel(a),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new lC(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new sC(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=aa(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=aa(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=aa(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,a=>this._onMouseOver(a)),this.onmouseleave(this._listenOnDomNode,a=>this._onMouseLeave(a)),this._hideTimeout=this._register(new Dd),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Yr(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,un&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new vv(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Yr(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new vv(n))};this._mouseWheelToDispose.push(we(this._listenOnDomNode,Bt.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var a;if((a=e.browserEvent)!=null&&a.defaultPrevented)return;let t=uC.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+o===0?c=o=0:Math.abs(o)>=Math.abs(c)?c=0:o=0),this._options.flipAxes&&([o,c]=[c,o]);let f=!un&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||f)&&!c&&(c=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),h={};if(o){let g=kv*o,_=p.scrollTop-(g<0?Math.floor(g):Math.ceil(g));this._verticalScrollbar.writeScrollPosition(h,_)}if(c){let g=kv*c,_=p.scrollLeft-(g<0?Math.floor(g):Math.ceil(g));this._horizontalScrollbar.writeScrollPosition(h,_)}h=this._scrollable.validateScrollPosition(h),(p.scrollLeft!==h.scrollLeft||p.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),n=!0)}let s=n;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,s=n?" left":"",a=t?" top":"",o=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${a}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${a}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),aC)}},hC=class extends cC{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function fC(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,un&&(t.className+=" mac"),t}var Xf=class extends Re{constructor(e,t,n,s,a,o,c,f){super(),this._bufferService=n,this._optionsService=c,this._renderService=f,this._onRequestScrollLines=this._register(new he),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new Jw({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Rd(s.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new hC(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},p)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(a.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Kt.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(lt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(lt(()=>this._styleElement.remove())),this._register(Kt.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(` -`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(h=>this._handleScroll(h)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};Xf=dt([de(2,si),de(3,zn),de(4,ob),de(5,Ks),de(6,li),de(7,On)],Xf);var $f=class extends Re{constructor(e,t,n,s,a){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=s,this._renderService=a,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(lt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};$f=dt([de(1,si),de(2,zn),de(3,va),de(4,On)],$f);var dC=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},rn={full:0,left:0,center:0,right:0},cr={full:0,left:0,center:0,right:0},Yl={full:0,left:0,center:0,right:0},uu=class extends Re{constructor(e,t,n,s,a,o,c,f){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=a,this._optionsService=o,this._themeService=c,this._coreBrowserService=f,this._colorZoneStore=new dC,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(h=this._viewportElement.parentElement)==null||h.insertBefore(this._canvas,this._viewportElement),this._register(lt(()=>{var g;return(g=this._canvas)==null?void 0:g.remove()}));let p=this._canvas.getContext("2d");if(p)this._ctx=p;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);cr.full=this._canvas.width,cr.left=e,cr.center=t,cr.right=e,this._refreshDrawHeightConstants(),Yl.full=1,Yl.left=1,Yl.center=1+cr.left,Yl.right=1+cr.left+cr.center}_refreshDrawHeightConstants(){rn.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);rn.left=t,rn.center=t,rn.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*rn.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*rn.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*rn.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*rn.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Yl[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-rn[e.position||"full"]/2),cr[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+rn[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};uu=dt([de(2,si),de(3,va),de(4,On),de(5,li),de(6,Ks),de(7,zn)],uu);var re;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=` -`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(re||(re={}));var nu;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(nu||(nu={}));var Db;(e=>e.ST=`${re.ESC}\\`)(Db||(Db={}));var Gf=class{constructor(e,t,n,s,a,o){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=s,this._coreService=a,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.lengththis.updateCompositionElements(!0),0)}}};Gf=dt([de(2,si),de(3,li),de(4,Xr),de(5,On)],Gf);var Nt=0,Lt=0,zt=0,ht=0,Ev={css:"#00000000",rgba:0},wt;(e=>{function t(a,o,c,f){return f!==void 0?`#${jr(a)}${jr(o)}${jr(c)}${jr(f)}`:`#${jr(a)}${jr(o)}${jr(c)}`}e.toCss=t;function n(a,o,c,f=255){return(a<<24|o<<16|c<<8|f)>>>0}e.toRgba=n;function s(a,o,c,f){return{css:e.toCss(a,o,c,f),rgba:e.toRgba(a,o,c,f)}}e.toColor=s})(wt||(wt={}));var rt;(e=>{function t(p,h){if(ht=(h.rgba&255)/255,ht===1)return{css:h.css,rgba:h.rgba};let g=h.rgba>>24&255,_=h.rgba>>16&255,b=h.rgba>>8&255,y=p.rgba>>24&255,x=p.rgba>>16&255,k=p.rgba>>8&255;Nt=y+Math.round((g-y)*ht),Lt=x+Math.round((_-x)*ht),zt=k+Math.round((b-k)*ht);let L=wt.toCss(Nt,Lt,zt),R=wt.toRgba(Nt,Lt,zt);return{css:L,rgba:R}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,h,g){let _=ru.ensureContrastRatio(p.rgba,h.rgba,g);if(_)return wt.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function a(p){let h=(p.rgba|255)>>>0;return[Nt,Lt,zt]=ru.toChannels(h),{css:wt.toCss(Nt,Lt,zt),rgba:h}}e.opaque=a;function o(p,h){return ht=Math.round(h*255),[Nt,Lt,zt]=ru.toChannels(p.rgba),{css:wt.toCss(Nt,Lt,zt,ht),rgba:wt.toRgba(Nt,Lt,zt,ht)}}e.opacity=o;function c(p,h){return ht=p.rgba&255,o(p,ht*h/255)}e.multiplyOpacity=c;function f(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=f})(rt||(rt={}));var ot;(e=>{let t,n;try{let a=document.createElement("canvas");a.width=1,a.height=1;let o=a.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return Nt=parseInt(a.slice(1,2).repeat(2),16),Lt=parseInt(a.slice(2,3).repeat(2),16),zt=parseInt(a.slice(3,4).repeat(2),16),wt.toColor(Nt,Lt,zt);case 5:return Nt=parseInt(a.slice(1,2).repeat(2),16),Lt=parseInt(a.slice(2,3).repeat(2),16),zt=parseInt(a.slice(3,4).repeat(2),16),ht=parseInt(a.slice(4,5).repeat(2),16),wt.toColor(Nt,Lt,zt,ht);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let o=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Nt=parseInt(o[1]),Lt=parseInt(o[2]),zt=parseInt(o[3]),ht=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),wt.toColor(Nt,Lt,zt,ht);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Nt,Lt,zt,ht]=t.getImageData(0,0,1,1).data,ht!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:wt.toRgba(Nt,Lt,zt,ht),css:a}}e.toColor=s})(ot||(ot={}));var ii;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,a,o){let c=s/255,f=a/255,p=o/255,h=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),_=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return h*.2126+g*.7152+_*.0722}e.relativeLuminance2=n})(ii||(ii={}));var ru;(e=>{function t(c,f){if(ht=(f&255)/255,ht===1)return f;let p=f>>24&255,h=f>>16&255,g=f>>8&255,_=c>>24&255,b=c>>16&255,y=c>>8&255;return Nt=_+Math.round((p-_)*ht),Lt=b+Math.round((h-b)*ht),zt=y+Math.round((g-y)*ht),wt.toRgba(Nt,Lt,zt)}e.blend=t;function n(c,f,p){let h=ii.relativeLuminance(c>>8),g=ii.relativeLuminance(f>>8);if(Mn(h,g)>8));if(x>8));return x>L?y:k}return y}let _=a(c,f,p),b=Mn(h,ii.relativeLuminance(_>>8));if(b>8));return b>x?_:y}return _}}e.ensureContrastRatio=n;function s(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=Mn(ii.relativeLuminance2(b,y,x),ii.relativeLuminance2(h,g,_));for(;k0||y>0||x>0);)b-=Math.max(0,Math.ceil(b*.1)),y-=Math.max(0,Math.ceil(y*.1)),x-=Math.max(0,Math.ceil(x*.1)),k=Mn(ii.relativeLuminance2(b,y,x),ii.relativeLuminance2(h,g,_));return(b<<24|y<<16|x<<8|255)>>>0}e.reduceLuminance=s;function a(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=Mn(ii.relativeLuminance2(b,y,x),ii.relativeLuminance2(h,g,_));for(;k>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(ru||(ru={}));function jr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Mn(e,t){return e1){let g=this._getJoinedRanges(s,c,o,t,a);for(let _=0;_1){let h=this._getJoinedRanges(s,c,o,t,a);for(let g=0;g=F,j=E,P=this._workCell;if(b.length>0&&E===b[0][0]&&A){let He=b.shift(),yi=this._isCellInSelection(He[0],t);for($=He[0]+1;$=He[1]),A?(N=!0,P=new pC(this._workCell,e.translateToString(!0,He[0],He[1]),He[1]-He[0]),j=He[1]-1,B=P.getWidth()):F=He[1]}let oe=this._isCellInSelection(E,t),T=n&&E===o,D=H&&E>=h&&E<=g,V=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,He=>{V=!0});let w=P.getChars()||mr;if(w===" "&&(P.isUnderline()||P.isOverline())&&(w=" "),pe=B*f-p.get(w,P.isBold(),P.isItalic()),!k)k=this._document.createElement("span");else if(L&&(oe&&ce||!oe&&!ce&&P.bg===I)&&(oe&&ce&&y.selectionForeground||P.fg===Z)&&P.extended.ext===Y&&D===O&&pe===J&&!T&&!N&&!V&&A){P.isInvisible()?R+=mr:R+=w,L++;continue}else L&&(k.textContent=R),k=this._document.createElement("span"),L=0,R="";if(I=P.bg,Z=P.fg,Y=P.extended.ext,O=D,J=pe,ce=oe,N&&o>=E&&o<=j&&(o=E),!this._coreService.isCursorHidden&&T&&this._coreService.isCursorInitialized){if(se.push("xterm-cursor"),this._coreBrowserService.isFocused)c&&se.push("xterm-cursor-blink"),se.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":se.push("xterm-cursor-outline");break;case"block":se.push("xterm-cursor-block");break;case"bar":se.push("xterm-cursor-bar");break;case"underline":se.push("xterm-cursor-underline");break}}if(P.isBold()&&se.push("xterm-bold"),P.isItalic()&&se.push("xterm-italic"),P.isDim()&&se.push("xterm-dim"),P.isInvisible()?R=mr:R=P.getChars()||mr,P.isUnderline()&&(se.push(`xterm-underline-${P.extended.underlineStyle}`),R===" "&&(R=" "),!P.isUnderlineColorDefault()))if(P.isUnderlineColorRGB())k.style.textDecorationColor=`rgb(${ga.toColorRGB(P.getUnderlineColor()).join(",")})`;else{let He=P.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&P.isBold()&&He<8&&(He+=8),k.style.textDecorationColor=y.ansi[He].css}P.isOverline()&&(se.push("xterm-overline"),R===" "&&(R=" ")),P.isStrikethrough()&&se.push("xterm-strikethrough"),D&&(k.style.textDecoration="underline");let ie=P.getFgColor(),ae=P.getFgColorMode(),le=P.getBgColor(),ge=P.getBgColorMode(),Ee=!!P.isInverse();if(Ee){let He=ie;ie=le,le=He;let yi=ae;ae=ge,ge=yi}let Se,Ze,Fe=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,He=>{He.options.layer!=="top"&&Fe||(He.backgroundColorRGB&&(ge=50331648,le=He.backgroundColorRGB.rgba>>8&16777215,Se=He.backgroundColorRGB),He.foregroundColorRGB&&(ae=50331648,ie=He.foregroundColorRGB.rgba>>8&16777215,Ze=He.foregroundColorRGB),Fe=He.options.layer==="top")}),!Fe&&oe&&(Se=this._coreBrowserService.isFocused?y.selectionBackgroundOpaque:y.selectionInactiveBackgroundOpaque,le=Se.rgba>>8&16777215,ge=50331648,Fe=!0,y.selectionForeground&&(ae=50331648,ie=y.selectionForeground.rgba>>8&16777215,Ze=y.selectionForeground)),Fe&&se.push("xterm-decoration-top");let ai;switch(ge){case 16777216:case 33554432:ai=y.ansi[le],se.push(`xterm-bg-${le}`);break;case 50331648:ai=wt.toColor(le>>16,le>>8&255,le&255),this._addStyle(k,`background-color:#${Tv((le>>>0).toString(16),"0",6)}`);break;case 0:default:Ee?(ai=y.foreground,se.push("xterm-bg-257")):ai=y.background}switch(Se||P.isDim()&&(Se=rt.multiplyOpacity(ai,.5)),ae){case 16777216:case 33554432:P.isBold()&&ie<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ie+=8),this._applyMinimumContrast(k,ai,y.ansi[ie],P,Se,void 0)||se.push(`xterm-fg-${ie}`);break;case 50331648:let He=wt.toColor(ie>>16&255,ie>>8&255,ie&255);this._applyMinimumContrast(k,ai,He,P,Se,Ze)||this._addStyle(k,`color:#${Tv(ie.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(k,ai,y.foreground,P,Se,Ze)||Ee&&se.push("xterm-fg-257")}se.length&&(k.className=se.join(" "),se.length=0),!T&&!N&&!V&&A?L++:k.textContent=R,pe!==this.defaultSpacing&&(k.style.letterSpacing=`${pe}px`),_.push(k),E=j}return k&&L&&(k.textContent=R),_}_applyMinimumContrast(e,t,n,s,a,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||gC(s.getCode()))return!1;let c=this._getContrastCache(s),f;if(!a&&!o&&(f=c.getColor(t.rgba,n.rgba)),f===void 0){let p=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);f=rt.ensureContrastRatio(a||t,o||n,p),c.setColor((a||t).rgba,(o||n).rgba,f??null)}return f?(this._addStyle(e,`color:${f.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t=n[0]&&e=n[0]}};Zf=dt([de(1,hb),de(2,li),de(3,zn),de(4,Xr),de(5,va),de(6,Ks)],Zf);function Tv(e,t,n){for(;e.length0&&(this._flat[s]=c),c}let a=e;t&&(a+="B"),n&&(a+="I");let o=this._holey.get(a);if(o===void 0){let c=0;t&&(c|=1),n&&(c|=2),o=this._measure(e,c),o>0&&this._holey.set(a,o)}return o}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},bC=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let a=e.buffers.active.ydisp,o=t[1]-a,c=n[1]-a,f=Math.max(o,0),p=Math.min(c,e.rows-1);if(f>=e.rows||p<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=o,this.viewportEndRow=c,this.viewportCappedStartRow=f,this.viewportCappedEndRow=p,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n=this.startCol&&t=this.startCol):!1}};function SC(){return new bC}var Jh="xterm-dom-renderer-owner-",Fi="xterm-rows",Ko="xterm-fg-",Av="xterm-bg-",Vl="xterm-focus",Xo="xterm-selection",xC=1,Qf=class extends Re{constructor(e,t,n,s,a,o,c,f,p,h,g,_,b,y){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=a,this._helperContainer=o,this._linkifier2=c,this._charSizeService=p,this._optionsService=h,this._bufferService=g,this._coreService=_,this._coreBrowserService=b,this._themeService=y,this._terminalClass=xC++,this._rowElements=[],this._selectionRenderModel=SC(),this.onRequestRedraw=this._register(new he).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Fi),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Xo),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=vC(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(x=>this._injectCss(x))),this._injectCss(this._themeService.colors),this._rowFactory=f.createInstance(Zf,document),this._element.classList.add(Jh+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(x=>this._handleLinkHover(x))),this._register(this._linkifier2.onHideLinkUnderline(x=>this._handleLinkLeave(x))),this._register(lt(()=>{this._element.classList.remove(Jh+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new yC(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Fi} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Fi} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Fi} .xterm-dim { color: ${rt.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,a=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${a} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Fi}.${Vl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Fi}.${Vl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Fi}.${Vl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${Fi} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Fi} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Fi} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Fi} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Fi} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Xo} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Xo} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Xo} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,c]of e.ansi.entries())t+=`${this._terminalSelector} .${Ko}${o} { color: ${c.css}; }${this._terminalSelector} .${Ko}${o}.xterm-dim { color: ${rt.multiplyOpacity(c,.5).css}; }${this._terminalSelector} .${Av}${o} { background-color: ${c.css}; }`;t+=`${this._terminalSelector} .${Ko}257 { color: ${rt.opaque(e.background).css}; }${this._terminalSelector} .${Ko}257.xterm-dim { color: ${rt.multiplyOpacity(rt.opaque(e.background),.5).css}; }${this._terminalSelector} .${Av}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Vl),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Vl),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,a=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,c=this._selectionRenderModel.viewportCappedEndRow,f=this._document.createDocumentFragment();if(n){let p=e[0]>t[0];f.appendChild(this._createSelectionElement(o,p?t[0]:e[0],p?e[0]:t[0],c-o+1))}else{let p=s===o?e[0]:0,h=o===a?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(o,p,h));let g=c-o-1;if(f.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,g)),o!==c){let _=a===c?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(c,0,_))}}this._selectionContainer.appendChild(f)}_createSelectionElement(e,t,n,s=1){let a=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,c=this.dimensions.css.cell.width*(n-t);return o+c>this.dimensions.css.canvas.width&&(c=this.dimensions.css.canvas.width-o),a.style.height=`${s*this.dimensions.css.cell.height}px`,a.style.top=`${e*this.dimensions.css.cell.height}px`,a.style.left=`${o}px`,a.style.width=`${c}px`,a}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,s=n.ybase+n.y,a=Math.min(n.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,c=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=e;p<=t;p++){let h=p+n.ydisp,g=this._rowElements[p],_=n.lines.get(h);if(!g||!_)break;g.replaceChildren(...this._rowFactory.createRow(_,h,h===s,c,f,a,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Jh}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,s,a,o){n<0&&(e=0),s<0&&(t=0);let c=this._bufferService.rows-1;n=Math.max(Math.min(n,c),0),s=Math.max(Math.min(s,c),0),a=Math.min(a,this._bufferService.cols);let f=this._bufferService.buffer,p=f.ybase+f.y,h=Math.min(f.x,a-1),g=this._optionsService.rawOptions.cursorBlink,_=this._optionsService.rawOptions.cursorStyle,b=this._optionsService.rawOptions.cursorInactiveStyle;for(let y=n;y<=s;++y){let x=y+f.ydisp,k=this._rowElements[y],L=f.lines.get(x);if(!k||!L)break;k.replaceChildren(...this._rowFactory.createRow(L,x,x===p,_,b,h,g,this.dimensions.css.cell.width,this._widthCache,o?y===n?e:0:-1,o?(y===s?t:a)-1:-1))}}};Qf=dt([de(7,Cd),de(8,yu),de(9,li),de(10,si),de(11,Xr),de(12,zn),de(13,Ks)],Qf);var Jf=class extends Re{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new he),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new CC(this._optionsService))}catch{this._measureStrategy=this._register(new wC(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Jf=dt([de(2,li)],Jf);var Rb=class extends Re{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},wC=class extends Rb{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},CC=class extends Rb{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},kC=class extends Re{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new EC(this._window)),this._onDprChange=this._register(new he),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new he),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Kt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(we(this._textarea,"focus",()=>this._isFocused=!0)),this._register(we(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},EC=class extends Re{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Ys),this._onDprChange=this._register(new he),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(lt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=we(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},TC=class extends Re{constructor(){super(),this.linkProviders=[],this._register(lt(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Bd(e,t,n){let s=n.getBoundingClientRect(),a=e.getComputedStyle(n),o=parseInt(a.getPropertyValue("padding-left")),c=parseInt(a.getPropertyValue("padding-top"));return[t.clientX-s.left-o,t.clientY-s.top-c]}function AC(e,t,n,s,a,o,c,f,p){if(!o)return;let h=Bd(e,t,n);if(h)return h[0]=Math.ceil((h[0]+(p?c/2:0))/c),h[1]=Math.ceil(h[1]/f),h[0]=Math.min(Math.max(h[0],1),s+(p?1:0)),h[1]=Math.min(Math.max(h[1],1),a),h}var ed=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,a){return AC(window,e,t,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,a)}getMouseReportCoords(e,t){let n=Bd(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};ed=dt([de(0,On),de(1,yu)],ed);var DC=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Mb={};Ux(Mb,{getSafariVersion:()=>MC,isChromeOS:()=>zb,isFirefox:()=>Bb,isIpad:()=>BC,isIphone:()=>NC,isLegacyEdge:()=>RC,isLinux:()=>Nd,isMac:()=>hu,isNode:()=>bu,isSafari:()=>Nb,isWindows:()=>Lb});var bu=typeof process<"u"&&"title"in process,ya=bu?"node":navigator.userAgent,ba=bu?"node":navigator.platform,Bb=ya.includes("Firefox"),RC=ya.includes("Edge"),Nb=/^((?!chrome|android).)*safari/i.test(ya);function MC(){if(!Nb)return 0;let e=ya.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var hu=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(ba),BC=ba==="iPad",NC=ba==="iPhone",Lb=["Windows","Win16","Win32","WinCE"].includes(ba),Nd=ba.indexOf("Linux")>=0,zb=/\bCrOS\b/.test(ya),Ob=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._ia){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=a}this.clear()}},LC=class extends Ob{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},zC=class extends Ob{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},fu=!bu&&"requestIdleCallback"in window?zC:LC,OC=class{constructor(){this._queue=new fu}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},td=class extends Re{constructor(e,t,n,s,a,o,c,f,p){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=a,this._coreBrowserService=f,this._renderer=this._register(new Ys),this._pausedResizeTask=new OC,this._observerDisposable=this._register(new Ys),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new he),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new he),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new he),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new he),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new DC((h,g)=>this._renderRows(h,g),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new jC(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(lt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(c.onResize(()=>this._fullRefresh())),this._register(c.buffers.onBufferActivate(()=>{var h;return(h=this._renderer.value)==null?void 0:h.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(c.cols,c.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(c.buffer.y,c.buffer.y,!0))),this._register(p.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(h=>this._registerIntersectionObserver(h,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=lt(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var n;return(n=this._renderer.value)==null?void 0:n.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,n){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};td=dt([de(2,li),de(3,yu),de(4,Xr),de(5,va),de(6,si),de(7,zn),de(8,Ks)],td);var jC=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function HC(e,t,n,s){let a=n.buffer.x,o=n.buffer.y;if(!n.buffer.hasScrollback)return IC(a,o,e,t,n,s)+Su(o,t,n,s)+FC(a,o,e,t,n,s);let c;if(o===t)return c=a>e?"D":"C",fa(Math.abs(a-e),ha(c,s));c=o>t?"D":"C";let f=Math.abs(o-t),p=PC(o>t?e:a,n)+(f-1)*n.cols+1+UC(o>t?a:e);return fa(p,ha(c,s))}function UC(e,t){return e-1}function PC(e,t){return t.cols-e}function IC(e,t,n,s,a,o){return Su(t,s,a,o).length===0?"":fa(Hb(e,t,e,t-Vr(t,a),!1,a).length,ha("D",o))}function Su(e,t,n,s){let a=e-Vr(e,n),o=t-Vr(t,n),c=Math.abs(a-o)-qC(e,t,n);return fa(c,ha(jb(e,t),s))}function FC(e,t,n,s,a,o){let c;Su(t,s,a,o).length>0?c=s-Vr(s,a):c=t;let f=s,p=WC(e,t,n,s,a,o);return fa(Hb(e,c,n,f,p==="C",a).length,ha(p,o))}function qC(e,t,n){var c;let s=0,a=e-Vr(e,n),o=t-Vr(t,n);for(let f=0;f=0&&e0?c=s-Vr(s,a):c=t,e=n&&ct?"A":"B"}function Hb(e,t,n,s,a,o){let c=e,f=t,p="";for(;(c!==n||f!==s)&&f>=0&&fo.cols-1?(p+=o.buffer.translateBufferLineToString(f,!1,e,c),c=0,e=0,f++):!a&&c<0&&(p+=o.buffer.translateBufferLineToString(f,!1,0,e+1),c=o.cols-1,e=c,f--);return p+o.buffer.translateBufferLineToString(f,!1,e,c)}function ha(e,t){let n=t?"O":"[";return re.ESC+n+e}function fa(e,t){e=Math.floor(e);let n="";for(let s=0;sthis._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Dv(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var ef=50,VC=15,KC=50,XC=500,$C=" ",GC=new RegExp($C,"g"),id=class extends Re{constructor(e,t,n,s,a,o,c,f,p){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=a,this._mouseService=o,this._optionsService=c,this._renderService=f,this._coreBrowserService=p,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Vi,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new he),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new he),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new he),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new he),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=h=>this._handleMouseMove(h),this._mouseUpListener=h=>this._handleMouseUp(h),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(h=>this._handleTrim(h)),this._register(this._bufferService.buffers.onBufferActivate(h=>this._handleBufferActivate(h))),this.enable(),this._model=new YC(this._bufferService),this._activeSelectionMode=0,this._register(lt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(h=>{h.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let a=e[0]a.replace(GC," ")).join(Lb?`\r -`:` -`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Nd&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s||!t?!1:this._areCoordsInSelection(t,n,s)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,t],n,s)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){var a,o;let n=(o=(a=this._linkifier.currentLink)==null?void 0:a.link)==null?void 0:o.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=Dv(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Bd(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-ef),ef),t/=ef,t/Math.abs(t)+Math.round(t*(VC-1)))}shouldForceSelection(e){return hu?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),KC)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(hu&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&tthis._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let s=0;t>=s;s++){let a=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:a>1&&t!==s&&(n+=a-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let a=this._bufferService.buffer,o=a.lines.get(e[1]);if(!o)return;let c=a.translateBufferLineToString(e[1],!1),f=this._convertViewportColToCharacterIndex(o,e[0]),p=f,h=e[0]-f,g=0,_=0,b=0,y=0;if(c.charAt(f)===" "){for(;f>0&&c.charAt(f-1)===" ";)f--;for(;p1&&(y+=$-1,p+=$-1);L>0&&f>0&&!this._isCharWordSeparator(o.loadCell(L-1,this._workCell));){o.loadCell(L-1,this._workCell);let I=this._workCell.getChars().length;this._workCell.getWidth()===0?(g++,L--):I>1&&(b+=I-1,f-=I-1),f--,L--}for(;R1&&(y+=I-1,p+=I-1),p++,R++}}p++;let x=f+h-g+b,k=Math.min(this._bufferService.cols,p-f+g+_-b-y);if(!(!t&&c.slice(f,p).trim()==="")){if(n&&x===0&&o.getCodePoint(0)!==32){let L=a.lines.get(e[1]-1);if(L&&o.isWrapped&&L.getCodePoint(this._bufferService.cols-1)!==32){let R=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(R){let $=this._bufferService.cols-R.start;x-=$,k+=$}}}if(s&&x+k===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let L=a.lines.get(e[1]+1);if(L!=null&&L.isWrapped&&L.getCodePoint(0)!==32){let R=this._getWordAt([0,e[1]+1],!1,!1,!0);R&&(k+=R.length)}}return{start:x,length:k}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Dv(n,this._bufferService.cols)}};id=dt([de(3,si),de(4,Xr),de(5,kd),de(6,li),de(7,On),de(8,zn)],id);var Rv=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Mv=class{constructor(){this._color=new Rv,this._css=new Rv}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Et=Object.freeze((()=>{let e=[ot.toColor("#2e3436"),ot.toColor("#cc0000"),ot.toColor("#4e9a06"),ot.toColor("#c4a000"),ot.toColor("#3465a4"),ot.toColor("#75507b"),ot.toColor("#06989a"),ot.toColor("#d3d7cf"),ot.toColor("#555753"),ot.toColor("#ef2929"),ot.toColor("#8ae234"),ot.toColor("#fce94f"),ot.toColor("#729fcf"),ot.toColor("#ad7fa8"),ot.toColor("#34e2e2"),ot.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],a=t[n/6%6|0],o=t[n%6];e.push({css:wt.toCss(s,a,o),rgba:wt.toRgba(s,a,o)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:wt.toCss(s,s,s),rgba:wt.toRgba(s,s,s)})}return e})()),Ir=ot.toColor("#ffffff"),na=ot.toColor("#000000"),Bv=ot.toColor("#ffffff"),Nv=na,Kl={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},ZC=Ir,nd=class extends Re{constructor(e){super(),this._optionsService=e,this._contrastCache=new Mv,this._halfContrastCache=new Mv,this._onChangeColors=this._register(new he),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Ir,background:na,cursor:Bv,cursorAccent:Nv,selectionForeground:void 0,selectionBackgroundTransparent:Kl,selectionBackgroundOpaque:rt.blend(na,Kl),selectionInactiveBackgroundTransparent:Kl,selectionInactiveBackgroundOpaque:rt.blend(na,Kl),scrollbarSliderBackground:rt.opacity(Ir,.2),scrollbarSliderHoverBackground:rt.opacity(Ir,.4),scrollbarSliderActiveBackground:rt.opacity(Ir,.5),overviewRulerBorder:Ir,ansi:Et.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=Ge(e.foreground,Ir),t.background=Ge(e.background,na),t.cursor=rt.blend(t.background,Ge(e.cursor,Bv)),t.cursorAccent=rt.blend(t.background,Ge(e.cursorAccent,Nv)),t.selectionBackgroundTransparent=Ge(e.selectionBackground,Kl),t.selectionBackgroundOpaque=rt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Ge(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=rt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Ge(e.selectionForeground,Ev):void 0,t.selectionForeground===Ev&&(t.selectionForeground=void 0),rt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=rt.opacity(t.selectionBackgroundTransparent,.3)),rt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=rt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Ge(e.scrollbarSliderBackground,rt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Ge(e.scrollbarSliderHoverBackground,rt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Ge(e.scrollbarSliderActiveBackground,rt.opacity(t.foreground,.5)),t.overviewRulerBorder=Ge(e.overviewRulerBorder,ZC),t.ansi=Et.slice(),t.ansi[0]=Ge(e.black,Et[0]),t.ansi[1]=Ge(e.red,Et[1]),t.ansi[2]=Ge(e.green,Et[2]),t.ansi[3]=Ge(e.yellow,Et[3]),t.ansi[4]=Ge(e.blue,Et[4]),t.ansi[5]=Ge(e.magenta,Et[5]),t.ansi[6]=Ge(e.cyan,Et[6]),t.ansi[7]=Ge(e.white,Et[7]),t.ansi[8]=Ge(e.brightBlack,Et[8]),t.ansi[9]=Ge(e.brightRed,Et[9]),t.ansi[10]=Ge(e.brightGreen,Et[10]),t.ansi[11]=Ge(e.brightYellow,Et[11]),t.ansi[12]=Ge(e.brightBlue,Et[12]),t.ansi[13]=Ge(e.brightMagenta,Et[13]),t.ansi[14]=Ge(e.brightCyan,Et[14]),t.ansi[15]=Ge(e.brightWhite,Et[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;so.index-c.index),s=[];for(let o of n){let c=this._services.get(o.id);if(!c)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);s.push(c)}let a=n.length>0?n[0].index:t.length;if(t.length!==a)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${a+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},e2={trace:0,debug:1,info:2,warn:3,error:4,off:5},t2="xterm.js: ",rd=class extends Re{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=e2[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;s--)this._array[this._getCyclicIndex(s+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;sthis._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let a=t-1;a>=0;a--)this.set(e+a+n,this.get(e+a));let s=e+t+n-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*De+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*De+0]=t|2097152|n[2]<<22):this._data[t*De+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*De+0]>>22}hasWidth(t){return this._data[t*De+0]&12582912}getFg(t){return this._data[t*De+1]}getBg(t){return this._data[t*De+2]}hasContent(t){return this._data[t*De+0]&4194303}getCodePoint(t){let n=this._data[t*De+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*De+0]&2097152}getString(t){let n=this._data[t*De+0];return n&2097152?this._combined[t]:n&2097151?dr(n&2097151):""}isProtected(t){return this._data[t*De+2]&536870912}loadCell(t,n){return $o=t*De,n.content=this._data[$o+0],n.fg=this._data[$o+1],n.bg=this._data[$o+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*De+0]=n.content,this._data[t*De+1]=n.fg,this._data[t*De+2]=n.bg}setCellFromCodepoint(t,n,s,a){a.bg&268435456&&(this._extendedAttrs[t]=a.extended),this._data[t*De+0]=n|s<<22,this._data[t*De+1]=a.fg,this._data[t*De+2]=a.bg}addCodepointToCell(t,n,s){let a=this._data[t*De+0];a&2097152?this._combined[t]+=dr(n):a&2097151?(this._combined[t]=dr(a&2097151)+dr(n),a&=-2097152,a|=2097152):a=n|1<<22,s&&(a&=-12582913,a|=s<<22),this._data[t*De+0]=a}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n=0;--o)this.setCell(t+n+o,this.loadCell(t+o,a));for(let o=0;othis.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let a=new Uint32Array(s);a.set(this._data),this._data=a}for(let a=this.length;a=t&&delete this._combined[f]}let o=Object.keys(this._extendedAttrs);for(let c=0;c=t&&delete this._extendedAttrs[f]}}return this.length=t,s*4*tf=0;--t)if(this._data[t*De+0]&4194303)return t+(this._data[t*De+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*De+0]&4194303||this._data[t*De+2]&50331648)return t+(this._data[t*De+0]>>22);return 0}copyCellsFrom(t,n,s,a,o){let c=t._data;if(o)for(let p=a-1;p>=0;p--){for(let h=0;h=n&&(this._combined[h-n+s]=t._combined[h])}}translateToString(t,n,s,a){n=n??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),a&&(a.length=0);let o="";for(;n>22||1}return a&&a.push(n),o}};function i2(e,t,n,s,a,o){let c=[];for(let f=0;f=f&&s0&&(L>_||g[L].getTrimmedLength()===0);L--)k++;k>0&&(c.push(f+g.length-k),c.push(k)),f+=g.length-1}return c}function n2(e,t){let n=[],s=0,a=t[s],o=0;for(let c=0;cda(e,h,t)).reduce((p,h)=>p+h),o=0,c=0,f=0;for(;fp&&(o-=p,c++);let h=e[c].getWidth(o-1)===2;h&&o--;let g=h?n-1:n;s.push(g),f+=g}return s}function da(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,a=e[t+1].getWidth(0)===2;return s&&a?n-1:n}var Pb=class Ib{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Ib._nextId++,this._onDispose=this.register(new he),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Yr(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Pb._nextId=1;var l2=Pb,Dt={},Fr=Dt.B;Dt[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Dt.A={"#":"£"};Dt.B=void 0;Dt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Dt.C=Dt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Dt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Dt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Dt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Dt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Dt.E=Dt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Dt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Dt.H=Dt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Dt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var zv=4294967295,Ov=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=xt.clone(),this.savedCharset=Fr,this.markers=[],this._nullCell=Vi.fromCharData([0,rb,1,0]),this._whitespaceCell=Vi.fromCharData([0,mr,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new fu,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Lv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new ou),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new ou),this._whitespaceCell}getBlankLine(e,t){return new ra(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&ezv?zv:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=xt);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Lv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(xt),s=0,a=this._getCorrectBufferLength(t);if(a>this.lines.maxLength&&(this.lines.maxLength=a),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new ra(e,n)));else for(let c=this._rows;c>t;c--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(a0&&(this.lines.trimStart(c),this.ybase=Math.max(this.ybase-c,0),this.ydisp=Math.max(this.ydisp-c,0),this.savedY=Math.max(this.savedY-c,0)),this.lines.maxLength=a}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let o=0;o.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=i2(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(xt),n);if(s.length>0){let a=n2(this.lines,s);r2(this.lines,a.layout),this._reflowLargerAdjustViewport(e,t,a.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(xt),a=n;for(;a-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;c--){let f=this.lines.get(c);if(!f||!f.isWrapped&&f.getTrimmedLength()<=e)continue;let p=[f];for(;f.isWrapped&&c>0;)f=this.lines.get(--c),p.unshift(f);if(!n){let I=this.ybase+this.y;if(I>=c&&I0&&(a.push({start:c+p.length+o,newLines:y}),o+=y.length),p.push(...y);let x=g.length-1,k=g[x];k===0&&(x--,k=g[x]);let L=p.length-_-1,R=h;for(;L>=0;){let I=Math.min(R,k);if(p[x]===void 0)break;if(p[x].copyCellsFrom(p[L],R-I,k-I,I,!0),k-=I,k===0&&(x--,k=g[x]),R-=I,R===0){L--;let Z=Math.max(L,0);R=da(p,Z,this._cols)}}for(let I=0;I0;)this.ybase===0?this.y0){let c=[],f=[];for(let k=0;k=0;k--)if(_&&_.start>h+b){for(let L=_.newLines.length-1;L>=0;L--)this.lines.set(k--,_.newLines[L]);k++,c.push({index:h+1,amount:_.newLines.length}),b+=_.newLines.length,_=a[++g]}else this.lines.set(k,f[h--]);let y=0;for(let k=c.length-1;k>=0;k--)c[k].index+=y,this.lines.onInsertEmitter.fire(c[k]),y+=c[k].amount;let x=Math.max(0,p+o-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(e,t,n=0,s){let a=this.lines.get(e);return a?a.translateToString(t,n,s):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+10;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.linen.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},a2=class extends Re{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new he),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new Ov(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Ov(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},Fb=2,qb=1,sd=class extends Re{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new he),this.onResize=this._onResize.event,this._onScroll=this._register(new he),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Fb),this.rows=Math.max(e.rawOptions.rows||0,qb),this.buffers=this._register(new a2(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=n.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let a=n.ybase+n.scrollTop,o=n.ybase+n.scrollBottom;if(n.scrollTop===0){let c=n.lines.isFull;o===n.lines.length-1?c?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(o+1,0,s.clone()),c?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let c=o-a+1;n.lines.shiftElements(a+1,c-1,-1),n.lines.set(o,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),s!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};sd=dt([de(0,li)],sd);var Us={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:hu,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},o2=["normal","bold","100","200","300","400","500","600","700","800","900"],u2=class extends Re{constructor(e){super(),this._onOptionChange=this._register(new he),this.onOptionChange=this._onOptionChange.event;let t={...Us};for(let n in e)if(n in t)try{let s=e[n];t[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(lt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in Us))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in Us))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Us[e]),!c2(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Us[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=o2.includes(t)?t:Us[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function c2(e){return e==="block"||e==="underline"||e==="bar"}function sa(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let s in e)n[s]=t<=1?e[s]:e[s]&&sa(e[s],t-1);return n}var jv=Object.freeze({insertMode:!1}),Hv=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),ld=class extends Re{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new he),this.onData=this._onData.event,this._onUserInput=this._register(new he),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new he),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new he),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=sa(jv),this.decPrivateModes=sa(Hv)}reset(){this.modes=sa(jv),this.decPrivateModes=sa(Hv)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};ld=dt([de(0,si),de(1,ub),de(2,li)],ld);var Uv={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function nf(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var rf=String.fromCharCode,Pv={DEFAULT:e=>{let t=[nf(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${rf(t[0])}${rf(t[1])}${rf(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${nf(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${nf(e,!0)};${e.x};${e.y}${t}`}},ad=class extends Re{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new he),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Uv))this.addProtocol(s,Uv[s]);for(let s of Object.keys(Pv))this.addEncoding(s,Pv[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let s=t/n,a=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(a/=s+0,Math.abs(e.deltaY)<50&&(a*=.3),this._wheelPartialScroll+=a,a=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(a*=this._bufferService.rows),a}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};ad=dt([de(0,si),de(1,Xr),de(2,li)],ad);var sf=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],h2=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Tt;function f2(e,t){let n=0,s=t.length-1,a;if(et[s][1])return!1;for(;s>=n;)if(a=n+s>>1,e>t[a][1])n=a+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let a=qr.extractWidth(t);a===0?s=!1:a>n&&(n=a)}return qr.createPropertyValue(0,n,s)}},qr=class su{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new he,this.onChange=this._onChange.event;let t=new d2;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,s=!1){return(t&16777215)<<3|(n&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,s=0,a=t.length;for(let o=0;o=a)return n+this.wcwidth(c);let h=t.charCodeAt(o);56320<=h&&h<=57343?c=(c-55296)*1024+h-56320+65536:n+=this.wcwidth(h)}let f=this.charProperties(c,s),p=su.extractWidth(f);su.extractShouldJoin(f)&&(p-=su.extractWidth(s)),n+=p,s=f}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},p2=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Iv(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var Xl=2147483647,m2=256,Wb=class od{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>m2)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new od;if(!t.length)return n;for(let s=Array.isArray(t[0])?1:0;s>8,a=this._subParamsIdx[n]&255;a-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,a))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Xl?Xl:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Xl?Xl:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let t={};for(let n=0;n>8,a=this._subParamsIdx[n]&255;a-s>0&&(t[n]=this._subParams.slice(s,a))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,a=s[n-1];s[n-1]=~a?Math.min(a*10+t,Xl):t}},$l=[],_2=class{constructor(){this._state=0,this._active=$l,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=$l}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=$l,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||$l,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",vu(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=$l,this._id=-1,this._state=0}}},Di=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=vu(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},Gl=[],g2=class{constructor(){this._handlers=Object.create(null),this._active=Gl,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Gl}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Gl,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Gl,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",vu(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=Gl,this._ident=0}},la=new Wb;la.addParam(0);var Fv=class{constructor(e){this._handler=e,this._data="",this._params=la,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():la,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=vu(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=la,this._data="",this._hitLimit=!1,n));return this._params=la,this._data="",this._hitLimit=!1,t}},v2=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let a=0;ap),n=(f,p)=>t.slice(f,p),s=n(32,127),a=n(0,24);a.push(25),a.push.apply(a,n(28,32));let o=n(0,14),c;e.setDefault(1,0),e.addMany(s,0,2,0);for(c in o)e.addMany([24,26,153,154],c,3,0),e.addMany(n(128,144),c,3,0),e.addMany(n(144,152),c,3,0),e.add(156,c,0,0),e.add(27,c,11,1),e.add(157,c,4,8),e.addMany([152,158,159],c,0,7),e.add(155,c,11,3),e.add(144,c,11,9);return e.addMany(a,0,3,0),e.addMany(a,1,3,1),e.add(127,1,0,1),e.addMany(a,8,0,8),e.addMany(a,3,3,3),e.add(127,3,0,3),e.addMany(a,4,3,4),e.add(127,4,0,4),e.addMany(a,6,3,6),e.addMany(a,5,3,5),e.add(127,5,0,5),e.addMany(a,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(a,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(a,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(a,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(a,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(a,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(a,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Wi,0,2,0),e.add(Wi,8,5,8),e.add(Wi,6,0,6),e.add(Wi,11,0,11),e.add(Wi,13,13,13),e})(),b2=class extends Re{constructor(e=y2){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Wb,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(lt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new _2),this._dcsParser=this._register(new g2),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let a=0;ao||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=s,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];return s.push(t),{dispose:()=>{let a=s.indexOf(t);a!==-1&&s.splice(a,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];return s.push(t),{dispose:()=>{let a=s.indexOf(t);a!==-1&&s.splice(a,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,s,a){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=a}parse(e,t,n){let s=0,a=0,o=0,c;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let f=this._parseStack.handlers,p=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&p>-1){for(;p>=0&&(c=f[p](this._params),c!==!0);p--)if(c instanceof Promise)return this._parseStack.handlerPos=p,c}this._parseStack.handlers=[];break;case 4:if(n===!1&&p>-1){for(;p>=0&&(c=f[p](),c!==!0);p--)if(c instanceof Promise)return this._parseStack.handlerPos=p,c}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],c=this._dcsParser.unhook(s!==24&&s!==26,n),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],c=this._oscParser.end(s!==24&&s!==26,n),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let f=o;f>4){case 2:for(let b=f+1;;++b){if(b>=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=0&&(c=p[h](this._params),c!==!0);h--)if(c instanceof Promise)return this._preserveStack(3,p,h,a,f),c;h<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++f47&&s<60);f--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let g=this._escHandlers[this._collect<<8|s],_=g?g.length-1:-1;for(;_>=0&&(c=g[_](),c!==!0);_--)if(c instanceof Promise)return this._preserveStack(4,g,_,a,f),c;_<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let b=f+1;;++b)if(b>=t||(s=e[b])===24||s===26||s===27||s>127&&s=t||(s=e[b])<32||s>127&&s>4:o>>8}return s}}function lf(e,t){let n=e.toString(16),s=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function w2(e,t=16){let[n,s,a]=e;return`rgb:${lf(n,t)}/${lf(s,t)}/${lf(a,t)}`}var C2={"(":0,")":1,"*":2,"+":3,"-":1,".":2},hr=131072,Wv=10;function Yv(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Vv=5e3,Kv=0,k2=class extends Re{constructor(e,t,n,s,a,o,c,f,p=new b2){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=a,this._oscLinkService=o,this._coreMouseService=c,this._unicodeService=f,this._parser=p,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Wx,this._utf8Decoder=new Yx,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=xt.clone(),this._eraseAttrDataInternal=xt.clone(),this._onRequestBell=this._register(new he),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new he),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new he),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new he),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new he),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new he),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new he),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new he),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new he),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new he),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new he),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new he),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new he),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new ud(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,g)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:g.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,g,_)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:g,data:_})}),this._parser.setDcsHandlerFallback((h,g,_)=>{g==="HOOK"&&(_=_.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:g,payload:_})}),this._parser.setPrintHandler((h,g,_)=>this.print(h,g,_)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler(re.BEL,()=>this.bell()),this._parser.setExecuteHandler(re.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(re.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(re.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(re.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(re.BS,()=>this.backspace()),this._parser.setExecuteHandler(re.HT,()=>this.tab()),this._parser.setExecuteHandler(re.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(re.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(nu.IND,()=>this.index()),this._parser.setExecuteHandler(nu.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(nu.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Di(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new Di(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new Di(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new Di(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new Di(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new Di(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new Di(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new Di(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new Di(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new Di(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new Di(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new Di(h=>this.restoreCursorColor(h))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let h in Dt)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Fv((h,g)=>this.requestStatusString(h,g)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),Vv))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Vv} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,a=this._activeBuffer.y,o=0,c=this._parseStack.paused;if(c){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,a=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>hr&&(o=this._parseStack.position+hr)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(h=>h.charCodeAt(0)):e),this._parseBuffer.lengthhr)for(let h=o;h0&&_.getWidth(this._activeBuffer.x-1)===2&&_.setCellFromCodepoint(this._activeBuffer.x-1,0,1,g);let b=this._parser.precedingJoinState;for(let y=t;yf){if(p){let R=_,$=this._activeBuffer.x-L;for(this._activeBuffer.x=L,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),_=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),L>0&&_ instanceof ra&&_.copyCellsFrom(R,$,0,L,!1);$=0;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,g);continue}if(h&&(_.insertCells(this._activeBuffer.x,a-L,this._activeBuffer.getNullCell(g)),_.getWidth(f-1)===2&&_.setCellFromCodepoint(f-1,0,1,g)),_.setCellFromCodepoint(this._activeBuffer.x++,s,a,g),a>0)for(;--a;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,g)}this._parser.precedingJoinState=b,this._activeBuffer.x0&&_.getWidth(this._activeBuffer.x)===0&&!_.hasContent(this._activeBuffer.x)&&_.setCellFromCodepoint(this._activeBuffer.x,0,1,g),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>Yv(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Fv(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Di(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,s=!1,a=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),a),s&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&s.getTrimmedLength()););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let a=this._activeBuffer.lines.length-this._bufferService.rows;a>0&&(this._activeBuffer.lines.trimStart(a),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-a,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-a,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y65535?2:1}let p=f;for(let h=1;h0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(re.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(re.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(re.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(re.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(re.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t(k[k.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",k[k.SET=1]="SET",k[k.RESET=2]="RESET",k[k.PERMANENTLY_SET=3]="PERMANENTLY_SET",k[k.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:a,activeEncoding:o}=this._coreMouseService,c=this._coreService,{buffers:f,cols:p}=this._bufferService,{active:h,alt:g}=f,_=this._optionsService.rawOptions,b=(k,L)=>(c.triggerDataEvent(`${re.ESC}[${t?"":"?"}${k};${L}$y`),!0),y=k=>k?1:2,x=e.params[0];return t?x===2?b(x,4):x===4?b(x,y(c.modes.insertMode)):x===12?b(x,3):x===20?b(x,y(_.convertEol)):b(x,0):x===1?b(x,y(s.applicationCursorKeys)):x===3?b(x,_.windowOptions.setWinLines?p===80?2:p===132?1:0:0):x===6?b(x,y(s.origin)):x===7?b(x,y(s.wraparound)):x===8?b(x,3):x===9?b(x,y(a==="X10")):x===12?b(x,y(_.cursorBlink)):x===25?b(x,y(!c.isCursorHidden)):x===45?b(x,y(s.reverseWraparound)):x===66?b(x,y(s.applicationKeypad)):x===67?b(x,4):x===1e3?b(x,y(a==="VT200")):x===1002?b(x,y(a==="DRAG")):x===1003?b(x,y(a==="ANY")):x===1004?b(x,y(s.sendFocus)):x===1005?b(x,4):x===1006?b(x,y(o==="SGR")):x===1015?b(x,4):x===1016?b(x,y(o==="SGR_PIXELS")):x===1048?b(x,1):x===47||x===1047||x===1049?b(x,y(h===g)):x===2004?b(x,y(s.bracketedPasteMode)):x===2026?b(x,y(s.synchronizedOutput)):b(x,0)}_updateAttrColor(e,t,n,s,a){return t===2?(e|=50331648,e&=-16777216,e|=ga.fromColorRGB([n,s,a])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let s=[0,0,-1,0,0,0],a=0,o=0;do{if(s[o+a]=e.params[t+o],e.hasSubParams(t+o)){let c=e.getSubParams(t+o),f=0;do s[1]===5&&(a=1),s[o+f+1+a]=c[f];while(++f=2||s[1]===2&&o+a>=5)break;s[1]&&(a=1)}while(++o+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=xt.fg,e.bg=xt.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,s=this._curAttrData;for(let a=0;a=30&&n<=37?(s.fg&=-50331904,s.fg|=16777216|n-30):n>=40&&n<=47?(s.bg&=-50331904,s.bg|=16777216|n-40):n>=90&&n<=97?(s.fg&=-50331904,s.fg|=16777216|n-90|8):n>=100&&n<=107?(s.bg&=-50331904,s.bg|=16777216|n-100|8):n===0?this._processSGR0(s):n===1?s.fg|=134217728:n===3?s.bg|=67108864:n===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(a)?e.getSubParams(a)[0]:1,s)):n===5?s.fg|=536870912:n===7?s.fg|=67108864:n===8?s.fg|=1073741824:n===9?s.fg|=2147483648:n===2?s.bg|=134217728:n===21?this._processUnderline(2,s):n===22?(s.fg&=-134217729,s.bg&=-134217729):n===23?s.bg&=-67108865:n===24?(s.fg&=-268435457,this._processUnderline(0,s)):n===25?s.fg&=-536870913:n===27?s.fg&=-67108865:n===28?s.fg&=-1073741825:n===29?s.fg&=2147483647:n===39?(s.fg&=-67108864,s.fg|=xt.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=xt.bg&16777215):n===38||n===48||n===58?a+=this._extractColor(e,a,s):n===53?s.bg|=1073741824:n===55?s.bg&=-1073741825:n===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):n===100?(s.fg&=-67108864,s.fg|=xt.fg&16777215,s.bg&=-67108864,s.bg|=xt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${re.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${re.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${re.ESC}[?${t};${n}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=xt.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Yv(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${re.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Wv&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Wv&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let s=n.shift(),a=n.shift();if(/^\d+$/.exec(s)){let o=parseInt(s);if(Xv(o))if(a==="?")t.push({type:0,index:o});else{let c=qv(a);c&&t.push({type:1,index:o,color:c})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),s,a=n.findIndex(o=>o.startsWith("id="));return a!==-1&&(s=n[a].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let s=0;s=this._specialColors.length);++s,++t)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let a=qv(n[s]);a&&this._onColor.fire([{type:1,index:this._specialColors[t],color:a}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let s=0;s=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=xt.clone(),this._eraseAttrDataInternal=xt.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Vi;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t(this._coreService.triggerDataEvent(`${re.ESC}${c}${re.ESC}\\`),!0),s=this._bufferService.buffer,a=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[a.cursorStyle]-(a.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},ud=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){ethis.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Kv=e,e=t,t=Kv),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};ud=dt([de(0,si)],ud);function Xv(e){return 0<=e&&e<256}var E2=5e7,$v=12,T2=50,A2=class extends Re{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new he),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>E2)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],a=this._action(s,t);if(a){let c=f=>performance.now()-n>=$v?setTimeout(()=>this._innerWrite(0,f)):this._innerWrite(n,f);a.catch(f=>(queueMicrotask(()=>{throw f}),Promise.resolve(!1))).then(c);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=$v)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>T2&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},cd=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let f=t.addMarker(t.ybase+t.y),p={data:e,id:this._nextId++,lines:[f]};return f.onDispose(()=>this._removeMarkerFromLink(p,f)),this._dataByLinkId.set(p.id,p),p.id}let n=e,s=this._getEntryIdKey(n),a=this._entriesWithId.get(s);if(a)return this.addLineToLink(a.id,t.ybase+t.y),a.id;let o=t.addMarker(t.ybase+t.y),c={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(c,o)),this._entriesWithId.set(c.key,c),this._dataByLinkId.set(c.id,c),c.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};cd=dt([de(0,si)],cd);var Gv=!1,D2=class extends Re{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Ys),this._onBinary=this._register(new he),this.onBinary=this._onBinary.event,this._onData=this._register(new he),this.onData=this._onData.event,this._onLineFeed=this._register(new he),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new he),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new he),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new he),this._instantiationService=new JC,this.optionsService=this._register(new u2(e)),this._instantiationService.setService(li,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(sd)),this._instantiationService.setService(si,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(rd)),this._instantiationService.setService(ub,this._logService),this.coreService=this._register(this._instantiationService.createInstance(ld)),this._instantiationService.setService(Xr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(ad)),this._instantiationService.setService(ob,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(qr)),this._instantiationService.setService($x,this.unicodeService),this._charsetService=this._instantiationService.createInstance(p2),this._instantiationService.setService(Xx,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(cd),this._instantiationService.setService(cb,this._oscLinkService),this._inputHandler=this._register(new k2(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Kt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Kt.forward(this._bufferService.onResize,this._onResize)),this._register(Kt.forward(this.coreService.onData,this._onData)),this._register(Kt.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new A2((t,n)=>this._inputHandler.parse(t,n))),this._register(Kt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new he),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Gv&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Gv=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,Fb),t=Math.max(t,qb),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Iv.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Iv(this._bufferService),!1))),this._windowsWrappingHeuristics.value=lt(()=>{for(let t of e)t.dispose()})}}},R2={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function M2(e,t,n,s){var c;let a={type:0,cancel:!1,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?a.key=re.ESC+"OA":a.key=re.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?a.key=re.ESC+"OD":a.key=re.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?a.key=re.ESC+"OC":a.key=re.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?a.key=re.ESC+"OB":a.key=re.ESC+"[B");break;case 8:a.key=e.ctrlKey?"\b":re.DEL,e.altKey&&(a.key=re.ESC+a.key);break;case 9:if(e.shiftKey){a.key=re.ESC+"[Z";break}a.key=re.HT,a.cancel=!0;break;case 13:a.key=e.altKey?re.ESC+re.CR:re.CR,a.cancel=!0;break;case 27:a.key=re.ESC,e.altKey&&(a.key=re.ESC+re.ESC),a.cancel=!0;break;case 37:if(e.metaKey)break;o?a.key=re.ESC+"[1;"+(o+1)+"D":t?a.key=re.ESC+"OD":a.key=re.ESC+"[D";break;case 39:if(e.metaKey)break;o?a.key=re.ESC+"[1;"+(o+1)+"C":t?a.key=re.ESC+"OC":a.key=re.ESC+"[C";break;case 38:if(e.metaKey)break;o?a.key=re.ESC+"[1;"+(o+1)+"A":t?a.key=re.ESC+"OA":a.key=re.ESC+"[A";break;case 40:if(e.metaKey)break;o?a.key=re.ESC+"[1;"+(o+1)+"B":t?a.key=re.ESC+"OB":a.key=re.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(a.key=re.ESC+"[2~");break;case 46:o?a.key=re.ESC+"[3;"+(o+1)+"~":a.key=re.ESC+"[3~";break;case 36:o?a.key=re.ESC+"[1;"+(o+1)+"H":t?a.key=re.ESC+"OH":a.key=re.ESC+"[H";break;case 35:o?a.key=re.ESC+"[1;"+(o+1)+"F":t?a.key=re.ESC+"OF":a.key=re.ESC+"[F";break;case 33:e.shiftKey?a.type=2:e.ctrlKey?a.key=re.ESC+"[5;"+(o+1)+"~":a.key=re.ESC+"[5~";break;case 34:e.shiftKey?a.type=3:e.ctrlKey?a.key=re.ESC+"[6;"+(o+1)+"~":a.key=re.ESC+"[6~";break;case 112:o?a.key=re.ESC+"[1;"+(o+1)+"P":a.key=re.ESC+"OP";break;case 113:o?a.key=re.ESC+"[1;"+(o+1)+"Q":a.key=re.ESC+"OQ";break;case 114:o?a.key=re.ESC+"[1;"+(o+1)+"R":a.key=re.ESC+"OR";break;case 115:o?a.key=re.ESC+"[1;"+(o+1)+"S":a.key=re.ESC+"OS";break;case 116:o?a.key=re.ESC+"[15;"+(o+1)+"~":a.key=re.ESC+"[15~";break;case 117:o?a.key=re.ESC+"[17;"+(o+1)+"~":a.key=re.ESC+"[17~";break;case 118:o?a.key=re.ESC+"[18;"+(o+1)+"~":a.key=re.ESC+"[18~";break;case 119:o?a.key=re.ESC+"[19;"+(o+1)+"~":a.key=re.ESC+"[19~";break;case 120:o?a.key=re.ESC+"[20;"+(o+1)+"~":a.key=re.ESC+"[20~";break;case 121:o?a.key=re.ESC+"[21;"+(o+1)+"~":a.key=re.ESC+"[21~";break;case 122:o?a.key=re.ESC+"[23;"+(o+1)+"~":a.key=re.ESC+"[23~";break;case 123:o?a.key=re.ESC+"[24;"+(o+1)+"~":a.key=re.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?a.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?a.key=re.NUL:e.keyCode>=51&&e.keyCode<=55?a.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?a.key=re.DEL:e.keyCode===219?a.key=re.ESC:e.keyCode===220?a.key=re.FS:e.keyCode===221&&(a.key=re.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let f=(c=R2[e.keyCode])==null?void 0:c[e.shiftKey?1:0];if(f)a.key=re.ESC+f;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,h=String.fromCharCode(p);e.shiftKey&&(h=h.toUpperCase()),a.key=re.ESC+h}else if(e.keyCode===32)a.key=re.ESC+(e.ctrlKey?re.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),a.key=re.ESC+p,a.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(a.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?a.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(a.key=re.US),e.key==="@"&&(a.key=re.NUL));break}return a}var _t=0,B2=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new fu,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new fu,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((a,o)=>this._getKey(a)-this._getKey(o)),t=0,n=0,s=new Array(this._array.length+this._insertedValues.length);for(let a=0;a=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(s[a]=e[t],t++):s[a]=this._array[n++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(_t=this._search(t),_t===-1)||this._getKey(this._array[_t])!==t)return!1;do if(this._array[_t]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(_t),!0;while(++_ta-o),t=0,n=new Array(this._array.length-e.length),s=0;for(let a=0;a0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(_t=this._search(e),!(_t<0||_t>=this._array.length)&&this._getKey(this._array[_t])===e))do yield this._array[_t];while(++_t=this._array.length)&&this._getKey(this._array[_t])===e))do t(this._array[_t]);while(++_t=t;){let s=t+n>>1,a=this._getKey(this._array[s]);if(a>e)n=s-1;else if(a0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},af=0,Zv=0,N2=class extends Re{constructor(){super(),this._decorations=new B2(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new he),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new he),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(lt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new L2(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let s=0,a=0;for(let o of this._decorations.getKeyIterator(t))s=o.options.x??0,a=s+(o.options.width??1),e>=s&&e{af=a.options.x??0,Zv=af+(a.options.width??1),e>=af&&e=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let a=s-this._lastRefreshMs,o=this._debounceThresholdMS-a;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Qv=20,du=class extends Re{constructor(e,t,n,s){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let a=this._coreBrowserService.mainDocument;this._accessibilityContainer=a.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=a.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;othis._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=a.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new O2(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(` -`))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(we(a,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(lt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===` -`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Qv+1&&(this._liveRegion.textContent+=Rf.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,s=n.lines.length.toString();for(let a=e;a<=t;a++){let o=n.lines.get(n.ydisp+a),c=[],f=(o==null?void 0:o.translateToString(!0,void 0,void 0,c))||"",p=(n.ydisp+a+1).toString(),h=this._rowElements[a];h&&(f.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=f,this._rowColumns.set(h,c)),h.setAttribute("aria-posinset",p),h.setAttribute("aria-setsize",s),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],a=n.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(a===o||e.relatedTarget!==s)return;let c,f;if(t===0?(c=n,f=this._rowElements.pop(),this._rowContainer.removeChild(f)):(c=this._rowElements.shift(),f=n,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),f.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let p=this._createAccessibilityTreeNode();this._rowElements.unshift(p),this._rowContainer.insertAdjacentElement("afterbegin",p)}else{let p=this._createAccessibilityTreeNode();this._rowElements.push(p),this._rowContainer.appendChild(p)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var f;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:s,offset:((f=s.textContent)==null?void 0:f.length)??0}),!this._rowContainer.contains(n.node))return;let a=({node:p,offset:h})=>{let g=p instanceof Text?p.parentNode:p,_=parseInt(g==null?void 0:g.getAttribute("aria-posinset"),10)-1;if(isNaN(_))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(g);if(!b)return console.warn("columns is null. Race condition?"),null;let y=h=this._terminal.cols&&(++_,y=0),{row:_,column:y}},o=a(t),c=a(n);if(!(!o||!c)){if(o.row>c.row||o.row===c.row&&o.column>=c.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(c.row-o.row)*this._terminal.cols-o.column+c.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;te;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e{var o;Yr(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(o=this._activeProviderReplies)==null||o.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(we(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(we(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(we(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(we(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let s=0;s{o==null||o.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[o,c]of this._linkProviderService.linkProviders.entries())t?(a=this._activeProviderReplies)!=null&&a.get(o)&&(n=this._checkLinkProviderResult(o,e,n)):c.provideLinks(e.y,f=>{var h,g;if(this._isMouseOut)return;let p=f==null?void 0:f.map(_=>({link:_}));(h=this._activeProviderReplies)==null||h.set(o,p),n=this._checkLinkProviderResult(o,e,n),((g=this._activeProviderReplies)==null?void 0:g.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;se?this._bufferService.cols:c.link.range.end.x;for(let h=f;h<=p;h++){if(n.has(h)){a.splice(o--,1);break}n.add(h)}}}}_checkLinkProviderResult(e,t,n){var o;if(!this._activeProviderReplies)return n;let s=this._activeProviderReplies.get(e),a=!1;for(let c=0;cthis._linkAtPosition(f.link,t));c&&(n=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let c=0;cthis._linkAtPosition(p.link,t));if(f){n=!0,this._handleNewLink(f);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&j2(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Yr(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.pointerCursor},set:n=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.underline},set:n=>{var s,a,o;(s=this._currentLink)!=null&&s.state&&((o=(a=this._currentLink)==null?void 0:a.state)==null?void 0:o.decorations.underline)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let s=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,a=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=a&&(this._clearCurrentLink(s,a),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,s=this._bufferService.buffer.ydisp,a=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(a)}_linkLeave(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,a=t.y*this._bufferService.cols+t.x;return n<=a&&a<=s}_positionFromMouseEvent(e,t,n){let s=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,s,a){return{x1:e,y1:t,x2:n,y2:s,cols:this._bufferService.cols,fg:a}}};hd=dt([de(1,kd),de(2,On),de(3,si),de(4,fb)],hd);function j2(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var H2=class extends D2{constructor(e={}){super(e),this._linkifier=this._register(new Ys),this.browser=Mb,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Ys),this._onCursorMove=this._register(new he),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new he),this.onKey=this._onKey.event,this._onRender=this._register(new he),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new he),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new he),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new he),this.onBell=this._onBell.event,this._onFocus=this._register(new he),this._onBlur=this._register(new he),this._onA11yCharEmitter=this._register(new he),this._onA11yTabEmitter=this._register(new he),this._onWillOpen=this._register(new he),this._setup(),this._decorationService=this._instantiationService.createInstance(N2),this._instantiationService.setService(va,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(TC),this._instantiationService.setService(fb,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Bf)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Kt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Kt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Kt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Kt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(lt(()=>{var t,n;this._customKeyEventHandler=void 0,(n=(t=this.element)==null?void 0:t.parentNode)==null||n.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,s="";switch(t.index){case 256:n="foreground",s="10";break;case 257:n="background",s="11";break;case 258:n="cursor",s="12";break;default:n="ansi",s="4;"+t.index}switch(t.type){case 0:let a=rt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${re.ESC}]${s};${w2(a)}${Db.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=wt.toColor(...t.color));else{let o=n;this._themeService.modifyColors(c=>c[o]=wt.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(du,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(re.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(re.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,a=t.getWidth(n),o=this._renderService.dimensions.css.cell.width*a,c=this.buffer.y*this._renderService.dimensions.css.cell.height,f=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=f+"px",this.textarea.style.top=c+"px",this.textarea.style.width=o+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(we(this.element,"copy",t=>{this.hasSelection()&&Fx(t,this._selectionService)}));let e=t=>qx(t,this.textarea,this.coreService,this.optionsService);this._register(we(this.textarea,"paste",e)),this._register(we(this.element,"paste",e)),Bb?this._register(we(this.element,"mousedown",t=>{t.button===2&&ov(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(we(this.element,"contextmenu",t=>{ov(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Nd&&this._register(we(this.element,"auxclick",t=>{t.button===1&&nb(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(we(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(we(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(we(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(we(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(we(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(we(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(we(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var a;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((a=this.element)==null?void 0:a.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(we(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Df.get()),zb||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(kC,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(zn,this._coreBrowserService),this._register(we(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(we(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Jf,this._document,this._helperContainer),this._instantiationService.setService(yu,this._charSizeService),this._themeService=this._instantiationService.createInstance(nd),this._instantiationService.setService(Ks,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(cu),this._instantiationService.setService(hb,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(td,this.rows,this.screenElement)),this._instantiationService.setService(On,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Gf,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(ed),this._instantiationService.setService(kd,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(hd,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Xf,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(id,this.element,this.screenElement,s)),this._instantiationService.setService(Zx,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register(Kt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance($f,this.screenElement)),this._register(we(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(du,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(uu,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(uu,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Qf,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(o){var h,g,_,b,y;let c=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!c)return!1;let f,p;switch(o.overrideType||o.type){case"mousemove":p=32,o.buttons===void 0?(f=3,o.button!==void 0&&(f=o.button<3?o.button:3)):f=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":p=0,f=o.button<3?o.button:3;break;case"mousedown":p=1,f=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let x=o.deltaY;if(x===0||e.coreMouseService.consumeWheelEvent(o,(b=(_=(g=(h=e._renderService)==null?void 0:h.dimensions)==null?void 0:g.device)==null?void 0:_.cell)==null?void 0:b.height,(y=e._coreBrowserService)==null?void 0:y.dpr)===0)return!1;p=x<0?0:1,f=4;break;default:return!1}return p===void 0||f===void 0||f>4?!1:e.coreMouseService.triggerMouseEvent({col:c.col,row:c.row,x:c.x,y:c.y,button:f,action:p,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:o=>(n(o),o.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(o)),wheel:o=>(n(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&n(o)},mousemove:o=>{o.buttons||n(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?s.mousemove||(t.addEventListener("mousemove",a.mousemove),s.mousemove=a.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),o&16?s.wheel||(t.addEventListener("wheel",a.wheel,{passive:!1}),s.wheel=a.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),o&2?s.mouseup||(s.mouseup=a.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),o&4?s.mousedrag||(s.mousedrag=a.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(we(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return n(o),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(o)})),this._register(we(t,"wheel",o=>{var c,f,p,h,g;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,(h=(p=(f=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:f.device)==null?void 0:p.cell)==null?void 0:h.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return this.cancel(o,!0);let _=re.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(_,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var n;(n=this._renderService)==null||n.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){ib(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var n;(n=this._selectionService)==null||n.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=M2(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let s=this.rows-1;return this.scrollLines(n.type===2?-s:s),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===re.ETX||n.key===re.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(U2(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var n;(n=this._charSizeService)==null||n.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Vi)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Jv=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new I2(t)}getNullCell(){return new Vi}},F2=class extends Re{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new he),this.onBufferChange=this._onBufferChange.event,this._normal=new Jv(this._core.buffers.normal,"normal"),this._alternate=new Jv(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},q2=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,s)=>t(n,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},W2=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},Y2=["cols","rows"],sn=0,V2=class extends Re{constructor(e){super(),this._core=this._register(new H2(e)),this._addonManager=this._register(new P2),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],n=(s,a)=>{this._checkReadonlyOptions(s),this._core.options[s]=a};for(let s in this._core.options){let a={get:t.bind(this,s),set:n.bind(this,s)};Object.defineProperty(this._publicOptions,s,a)}}_checkReadonlyOptions(e){if(Y2.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new q2(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new W2(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new F2(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r -`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Df.get()},set promptLabel(e){Df.set(e)},get tooMuchOutput(){return Rf.get()},set tooMuchOutput(e){Rf.set(e)}}}_verifyIntegers(...e){for(sn of e)if(sn===1/0||isNaN(sn)||sn%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(sn of e)if(sn&&(sn===1/0||isNaN(sn)||sn%1!==0||sn<0))throw new Error("This API only accepts positive integers")}};/** - * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. - * @license MIT - * - * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) - * @license MIT - * - * Originally forked from (with the author's permission): - * Fabrice Bellard's javascript vt100 for jslinux: - * http://bellard.org/jslinux/ - * Copyright (c) 2011 Fabrice Bellard - */var K2=2,X2=1,$2=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var _;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((_=this._terminal.options.overviewRuler)==null?void 0:_.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),a=Math.max(0,parseInt(n.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),c={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},f=c.top+c.bottom,p=c.right+c.left,h=s-f,g=a-p-t;return{cols:Math.max(K2,Math.floor(g/e.css.cell.width)),rows:Math.max(X2,Math.floor(h/e.css.cell.height))}}};/** - * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. - * @license MIT - * - * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) - * @license MIT - * - * Originally forked from (with the author's permission): - * Fabrice Bellard's javascript vt100 for jslinux: - * http://bellard.org/jslinux/ - * Copyright (c) 2011 Fabrice Bellard - */var Ot=0,jt=0,Ht=0,ft=0,Gt;(e=>{function t(a,o,c,f){return f!==void 0?`#${Hr(a)}${Hr(o)}${Hr(c)}${Hr(f)}`:`#${Hr(a)}${Hr(o)}${Hr(c)}`}e.toCss=t;function n(a,o,c,f=255){return(a<<24|o<<16|c<<8|f)>>>0}e.toRgba=n;function s(a,o,c,f){return{css:e.toCss(a,o,c,f),rgba:e.toRgba(a,o,c,f)}}e.toColor=s})(Gt||(Gt={}));var G2;(e=>{function t(p,h){if(ft=(h.rgba&255)/255,ft===1)return{css:h.css,rgba:h.rgba};let g=h.rgba>>24&255,_=h.rgba>>16&255,b=h.rgba>>8&255,y=p.rgba>>24&255,x=p.rgba>>16&255,k=p.rgba>>8&255;Ot=y+Math.round((g-y)*ft),jt=x+Math.round((_-x)*ft),Ht=k+Math.round((b-k)*ft);let L=Gt.toCss(Ot,jt,Ht),R=Gt.toRgba(Ot,jt,Ht);return{css:L,rgba:R}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,h,g){let _=lu.ensureContrastRatio(p.rgba,h.rgba,g);if(_)return Gt.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function a(p){let h=(p.rgba|255)>>>0;return[Ot,jt,Ht]=lu.toChannels(h),{css:Gt.toCss(Ot,jt,Ht),rgba:h}}e.opaque=a;function o(p,h){return ft=Math.round(h*255),[Ot,jt,Ht]=lu.toChannels(p.rgba),{css:Gt.toCss(Ot,jt,Ht,ft),rgba:Gt.toRgba(Ot,jt,Ht,ft)}}e.opacity=o;function c(p,h){return ft=p.rgba&255,o(p,ft*h/255)}e.multiplyOpacity=c;function f(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=f})(G2||(G2={}));var Yt;(e=>{let t,n;try{let a=document.createElement("canvas");a.width=1,a.height=1;let o=a.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return Ot=parseInt(a.slice(1,2).repeat(2),16),jt=parseInt(a.slice(2,3).repeat(2),16),Ht=parseInt(a.slice(3,4).repeat(2),16),Gt.toColor(Ot,jt,Ht);case 5:return Ot=parseInt(a.slice(1,2).repeat(2),16),jt=parseInt(a.slice(2,3).repeat(2),16),Ht=parseInt(a.slice(3,4).repeat(2),16),ft=parseInt(a.slice(4,5).repeat(2),16),Gt.toColor(Ot,jt,Ht,ft);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let o=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Ot=parseInt(o[1]),jt=parseInt(o[2]),Ht=parseInt(o[3]),ft=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Gt.toColor(Ot,jt,Ht,ft);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ot,jt,Ht,ft]=t.getImageData(0,0,1,1).data,ft!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Gt.toRgba(Ot,jt,Ht,ft),css:a}}e.toColor=s})(Yt||(Yt={}));var ni;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,a,o){let c=s/255,f=a/255,p=o/255,h=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),_=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return h*.2126+g*.7152+_*.0722}e.relativeLuminance2=n})(ni||(ni={}));var lu;(e=>{function t(c,f){if(ft=(f&255)/255,ft===1)return f;let p=f>>24&255,h=f>>16&255,g=f>>8&255,_=c>>24&255,b=c>>16&255,y=c>>8&255;return Ot=_+Math.round((p-_)*ft),jt=b+Math.round((h-b)*ft),Ht=y+Math.round((g-y)*ft),Gt.toRgba(Ot,jt,Ht)}e.blend=t;function n(c,f,p){let h=ni.relativeLuminance(c>>8),g=ni.relativeLuminance(f>>8);if(Bn(h,g)>8));if(x>8));return x>L?y:k}return y}let _=a(c,f,p),b=Bn(h,ni.relativeLuminance(_>>8));if(b>8));return b>x?_:y}return _}}e.ensureContrastRatio=n;function s(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=Bn(ni.relativeLuminance2(b,y,x),ni.relativeLuminance2(h,g,_));for(;k0||y>0||x>0);)b-=Math.max(0,Math.ceil(b*.1)),y-=Math.max(0,Math.ceil(y*.1)),x-=Math.max(0,Math.ceil(x*.1)),k=Bn(ni.relativeLuminance2(b,y,x),ni.relativeLuminance2(h,g,_));return(b<<24|y<<16|x<<8|255)>>>0}e.reduceLuminance=s;function a(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=Bn(ni.relativeLuminance2(b,y,x),ni.relativeLuminance2(h,g,_));for(;k>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(lu||(lu={}));function Hr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Bn(e,t){return e{let e=[Yt.toColor("#2e3436"),Yt.toColor("#cc0000"),Yt.toColor("#4e9a06"),Yt.toColor("#c4a000"),Yt.toColor("#3465a4"),Yt.toColor("#75507b"),Yt.toColor("#06989a"),Yt.toColor("#d3d7cf"),Yt.toColor("#555753"),Yt.toColor("#ef2929"),Yt.toColor("#8ae234"),Yt.toColor("#fce94f"),Yt.toColor("#729fcf"),Yt.toColor("#ad7fa8"),Yt.toColor("#34e2e2"),Yt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],a=t[n/6%6|0],o=t[n%6];e.push({css:Gt.toCss(s,a,o),rgba:Gt.toRgba(s,a,o)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:Gt.toCss(s,s,s),rgba:Gt.toRgba(s,s,s)})}return e})());function ey(e,t,n){return Math.max(t,Math.min(e,n))}function Q2(e){switch(e){case"&":return"&";case"<":return"<"}return e}var Yb=class{constructor(e){this._buffer=e}serialize(e,t){let n=this._buffer.getNullCell(),s=this._buffer.getNullCell(),a=n,o=e.start.y,c=e.end.y,f=e.start.x,p=e.end.x;this._beforeSerialize(c-o,o,c);for(let h=o;h<=c;h++){let g=this._buffer.getLine(h);if(g){let _=h===e.start.y?f:0,b=h===e.end.y?p:g.length;for(let y=_;y0&&!Nn(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let n="";if(!t){e-this._firstRow>=this._terminal.rows&&((s=this._buffer.getLine(this._cursorStyleRow))==null||s.getCell(this._cursorStyleCol,this._backgroundCell));let a=this._buffer.getLine(e),o=this._buffer.getLine(e+1);if(!o.isWrapped)n=`\r -`,this._lastCursorRow=e+1,this._lastCursorCol=0;else{n="";let c=a.getCell(a.length-1,this._thisRowLastChar),f=a.getCell(a.length-2,this._thisRowLastSecondChar),p=o.getCell(0,this._nextRowFirstChar),h=p.getWidth()>1,g=!1;(p.getChars()&&h?this._nullCellCount<=1:this._nullCellCount<=0)&&((c.getChars()||c.getWidth()===0)&&Nn(c,p)&&(g=!0),h&&(f.getChars()||f.getWidth()===0)&&Nn(c,p)&&Nn(f,p)&&(g=!0)),g||(n="-".repeat(this._nullCellCount+1),n+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(n+="\x1B[A",n+=`\x1B[${a.length-this._nullCellCount}C`,n+=`\x1B[${this._nullCellCount}X`,n+=`\x1B[${a.length-this._nullCellCount}D`,n+="\x1B[B"),this._lastContentCursorRow=e+1,this._lastContentCursorCol=0,this._lastCursorRow=e+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=n,this._currentRow="",this._nullCellCount=0}_diffStyle(e,t){let n=[],s=!Vb(e,t),a=!Nn(e,t),o=!Kb(e,t);if(s||a||o)if(e.isAttributeDefault())t.isAttributeDefault()||n.push(0);else{if(s){let c=e.getFgColor();e.isFgRGB()?n.push(38,2,c>>>16&255,c>>>8&255,c&255):e.isFgPalette()?c>=16?n.push(38,5,c):n.push(c&8?90+(c&7):30+(c&7)):n.push(39)}if(a){let c=e.getBgColor();e.isBgRGB()?n.push(48,2,c>>>16&255,c>>>8&255,c&255):e.isBgPalette()?c>=16?n.push(48,5,c):n.push(c&8?100+(c&7):40+(c&7)):n.push(49)}o&&(e.isInverse()!==t.isInverse()&&n.push(e.isInverse()?7:27),e.isBold()!==t.isBold()&&n.push(e.isBold()?1:22),e.isUnderline()!==t.isUnderline()&&n.push(e.isUnderline()?4:24),e.isOverline()!==t.isOverline()&&n.push(e.isOverline()?53:55),e.isBlink()!==t.isBlink()&&n.push(e.isBlink()?5:25),e.isInvisible()!==t.isInvisible()&&n.push(e.isInvisible()?8:28),e.isItalic()!==t.isItalic()&&n.push(e.isItalic()?3:23),e.isDim()!==t.isDim()&&n.push(e.isDim()?2:22),e.isStrikethrough()!==t.isStrikethrough()&&n.push(e.isStrikethrough()?9:29))}return n}_nextCell(e,t,n,s){if(e.getWidth()===0)return;let a=e.getChars()==="",o=this._diffStyle(e,this._cursorStyle);if(a?!Nn(this._cursorStyle,e):o.length>0){this._nullCellCount>0&&(Nn(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=s,this._currentRow+=`\x1B[${o.join(";")}m`;let c=this._buffer.getLine(n);c!==void 0&&(c.getCell(s,this._cursorStyle),this._cursorStyleRow=n,this._cursorStyleCol=s)}a?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(Nn(this._cursorStyle,this._backgroundCell)?this._currentRow+=`\x1B[${this._nullCellCount}C`:(this._currentRow+=`\x1B[${this._nullCellCount}X`,this._currentRow+=`\x1B[${this._nullCellCount}C`),this._nullCellCount=0),this._currentRow+=e.getChars(),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=s+e.getWidth())}_serializeString(e){let t=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(t=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let n="";for(let o=0;o{h>0?n+=`\x1B[${h}C`:h<0&&(n+=`\x1B[${-h}D`)};f&&((h=>{h>0?n+=`\x1B[${h}B`:h<0&&(n+=`\x1B[${-h}A`)})(o-this._lastCursorRow),p(c-this._lastCursorCol))}let s=this._terminal._core._inputHandler._curAttrData,a=this._diffStyle(s,this._cursorStyle);return a.length>0&&(n+=`\x1B[${a.join(";")}m`),n}},ek=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,n){let s=t.length,a=n===void 0?s:ey(n+e.rows,0,s);return this._serializeBufferByRange(e,t,{start:s-a,end:s-1},!1)}_serializeBufferByRange(e,t,n,s){return new J2(t,e).serialize({start:{x:0,y:typeof n.start=="number"?n.start:n.start.line},end:{x:e.cols,y:typeof n.end=="number"?n.end:n.end.line}},s)}_serializeBufferAsHTML(e,t){var f;let n=e.buffer.active,s=new tk(n,e,t),a=t.onlySelection??!1,o=t.range;if(o)return s.serialize({start:{x:o.startCol,y:(o.startLine,o.startLine)},end:{x:e.cols,y:(o.endLine,o.endLine)}});if(!a){let p=n.length,h=t.scrollback,g=h===void 0?p:ey(h+e.rows,0,p);return s.serialize({start:{x:0,y:p-g},end:{x:e.cols,y:p-1}})}let c=(f=this._terminal)==null?void 0:f.getSelectionPosition();return c!==void 0?s.serialize({start:{x:c.start.x,y:c.start.y},end:{x:c.end.x,y:c.end.y}}):""}_serializeModes(e){let t="",n=e.modes;if(n.applicationCursorKeysMode&&(t+="\x1B[?1h"),n.applicationKeypadMode&&(t+="\x1B[?66h"),n.bracketedPasteMode&&(t+="\x1B[?2004h"),n.insertMode&&(t+="\x1B[4h"),n.originMode&&(t+="\x1B[?6h"),n.reverseWraparoundMode&&(t+="\x1B[?45h"),n.sendFocusMode&&(t+="\x1B[?1004h"),n.wraparoundMode===!1&&(t+="\x1B[?7l"),n.mouseTrackingMode!=="none")switch(n.mouseTrackingMode){case"x10":t+="\x1B[?9h";break;case"vt200":t+="\x1B[?1000h";break;case"drag":t+="\x1B[?1002h";break;case"any":t+="\x1B[?1003h";break}return t}serialize(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let t=e!=null&&e.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,e.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,e==null?void 0:e.scrollback);if(!(e!=null&&e.excludeAltBuffer)&&this._terminal.buffer.active.type==="alternate"){let n=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);t+=`\x1B[?1049h\x1B[H${n}`}return e!=null&&e.excludeModes||(t+=this._serializeModes(this._terminal)),t}serializeAsHTML(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,e||{})}dispose(){}},tk=class extends Yb{constructor(e,t,n){super(e),this._terminal=t,this._options=n,this._currentRow="",this._htmlContent="",t._core._themeService?this._ansiColors=t._core._themeService.colors.ansi:this._ansiColors=Z2}_padStart(e,t,n){return t=t>>0,n=n??" ",e.length>t?e:(t-=e.length,t>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}_beforeSerialize(e,t,n){var c,f;this._htmlContent+="
";let s="#000000",a="#ffffff";(this._options.includeGlobalBackground??!1)&&(s=((c=this._terminal.options.theme)==null?void 0:c.foreground)??"#ffffff",a=((f=this._terminal.options.theme)==null?void 0:f.background)??"#000000");let o=[];o.push("color: "+s+";"),o.push("background-color: "+a+";"),o.push("font-family: "+this._terminal.options.fontFamily+";"),o.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="
"}_afterSerialize(){this._htmlContent+="
",this._htmlContent+="
"}_rowEnd(e,t){this._htmlContent+="
"+this._currentRow+"
",this._currentRow=""}_getHexColor(e,t){let n=t?e.getFgColor():e.getBgColor();if(t?e.isFgRGB():e.isBgRGB())return"#"+[n>>16&255,n>>8&255,n&255].map(s=>this._padStart(s.toString(16),2,"0")).join("");if(t?e.isFgPalette():e.isBgPalette())return this._ansiColors[n].css}_diffStyle(e,t){let n=[],s=!Vb(e,t),a=!Nn(e,t),o=!Kb(e,t);if(s||a||o){let c=this._getHexColor(e,!0);c&&n.push("color: "+c+";");let f=this._getHexColor(e,!1);return f&&n.push("background-color: "+f+";"),e.isInverse()&&n.push("color: #000000; background-color: #BFBFBF;"),e.isBold()&&n.push("font-weight: bold;"),e.isUnderline()&&e.isOverline()?n.push("text-decoration: overline underline;"):e.isUnderline()?n.push("text-decoration: underline;"):e.isOverline()&&n.push("text-decoration: overline;"),e.isBlink()&&n.push("text-decoration: blink;"),e.isInvisible()&&n.push("visibility: hidden;"),e.isItalic()&&n.push("font-style: italic;"),e.isDim()&&n.push("opacity: 0.5;"),e.isStrikethrough()&&n.push("text-decoration: line-through;"),n}}_nextCell(e,t,n,s){if(e.getWidth()===0)return;let a=e.getChars()==="",o=this._diffStyle(e,t);o&&(this._currentRow+=o.length===0?"
":""),a?this._currentRow+=" ":this._currentRow+=Q2(e.getChars())}_serializeString(){return this._htmlContent}};const ik={background:"#F0EBE1",foreground:"#2C1810",cursor:"#8B4513",cursorAccent:"#F0EBE1",selectionBackground:"#D4C5B0",selectionForeground:"#2C1810",black:"#2C1810",red:"#A63D40",green:"#4A7A4A",yellow:"#8B6914",blue:"#4A6FA5",magenta:"#7B4B8A",cyan:"#3D7A7A",white:"#E6DDD0",brightBlack:"#8B7355",brightRed:"#B85C5C",brightGreen:"#5A8A5A",brightYellow:"#A07D1C",brightBlue:"#5A82BA",brightMagenta:"#8E5D9F",brightCyan:"#5A8F8F",brightWhite:"#4A3728"},nk="plotlink-terminal",rk=1,gr="scrollback",ty=10*1024*1024;function Ld(){return new Promise((e,t)=>{const n=indexedDB.open(nk,rk);n.onupgradeneeded=()=>{const s=n.result;s.objectStoreNames.contains(gr)||s.createObjectStore(gr)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function Zl(e,t){const n=t.length>ty?t.slice(-ty):t,s=await Ld();return new Promise((a,o)=>{const c=s.transaction(gr,"readwrite");c.objectStore(gr).put(n,e),c.oncomplete=()=>{s.close(),a()},c.onerror=()=>{s.close(),o(c.error)}})}async function sk(e){const t=await Ld();return new Promise((n,s)=>{const o=t.transaction(gr,"readonly").objectStore(gr).get(e);o.onsuccess=()=>{t.close(),n(o.result??null)},o.onerror=()=>{t.close(),s(o.error)}})}async function iy(e){const t=await Ld();return new Promise((n,s)=>{const a=t.transaction(gr,"readwrite");a.objectStore(gr).delete(e),a.oncomplete=()=>{t.close(),n()},a.onerror=()=>{t.close(),s(a.error)}})}const At=new Map;function lk({token:e,storyName:t,authFetch:n,onSelectStory:s,onDestroySession:a,onArchiveStory:o,confirmedStories:c,renameRef:f}){const p=Q.useRef(null),h=Q.useRef(n),[g,_]=Q.useState([]),[b,y]=Q.useState(new Set),[x,k]=Q.useState(null),[L,R]=Q.useState(null),$=Q.useRef(()=>{});Q.useEffect(()=>{h.current=n},[n]);const I=Q.useCallback(E=>{var N;const{width:B}=E.container.getBoundingClientRect();if(!(B<50))try{E.fit.fit(),((N=E.ws)==null?void 0:N.readyState)===WebSocket.OPEN&&E.ws.send(JSON.stringify({type:"resize",cols:E.term.cols,rows:E.term.rows}))}catch{}},[]),Z=Q.useCallback(E=>{for(const[B,N]of At)N.container.style.display=B===E?"block":"none";if(E){const B=At.get(E);B&&setTimeout(()=>I(B),50)}},[I]),Y=Q.useCallback((E,B,N)=>{const A=window.location.protocol==="https:"?"wss:":"ws:",j=new WebSocket(`${A}//${window.location.host}/ws/terminal?story=${encodeURIComponent(E)}&token=${e}&resume=${N}`);j.onopen=()=>{B.connected=!0,B._retried=!1,y(P=>{const oe=new Set(P);return oe.delete(E),oe}),j.send(JSON.stringify({type:"resize",cols:B.term.cols,rows:B.term.rows}))},j.onmessage=P=>{B.term.write(P.data)},j.onclose=P=>{if(B.connected=!1,B.ws===j){B.ws=null;try{const oe=B.serialize.serialize();Zl(E,oe).catch(()=>{})}catch{}if(P.code===4e3&&!B._retried){B._retried=!0,B.term.write(`\r -\x1B[33m[Resume failed — starting fresh session...]\x1B[0m\r -`),$.current(E,B,!1);return}y(oe=>new Set(oe).add(E))}},B.term.onData(P=>{j.readyState===WebSocket.OPEN&&j.send(P)}),B.ws=j},[e]);Q.useEffect(()=>{$.current=Y},[Y]);const O=Q.useCallback(async(E,B)=>{if(!p.current||At.has(E))return;const{resume:N=!1,autoConnect:A=!0}=B??{},j=document.createElement("div");j.style.width="100%",j.style.height="100%",j.style.display="none",j.style.paddingLeft="10px",j.style.boxSizing="border-box",p.current.appendChild(j);const P=new V2({cols:80,scrollback:5e3,fontSize:13,fontFamily:'"Geist Mono", ui-monospace, monospace',lineHeight:1.05,letterSpacing:0,cursorBlink:!0,cursorStyle:"block",theme:ik,allowTransparency:!1,drawBoldTextInBrightColors:!1,minimumContrastRatio:7}),oe=new $2,T=new ek;P.loadAddon(oe),P.loadAddon(T),P.open(j);const D={term:P,fit:oe,serialize:T,ws:null,container:j,observer:null,connected:!1},V=new ResizeObserver(()=>{var ie;const{width:w}=j.getBoundingClientRect();if(!(w<50))try{oe.fit(),((ie=D.ws)==null?void 0:ie.readyState)===WebSocket.OPEN&&D.ws.send(JSON.stringify({type:"resize",cols:P.cols,rows:P.rows}))}catch{}});V.observe(j),D.observer=V,At.set(E,D),_(w=>[...w,E]);try{const w=await sk(E);w&&P.write(w)}catch{}A?Y(E,D,N):y(w=>new Set(w).add(E)),setTimeout(()=>I(D),50)},[Y,I]),J=Q.useCallback(async(E,B)=>{const N=At.get(E);N&&(N.ws&&(N.ws.close(),N.ws=null),B||(await h.current(`/api/terminal/${encodeURIComponent(E)}`,{method:"DELETE"}).catch(()=>{}),N.term.clear()),Y(E,N,B))},[Y]),ce=Q.useCallback(E=>{const B=At.get(E);if(B){try{const N=B.serialize.serialize();Zl(E,N).catch(()=>{})}catch{}B.observer.disconnect(),B.ws&&B.ws.close(),B.term.dispose(),B.container.remove(),At.delete(E),_(N=>N.filter(A=>A!==E)),y(N=>{const A=new Set(N);return A.delete(E),A}),n(`/api/terminal/${encodeURIComponent(E)}`,{method:"DELETE"}).catch(()=>{}),a==null||a(E)}},[n,a]),pe=Q.useCallback(E=>{var N;const B=At.get(E);B&&(((N=B.ws)==null?void 0:N.readyState)===WebSocket.OPEN&&B.ws.send(`exit -`),iy(E).catch(()=>{}),B.observer.disconnect(),B.ws&&B.ws.close(),B.term.dispose(),B.container.remove(),At.delete(E),_(A=>A.filter(j=>j!==E)),y(A=>{const j=new Set(A);return j.delete(E),j}),n(`/api/terminal/${encodeURIComponent(E)}/discard`,{method:"DELETE"}).catch(()=>{}),a==null||a(E))},[n,a]),F=Q.useCallback(async(E,B)=>{const N=At.get(E);if(!N||At.has(B)||!(await h.current("/api/terminal/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldName:E,newName:B})})).ok)return!1;At.delete(E),At.set(B,N);try{const j=N.serialize.serialize();await iy(E),await Zl(B,j)}catch{}return _(j=>j.map(P=>P===E?B:P)),y(j=>{if(!j.has(E))return j;const P=new Set(j);return P.delete(E),P.add(B),P}),!0},[]);Q.useEffect(()=>(f&&(f.current=F),()=>{f&&(f.current=null)}),[f,F]),Q.useEffect(()=>{t&&(At.has(t)?Z(t):h.current(`/api/terminal/session/${encodeURIComponent(t)}`).then(E=>E.ok?E.json():null).then(E=>{if(!At.has(t)){const B=(E==null?void 0:E.sessionId)&&!(E!=null&&E.running);O(t,{autoConnect:!B}),Z(t)}}).catch(()=>{At.has(t)||(O(t),Z(t))}))},[t,O,Z]),Q.useEffect(()=>{const E=setInterval(()=>{for(const[B,N]of At)if(N.connected)try{const A=N.serialize.serialize();Zl(B,A).catch(()=>{})}catch{}},3e4);return()=>clearInterval(E)},[]),Q.useEffect(()=>()=>{for(const[E,B]of At){try{const N=B.serialize.serialize();Zl(E,N).catch(()=>{})}catch{}B.observer.disconnect(),B.ws&&B.ws.close(),B.term.dispose(),B.container.remove(),h.current(`/api/terminal/${encodeURIComponent(E)}`,{method:"DELETE"}).catch(()=>{})}At.clear()},[]);const se=t?b.has(t):!1,H=g.length===0;return S.jsxs("div",{className:"h-full flex flex-col",children:[!H&&S.jsxs("div",{className:"px-2 py-1 border-b border-border flex items-center gap-1 overflow-x-auto",children:[g.map(E=>S.jsxs("div",{onClick:()=>s==null?void 0:s(E),className:`flex items-center gap-1 px-2 py-0.5 rounded text-xs font-mono cursor-pointer ${E===t?"bg-accent/10 text-accent":"text-muted hover:text-foreground"}`,children:[S.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${b.has(E)?"bg-amber-500":E===t?"bg-green-600":"bg-muted/50"}`}),S.jsx("span",{className:`truncate max-w-[120px] ${E.startsWith("_new_")?"italic":""}`,children:E.startsWith("_new_")?"Untitled":E}),S.jsx("button",{onClick:B=>{B.stopPropagation(),E.startsWith("_new_")?k(E):ce(E)},className:"ml-0.5 text-muted hover:text-error text-[10px] leading-none",title:"Close terminal",children:"×"})]},E)),t!=null&&t.startsWith("_new_")?S.jsx("button",{onClick:()=>k(t),className:"ml-auto px-2 py-0.5 text-xs text-error hover:bg-surface rounded flex items-center gap-1 flex-shrink-0",children:"Cancel ×"}):t&&o&&(c!=null&&c.has(t))?S.jsx("button",{onClick:()=>R(t),className:"ml-auto px-2 py-0.5 text-xs text-muted hover:text-foreground hover:bg-surface rounded flex items-center gap-1 flex-shrink-0",children:"Archive"}):null]}),S.jsxs("div",{className:"relative flex-1 min-h-0",children:[S.jsx("div",{ref:p,className:"h-full"}),H&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-muted",children:S.jsxs("div",{className:"text-center",children:[S.jsx("p",{className:"text-lg font-serif",children:"Select a story on the left menu"}),S.jsx("p",{className:"text-sm mt-1",children:"to start an AI Writer session"})]})}),x&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[S.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Discard this session?"}),S.jsx("p",{className:"text-xs text-muted",children:"This session will be lost — your AI hasn't created a story structure yet."}),S.jsxs("div",{className:"flex items-center justify-center gap-2",children:[S.jsx("button",{onClick:()=>k(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),S.jsx("button",{onClick:()=>{const E=x;k(null),pe(E)},className:"px-4 py-1.5 bg-error text-white text-sm rounded hover:opacity-80",children:"Discard"})]})]})}),L&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[S.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Archive this story?"}),S.jsx("p",{className:"text-xs text-muted",children:"You can restore it later from the Archives view."}),S.jsxs("div",{className:"flex items-center justify-center gap-2",children:[S.jsx("button",{onClick:()=>R(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),S.jsx("button",{onClick:async()=>{const E=L;R(null);try{(await h.current("/api/stories/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:E})})).ok&&(ce(E),o==null||o(E))}catch{}},className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Archive"})]})]})}),se&&t&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3",children:[S.jsx("p",{className:"text-sm font-serif text-foreground",children:"Terminal disconnected"}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("button",{onClick:()=>J(t,!0),className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Resume Session"}),S.jsx("button",{onClick:()=>J(t,!1),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Start Fresh"})]}),S.jsx("p",{className:"text-xs text-muted",children:"Resume continues your previous Claude conversation"})]})})]})]})}function ak(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const ok=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,uk=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ck={};function ny(e,t){return(ck.jsx?uk:ok).test(e)}const hk=/[ \t\n\f\r]/g;function fk(e){return typeof e=="object"?e.type==="text"?ry(e.value):!1:ry(e)}function ry(e){return e.replace(hk,"")===""}class Sa{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}}Sa.prototype.normal={};Sa.prototype.property={};Sa.prototype.space=void 0;function Xb(e,t){const n={},s={};for(const a of e)Object.assign(n,a.property),Object.assign(s,a.normal);return new Sa(n,s,t)}function fd(e){return e.toLowerCase()}class vi{constructor(t,n){this.attribute=n,this.property=t}}vi.prototype.attribute="";vi.prototype.booleanish=!1;vi.prototype.boolean=!1;vi.prototype.commaOrSpaceSeparated=!1;vi.prototype.commaSeparated=!1;vi.prototype.defined=!1;vi.prototype.mustUseProperty=!1;vi.prototype.number=!1;vi.prototype.overloadedBoolean=!1;vi.prototype.property="";vi.prototype.spaceSeparated=!1;vi.prototype.space=void 0;let dk=0;const Ae=$r(),St=$r(),dd=$r(),ue=$r(),tt=$r(),Ws=$r(),Ri=$r();function $r(){return 2**++dk}const pd=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ae,booleanish:St,commaOrSpaceSeparated:Ri,commaSeparated:Ws,number:ue,overloadedBoolean:dd,spaceSeparated:tt},Symbol.toStringTag,{value:"Module"})),of=Object.keys(pd);class zd extends vi{constructor(t,n,s,a){let o=-1;if(super(t,n),sy(this,"space",a),typeof s=="number")for(;++o4&&n.slice(0,4)==="data"&&vk.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(ly,Sk);s="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!ly.test(o)){let c=o.replace(gk,bk);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=zd}return new a(s,t)}function bk(e){return"-"+e.toLowerCase()}function Sk(e){return e.charAt(1).toUpperCase()}const xk=Xb([$b,pk,Qb,Jb,eS],"html"),Od=Xb([$b,mk,Qb,Jb,eS],"svg");function wk(e){return e.join(" ").trim()}var Ps={},uf,ay;function Ck(){if(ay)return uf;ay=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,f=/^\s+|\s+$/g,p=` -`,h="/",g="*",_="",b="comment",y="declaration";function x(L,R){if(typeof L!="string")throw new TypeError("First argument must be a string");if(!L)return[];R=R||{};var $=1,I=1;function Z(B){var N=B.match(t);N&&($+=N.length);var A=B.lastIndexOf(p);I=~A?B.length-A:I+B.length}function Y(){var B={line:$,column:I};return function(N){return N.position=new O(B),pe(),N}}function O(B){this.start=B,this.end={line:$,column:I},this.source=R.source}O.prototype.content=L;function J(B){var N=new Error(R.source+":"+$+":"+I+": "+B);if(N.reason=B,N.filename=R.source,N.line=$,N.column=I,N.source=L,!R.silent)throw N}function ce(B){var N=B.exec(L);if(N){var A=N[0];return Z(A),L=L.slice(A.length),N}}function pe(){ce(n)}function F(B){var N;for(B=B||[];N=se();)N!==!1&&B.push(N);return B}function se(){var B=Y();if(!(h!=L.charAt(0)||g!=L.charAt(1))){for(var N=2;_!=L.charAt(N)&&(g!=L.charAt(N)||h!=L.charAt(N+1));)++N;if(N+=2,_===L.charAt(N-1))return J("End of comment missing");var A=L.slice(2,N-2);return I+=2,Z(A),L=L.slice(N),I+=2,B({type:b,comment:A})}}function H(){var B=Y(),N=ce(s);if(N){if(se(),!ce(a))return J("property missing ':'");var A=ce(o),j=B({type:y,property:k(N[0].replace(e,_)),value:A?k(A[0].replace(e,_)):_});return ce(c),j}}function E(){var B=[];F(B);for(var N;N=H();)N!==!1&&(B.push(N),F(B));return B}return pe(),E()}function k(L){return L?L.replace(f,_):_}return uf=x,uf}var oy;function kk(){if(oy)return Ps;oy=1;var e=Ps&&Ps.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Ps,"__esModule",{value:!0}),Ps.default=n;const t=e(Ck());function n(s,a){let o=null;if(!s||typeof s!="string")return o;const c=(0,t.default)(s),f=typeof a=="function";return c.forEach(p=>{if(p.type!=="declaration")return;const{property:h,value:g}=p;f?a(h,g,p):g&&(o=o||{},o[h]=g)}),o}return Ps}var Ql={},uy;function Ek(){if(uy)return Ql;uy=1,Object.defineProperty(Ql,"__esModule",{value:!0}),Ql.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(h){return!h||n.test(h)||e.test(h)},c=function(h,g){return g.toUpperCase()},f=function(h,g){return"".concat(g,"-")},p=function(h,g){return g===void 0&&(g={}),o(h)?h:(h=h.toLowerCase(),g.reactCompat?h=h.replace(a,f):h=h.replace(s,f),h.replace(t,c))};return Ql.camelCase=p,Ql}var Jl,cy;function Tk(){if(cy)return Jl;cy=1;var e=Jl&&Jl.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(kk()),n=Ek();function s(a,o){var c={};return!a||typeof a!="string"||(0,t.default)(a,function(f,p){f&&p&&(c[(0,n.camelCase)(f,o)]=p)}),c}return s.default=s,Jl=s,Jl}var Ak=Tk();const Dk=gu(Ak),tS=iS("end"),jd=iS("start");function iS(e){return t;function t(n){const s=n&&n.position&&n.position[e]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function nS(e){const t=jd(e),n=tS(e);if(t&&n)return{start:t,end:n}}function oa(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?hy(e.position):"start"in e||"end"in e?hy(e):"line"in e||"column"in e?md(e):""}function md(e){return fy(e&&e.line)+":"+fy(e&&e.column)}function hy(e){return md(e&&e.start)+"-"+md(e&&e.end)}function fy(e){return e&&typeof e=="number"?e:1}class Qt extends Error{constructor(t,n,s){super(),typeof n=="string"&&(s=n,n=void 0);let a="",o={},c=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?a=t:!o.cause&&t&&(c=!0,a=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof s=="string"){const p=s.indexOf(":");p===-1?o.ruleId=s:(o.source=s.slice(0,p),o.ruleId=s.slice(p+1))}if(!o.place&&o.ancestors&&o.ancestors){const p=o.ancestors[o.ancestors.length-1];p&&(o.place=p.position)}const f=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=f?f.line:void 0,this.name=oa(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=c&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Qt.prototype.file="";Qt.prototype.name="";Qt.prototype.reason="";Qt.prototype.message="";Qt.prototype.stack="";Qt.prototype.column=void 0;Qt.prototype.line=void 0;Qt.prototype.ancestors=void 0;Qt.prototype.cause=void 0;Qt.prototype.fatal=void 0;Qt.prototype.place=void 0;Qt.prototype.ruleId=void 0;Qt.prototype.source=void 0;const Hd={}.hasOwnProperty,Rk=new Map,Mk=/[A-Z]/g,Bk=new Set(["table","tbody","thead","tfoot","tr"]),Nk=new Set(["td","th"]),rS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Lk(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let s;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=Fk(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");s=Ik(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Od:xk,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=sS(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function sS(e,t,n){if(t.type==="element")return zk(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Ok(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Hk(e,t,n);if(t.type==="mdxjsEsm")return jk(e,t);if(t.type==="root")return Uk(e,t,n);if(t.type==="text")return Pk(e,t)}function zk(e,t,n){const s=e.schema;let a=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(a=Od,e.schema=a),e.ancestors.push(t);const o=aS(e,t.tagName,!1),c=qk(e,t);let f=Pd(e,t);return Bk.has(t.tagName)&&(f=f.filter(function(p){return typeof p=="string"?!fk(p):!0})),lS(e,c,o,t),Ud(c,f),e.ancestors.pop(),e.schema=s,e.create(t,o,c,n)}function Ok(e,t){if(t.data&&t.data.estree&&e.evaluater){const s=t.data.estree.body[0];return s.type,e.evaluater.evaluateExpression(s.expression)}pa(e,t.position)}function jk(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);pa(e,t.position)}function Hk(e,t,n){const s=e.schema;let a=s;t.name==="svg"&&s.space==="html"&&(a=Od,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:aS(e,t.name,!0),c=Wk(e,t),f=Pd(e,t);return lS(e,c,o,t),Ud(c,f),e.ancestors.pop(),e.schema=s,e.create(t,o,c,n)}function Uk(e,t,n){const s={};return Ud(s,Pd(e,t)),e.create(t,e.Fragment,s,n)}function Pk(e,t){return t.value}function lS(e,t,n,s){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=s)}function Ud(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Ik(e,t,n){return s;function s(a,o,c,f){const h=Array.isArray(c.children)?n:t;return f?h(o,c,f):h(o,c)}}function Fk(e,t){return n;function n(s,a,o,c){const f=Array.isArray(o.children),p=jd(s);return t(a,o,c,f,{columnNumber:p?p.column-1:void 0,fileName:e,lineNumber:p?p.line:void 0},void 0)}}function qk(e,t){const n={};let s,a;for(a in t.properties)if(a!=="children"&&Hd.call(t.properties,a)){const o=Yk(e,a,t.properties[a]);if(o){const[c,f]=o;e.tableCellAlignToStyle&&c==="align"&&typeof f=="string"&&Nk.has(t.tagName)?s=f:n[c]=f}}if(s){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return n}function Wk(e,t){const n={};for(const s of t.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&e.evaluater){const o=s.data.estree.body[0];o.type;const c=o.expression;c.type;const f=c.properties[0];f.type,Object.assign(n,e.evaluater.evaluateExpression(f.argument))}else pa(e,t.position);else{const a=s.name;let o;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&e.evaluater){const f=s.value.data.estree.body[0];f.type,o=e.evaluater.evaluateExpression(f.expression)}else pa(e,t.position);else o=s.value===null?!0:s.value;n[a]=o}return n}function Pd(e,t){const n=[];let s=-1;const a=e.passKeys?new Map:Rk;for(;++sa?0:a+t:t=t>a?a:t,n=n>0?n:0,s.length<1e4)c=Array.from(s),c.unshift(t,n),e.splice(...c);else for(n&&e.splice(t,n);o0?(Mi(e,e.length,0,t),e):t}const my={}.hasOwnProperty;function uS(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Qi(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ri=vr(/[A-Za-z]/),Zt=vr(/[\dA-Za-z]/),eE=vr(/[#-'*+\--9=?A-Z^-~]/);function pu(e){return e!==null&&(e<32||e===127)}const _d=vr(/\d/),tE=vr(/[\dA-Fa-f]/),iE=vr(/[!-/:-@[-`{-~]/);function ye(e){return e!==null&&e<-2}function et(e){return e!==null&&(e<0||e===32)}function Le(e){return e===-2||e===-1||e===32}const xu=vr(new RegExp("\\p{P}|\\p{S}","u")),Kr=vr(/\s/);function vr(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Gs(e){const t=[];let n=-1,s=0,a=0;for(;++n55295&&o<57344){const f=e.charCodeAt(n+1);o<56320&&f>56319&&f<57344?(c=String.fromCharCode(o,f),a=1):c="�"}else c=String.fromCharCode(o);c&&(t.push(e.slice(s,n),encodeURIComponent(c)),s=n+a+1,c=""),a&&(n+=a,a=0)}return t.join("")+e.slice(s)}function Ue(e,t,n,s){const a=s?s-1:Number.POSITIVE_INFINITY;let o=0;return c;function c(p){return Le(p)?(e.enter(n),f(p)):t(p)}function f(p){return Le(p)&&o++c))return;const J=t.events.length;let ce=J,pe,F;for(;ce--;)if(t.events[ce][0]==="exit"&&t.events[ce][1].type==="chunkFlow"){if(pe){F=t.events[ce][1].end;break}pe=!0}for(R(s),O=J;OI;){const Y=n[Z];t.containerState=Y[1],Y[0].exit.call(t,e)}n.length=I}function $(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function aE(e,t,n){return Ue(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Vs(e){if(e===null||et(e)||Kr(e))return 1;if(xu(e))return 2}function wu(e,t,n){const s=[];let a=-1;for(;++a1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const _={...e[s][1].end},b={...e[n][1].start};gy(_,-p),gy(b,p),c={type:p>1?"strongSequence":"emphasisSequence",start:_,end:{...e[s][1].end}},f={type:p>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:b},o={type:p>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[n][1].start}},a={type:p>1?"strong":"emphasis",start:{...c.start},end:{...f.end}},e[s][1].end={...c.start},e[n][1].start={...f.end},h=[],e[s][1].end.offset-e[s][1].start.offset&&(h=Yi(h,[["enter",e[s][1],t],["exit",e[s][1],t]])),h=Yi(h,[["enter",a,t],["enter",c,t],["exit",c,t],["enter",o,t]]),h=Yi(h,wu(t.parser.constructs.insideSpan.null,e.slice(s+1,n),t)),h=Yi(h,[["exit",o,t],["enter",f,t],["exit",f,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(g=2,h=Yi(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):g=0,Mi(e,s-1,n-s+3,h),n=s+h.length-g-2;break}}for(n=-1;++n0&&Le(O)?Ue(e,$,"linePrefix",o+1)(O):$(O)}function $(O){return O===null||ye(O)?e.check(vy,k,Z)(O):(e.enter("codeFlowValue"),I(O))}function I(O){return O===null||ye(O)?(e.exit("codeFlowValue"),$(O)):(e.consume(O),I)}function Z(O){return e.exit("codeFenced"),t(O)}function Y(O,J,ce){let pe=0;return F;function F(N){return O.enter("lineEnding"),O.consume(N),O.exit("lineEnding"),se}function se(N){return O.enter("codeFencedFence"),Le(N)?Ue(O,H,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):H(N)}function H(N){return N===f?(O.enter("codeFencedFenceSequence"),E(N)):ce(N)}function E(N){return N===f?(pe++,O.consume(N),E):pe>=c?(O.exit("codeFencedFenceSequence"),Le(N)?Ue(O,B,"whitespace")(N):B(N)):ce(N)}function B(N){return N===null||ye(N)?(O.exit("codeFencedFence"),J(N)):ce(N)}}}function yE(e,t,n){const s=this;return a;function a(c){return c===null?n(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o)}function o(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}const hf={name:"codeIndented",tokenize:SE},bE={partial:!0,tokenize:xE};function SE(e,t,n){const s=this;return a;function a(h){return e.enter("codeIndented"),Ue(e,o,"linePrefix",5)(h)}function o(h){const g=s.events[s.events.length-1];return g&&g[1].type==="linePrefix"&&g[2].sliceSerialize(g[1],!0).length>=4?c(h):n(h)}function c(h){return h===null?p(h):ye(h)?e.attempt(bE,c,p)(h):(e.enter("codeFlowValue"),f(h))}function f(h){return h===null||ye(h)?(e.exit("codeFlowValue"),c(h)):(e.consume(h),f)}function p(h){return e.exit("codeIndented"),t(h)}}function xE(e,t,n){const s=this;return a;function a(c){return s.parser.lazy[s.now().line]?n(c):ye(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):Ue(e,o,"linePrefix",5)(c)}function o(c){const f=s.events[s.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?t(c):ye(c)?a(c):n(c)}}const wE={name:"codeText",previous:kE,resolve:CE,tokenize:EE};function CE(e){let t=e.length-4,n=3,s,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(s=n;++s=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(t,n,s){const a=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return s&&ea(this.left,s),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),ea(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ea(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(c):e.interrupt(s.parser.constructs.flow,n,t)(c)}}function mS(e,t,n,s,a,o,c,f,p){const h=p||Number.POSITIVE_INFINITY;let g=0;return _;function _(R){return R===60?(e.enter(s),e.enter(a),e.enter(o),e.consume(R),e.exit(o),b):R===null||R===32||R===41||pu(R)?n(R):(e.enter(s),e.enter(c),e.enter(f),e.enter("chunkString",{contentType:"string"}),k(R))}function b(R){return R===62?(e.enter(o),e.consume(R),e.exit(o),e.exit(a),e.exit(s),t):(e.enter(f),e.enter("chunkString",{contentType:"string"}),y(R))}function y(R){return R===62?(e.exit("chunkString"),e.exit(f),b(R)):R===null||R===60||ye(R)?n(R):(e.consume(R),R===92?x:y)}function x(R){return R===60||R===62||R===92?(e.consume(R),y):y(R)}function k(R){return!g&&(R===null||R===41||et(R))?(e.exit("chunkString"),e.exit(f),e.exit(c),e.exit(s),t(R)):g999||y===null||y===91||y===93&&!p||y===94&&!f&&"_hiddenFootnoteSupport"in c.parser.constructs?n(y):y===93?(e.exit(o),e.enter(a),e.consume(y),e.exit(a),e.exit(s),t):ye(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),g):(e.enter("chunkString",{contentType:"string"}),_(y))}function _(y){return y===null||y===91||y===93||ye(y)||f++>999?(e.exit("chunkString"),g(y)):(e.consume(y),p||(p=!Le(y)),y===92?b:_)}function b(y){return y===91||y===92||y===93?(e.consume(y),f++,_):_(y)}}function gS(e,t,n,s,a,o){let c;return f;function f(b){return b===34||b===39||b===40?(e.enter(s),e.enter(a),e.consume(b),e.exit(a),c=b===40?41:b,p):n(b)}function p(b){return b===c?(e.enter(a),e.consume(b),e.exit(a),e.exit(s),t):(e.enter(o),h(b))}function h(b){return b===c?(e.exit(o),p(c)):b===null?n(b):ye(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),Ue(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),g(b))}function g(b){return b===c||b===null||ye(b)?(e.exit("chunkString"),h(b)):(e.consume(b),b===92?_:g)}function _(b){return b===c||b===92?(e.consume(b),g):g(b)}}function ua(e,t){let n;return s;function s(a){return ye(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,s):Le(a)?Ue(e,s,n?"linePrefix":"lineSuffix")(a):t(a)}}const LE={name:"definition",tokenize:OE},zE={partial:!0,tokenize:jE};function OE(e,t,n){const s=this;let a;return o;function o(y){return e.enter("definition"),c(y)}function c(y){return _S.call(s,e,f,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function f(y){return a=Qi(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),p):n(y)}function p(y){return et(y)?ua(e,h)(y):h(y)}function h(y){return mS(e,g,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function g(y){return e.attempt(zE,_,_)(y)}function _(y){return Le(y)?Ue(e,b,"whitespace")(y):b(y)}function b(y){return y===null||ye(y)?(e.exit("definition"),s.parser.defined.push(a),t(y)):n(y)}}function jE(e,t,n){return s;function s(f){return et(f)?ua(e,a)(f):n(f)}function a(f){return gS(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function o(f){return Le(f)?Ue(e,c,"whitespace")(f):c(f)}function c(f){return f===null||ye(f)?t(f):n(f)}}const HE={name:"hardBreakEscape",tokenize:UE};function UE(e,t,n){return s;function s(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return ye(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const PE={name:"headingAtx",resolve:IE,tokenize:FE};function IE(e,t){let n=e.length-2,s=3,a,o;return e[s][1].type==="whitespace"&&(s+=2),n-2>s&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(s===n-1||n-4>s&&e[n-2][1].type==="whitespace")&&(n-=s+1===n?2:4),n>s&&(a={type:"atxHeadingText",start:e[s][1].start,end:e[n][1].end},o={type:"chunkText",start:e[s][1].start,end:e[n][1].end,contentType:"text"},Mi(e,s,n-s+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function FE(e,t,n){let s=0;return a;function a(g){return e.enter("atxHeading"),o(g)}function o(g){return e.enter("atxHeadingSequence"),c(g)}function c(g){return g===35&&s++<6?(e.consume(g),c):g===null||et(g)?(e.exit("atxHeadingSequence"),f(g)):n(g)}function f(g){return g===35?(e.enter("atxHeadingSequence"),p(g)):g===null||ye(g)?(e.exit("atxHeading"),t(g)):Le(g)?Ue(e,f,"whitespace")(g):(e.enter("atxHeadingText"),h(g))}function p(g){return g===35?(e.consume(g),p):(e.exit("atxHeadingSequence"),f(g))}function h(g){return g===null||g===35||et(g)?(e.exit("atxHeadingText"),f(g)):(e.consume(g),h)}}const qE=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],by=["pre","script","style","textarea"],WE={concrete:!0,name:"htmlFlow",resolveTo:KE,tokenize:XE},YE={partial:!0,tokenize:GE},VE={partial:!0,tokenize:$E};function KE(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function XE(e,t,n){const s=this;let a,o,c,f,p;return h;function h(w){return g(w)}function g(w){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(w),_}function _(w){return w===33?(e.consume(w),b):w===47?(e.consume(w),o=!0,k):w===63?(e.consume(w),a=3,s.interrupt?t:T):ri(w)?(e.consume(w),c=String.fromCharCode(w),L):n(w)}function b(w){return w===45?(e.consume(w),a=2,y):w===91?(e.consume(w),a=5,f=0,x):ri(w)?(e.consume(w),a=4,s.interrupt?t:T):n(w)}function y(w){return w===45?(e.consume(w),s.interrupt?t:T):n(w)}function x(w){const ie="CDATA[";return w===ie.charCodeAt(f++)?(e.consume(w),f===ie.length?s.interrupt?t:H:x):n(w)}function k(w){return ri(w)?(e.consume(w),c=String.fromCharCode(w),L):n(w)}function L(w){if(w===null||w===47||w===62||et(w)){const ie=w===47,ae=c.toLowerCase();return!ie&&!o&&by.includes(ae)?(a=1,s.interrupt?t(w):H(w)):qE.includes(c.toLowerCase())?(a=6,ie?(e.consume(w),R):s.interrupt?t(w):H(w)):(a=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(w):o?$(w):I(w))}return w===45||Zt(w)?(e.consume(w),c+=String.fromCharCode(w),L):n(w)}function R(w){return w===62?(e.consume(w),s.interrupt?t:H):n(w)}function $(w){return Le(w)?(e.consume(w),$):F(w)}function I(w){return w===47?(e.consume(w),F):w===58||w===95||ri(w)?(e.consume(w),Z):Le(w)?(e.consume(w),I):F(w)}function Z(w){return w===45||w===46||w===58||w===95||Zt(w)?(e.consume(w),Z):Y(w)}function Y(w){return w===61?(e.consume(w),O):Le(w)?(e.consume(w),Y):I(w)}function O(w){return w===null||w===60||w===61||w===62||w===96?n(w):w===34||w===39?(e.consume(w),p=w,J):Le(w)?(e.consume(w),O):ce(w)}function J(w){return w===p?(e.consume(w),p=null,pe):w===null||ye(w)?n(w):(e.consume(w),J)}function ce(w){return w===null||w===34||w===39||w===47||w===60||w===61||w===62||w===96||et(w)?Y(w):(e.consume(w),ce)}function pe(w){return w===47||w===62||Le(w)?I(w):n(w)}function F(w){return w===62?(e.consume(w),se):n(w)}function se(w){return w===null||ye(w)?H(w):Le(w)?(e.consume(w),se):n(w)}function H(w){return w===45&&a===2?(e.consume(w),A):w===60&&a===1?(e.consume(w),j):w===62&&a===4?(e.consume(w),D):w===63&&a===3?(e.consume(w),T):w===93&&a===5?(e.consume(w),oe):ye(w)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(YE,V,E)(w)):w===null||ye(w)?(e.exit("htmlFlowData"),E(w)):(e.consume(w),H)}function E(w){return e.check(VE,B,V)(w)}function B(w){return e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),N}function N(w){return w===null||ye(w)?E(w):(e.enter("htmlFlowData"),H(w))}function A(w){return w===45?(e.consume(w),T):H(w)}function j(w){return w===47?(e.consume(w),c="",P):H(w)}function P(w){if(w===62){const ie=c.toLowerCase();return by.includes(ie)?(e.consume(w),D):H(w)}return ri(w)&&c.length<8?(e.consume(w),c+=String.fromCharCode(w),P):H(w)}function oe(w){return w===93?(e.consume(w),T):H(w)}function T(w){return w===62?(e.consume(w),D):w===45&&a===2?(e.consume(w),T):H(w)}function D(w){return w===null||ye(w)?(e.exit("htmlFlowData"),V(w)):(e.consume(w),D)}function V(w){return e.exit("htmlFlow"),t(w)}}function $E(e,t,n){const s=this;return a;function a(c){return ye(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):n(c)}function o(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}function GE(e,t,n){return s;function s(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(xa,t,n)}}const ZE={name:"htmlText",tokenize:QE};function QE(e,t,n){const s=this;let a,o,c;return f;function f(T){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(T),p}function p(T){return T===33?(e.consume(T),h):T===47?(e.consume(T),Y):T===63?(e.consume(T),I):ri(T)?(e.consume(T),ce):n(T)}function h(T){return T===45?(e.consume(T),g):T===91?(e.consume(T),o=0,x):ri(T)?(e.consume(T),$):n(T)}function g(T){return T===45?(e.consume(T),y):n(T)}function _(T){return T===null?n(T):T===45?(e.consume(T),b):ye(T)?(c=_,j(T)):(e.consume(T),_)}function b(T){return T===45?(e.consume(T),y):_(T)}function y(T){return T===62?A(T):T===45?b(T):_(T)}function x(T){const D="CDATA[";return T===D.charCodeAt(o++)?(e.consume(T),o===D.length?k:x):n(T)}function k(T){return T===null?n(T):T===93?(e.consume(T),L):ye(T)?(c=k,j(T)):(e.consume(T),k)}function L(T){return T===93?(e.consume(T),R):k(T)}function R(T){return T===62?A(T):T===93?(e.consume(T),R):k(T)}function $(T){return T===null||T===62?A(T):ye(T)?(c=$,j(T)):(e.consume(T),$)}function I(T){return T===null?n(T):T===63?(e.consume(T),Z):ye(T)?(c=I,j(T)):(e.consume(T),I)}function Z(T){return T===62?A(T):I(T)}function Y(T){return ri(T)?(e.consume(T),O):n(T)}function O(T){return T===45||Zt(T)?(e.consume(T),O):J(T)}function J(T){return ye(T)?(c=J,j(T)):Le(T)?(e.consume(T),J):A(T)}function ce(T){return T===45||Zt(T)?(e.consume(T),ce):T===47||T===62||et(T)?pe(T):n(T)}function pe(T){return T===47?(e.consume(T),A):T===58||T===95||ri(T)?(e.consume(T),F):ye(T)?(c=pe,j(T)):Le(T)?(e.consume(T),pe):A(T)}function F(T){return T===45||T===46||T===58||T===95||Zt(T)?(e.consume(T),F):se(T)}function se(T){return T===61?(e.consume(T),H):ye(T)?(c=se,j(T)):Le(T)?(e.consume(T),se):pe(T)}function H(T){return T===null||T===60||T===61||T===62||T===96?n(T):T===34||T===39?(e.consume(T),a=T,E):ye(T)?(c=H,j(T)):Le(T)?(e.consume(T),H):(e.consume(T),B)}function E(T){return T===a?(e.consume(T),a=void 0,N):T===null?n(T):ye(T)?(c=E,j(T)):(e.consume(T),E)}function B(T){return T===null||T===34||T===39||T===60||T===61||T===96?n(T):T===47||T===62||et(T)?pe(T):(e.consume(T),B)}function N(T){return T===47||T===62||et(T)?pe(T):n(T)}function A(T){return T===62?(e.consume(T),e.exit("htmlTextData"),e.exit("htmlText"),t):n(T)}function j(T){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),P}function P(T){return Le(T)?Ue(e,oe,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):oe(T)}function oe(T){return e.enter("htmlTextData"),c(T)}}const qd={name:"labelEnd",resolveAll:i5,resolveTo:n5,tokenize:r5},JE={tokenize:s5},e5={tokenize:l5},t5={tokenize:a5};function i5(e){let t=-1;const n=[];for(;++t=3&&(h===null||ye(h))?(e.exit("thematicBreak"),t(h)):n(h)}function p(h){return h===a?(e.consume(h),s++,p):(e.exit("thematicBreakSequence"),Le(h)?Ue(e,f,"whitespace")(h):f(h))}}const gi={continuation:{tokenize:g5},exit:y5,name:"list",tokenize:_5},p5={partial:!0,tokenize:b5},m5={partial:!0,tokenize:v5};function _5(e,t,n){const s=this,a=s.events[s.events.length-1];let o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,c=0;return f;function f(y){const x=s.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(x==="listUnordered"?!s.containerState.marker||y===s.containerState.marker:_d(y)){if(s.containerState.type||(s.containerState.type=x,e.enter(x,{_container:!0})),x==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(au,n,h)(y):h(y);if(!s.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),p(y)}return n(y)}function p(y){return _d(y)&&++c<10?(e.consume(y),p):(!s.interrupt||c<2)&&(s.containerState.marker?y===s.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),h(y)):n(y)}function h(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||y,e.check(xa,s.interrupt?n:g,e.attempt(p5,b,_))}function g(y){return s.containerState.initialBlankLine=!0,o++,b(y)}function _(y){return Le(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),b):n(y)}function b(y){return s.containerState.size=o+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function g5(e,t,n){const s=this;return s.containerState._closeFlow=void 0,e.check(xa,a,o);function a(f){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,Ue(e,t,"listItemIndent",s.containerState.size+1)(f)}function o(f){return s.containerState.furtherBlankLines||!Le(f)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,c(f)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(m5,t,c)(f))}function c(f){return s.containerState._closeFlow=!0,s.interrupt=void 0,Ue(e,e.attempt(gi,t,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function v5(e,t,n){const s=this;return Ue(e,a,"listItemIndent",s.containerState.size+1);function a(o){const c=s.events[s.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===s.containerState.size?t(o):n(o)}}function y5(e){e.exit(this.containerState.type)}function b5(e,t,n){const s=this;return Ue(e,a,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(o){const c=s.events[s.events.length-1];return!Le(o)&&c&&c[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const Sy={name:"setextUnderline",resolveTo:S5,tokenize:x5};function S5(e,t){let n=e.length,s,a,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){s=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const c={type:"setextHeading",start:{...e[s][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",o?(e.splice(a,0,["enter",c,t]),e.splice(o+1,0,["exit",e[s][1],t]),e[s][1].end={...e[o][1].end}):e[s][1]=c,e.push(["exit",c,t]),e}function x5(e,t,n){const s=this;let a;return o;function o(h){let g=s.events.length,_;for(;g--;)if(s.events[g][1].type!=="lineEnding"&&s.events[g][1].type!=="linePrefix"&&s.events[g][1].type!=="content"){_=s.events[g][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||_)?(e.enter("setextHeadingLine"),a=h,c(h)):n(h)}function c(h){return e.enter("setextHeadingLineSequence"),f(h)}function f(h){return h===a?(e.consume(h),f):(e.exit("setextHeadingLineSequence"),Le(h)?Ue(e,p,"lineSuffix")(h):p(h))}function p(h){return h===null||ye(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const w5={tokenize:C5};function C5(e){const t=this,n=e.attempt(xa,s,e.attempt(this.parser.constructs.flowInitial,a,Ue(e,e.attempt(this.parser.constructs.flow,a,e.attempt(DE,a)),"linePrefix")));return n;function s(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const k5={resolveAll:yS()},E5=vS("string"),T5=vS("text");function vS(e){return{resolveAll:yS(e==="text"?A5:void 0),tokenize:t};function t(n){const s=this,a=this.parser.constructs[e],o=n.attempt(a,c,f);return c;function c(g){return h(g)?o(g):f(g)}function f(g){if(g===null){n.consume(g);return}return n.enter("data"),n.consume(g),p}function p(g){return h(g)?(n.exit("data"),o(g)):(n.consume(g),p)}function h(g){if(g===null)return!0;const _=a[g];let b=-1;if(_)for(;++b<_.length;){const y=_[b];if(!y.previous||y.previous.call(s,s.previous))return!0}return!1}}}function yS(e){return t;function t(n,s){let a=-1,o;for(;++a<=n.length;)o===void 0?n[a]&&n[a][1].type==="data"&&(o=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==o+2&&(n[o][1].end=n[a-1][1].end,n.splice(o+2,a-o-2),a=o+2),o=void 0);return e?e(n,s):n}}function A5(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const s=e[n-1][1],a=t.sliceStream(s);let o=a.length,c=-1,f=0,p;for(;o--;){const h=a[o];if(typeof h=="string"){for(c=h.length;h.charCodeAt(c-1)===32;)f++,c--;if(c)break;c=-1}else if(h===-2)p=!0,f++;else if(h!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(f=0),f){const h={type:n===e.length||p||f<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?c:s.start._bufferIndex+c,_index:s.start._index+o,line:s.end.line,column:s.end.column-f,offset:s.end.offset-f},end:{...s.end}};s.end={...h.start},s.start.offset===s.end.offset?Object.assign(s,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const D5={42:gi,43:gi,45:gi,48:gi,49:gi,50:gi,51:gi,52:gi,53:gi,54:gi,55:gi,56:gi,57:gi,62:hS},R5={91:LE},M5={[-2]:hf,[-1]:hf,32:hf},B5={35:PE,42:au,45:[Sy,au],60:WE,61:Sy,95:au,96:yy,126:yy},N5={38:dS,92:fS},L5={[-5]:ff,[-4]:ff,[-3]:ff,33:o5,38:dS,42:gd,60:[cE,ZE],91:c5,92:[HE,fS],93:qd,95:gd,96:wE},z5={null:[gd,k5]},O5={null:[42,95]},j5={null:[]},H5=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:O5,contentInitial:R5,disable:j5,document:D5,flow:B5,flowInitial:M5,insideSpan:z5,string:N5,text:L5},Symbol.toStringTag,{value:"Module"}));function U5(e,t,n){let s={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},o=[];let c=[],f=[];const p={attempt:J(Y),check:J(O),consume:$,enter:I,exit:Z,interrupt:J(O,{interrupt:!0})},h={code:null,containerState:{},defineSkip:k,events:[],now:x,parser:e,previous:null,sliceSerialize:b,sliceStream:y,write:_};let g=t.tokenize.call(h,p);return t.resolveAll&&o.push(t),h;function _(se){return c=Yi(c,se),L(),c[c.length-1]!==null?[]:(ce(t,0),h.events=wu(o,h.events,h),h.events)}function b(se,H){return I5(y(se),H)}function y(se){return P5(c,se)}function x(){const{_bufferIndex:se,_index:H,line:E,column:B,offset:N}=s;return{_bufferIndex:se,_index:H,line:E,column:B,offset:N}}function k(se){a[se.line]=se.column,F()}function L(){let se;for(;s._index-1){const f=c[0];typeof f=="string"?c[0]=f.slice(s):c.shift()}o>0&&c.push(e[a].slice(0,o))}return c}function I5(e,t){let n=-1;const s=[];let a;for(;++n0){const bi=xe.tokenStack[xe.tokenStack.length-1];(bi[1]||wy).call(xe,void 0,bi[0])}for(fe.position={start:fr(ee.length>0?ee[0][1].start:{line:1,column:1,offset:0}),end:fr(ee.length>0?ee[ee.length-2][1].end:{line:1,column:1,offset:0})},We=-1;++We0&&(s.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:s,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function tT(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function iT(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nT(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),a=Gs(s.toLowerCase()),o=e.footnoteOrder.indexOf(s);let c,f=e.footnoteCounts.get(s);f===void 0?(f=0,e.footnoteOrder.push(s),c=e.footnoteOrder.length):c=o+1,f+=1,e.footnoteCounts.set(s,f);const p={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(f>1?"-"+f:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};e.patch(t,p);const h={type:"element",tagName:"sup",properties:{},children:[p]};return e.patch(t,h),e.applyData(t,h)}function rT(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function sT(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function xS(e,t){const n=t.referenceType;let s="]";if(n==="collapsed"?s+="[]":n==="full"&&(s+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+s}];const a=e.all(t),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const c=a[a.length-1];return c&&c.type==="text"?c.value+=s:a.push({type:"text",value:s}),a}function lT(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return xS(e,t);const a={src:Gs(s.url||""),alt:t.alt};s.title!==null&&s.title!==void 0&&(a.title=s.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)}function aT(e,t){const n={src:Gs(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,s),e.applyData(t,s)}function oT(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const s={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,s),e.applyData(t,s)}function uT(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return xS(e,t);const a={href:Gs(s.url||"")};s.title!==null&&s.title!==void 0&&(a.title=s.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function cT(e,t){const n={href:Gs(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function hT(e,t,n){const s=e.all(t),a=n?fT(n):wS(t),o={},c=[];if(typeof t.checked=="boolean"){const g=s[0];let _;g&&g.type==="element"&&g.tagName==="p"?_=g:(_={type:"element",tagName:"p",properties:{},children:[]},s.unshift(_)),_.children.length>0&&_.children.unshift({type:"text",value:" "}),_.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let f=-1;for(;++f1}function dT(e,t){const n={},s=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++a0){const c={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},f=jd(t.children[1]),p=tS(t.children[t.children.length-1]);f&&p&&(c.position={start:f,end:p}),a.push(c)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,o),e.applyData(t,o)}function vT(e,t,n){const s=n?n.children:void 0,o=(s?s.indexOf(t):1)===0?"th":"td",c=n&&n.type==="table"?n.align:void 0,f=c?c.length:t.children.length;let p=-1;const h=[];for(;++p0,!0),s[0]),a=s.index+s[0].length,s=n.exec(t);return o.push(Ey(t.slice(a),a>0,!1)),o.join("")}function Ey(e,t,n){let s=0,a=e.length;if(t){let o=e.codePointAt(s);for(;o===Cy||o===ky;)s++,o=e.codePointAt(s)}if(n){let o=e.codePointAt(a-1);for(;o===Cy||o===ky;)a--,o=e.codePointAt(a-1)}return a>s?e.slice(s,a):""}function ST(e,t){const n={type:"text",value:bT(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function xT(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const wT={blockquote:Q5,break:J5,code:eT,delete:tT,emphasis:iT,footnoteReference:nT,heading:rT,html:sT,imageReference:lT,image:aT,inlineCode:oT,linkReference:uT,link:cT,listItem:hT,list:dT,paragraph:pT,root:mT,strong:_T,table:gT,tableCell:yT,tableRow:vT,text:ST,thematicBreak:xT,toml:Go,yaml:Go,definition:Go,footnoteDefinition:Go};function Go(){}const CS=-1,Cu=0,ca=1,mu=2,Wd=3,Yd=4,Vd=5,Kd=6,kS=7,ES=8,Ty=typeof self=="object"?self:globalThis,CT=(e,t)=>{const n=(a,o)=>(e.set(o,a),a),s=a=>{if(e.has(a))return e.get(a);const[o,c]=t[a];switch(o){case Cu:case CS:return n(c,a);case ca:{const f=n([],a);for(const p of c)f.push(s(p));return f}case mu:{const f=n({},a);for(const[p,h]of c)f[s(p)]=s(h);return f}case Wd:return n(new Date(c),a);case Yd:{const{source:f,flags:p}=c;return n(new RegExp(f,p),a)}case Vd:{const f=n(new Map,a);for(const[p,h]of c)f.set(s(p),s(h));return f}case Kd:{const f=n(new Set,a);for(const p of c)f.add(s(p));return f}case kS:{const{name:f,message:p}=c;return n(new Ty[f](p),a)}case ES:return n(BigInt(c),a);case"BigInt":return n(Object(BigInt(c)),a);case"ArrayBuffer":return n(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:f}=new Uint8Array(c);return n(new DataView(f),c)}}return n(new Ty[o](c),a)};return s},Ay=e=>CT(new Map,e)(0),Is="",{toString:kT}={},{keys:ET}=Object,ta=e=>{const t=typeof e;if(t!=="object"||!e)return[Cu,t];const n=kT.call(e).slice(8,-1);switch(n){case"Array":return[ca,Is];case"Object":return[mu,Is];case"Date":return[Wd,Is];case"RegExp":return[Yd,Is];case"Map":return[Vd,Is];case"Set":return[Kd,Is];case"DataView":return[ca,n]}return n.includes("Array")?[ca,n]:n.includes("Error")?[kS,n]:[mu,n]},Zo=([e,t])=>e===Cu&&(t==="function"||t==="symbol"),TT=(e,t,n,s)=>{const a=(c,f)=>{const p=s.push(c)-1;return n.set(f,p),p},o=c=>{if(n.has(c))return n.get(c);let[f,p]=ta(c);switch(f){case Cu:{let g=c;switch(p){case"bigint":f=ES,g=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+p);g=null;break;case"undefined":return a([CS],c)}return a([f,g],c)}case ca:{if(p){let b=c;return p==="DataView"?b=new Uint8Array(c.buffer):p==="ArrayBuffer"&&(b=new Uint8Array(c)),a([p,[...b]],c)}const g=[],_=a([f,g],c);for(const b of c)g.push(o(b));return _}case mu:{if(p)switch(p){case"BigInt":return a([p,c.toString()],c);case"Boolean":case"Number":case"String":return a([p,c.valueOf()],c)}if(t&&"toJSON"in c)return o(c.toJSON());const g=[],_=a([f,g],c);for(const b of ET(c))(e||!Zo(ta(c[b])))&&g.push([o(b),o(c[b])]);return _}case Wd:return a([f,c.toISOString()],c);case Yd:{const{source:g,flags:_}=c;return a([f,{source:g,flags:_}],c)}case Vd:{const g=[],_=a([f,g],c);for(const[b,y]of c)(e||!(Zo(ta(b))||Zo(ta(y))))&&g.push([o(b),o(y)]);return _}case Kd:{const g=[],_=a([f,g],c);for(const b of c)(e||!Zo(ta(b)))&&g.push(o(b));return _}}const{message:h}=c;return a([f,{name:p,message:h}],c)};return o},Dy=(e,{json:t,lossy:n}={})=>{const s=[];return TT(!(t||n),!!t,new Map,s)(e),s},ma=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Ay(Dy(e,t)):structuredClone(e):(e,t)=>Ay(Dy(e,t));function AT(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function DT(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function RT(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||AT,s=e.options.footnoteBackLabel||DT,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",c=e.options.footnoteLabelProperties||{className:["sr-only"]},f=[];let p=-1;for(;++p0&&x.push({type:"text",value:" "});let $=typeof n=="string"?n:n(p,y);typeof $=="string"&&($={type:"text",value:$}),x.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+b+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof s=="string"?s:s(p,y),className:["data-footnote-backref"]},children:Array.isArray($)?$:[$]})}const L=g[g.length-1];if(L&&L.type==="element"&&L.tagName==="p"){const $=L.children[L.children.length-1];$&&$.type==="text"?$.value+=" ":L.children.push({type:"text",value:" "}),L.children.push(...x)}else g.push(...x);const R={type:"element",tagName:"li",properties:{id:t+"fn-"+b},children:e.wrap(g,!0)};e.patch(h,R),f.push(R)}if(f.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...ma(c),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:` -`},{type:"element",tagName:"ol",properties:{},children:e.wrap(f,!0)},{type:"text",value:` -`}]}}const ku=(function(e){if(e==null)return LT;if(typeof e=="function")return Eu(e);if(typeof e=="object")return Array.isArray(e)?MT(e):BT(e);if(typeof e=="string")return NT(e);throw new Error("Expected function, string, or object as test")});function MT(e){const t=[];let n=-1;for(;++n":""))+")"})}return b;function b(){let y=TS,x,k,L;if((!t||o(p,h,g[g.length-1]||void 0))&&(y=HT(n(p,g)),y[0]===vd))return y;if("children"in p&&p.children){const R=p;if(R.children&&y[0]!==jT)for(k=(s?R.children.length:-1)+c,L=g.concat(R);k>-1&&k0&&n.push({type:"text",value:` -`}),n}function Ry(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function My(e,t){const n=PT(e,t),s=n.one(e,void 0),a=RT(n),o=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return a&&o.children.push({type:"text",value:` -`},a),o}function YT(e,t){return e&&"run"in e?async function(n,s){const a=My(n,{file:s,...t});await e.run(a,s)}:function(n,s){return My(n,{file:s,...e||t})}}function By(e){if(e)throw e}var df,Ny;function VT(){if(Ny)return df;Ny=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},o=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var g=e.call(h,"constructor"),_=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!g&&!_)return!1;var b;for(b in h);return typeof b>"u"||e.call(h,b)},c=function(h,g){n&&g.name==="__proto__"?n(h,g.name,{enumerable:!0,configurable:!0,value:g.newValue,writable:!0}):h[g.name]=g.newValue},f=function(h,g){if(g==="__proto__")if(e.call(h,g)){if(s)return s(h,g).value}else return;return h[g]};return df=function p(){var h,g,_,b,y,x,k=arguments[0],L=1,R=arguments.length,$=!1;for(typeof k=="boolean"&&($=k,k=arguments[1]||{},L=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});Lc.length;let p;f&&c.push(a);try{p=e.apply(this,c)}catch(h){const g=h;if(f&&n)throw g;return a(g)}f||(p&&p.then&&typeof p.then=="function"?p.then(o,a):p instanceof Error?a(p):o(p))}function a(c,...f){n||(n=!0,t(c,...f))}function o(c){a(null,c)}}const an={basename:GT,dirname:ZT,extname:QT,join:JT,sep:"/"};function GT(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');wa(e);let n=0,s=-1,a=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else s<0&&(o=!0,s=a+1);return s<0?"":e.slice(n,s)}if(t===e)return"";let c=-1,f=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else c<0&&(o=!0,c=a+1),f>-1&&(e.codePointAt(a)===t.codePointAt(f--)?f<0&&(s=a):(f=-1,s=c));return n===s?s=c:s<0&&(s=e.length),e.slice(n,s)}function ZT(e){if(wa(e),e.length===0)return".";let t=-1,n=e.length,s;for(;--n;)if(e.codePointAt(n)===47){if(s){t=n;break}}else s||(s=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function QT(e){wa(e);let t=e.length,n=-1,s=0,a=-1,o=0,c;for(;t--;){const f=e.codePointAt(t);if(f===47){if(c){s=t+1;break}continue}n<0&&(c=!0,n=t+1),f===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||n<0||o===0||o===1&&a===n-1&&a===s+1?"":e.slice(a,n)}function JT(...e){let t=-1,n;for(;++t0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function t3(e,t){let n="",s=0,a=-1,o=0,c=-1,f,p;for(;++c<=e.length;){if(c2){if(p=n.lastIndexOf("/"),p!==n.length-1){p<0?(n="",s=0):(n=n.slice(0,p),s=n.length-1-n.lastIndexOf("/")),a=c,o=0;continue}}else if(n.length>0){n="",s=0,a=c,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",s=2)}else n.length>0?n+="/"+e.slice(a+1,c):n=e.slice(a+1,c),s=c-a-1;a=c,o=0}else f===46&&o>-1?o++:o=-1}return n}function wa(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const i3={cwd:n3};function n3(){return"/"}function Sd(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function r3(e){if(typeof e=="string")e=new URL(e);else if(!Sd(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return s3(e)}function s3(e){if(e.hostname!==""){const s=new TypeError('File URL host must be "localhost" or empty on darwin');throw s.code="ERR_INVALID_FILE_URL_HOST",s}const t=e.pathname;let n=-1;for(;++n0){let[y,...x]=g;const k=s[b][1];bd(k)&&bd(y)&&(y=pf(!0,k,y)),s[b]=[h,y,...x]}}}}const u3=new $d().freeze();function vf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function yf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function bf(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function zy(e){if(!bd(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Oy(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Qo(e){return c3(e)?e:new DS(e)}function c3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function h3(e){return typeof e=="string"||f3(e)}function f3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const d3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",jy=[],Hy={allowDangerousHtml:!0},p3=/^(https?|ircs?|mailto|xmpp)$/i,m3=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function _3(e){const t=g3(e),n=v3(e);return y3(t.runSync(t.parse(n),n),e)}function g3(e){const t=e.rehypePlugins||jy,n=e.remarkPlugins||jy,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Hy}:Hy;return u3().use(Z5).use(n).use(YT,s).use(t)}function v3(e){const t=e.children||"",n=new DS;return typeof t=="string"&&(n.value=t),n}function y3(e,t){const n=t.allowedElements,s=t.allowElement,a=t.components,o=t.disallowedElements,c=t.skipHtml,f=t.unwrapDisallowed,p=t.urlTransform||b3;for(const g of m3)Object.hasOwn(t,g.from)&&(""+g.from+(g.to?"use `"+g.to+"` instead":"remove it")+d3+g.id,void 0);return Xd(e,h),Lk(e,{Fragment:S.Fragment,components:a,ignoreInvalidStyle:!0,jsx:S.jsx,jsxs:S.jsxs,passKeys:!0,passNode:!0});function h(g,_,b){if(g.type==="raw"&&b&&typeof _=="number")return c?b.children.splice(_,1):b.children[_]={type:"text",value:g.value},_;if(g.type==="element"){let y;for(y in cf)if(Object.hasOwn(cf,y)&&Object.hasOwn(g.properties,y)){const x=g.properties[y],k=cf[y];(k===null||k.includes(g.tagName))&&(g.properties[y]=p(String(x||""),y,g))}}if(g.type==="element"){let y=n?!n.includes(g.tagName):o?o.includes(g.tagName):!1;if(!y&&s&&typeof _=="number"&&(y=!s(g,_,b)),y&&b&&typeof _=="number")return f&&g.children?b.children.splice(_,1,...g.children):b.children.splice(_,1),_}}}function b3(e){const t=e.indexOf(":"),n=e.indexOf("?"),s=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||s!==-1&&t>s||p3.test(e.slice(0,t))?e:""}function S3(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function RS(e,t,n){const a=ku((n||{}).ignore||[]),o=x3(t);let c=-1;for(;++c0?{type:"text",value:O}:void 0),O===!1?b.lastIndex=Z+1:(x!==Z&&$.push({type:"text",value:h.value.slice(x,Z)}),Array.isArray(O)?$.push(...O):O&&$.push(O),x=Z+I[0].length,R=!0),!b.global)break;I=b.exec(h.value)}return R?(x?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],s=n.indexOf(")");const a=Uy(e,"(");let o=Uy(e,")");for(;s!==-1&&a>o;)e+=n.slice(0,s+1),n=n.slice(s+1),s=n.indexOf(")"),o++;return[e,n]}function MS(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Kr(n)||xu(n))&&(!t||n!==47)}BS.peek=X3;function P3(){this.buffer()}function I3(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function F3(){this.buffer()}function q3(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function W3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Qi(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Y3(e){this.exit(e)}function V3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Qi(this.sliceSerialize(e)).toLowerCase(),n.label=t}function K3(e){this.exit(e)}function X3(){return"["}function BS(e,t,n,s){const a=n.createTracker(s);let o=a.move("[^");const c=n.enter("footnoteReference"),f=n.enter("reference");return o+=a.move(n.safe(n.associationId(e),{after:"]",before:o})),f(),c(),o+=a.move("]"),o}function $3(){return{enter:{gfmFootnoteCallString:P3,gfmFootnoteCall:I3,gfmFootnoteDefinitionLabelString:F3,gfmFootnoteDefinition:q3},exit:{gfmFootnoteCallString:W3,gfmFootnoteCall:Y3,gfmFootnoteDefinitionLabelString:V3,gfmFootnoteDefinition:K3}}}function G3(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:BS},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(s,a,o,c){const f=o.createTracker(c);let p=f.move("[^");const h=o.enter("footnoteDefinition"),g=o.enter("label");return p+=f.move(o.safe(o.associationId(s),{before:p,after:"]"})),g(),p+=f.move("]:"),s.children&&s.children.length>0&&(f.shift(4),p+=f.move((t?` -`:" ")+o.indentLines(o.containerFlow(s,f.current()),t?NS:Z3))),h(),p}}function Z3(e,t,n){return t===0?e:NS(e,t,n)}function NS(e,t,n){return(n?"":" ")+e}const Q3=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];LS.peek=nA;function J3(){return{canContainEols:["delete"],enter:{strikethrough:tA},exit:{strikethrough:iA}}}function eA(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Q3}],handlers:{delete:LS}}}function tA(e){this.enter({type:"delete",children:[]},e)}function iA(e){this.exit(e)}function LS(e,t,n,s){const a=n.createTracker(s),o=n.enter("strikethrough");let c=a.move("~~");return c+=n.containerPhrasing(e,{...a.current(),before:c,after:"~"}),c+=a.move("~~"),o(),c}function nA(){return"~"}function rA(e){return e.length}function sA(e,t){const n=t||{},s=(n.align||[]).concat(),a=n.stringLength||rA,o=[],c=[],f=[],p=[];let h=0,g=-1;for(;++gh&&(h=e[g].length);++Rp[R])&&(p[R]=I)}k.push($)}c[g]=k,f[g]=L}let _=-1;if(typeof s=="object"&&"length"in s)for(;++_p[_]&&(p[_]=$),y[_]=$),b[_]=I}c.splice(1,0,b),f.splice(1,0,y),g=-1;const x=[];for(;++g "),o.shift(2);const c=n.indentLines(n.containerFlow(e,o.current()),oA);return a(),c}function oA(e,t,n){return">"+(n?"":" ")+e}function uA(e,t){return Iy(e,t.inConstruct,!0)&&!Iy(e,t.notInConstruct,!1)}function Iy(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let s=-1;for(;++sc&&(c=o):o=1,a=s+t.length,s=n.indexOf(t,a);return c}function hA(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function fA(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function dA(e,t,n,s){const a=fA(n),o=e.value||"",c=a==="`"?"GraveAccent":"Tilde";if(hA(e,n)){const _=n.enter("codeIndented"),b=n.indentLines(o,pA);return _(),b}const f=n.createTracker(s),p=a.repeat(Math.max(cA(o,a)+1,3)),h=n.enter("codeFenced");let g=f.move(p);if(e.lang){const _=n.enter(`codeFencedLang${c}`);g+=f.move(n.safe(e.lang,{before:g,after:" ",encode:["`"],...f.current()})),_()}if(e.lang&&e.meta){const _=n.enter(`codeFencedMeta${c}`);g+=f.move(" "),g+=f.move(n.safe(e.meta,{before:g,after:` -`,encode:["`"],...f.current()})),_()}return g+=f.move(` -`),o&&(g+=f.move(o+` -`)),g+=f.move(p),h(),g}function pA(e,t,n){return(n?"":" ")+e}function Gd(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function mA(e,t,n,s){const a=Gd(n),o=a==='"'?"Quote":"Apostrophe",c=n.enter("definition");let f=n.enter("label");const p=n.createTracker(s);let h=p.move("[");return h+=p.move(n.safe(n.associationId(e),{before:h,after:"]",...p.current()})),h+=p.move("]: "),f(),!e.url||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(n.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(f=n.enter("destinationRaw"),h+=p.move(n.safe(e.url,{before:h,after:e.title?" ":` -`,...p.current()}))),f(),e.title&&(f=n.enter(`title${o}`),h+=p.move(" "+a),h+=p.move(n.safe(e.title,{before:h,after:a,...p.current()})),h+=p.move(a),f()),c(),h}function _A(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function _a(e){return"&#x"+e.toString(16).toUpperCase()+";"}function _u(e,t,n){const s=Vs(e),a=Vs(t);return s===void 0?a===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:s===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}zS.peek=gA;function zS(e,t,n,s){const a=_A(n),o=n.enter("emphasis"),c=n.createTracker(s),f=c.move(a);let p=c.move(n.containerPhrasing(e,{after:a,before:f,...c.current()}));const h=p.charCodeAt(0),g=_u(s.before.charCodeAt(s.before.length-1),h,a);g.inside&&(p=_a(h)+p.slice(1));const _=p.charCodeAt(p.length-1),b=_u(s.after.charCodeAt(0),_,a);b.inside&&(p=p.slice(0,-1)+_a(_));const y=c.move(a);return o(),n.attentionEncodeSurroundingInfo={after:b.outside,before:g.outside},f+p+y}function gA(e,t,n){return n.options.emphasis||"*"}function vA(e,t){let n=!1;return Xd(e,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return n=!0,vd}),!!((!e.depth||e.depth<3)&&Id(e)&&(t.options.setext||n))}function yA(e,t,n,s){const a=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(s);if(vA(e,n)){const g=n.enter("headingSetext"),_=n.enter("phrasing"),b=n.containerPhrasing(e,{...o.current(),before:` -`,after:` -`});return _(),g(),b+` -`+(a===1?"=":"-").repeat(b.length-(Math.max(b.lastIndexOf("\r"),b.lastIndexOf(` -`))+1))}const c="#".repeat(a),f=n.enter("headingAtx"),p=n.enter("phrasing");o.move(c+" ");let h=n.containerPhrasing(e,{before:"# ",after:` -`,...o.current()});return/^[\t ]/.test(h)&&(h=_a(h.charCodeAt(0))+h.slice(1)),h=h?c+" "+h:c,n.options.closeAtx&&(h+=" "+c),p(),f(),h}OS.peek=bA;function OS(e){return e.value||""}function bA(){return"<"}jS.peek=SA;function jS(e,t,n,s){const a=Gd(n),o=a==='"'?"Quote":"Apostrophe",c=n.enter("image");let f=n.enter("label");const p=n.createTracker(s);let h=p.move("![");return h+=p.move(n.safe(e.alt,{before:h,after:"]",...p.current()})),h+=p.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(n.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(f=n.enter("destinationRaw"),h+=p.move(n.safe(e.url,{before:h,after:e.title?" ":")",...p.current()}))),f(),e.title&&(f=n.enter(`title${o}`),h+=p.move(" "+a),h+=p.move(n.safe(e.title,{before:h,after:a,...p.current()})),h+=p.move(a),f()),h+=p.move(")"),c(),h}function SA(){return"!"}HS.peek=xA;function HS(e,t,n,s){const a=e.referenceType,o=n.enter("imageReference");let c=n.enter("label");const f=n.createTracker(s);let p=f.move("![");const h=n.safe(e.alt,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),c();const g=n.stack;n.stack=[],c=n.enter("reference");const _=n.safe(n.associationId(e),{before:p,after:"]",...f.current()});return c(),n.stack=g,o(),a==="full"||!h||h!==_?p+=f.move(_+"]"):a==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function xA(){return"!"}US.peek=wA;function US(e,t,n){let s=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(s);)a+="`";for(/[^ \r\n]/.test(s)&&(/^[ \r\n]/.test(s)&&/[ \r\n]$/.test(s)||/^`|`$/.test(s))&&(s=" "+s+" ");++o\u007F]/.test(e.url))}IS.peek=CA;function IS(e,t,n,s){const a=Gd(n),o=a==='"'?"Quote":"Apostrophe",c=n.createTracker(s);let f,p;if(PS(e,n)){const g=n.stack;n.stack=[],f=n.enter("autolink");let _=c.move("<");return _+=c.move(n.containerPhrasing(e,{before:_,after:">",...c.current()})),_+=c.move(">"),f(),n.stack=g,_}f=n.enter("link"),p=n.enter("label");let h=c.move("[");return h+=c.move(n.containerPhrasing(e,{before:h,after:"](",...c.current()})),h+=c.move("]("),p(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(p=n.enter("destinationLiteral"),h+=c.move("<"),h+=c.move(n.safe(e.url,{before:h,after:">",...c.current()})),h+=c.move(">")):(p=n.enter("destinationRaw"),h+=c.move(n.safe(e.url,{before:h,after:e.title?" ":")",...c.current()}))),p(),e.title&&(p=n.enter(`title${o}`),h+=c.move(" "+a),h+=c.move(n.safe(e.title,{before:h,after:a,...c.current()})),h+=c.move(a),p()),h+=c.move(")"),f(),h}function CA(e,t,n){return PS(e,n)?"<":"["}FS.peek=kA;function FS(e,t,n,s){const a=e.referenceType,o=n.enter("linkReference");let c=n.enter("label");const f=n.createTracker(s);let p=f.move("[");const h=n.containerPhrasing(e,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),c();const g=n.stack;n.stack=[],c=n.enter("reference");const _=n.safe(n.associationId(e),{before:p,after:"]",...f.current()});return c(),n.stack=g,o(),a==="full"||!h||h!==_?p+=f.move(_+"]"):a==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function kA(){return"["}function Zd(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function EA(e){const t=Zd(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function TA(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function qS(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function AA(e,t,n,s){const a=n.enter("list"),o=n.bulletCurrent;let c=e.ordered?TA(n):Zd(n);const f=e.ordered?c==="."?")":".":EA(n);let p=t&&n.bulletLastUsed?c===n.bulletLastUsed:!1;if(!e.ordered){const g=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&g&&(!g.children||!g.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(p=!0),qS(n)===c&&g){let _=-1;for(;++_-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let c=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(c=Math.ceil(c/4)*4);const f=n.createTracker(s);f.move(o+" ".repeat(c-o.length)),f.shift(c);const p=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,f.current()),g);return p(),h;function g(_,b,y){return b?(y?"":" ".repeat(c))+_:(y?o:o+" ".repeat(c-o.length))+_}}function MA(e,t,n,s){const a=n.enter("paragraph"),o=n.enter("phrasing"),c=n.containerPhrasing(e,s);return o(),a(),c}const BA=ku(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function NA(e,t,n,s){return(e.children.some(function(c){return BA(c)})?n.containerPhrasing:n.containerFlow).call(n,e,s)}function LA(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}WS.peek=zA;function WS(e,t,n,s){const a=LA(n),o=n.enter("strong"),c=n.createTracker(s),f=c.move(a+a);let p=c.move(n.containerPhrasing(e,{after:a,before:f,...c.current()}));const h=p.charCodeAt(0),g=_u(s.before.charCodeAt(s.before.length-1),h,a);g.inside&&(p=_a(h)+p.slice(1));const _=p.charCodeAt(p.length-1),b=_u(s.after.charCodeAt(0),_,a);b.inside&&(p=p.slice(0,-1)+_a(_));const y=c.move(a+a);return o(),n.attentionEncodeSurroundingInfo={after:b.outside,before:g.outside},f+p+y}function zA(e,t,n){return n.options.strong||"*"}function OA(e,t,n,s){return n.safe(e.value,s)}function jA(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function HA(e,t,n){const s=(qS(n)+(n.options.ruleSpaces?" ":"")).repeat(jA(n));return n.options.ruleSpaces?s.slice(0,-1):s}const YS={blockquote:aA,break:Fy,code:dA,definition:mA,emphasis:zS,hardBreak:Fy,heading:yA,html:OS,image:jS,imageReference:HS,inlineCode:US,link:IS,linkReference:FS,list:AA,listItem:RA,paragraph:MA,root:NA,strong:WS,text:OA,thematicBreak:HA};function UA(){return{enter:{table:PA,tableData:qy,tableHeader:qy,tableRow:FA},exit:{codeText:qA,table:IA,tableData:Cf,tableHeader:Cf,tableRow:Cf}}}function PA(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function IA(e){this.exit(e),this.data.inTable=void 0}function FA(e){this.enter({type:"tableRow",children:[]},e)}function Cf(e){this.exit(e)}function qy(e){this.enter({type:"tableCell",children:[]},e)}function qA(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,WA));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function WA(e,t){return t==="|"?t:e}function YA(e){const t=e||{},n=t.tableCellPadding,s=t.tablePipeAlign,a=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` -`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:b,table:c,tableCell:p,tableRow:f}};function c(y,x,k,L){return h(g(y,k,L),y.align)}function f(y,x,k,L){const R=_(y,k,L),$=h([R]);return $.slice(0,$.indexOf(` -`))}function p(y,x,k,L){const R=k.enter("tableCell"),$=k.enter("phrasing"),I=k.containerPhrasing(y,{...L,before:o,after:o});return $(),R(),I}function h(y,x){return sA(y,{align:x,alignDelimiters:s,padding:n,stringLength:a})}function g(y,x,k){const L=y.children;let R=-1;const $=[],I=x.enter("table");for(;++R0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const uD={tokenize:gD,partial:!0};function cD(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:pD,continuation:{tokenize:mD},exit:_D}},text:{91:{name:"gfmFootnoteCall",tokenize:dD},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:hD,resolveTo:fD}}}}function hD(e,t,n){const s=this;let a=s.events.length;const o=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let c;for(;a--;){const p=s.events[a][1];if(p.type==="labelImage"){c=p;break}if(p.type==="gfmFootnoteCall"||p.type==="labelLink"||p.type==="label"||p.type==="image"||p.type==="link")break}return f;function f(p){if(!c||!c._balanced)return n(p);const h=Qi(s.sliceSerialize({start:c.end,end:s.now()}));return h.codePointAt(0)!==94||!o.includes(h.slice(1))?n(p):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),t(p))}}function fD(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const s={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},f=[e[n+1],e[n+2],["enter",s,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",c,t],["exit",c,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",s,t]];return e.splice(n,e.length-n+1,...f),e}function dD(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o=0,c;return f;function f(_){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(_),e.exit("gfmFootnoteCallLabelMarker"),p}function p(_){return _!==94?n(_):(e.enter("gfmFootnoteCallMarker"),e.consume(_),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(_){if(o>999||_===93&&!c||_===null||_===91||et(_))return n(_);if(_===93){e.exit("chunkString");const b=e.exit("gfmFootnoteCallString");return a.includes(Qi(s.sliceSerialize(b)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(_),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(_)}return et(_)||(c=!0),o++,e.consume(_),_===92?g:h}function g(_){return _===91||_===92||_===93?(e.consume(_),o++,h):h(_)}}function pD(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o,c=0,f;return p;function p(x){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(x){return x===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",g):n(x)}function g(x){if(c>999||x===93&&!f||x===null||x===91||et(x))return n(x);if(x===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return o=Qi(s.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),b}return et(x)||(f=!0),c++,e.consume(x),x===92?_:g}function _(x){return x===91||x===92||x===93?(e.consume(x),c++,g):g(x)}function b(x){return x===58?(e.enter("definitionMarker"),e.consume(x),e.exit("definitionMarker"),a.includes(o)||a.push(o),Ue(e,y,"gfmFootnoteDefinitionWhitespace")):n(x)}function y(x){return t(x)}}function mD(e,t,n){return e.check(xa,t,e.attempt(uD,t,n))}function _D(e){e.exit("gfmFootnoteDefinition")}function gD(e,t,n){const s=this;return Ue(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const c=s.events[s.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?t(o):n(o)}}function vD(e){let n=(e||{}).singleTilde;const s={name:"strikethrough",tokenize:o,resolveAll:a};return n==null&&(n=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function a(c,f){let p=-1;for(;++p1?p(x):(c.consume(x),_++,y);if(_<2&&!n)return p(x);const L=c.exit("strikethroughSequenceTemporary"),R=Vs(x);return L._open=!R||R===2&&!!k,L._close=!k||k===2&&!!R,f(x)}}}class yD{constructor(){this.map=[]}add(t,n,s){bD(this,t,n,s)}consume(t){if(this.map.sort(function(o,c){return o[0]-c[0]}),this.map.length===0)return;let n=this.map.length;const s=[];for(;n>0;)n-=1,s.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];s.push(t.slice()),t.length=0;let a=s.pop();for(;a;){for(const o of a)t.push(o);a=s.pop()}this.map.length=0}}function bD(e,t,n,s){let a=0;if(!(n===0&&s.length===0)){for(;a-1;){const B=s.events[se][1].type;if(B==="lineEnding"||B==="linePrefix")se--;else break}const H=se>-1?s.events[se][1].type:null,E=H==="tableHead"||H==="tableRow"?O:p;return E===O&&s.parser.lazy[s.now().line]?n(F):E(F)}function p(F){return e.enter("tableHead"),e.enter("tableRow"),h(F)}function h(F){return F===124||(c=!0,o+=1),g(F)}function g(F){return F===null?n(F):ye(F)?o>1?(o=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(F),e.exit("lineEnding"),y):n(F):Le(F)?Ue(e,g,"whitespace")(F):(o+=1,c&&(c=!1,a+=1),F===124?(e.enter("tableCellDivider"),e.consume(F),e.exit("tableCellDivider"),c=!0,g):(e.enter("data"),_(F)))}function _(F){return F===null||F===124||et(F)?(e.exit("data"),g(F)):(e.consume(F),F===92?b:_)}function b(F){return F===92||F===124?(e.consume(F),_):_(F)}function y(F){return s.interrupt=!1,s.parser.lazy[s.now().line]?n(F):(e.enter("tableDelimiterRow"),c=!1,Le(F)?Ue(e,x,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):x(F))}function x(F){return F===45||F===58?L(F):F===124?(c=!0,e.enter("tableCellDivider"),e.consume(F),e.exit("tableCellDivider"),k):Y(F)}function k(F){return Le(F)?Ue(e,L,"whitespace")(F):L(F)}function L(F){return F===58?(o+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(F),e.exit("tableDelimiterMarker"),R):F===45?(o+=1,R(F)):F===null||ye(F)?Z(F):Y(F)}function R(F){return F===45?(e.enter("tableDelimiterFiller"),$(F)):Y(F)}function $(F){return F===45?(e.consume(F),$):F===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(F),e.exit("tableDelimiterMarker"),I):(e.exit("tableDelimiterFiller"),I(F))}function I(F){return Le(F)?Ue(e,Z,"whitespace")(F):Z(F)}function Z(F){return F===124?x(F):F===null||ye(F)?!c||a!==o?Y(F):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(F)):Y(F)}function Y(F){return n(F)}function O(F){return e.enter("tableRow"),J(F)}function J(F){return F===124?(e.enter("tableCellDivider"),e.consume(F),e.exit("tableCellDivider"),J):F===null||ye(F)?(e.exit("tableRow"),t(F)):Le(F)?Ue(e,J,"whitespace")(F):(e.enter("data"),ce(F))}function ce(F){return F===null||F===124||et(F)?(e.exit("data"),J(F)):(e.consume(F),F===92?pe:ce)}function pe(F){return F===92||F===124?(e.consume(F),ce):ce(F)}}function CD(e,t){let n=-1,s=!0,a=0,o=[0,0,0,0],c=[0,0,0,0],f=!1,p=0,h,g,_;const b=new yD;for(;++nn[2]+1){const x=n[2]+1,k=n[3]-n[2]-1;e.add(x,k,[])}}e.add(n[3]+1,0,[["exit",_,t]])}return a!==void 0&&(o.end=Object.assign({},Fs(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function Yy(e,t,n,s,a){const o=[],c=Fs(t.events,n);a&&(a.end=Object.assign({},c),o.push(["exit",a,t])),s.end=Object.assign({},c),o.push(["exit",s,t]),e.add(n+1,0,o)}function Fs(e,t){const n=e[t],s=n[0]==="enter"?"start":"end";return n[1][s]}const kD={name:"tasklistCheck",tokenize:TD};function ED(){return{text:{91:kD}}}function TD(e,t,n){const s=this;return a;function a(p){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?n(p):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),o)}function o(p){return et(p)?(e.enter("taskListCheckValueUnchecked"),e.consume(p),e.exit("taskListCheckValueUnchecked"),c):p===88||p===120?(e.enter("taskListCheckValueChecked"),e.consume(p),e.exit("taskListCheckValueChecked"),c):n(p)}function c(p){return p===93?(e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):n(p)}function f(p){return ye(p)?t(p):Le(p)?e.check({tokenize:AD},t,n)(p):n(p)}}function AD(e,t,n){return Ue(e,s,"whitespace");function s(a){return a===null?n(a):t(a)}}function DD(e){return uS([eD(),cD(),vD(e),xD(),ED()])}const RD={};function MD(e){const t=this,n=e||RD,s=t.data(),a=s.micromarkExtensions||(s.micromarkExtensions=[]),o=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),c=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);a.push(DD(n)),o.push(GA()),c.push(ZA(n))}const Pr=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],Vy={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...Pr,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...Pr],h2:[["className","sr-only"]],img:[...Pr,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...Pr,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...Pr],table:[...Pr],ul:[...Pr,["className","contains-task-list"]],"*":["abbr","accept","acceptCharset","accessKey","action","align","alt","axis","border","cellPadding","cellSpacing","char","charOff","charSet","checked","clear","colSpan","color","cols","compact","coords","dateTime","dir","encType","frame","hSpace","headers","height","hrefLang","htmlFor","id","isMap","itemProp","label","lang","maxLength","media","method","multiple","name","noHref","noShade","noWrap","open","prompt","readOnly","rev","rowSpan","rows","rules","scope","selected","shape","size","span","start","summary","tabIndex","title","useMap","vAlign","value","width"]},clobber:["ariaDescribedBy","ariaLabelledBy","id","name"],clobberPrefix:"user-content-",protocols:{cite:["http","https"],href:["http","https","irc","ircs","mailto","xmpp"],longDesc:["http","https"],src:["http","https"]},required:{input:{disabled:!0,type:"checkbox"}},strip:["script"],tagNames:["a","b","blockquote","br","code","dd","del","details","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","i","img","input","ins","kbd","li","ol","p","picture","pre","q","rp","rt","ruby","s","samp","section","source","span","strike","strong","sub","summary","sup","table","tbody","td","tfoot","th","thead","tr","tt","ul","var"]},pr={}.hasOwnProperty;function BD(e,t){let n={type:"root",children:[]};const s={schema:t?{...Vy,...t}:Vy,stack:[]},a=e0(s,e);return a&&(Array.isArray(a)?a.length===1?n=a[0]:n.children=a:n=a),n}function e0(e,t){if(t&&typeof t=="object"){const n=t;switch(typeof n.type=="string"?n.type:""){case"comment":return ND(e,n);case"doctype":return LD(e,n);case"element":return zD(e,n);case"root":return OD(e,n);case"text":return jD(e,n)}}}function ND(e,t){if(e.schema.allowComments){const n=typeof t.value=="string"?t.value:"",s=n.indexOf("-->"),o={type:"comment",value:s<0?n:n.slice(0,s)};return Ca(o,t),o}}function LD(e,t){if(e.schema.allowDoctypes){const n={type:"doctype"};return Ca(n,t),n}}function zD(e,t){const n=typeof t.tagName=="string"?t.tagName:"";e.stack.push(n);const s=t0(e,t.children),a=HD(e,t.properties);e.stack.pop();let o=!1;if(n&&n!=="*"&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(o=!0,e.schema.ancestors&&pr.call(e.schema.ancestors,n))){const f=e.schema.ancestors[n];let p=-1;for(o=!1;++p1){let a=!1,o=0;for(;++o-1&&o>p||c>-1&&o>c||f>-1&&o>f)return!0;let h=-1;for(;++h4&&t.slice(0,4).toLowerCase()==="data")return n}function ID(e){return function(t){return BD(t,e)}}const kf=["Romance","Fantasy","Science Fiction","Mystery","Thriller","Horror","Adventure","Historical Fiction","Contemporary Lit","Humor","Poetry","Non-Fiction","Fanfiction","Short Story","Paranormal","Werewolf","LGBTQ+","New Adult","Teen Fiction","Diverse Lit","Others"],Ef=["English","Chinese","Korean","Japanese","Spanish","French","Hindi","Arabic","Portuguese","Russian","Others"];function FD({storyName:e,fileName:t,authFetch:n,onPublish:s,publishingFile:a}){const[o,c]=Q.useState(null),[f,p]=Q.useState(!1),[h,g]=Q.useState("preview"),[_,b]=Q.useState(""),[y,x]=Q.useState(!1),[k,L]=Q.useState(!1),[R,$]=Q.useState(!1),[I,Z]=Q.useState(null),[Y,O]=Q.useState(kf[0]),[J,ce]=Q.useState(Ef[0]),[pe,F]=Q.useState(!1),se=Q.useRef(null),H=Q.useRef(!1),E=Q.useRef(null),B=Q.useCallback(async()=>{if(!e||!t){c(null);return}const ae=`${e}/${t}`,le=E.current!==ae;le&&(E.current=ae);try{const ge=await n(`/api/stories/${e}/${t}`);if(ge.ok){const Ee=await ge.json();c(Ee),(le||!H.current)&&(b(Ee.content??""),le&&(L(!1),H.current=!1))}}catch{}},[e,t,n]);Q.useEffect(()=>{p(!0),B().finally(()=>p(!1))},[B]),Q.useEffect(()=>{if(!e||!t||h==="edit"&&k)return;const ae=setInterval(B,3e3);return()=>clearInterval(ae)},[e,t,B,h,k]),Q.useEffect(()=>{if(!e)return;let ae=!1;return n(`/api/stories/${e}/structure.md`).then(le=>le.ok?le.json():null).then(le=>{if(ae||!(le!=null&&le.content))return;const ge=le.content.match(/\*{0,2}genre\*{0,2}[:\s]+(.+)/i);if(ge){const Se=ge[1].replace(/\*+/g,"").trim(),Ze=kf.find(Fe=>Fe.toLowerCase()===Se.toLowerCase());Ze&&O(Ze)}const Ee=le.content.match(/\*{0,2}language\*{0,2}[:\s]+(.+)/i);if(Ee){const Se=Ee[1].replace(/\*+/g,"").trim(),Ze=Ef.find(Fe=>Fe.toLowerCase()===Se.toLowerCase());Ze&&ce(Ze)}}).catch(()=>{}),()=>{ae=!0}},[e,n]);const N=Q.useCallback(async()=>{if(!(!e||!t)){x(!0);try{(await n(`/api/stories/${e}/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:_})})).ok&&(L(!1),H.current=!1,c(le=>le&&{...le,content:_}))}catch{}x(!1)}},[e,t,n,_]);Q.useEffect(()=>{if(h!=="edit")return;const ae=le=>{(le.metaKey||le.ctrlKey)&&le.key==="s"&&(le.preventDefault(),N())};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[h,N]),Q.useEffect(()=>{if((o==null?void 0:o.status)!=="published-not-indexed"||!o.publishedAt)return;const ae=new Date(o.publishedAt).getTime(),le=300*1e3,ge=()=>{const Se=Math.max(0,le-(Date.now()-ae));Z(Se)};ge();const Ee=setInterval(ge,1e3);return()=>clearInterval(Ee)},[o==null?void 0:o.status,o==null?void 0:o.publishedAt]);const A=I!==null&&I<=0,j=I!==null&&I>0?`${Math.floor(I/6e4)}:${String(Math.floor(I%6e4/1e3)).padStart(2,"0")}`:null;if(!e||!t)return S.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:S.jsxs("div",{className:"text-center",children:[S.jsx("p",{className:"text-lg font-serif",children:"Select a file to preview"}),S.jsx("p",{className:"text-sm mt-1",children:"Click a story file in the sidebar"})]})});if(f&&!o)return S.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:"Loading..."});const oe=(h==="edit"?_:(o==null?void 0:o.content)??"").length,T=t==="genesis.md",D=t?/^plot-\d+\.md$/.test(t):!1,V=(o==null?void 0:o.status)==="published"||(o==null?void 0:o.status)==="published-not-indexed",w=T||D?1e4:null,ie=!V&&w!==null&&oe>w;return S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"border-b border-border",children:[S.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[S.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono text-muted",children:[S.jsxs("span",{children:[e,"/",t]}),(o==null?void 0:o.status)==="published"&&S.jsx("span",{className:"text-green-700 font-medium",children:"Published"}),(o==null?void 0:o.status)==="published-not-indexed"&&S.jsx("span",{className:"text-amber-700 font-medium",title:o.indexError,children:"Published (not indexed)"}),(o==null?void 0:o.status)==="pending"&&S.jsx("span",{className:"text-amber-700 font-medium",children:"Pending"})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsxs("span",{className:`text-xs font-mono ${ie?"text-error font-medium":"text-muted"}`,children:[oe.toLocaleString(),w!==null?`/${w.toLocaleString()}`:" chars"]}),ie&&S.jsxs("span",{className:"text-error text-xs font-medium",children:[(oe-w).toLocaleString()," over limit"]})]})]}),S.jsxs("div",{className:"flex px-3 gap-1",children:[S.jsx("button",{onClick:()=>g("preview"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${h==="preview"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:"Preview"}),S.jsxs("button",{onClick:()=>g("edit"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${h==="edit"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:["Edit",k&&S.jsx("span",{className:"ml-1 text-amber-600",children:"*"})]})]})]}),h==="preview"?S.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-6 py-4",style:{background:"var(--paper-bg)"},children:o!=null&&o.content?S.jsx("div",{className:"prose max-w-none",children:S.jsx(_3,{remarkPlugins:[T3,MD],rehypePlugins:[ID],children:o.content})}):S.jsx("p",{className:"text-muted italic",children:"No content"})}):S.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",style:{background:"var(--paper-bg)"},children:[S.jsx("textarea",{ref:se,value:_,onChange:ae=>{b(ae.target.value),L(!0),H.current=!0},className:"flex-1 min-h-0 w-full resize-none px-4 py-3 text-sm leading-relaxed focus:outline-none",style:{fontFamily:'"Geist Mono", ui-monospace, monospace',background:"var(--paper-bg)",color:"var(--text)"},spellCheck:!1}),S.jsxs("div",{className:"px-3 py-1.5 border-t border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs text-muted",children:k?"Unsaved changes":"No changes"}),S.jsx("button",{onClick:N,disabled:!k||y,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:y?"Saving...":"Save"})]})]}),S.jsx("div",{className:"px-3 py-2 border-t border-border flex items-center justify-between",children:t==="structure.md"?S.jsx("p",{className:"text-muted text-xs italic",children:"This is your story outline — not publishable. Ask AI to write the genesis next."}):(o==null?void 0:o.status)==="published-not-indexed"?S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[S.jsx("span",{className:"text-amber-700",children:"Published on-chain but not indexed on PlotLink"}),!A&&S.jsx("button",{onClick:async()=>{if(!(!e||!t||!o.txHash)){$(!0);try{(await(await n("/api/publish/retry-index",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:e,fileName:t,txHash:o.txHash,content:o.content,storylineId:o.storylineId})})).json()).ok&&(await n(`/api/stories/${e}/${t}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:o.txHash,storylineId:o.storylineId,contentCid:"",gasCost:""})}),B())}catch{}$(!1)}},disabled:R,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:R?"Retrying...":`Retry Index${j?` (${j})`:""}`}),D&&S.jsx("button",{onClick:()=>e&&t&&(s==null?void 0:s(e,t,Y,J,pe)),disabled:!!a,className:"px-3 py-1 border border-border text-xs rounded hover:bg-surface disabled:opacity-50",children:a===t?"Publishing...":"Retry Publish"}),o.txHash&&S.jsx("a",{href:`https://basescan.org/tx/${o.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"})]}),S.jsx("p",{className:"text-muted text-xs",children:A?D?"Index window expired. Use Retry Publish to create a new on-chain tx.":"Index window expired. Contact support or re-publish manually.":D?"Try Retry Index first (available for 5 min after publish). If that fails, Retry Publish creates a new on-chain tx.":"Retry Index is available for 5 min after publish."}),o.indexError&&S.jsx("p",{className:"text-error text-xs",children:o.indexError})]}):(o==null?void 0:o.status)==="published"?S.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[S.jsx("span",{className:"text-green-700",children:"Published"}),o.storylineId&&S.jsx("a",{href:(()=>{var ge;const ae=`https://plotlink.xyz/story/${o.storylineId}`;if(!D)return ae;const le=o.plotIndex!=null&&o.plotIndex>0?o.plotIndex:parseInt(((ge=t==null?void 0:t.match(/^plot-(\d+)\.md$/))==null?void 0:ge[1])??"1");return`${ae}/${le}`})(),target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"}),o.txHash&&S.jsx("a",{href:`https://basescan.org/tx/${o.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"})]}):S.jsxs("div",{className:"flex flex-col gap-2",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[T&&S.jsxs(S.Fragment,{children:[S.jsx("select",{value:Y,onChange:ae=>O(ae.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:kf.map(ae=>S.jsx("option",{value:ae,children:ae},ae))}),S.jsx("select",{value:J,onChange:ae=>ce(ae.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:Ef.map(ae=>S.jsx("option",{value:ae,children:ae},ae))})]}),S.jsx("button",{onClick:()=>e&&t&&(s==null?void 0:s(e,t,Y,J,pe)),disabled:!!a||ie,className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:a===t?"Publishing...":"Publish to PlotLink"}),ie&&S.jsx("span",{className:"text-error text-xs",children:"Reduce content to publish"})]}),T&&S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[S.jsx("input",{type:"checkbox",checked:pe,onChange:ae=>F(ae.target.checked),className:"rounded border-border"}),"This story contains adult content (18+)"]}),pe&&S.jsx("span",{className:"text-xs text-amber-600",children:"Adult content will be hidden from the default browse view."})]})]})})]})}const n0="plotlink-panel-ratio",qD=.6,$y=300,Tf=224,Af=6;function WD(){try{const e=localStorage.getItem(n0);if(e){const t=parseFloat(e);if(t>0&&t<1)return t}}catch{}return qD}function Gy(e,t){if(t<=0)return e;const n=$y/t,s=1-$y/t;return n>=s?.5:Math.min(s,Math.max(n,e))}function YD({token:e,authFetch:t}){const[n,s]=Q.useState(null),[a,o]=Q.useState(null),[c,f]=Q.useState(null),[p,h]=Q.useState(""),[g,_]=Q.useState(WD),[b,y]=Q.useState([]),x=Q.useRef(new Set),k=Q.useRef(null),L=Q.useRef(null),R=Q.useRef(!1);Q.useEffect(()=>{try{localStorage.setItem(n0,String(g))}catch{}},[g]),Q.useEffect(()=>{const H=()=>{if(!L.current)return;const E=L.current.getBoundingClientRect().width-Tf-Af;_(B=>Gy(B,E))};return window.addEventListener("resize",H),H(),()=>window.removeEventListener("resize",H)},[]);const $=Q.useCallback(()=>{const H=`_new_${Date.now()}`;y(E=>[...E,H]),s(H),o(null)},[]);Q.useEffect(()=>{if(b.length===0)return;const H=setInterval(async()=>{try{const E=await t("/api/stories");if(!E.ok)return;const B=await E.json(),N=new Set(B.stories.filter(A=>A.name!=="_example").map(A=>A.name));for(const A of N)if(!x.current.has(A)&&b.length>0){const j=b[0];let P=!1;k.current&&(P=await k.current(j,A).catch(()=>!1)),P&&y(oe=>oe.slice(1)),s(A),o(null)}x.current=N}catch{}},3e3);return()=>clearInterval(H)},[t,b]),Q.useEffect(()=>{t("/api/stories").then(H=>{if(H.ok)return H.json()}).then(H=>{H!=null&&H.stories&&(x.current=new Set(H.stories.filter(E=>E.name!=="_example").map(E=>E.name)))}).catch(()=>{})},[t]);const I=Q.useCallback((H,E)=>{s(H),o(E)},[]),Z=Q.useRef(null),Y=Q.useCallback(async H=>{var E,B,N,A;Z.current=H,s(H),o(null);try{const j=await t(`/api/stories/${H}`);if(j.ok&&Z.current===H){const oe=(await j.json()).files||[],D=((E=oe.map(V=>{var w;return{file:V.file,num:(w=V.file.match(/^plot-(\d+)\.md$/))==null?void 0:w[1]}}).filter(V=>V.num!=null).sort((V,w)=>parseInt(w.num)-parseInt(V.num))[0])==null?void 0:E.file)??((B=oe.find(V=>V.file==="genesis.md"))==null?void 0:B.file)??((N=oe.find(V=>V.file==="structure.md"))==null?void 0:N.file)??((A=oe[0])==null?void 0:A.file);D&&Z.current===H&&o(D)}}catch{}},[t]),O=Q.useCallback(H=>{H.preventDefault(),R.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";const E=N=>{if(!R.current||!L.current)return;const A=L.current.getBoundingClientRect(),j=A.width-Tf-Af,P=N.clientX-A.left-Tf;_(Gy(P/j,j))},B=()=>{R.current=!1,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",E),window.removeEventListener("mouseup",B)};window.addEventListener("mousemove",E),window.addEventListener("mouseup",B)},[]),J=Q.useCallback(async(H,E,B,N,A)=>{var j;f(E),h("Reading file...");try{const P=await t(`/api/stories/${H}/${E}`);if(!P.ok)throw new Error("Failed to read file");const oe=await P.json(),T=oe.content.match(/^#\s+(.+)$/m),D=T?T[1].slice(0,60):E.replace(".md","");let V;if(E.match(/^plot-\d+\.md$/)){try{const le=await t(`/api/stories/${H}`);if(le.ok){const Ee=(await le.json()).files.find(Se=>Se.file==="genesis.md"&&Se.storylineId);V=Ee==null?void 0:Ee.storylineId}}catch{}if(!V){h("Error: Publish genesis first to create the storyline"),setTimeout(()=>{f(null),h("")},3e3);return}}h("Publishing...");const w=await t("/api/publish/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:H,fileName:E,title:D,content:oe.content,genre:B,language:N,isNsfw:A,storylineId:V})});if(!w.ok){const le=await w.json();throw new Error(le.error||"Publish failed")}const ie=(j=w.body)==null?void 0:j.getReader(),ae=new TextDecoder;if(ie)for(;;){const{done:le,value:ge}=await ie.read();if(le)break;const Se=ae.decode(ge).split(` -`).filter(Ze=>Ze.startsWith("data: "));for(const Ze of Se)try{const Fe=JSON.parse(Ze.slice(6));Fe.step&&h(Fe.message||Fe.step),Fe.step==="done"&&Fe.txHash&&await t(`/api/stories/${H}/${E}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:Fe.txHash,storylineId:Fe.storylineId,plotIndex:Fe.plotIndex,contentCid:Fe.contentCid,gasCost:Fe.gasCost,indexError:Fe.indexError})})}catch{}}h("Published!")}catch(P){const oe=P instanceof Error?P.message:"Publish failed";h(`Error: ${oe}`)}finally{setTimeout(()=>{f(null),h("")},3e3)}},[t]),ce=Q.useCallback(H=>{H.startsWith("_new_")&&y(E=>E.filter(B=>B!==H))},[]),[pe,F]=Q.useState(new Set);Q.useEffect(()=>{t("/api/stories").then(E=>E.ok?E.json():null).then(E=>{E!=null&&E.stories&&F(new Set(E.stories.filter(B=>B.hasStructure).map(B=>B.name)))}).catch(()=>{});const H=setInterval(async()=>{try{const E=await t("/api/stories");if(E.ok){const B=await E.json();F(new Set(B.stories.filter(N=>N.hasStructure).map(N=>N.name)))}}catch{}},5e3);return()=>clearInterval(H)},[t]);const se=Q.useCallback(H=>{n===H&&(s(null),o(null))},[n]);return S.jsxs("div",{ref:L,className:"h-[calc(100vh-3.5rem)] flex",children:[S.jsx("div",{className:"w-56 border-r border-border flex-shrink-0",children:S.jsx(jx,{authFetch:t,selectedStory:n,selectedFile:a,onSelectFile:I,onNewStory:$,untitledSessions:b})}),S.jsx("div",{className:"min-w-0 border-r border-border",style:{flex:`${g} 0 0`},children:S.jsx(lk,{token:e,storyName:n,authFetch:t,onSelectStory:Y,onDestroySession:ce,onArchiveStory:se,confirmedStories:pe,renameRef:k})}),S.jsx("div",{onMouseDown:O,className:"flex-shrink-0 flex items-center justify-center hover:bg-border/50 transition-colors",style:{width:Af,cursor:"col-resize",background:"var(--border)"},children:S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}})]})}),S.jsxs("div",{className:"min-w-0 flex flex-col",style:{flex:`${1-g} 0 0`},children:[S.jsx(FD,{storyName:n,fileName:a,authFetch:t,onPublish:J,publishingFile:c}),p&&S.jsx("div",{className:"px-3 py-1.5 bg-surface border-t border-border text-xs text-muted",children:p})]})]})}function VD({token:e,onComplete:t}){const[n,s]=Q.useState(!1),[a,o]=Q.useState(null),[c,f]=Q.useState(!1),p=async()=>{s(!0),o(null);try{const h=await fetch("/api/wallet/create",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),g=await h.json();if(!h.ok)throw new Error(g.error||"Wallet creation failed");f(!0)}catch(h){o(h instanceof Error?h.message:"Wallet creation failed")}s(!1)};return Q.useEffect(()=>{p()},[]),S.jsxs("div",{className:"mx-auto max-w-sm p-6 text-center",children:[S.jsx("h2",{className:"text-accent mb-1 text-lg font-bold",children:"Wallet Setup"}),S.jsx("p",{className:"text-muted mb-6 text-xs",children:"creating your OWS wallet for on-chain publishing"}),n&&S.jsx("p",{className:"text-accent text-sm",children:"creating wallet..."}),a&&S.jsxs("div",{className:"space-y-4",children:[S.jsx("div",{className:"rounded border border-red-700/30 p-3 text-xs text-red-700",children:a}),S.jsx("button",{onClick:p,className:"border-accent text-accent hover:bg-accent/10 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:"retry"})]}),c&&S.jsxs("div",{className:"space-y-4",children:[S.jsx("div",{className:"text-accent text-2xl",children:"✓"}),S.jsx("p",{className:"text-foreground text-sm font-medium",children:"wallet created"}),S.jsx("button",{onClick:t,className:"border-accent text-accent hover:bg-accent/10 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:"continue"})]})]})}function KD({token:e,onLogout:t}){const[n,s]=Q.useState("home"),[a,o]=Q.useState(0),c=Q.useCallback(async(f,p)=>fetch(f,{...p,headers:{...(p==null?void 0:p.headers)||{},Authorization:`Bearer ${e}`}}),[e]);return Q.useEffect(()=>{async function f(){try{if(!(await(await c("/api/wallet")).json()).exists){s("wallet-setup");return}const g=await c("/api/stories");if(g.ok){const _=await g.json();o(_.stories.filter(b=>b.name!=="_example").length)}}catch{}}f()},[e]),S.jsxs("div",{className:"flex h-screen flex-col",children:[S.jsxs("header",{className:"border-border flex h-14 items-center justify-between border-b px-4 flex-shrink-0",children:[S.jsxs("div",{className:"flex items-center gap-3",children:[S.jsx("button",{onClick:()=>{n!=="wallet-setup"&&s("home")},className:"flex items-center gap-2 hover:opacity-80",children:S.jsx("span",{className:"text-accent text-sm font-bold tracking-tight",children:"PlotLink OWS"})}),S.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"writer"})]}),n!=="wallet-setup"&&S.jsxs("nav",{className:"flex items-center gap-4",children:[S.jsx("button",{onClick:()=>s("stories"),className:`text-xs transition-colors ${n==="stories"?"text-accent":"text-muted hover:text-foreground"}`,children:"stories"}),S.jsx("button",{onClick:()=>s("dashboard"),className:`text-xs transition-colors ${n==="dashboard"?"text-accent":"text-muted hover:text-foreground"}`,children:"dashboard"}),S.jsx("button",{onClick:()=>s("settings"),className:`text-xs transition-colors ${n==="settings"?"text-accent":"text-muted hover:text-foreground"}`,children:"settings"}),S.jsx("button",{onClick:t,className:"text-muted hover:text-foreground text-xs transition-colors",children:"logout"})]})]}),S.jsxs("main",{className:"flex-1 min-h-0",children:[n==="home"&&S.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-8",children:[S.jsxs("div",{className:"text-center space-y-2",children:[S.jsx("h1",{className:"text-2xl font-serif text-foreground",children:"Write. Publish. Earn."}),S.jsx("p",{className:"text-muted text-sm",children:"Claude CLI writes stories. You publish them on-chain."})]}),S.jsxs("div",{className:"text-center space-y-3",children:[S.jsx("button",{onClick:()=>s("stories"),className:"bg-accent text-white hover:bg-accent-dim px-6 py-2.5 rounded text-sm font-medium transition-colors",children:"Start Writing"}),a>0&&S.jsxs("p",{className:"text-muted text-xs",children:[a," ",a===1?"story":"stories"," in progress"]})]}),S.jsxs("div",{className:"rounded border border-border p-4 space-y-2 text-xs text-muted",children:[S.jsx("p",{className:"font-medium text-foreground text-sm",children:"How it works"}),S.jsxs("ol",{className:"space-y-1.5 list-decimal list-inside",children:[S.jsxs("li",{children:["Open the ",S.jsx("strong",{children:"Stories"})," tab — Claude CLI launches in the terminal"]}),S.jsx("li",{children:"Tell Claude your story idea — it brainstorms, outlines, and writes"}),S.jsx("li",{children:"Review the live preview as Claude creates files"}),S.jsxs("li",{children:["Click ",S.jsx("strong",{children:"Publish"})," to put your story on-chain"]}),S.jsxs("li",{children:["Earn 5% royalties on every trade at ",S.jsx("a",{href:"https://plotlink.xyz",target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"plotlink.xyz"})]})]})]}),S.jsx("div",{className:"text-center",children:S.jsx("a",{href:"https://github.com/realproject7/plotlink-ows#-wallet-setup",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted hover:text-accent underline transition-colors",children:"Wallet Setup Guide"})}),S.jsx(eb,{token:e})]}),n==="stories"&&S.jsx(YD,{token:e,authFetch:c}),n==="dashboard"&&S.jsx(Lx,{token:e}),n==="wallet-setup"&&S.jsx(VD,{token:e,onComplete:()=>s("home")}),n==="settings"&&S.jsx(Bx,{token:e,onLogout:t})]})]})}function XD(){const[e,t]=Q.useState(()=>localStorage.getItem("ows-token")),[n,s]=Q.useState(null),[a,o]=Q.useState(!0);Q.useEffect(()=>{fetch("/api/auth/status").then(h=>h.json()).then(h=>s(h.configured)).catch(()=>s(null))},[]),Q.useEffect(()=>{if(!e){o(!1);return}fetch("/api/auth/verify",{headers:{Authorization:`Bearer ${e}`}}).then(h=>{h.ok||(localStorage.removeItem("ows-token"),t(null))}).catch(()=>{localStorage.removeItem("ows-token"),t(null)}).finally(()=>o(!1))},[e]);const c=async h=>{try{const g=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:h})}),_=await g.json();return g.ok?(localStorage.setItem("ows-token",_.token),t(_.token),null):_.error||"Login failed"}catch{return"Cannot connect to server"}},f=async h=>{try{const g=await fetch("/api/auth/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:h})}),_=await g.json();return g.ok?(localStorage.setItem("ows-token",_.token),t(_.token),s(!0),null):_.error||"Setup failed"}catch{return"Cannot connect to server"}},p=()=>{localStorage.removeItem("ows-token"),t(null)};return a||n===null?S.jsx("div",{className:"flex h-screen items-center justify-center",children:S.jsx("span",{className:"text-muted text-sm",children:"connecting..."})}):n?e?S.jsx(KD,{token:e,onLogout:p}):S.jsx(Rx,{onLogin:c}):S.jsx(Mx,{onSetup:f})}Dx.createRoot(document.getElementById("root")).render(S.jsx(Sx.StrictMode,{children:S.jsx(XD,{})})); diff --git a/app/web/dist/index.html b/app/web/dist/index.html index 9ac5d90..4bb3642 100644 --- a/app/web/dist/index.html +++ b/app/web/dist/index.html @@ -7,8 +7,8 @@ - - + +
diff --git a/package.json b/package.json index f84e11a..4e10f0d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plotlink-ows", - "version": "1.0.25", + "version": "1.1.0", "bin": { "plotlink-ows": "./bin/plotlink-ows.js" }, From 29425eac21346d9d2fa042e54d4342a47191b731 Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Sat, 9 May 2026 13:49:05 +0900 Subject: [PATCH 2/5] [#177] Fetch current metadata when edit panel opens Initialize genre, language, and NSFW fields from the storyline's current values on PlotLink so saving with only a cover change doesn't silently overwrite existing metadata to defaults. Co-Authored-By: Claude Opus 4.6 (1M context) --- app/web/components/PreviewPanel.tsx | 25 ++++++- .../{index-CkTK65WZ.js => index-xXd0uHn_.js} | 66 +++++++++---------- app/web/dist/index.html | 2 +- 3 files changed, 58 insertions(+), 35 deletions(-) rename app/web/dist/assets/{index-CkTK65WZ.js => index-xXd0uHn_.js} (87%) diff --git a/app/web/components/PreviewPanel.tsx b/app/web/components/PreviewPanel.tsx index 59b16e5..af28834 100644 --- a/app/web/components/PreviewPanel.tsx +++ b/app/web/components/PreviewPanel.tsx @@ -205,7 +205,7 @@ export function PreviewPanel({ storyName, fileName, authFetch, onPublish, publis } }, [fileData?.storylineId, coverFile, editGenre, editLanguage, editNsfw, authFetch]); - // Reset edit panel state when toggling or changing files + // Reset edit panel state when changing files useEffect(() => { setShowEditPanel(false); setCoverFile(null); @@ -214,6 +214,29 @@ export function PreviewPanel({ storyName, fileName, authFetch, onPublish, publis setEditSuccess(false); }, [storyName, fileName]); + // Fetch current storyline metadata when edit panel opens + useEffect(() => { + if (!showEditPanel || !fileData?.storylineId) return; + const PLOTLINK_URL = "https://plotlink.xyz"; + let cancelled = false; + fetch(`${PLOTLINK_URL}/api/storyline/${fileData.storylineId}`) + .then((res) => res.ok ? res.json() : null) + .then((data) => { + if (cancelled || !data) return; + if (data.genre) { + const found = GENRES.find((g) => g.toLowerCase() === data.genre.toLowerCase()); + if (found) setEditGenre(found); + } + if (data.language) { + const found = LANGUAGES.find((l) => l.toLowerCase() === data.language.toLowerCase()); + if (found) setEditLanguage(found); + } + if (data.isNsfw !== undefined) setEditNsfw(!!data.isNsfw); + }) + .catch(() => {}); + return () => { cancelled = true; }; + }, [showEditPanel, fileData?.storylineId]); + // Ctrl+S / Cmd+S to save useEffect(() => { if (activeTab !== "edit") return; diff --git a/app/web/dist/assets/index-CkTK65WZ.js b/app/web/dist/assets/index-xXd0uHn_.js similarity index 87% rename from app/web/dist/assets/index-CkTK65WZ.js rename to app/web/dist/assets/index-xXd0uHn_.js index 0bf084a..f97bc36 100644 --- a/app/web/dist/assets/index-CkTK65WZ.js +++ b/app/web/dist/assets/index-xXd0uHn_.js @@ -1,4 +1,4 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();function xu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Wh={exports:{}},Xl={};/** +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();function xu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Wh={exports:{}},Gl={};/** * @license React * react-jsx-runtime.production.js * @@ -6,7 +6,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Gg;function vx(){if(Gg)return Xl;Gg=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,a,o){var c=null;if(o!==void 0&&(c=""+o),a.key!==void 0&&(c=""+a.key),"key"in a){o={};for(var f in a)f!=="key"&&(o[f]=a[f])}else o=a;return a=o.ref,{$$typeof:e,type:s,key:c,ref:a!==void 0?a:null,props:o}}return Xl.Fragment=t,Xl.jsx=n,Xl.jsxs=n,Xl}var $g;function yx(){return $g||($g=1,Wh.exports=vx()),Wh.exports}var S=yx(),Yh={exports:{}},Ee={};/** + */var $g;function vx(){if($g)return Gl;$g=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,a,o){var c=null;if(o!==void 0&&(c=""+o),a.key!==void 0&&(c=""+a.key),"key"in a){o={};for(var f in a)f!=="key"&&(o[f]=a[f])}else o=a;return a=o.ref,{$$typeof:e,type:s,key:c,ref:a!==void 0?a:null,props:o}}return Gl.Fragment=t,Gl.jsx=n,Gl.jsxs=n,Gl}var Gg;function yx(){return Gg||(Gg=1,Wh.exports=vx()),Wh.exports}var S=yx(),Yh={exports:{}},Te={};/** * @license React * react.production.js * @@ -14,7 +14,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Zg;function bx(){if(Zg)return Ee;Zg=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),b=Symbol.iterator;function y(D){return D===null||typeof D!="object"?null:(D=b&&D[b]||D["@@iterator"],typeof D=="function"?D:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,L={};function M(D,K,C){this.props=D,this.context=K,this.refs=L,this.updater=C||x}M.prototype.isReactComponent={},M.prototype.setState=function(D,K){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,K,"setState")},M.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function Z(){}Z.prototype=M.prototype;function I(D,K,C){this.props=D,this.context=K,this.refs=L,this.updater=C||x}var Q=I.prototype=new Z;Q.constructor=I,k(Q,M.prototype),Q.isPureReactComponent=!0;var W=Array.isArray;function O(){}var ie={H:null,A:null,T:null,S:null},ue=Object.prototype.hasOwnProperty;function me(D,K,C){var J=C.ref;return{$$typeof:e,type:D,key:K,ref:J!==void 0?J:null,props:C}}function U(D,K){return me(D.type,K,D.props)}function le(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function V(D){var K={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(C){return K[C]})}var B=/\/+/g;function A(D,K){return typeof D=="object"&&D!==null&&D.key!=null?V(""+D.key):K.toString(36)}function R(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(O,O):(D.status="pending",D.then(function(K){D.status==="pending"&&(D.status="fulfilled",D.value=K)},function(K){D.status==="pending"&&(D.status="rejected",D.reason=K)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function T(D,K,C,J,fe){var de=typeof D;(de==="undefined"||de==="boolean")&&(D=null);var xe=!1;if(D===null)xe=!0;else switch(de){case"bigint":case"string":case"number":xe=!0;break;case"object":switch(D.$$typeof){case e:case t:xe=!0;break;case g:return xe=D._init,T(xe(D._payload),K,C,J,fe)}}if(xe)return fe=fe(D),xe=J===""?"."+A(D,0):J,W(fe)?(C="",xe!=null&&(C=xe.replace(B,"$&/")+"/"),T(fe,K,C,"",function(rt){return rt})):fe!=null&&(le(fe)&&(fe=U(fe,C+(fe.key==null||D&&D.key===fe.key?"":(""+fe.key).replace(B,"$&/")+"/")+xe)),K.push(fe)),1;xe=0;var Ne=J===""?".":J+":";if(W(D))for(var Ce=0;Ce>>1,E=T[oe];if(0>>1;oea(C,H))Ja(fe,C)?(T[oe]=fe,T[J]=H,oe=J):(T[oe]=C,T[K]=H,oe=K);else if(Ja(fe,H))T[oe]=fe,T[J]=H,oe=J;else break e}}return j}function a(T,j){var H=T.sortIndex-j.sortIndex;return H!==0?H:T.id-j.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,f=c.now();e.unstable_now=function(){return c.now()-f}}var p=[],h=[],g=1,_=null,b=3,y=!1,x=!1,k=!1,L=!1,M=typeof setTimeout=="function"?setTimeout:null,Z=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;function Q(T){for(var j=n(h);j!==null;){if(j.callback===null)s(h);else if(j.startTime<=T)s(h),j.sortIndex=j.expirationTime,t(p,j);else break;j=n(h)}}function W(T){if(k=!1,Q(T),!x)if(n(p)!==null)x=!0,O||(O=!0,V());else{var j=n(h);j!==null&&R(W,j.startTime-T)}}var O=!1,ie=-1,ue=5,me=-1;function U(){return L?!0:!(e.unstable_now()-meT&&U());){var oe=_.callback;if(typeof oe=="function"){_.callback=null,b=_.priorityLevel;var E=oe(_.expirationTime<=T);if(T=e.unstable_now(),typeof E=="function"){_.callback=E,Q(T),j=!0;break t}_===n(p)&&s(p),Q(T)}else s(p);_=n(p)}if(_!==null)j=!0;else{var D=n(h);D!==null&&R(W,D.startTime-T),j=!1}}break e}finally{_=null,b=H,y=!1}j=void 0}}finally{j?V():O=!1}}}var V;if(typeof I=="function")V=function(){I(le)};else if(typeof MessageChannel<"u"){var B=new MessageChannel,A=B.port2;B.port1.onmessage=le,V=function(){A.postMessage(null)}}else V=function(){M(le,0)};function R(T,j){ie=M(function(){T(e.unstable_now())},j)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(T){T.callback=null},e.unstable_forceFrameRate=function(T){0>T||125oe?(T.sortIndex=H,t(h,T),n(p)===null&&T===n(h)&&(k?(Z(ie),ie=-1):k=!0,R(W,H-oe))):(T.sortIndex=E,t(p,T),x||y||(x=!0,O||(O=!0,V()))),T},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(T){var j=b;return function(){var H=b;b=j;try{return T.apply(this,arguments)}finally{b=H}}}})(Xh)),Xh}var ev;function wx(){return ev||(ev=1,Kh.exports=xx()),Kh.exports}var Gh={exports:{}},ei={};/** + */var Jg;function xx(){return Jg||(Jg=1,(function(e){function t(T,j){var H=T.length;T.push(j);e:for(;0>>1,E=T[ae];if(0>>1;aea(C,H))Ja(fe,C)?(T[ae]=fe,T[J]=H,ae=J):(T[ae]=C,T[K]=H,ae=K);else if(Ja(fe,H))T[ae]=fe,T[J]=H,ae=J;else break e}}return j}function a(T,j){var H=T.sortIndex-j.sortIndex;return H!==0?H:T.id-j.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,f=c.now();e.unstable_now=function(){return c.now()-f}}var p=[],h=[],g=1,_=null,b=3,y=!1,x=!1,k=!1,L=!1,M=typeof setTimeout=="function"?setTimeout:null,Z=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;function Q(T){for(var j=n(h);j!==null;){if(j.callback===null)s(h);else if(j.startTime<=T)s(h),j.sortIndex=j.expirationTime,t(p,j);else break;j=n(h)}}function W(T){if(k=!1,Q(T),!x)if(n(p)!==null)x=!0,O||(O=!0,V());else{var j=n(h);j!==null&&R(W,j.startTime-T)}}var O=!1,ie=-1,ue=5,me=-1;function U(){return L?!0:!(e.unstable_now()-meT&&U());){var ae=_.callback;if(typeof ae=="function"){_.callback=null,b=_.priorityLevel;var E=ae(_.expirationTime<=T);if(T=e.unstable_now(),typeof E=="function"){_.callback=E,Q(T),j=!0;break t}_===n(p)&&s(p),Q(T)}else s(p);_=n(p)}if(_!==null)j=!0;else{var D=n(h);D!==null&&R(W,D.startTime-T),j=!1}}break e}finally{_=null,b=H,y=!1}j=void 0}}finally{j?V():O=!1}}}var V;if(typeof I=="function")V=function(){I(le)};else if(typeof MessageChannel<"u"){var B=new MessageChannel,A=B.port2;B.port1.onmessage=le,V=function(){A.postMessage(null)}}else V=function(){M(le,0)};function R(T,j){ie=M(function(){T(e.unstable_now())},j)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(T){T.callback=null},e.unstable_forceFrameRate=function(T){0>T||125ae?(T.sortIndex=H,t(h,T),n(p)===null&&T===n(h)&&(k?(Z(ie),ie=-1):k=!0,R(W,H-ae))):(T.sortIndex=E,t(p,T),x||y||(x=!0,O||(O=!0,V()))),T},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(T){var j=b;return function(){var H=b;b=j;try{return T.apply(this,arguments)}finally{b=H}}}})(Xh)),Xh}var ev;function wx(){return ev||(ev=1,Kh.exports=xx()),Kh.exports}var $h={exports:{}},ei={};/** * @license React * react-dom.production.js * @@ -30,7 +30,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var tv;function Cx(){if(tv)return ei;tv=1;var e=wd();function t(p){var h="https://react.dev/errors/"+p;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Gh.exports=Cx(),Gh.exports}/** + */var tv;function Cx(){if(tv)return ei;tv=1;var e=wd();function t(p){var h="https://react.dev/errors/"+p;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),$h.exports=Cx(),$h.exports}/** * @license React * react-dom-client.production.js * @@ -38,15 +38,15 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var nv;function Ex(){if(nv)return Gl;nv=1;var e=wx(),t=wd(),n=kx();function s(i){var r="https://react.dev/errors/"+i;if(1E||(i.current=oe[E],oe[E]=null,E--)}function C(i,r){E++,oe[E]=i.current,i.current=r}var J=D(null),fe=D(null),de=D(null),xe=D(null);function Ne(i,r){switch(C(de,r),C(fe,i),C(J,null),r.nodeType){case 9:case 11:i=(i=r.documentElement)&&(i=i.namespaceURI)?vg(i):0;break;default:if(i=r.tagName,r=r.namespaceURI)r=vg(r),i=yg(r,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}K(J),C(J,i)}function Ce(){K(J),K(fe),K(de)}function rt(i){i.memoizedState!==null&&C(xe,i);var r=J.current,l=yg(r,i.type);r!==l&&(C(fe,i),C(J,l))}function et(i){fe.current===i&&(K(J),K(fe)),xe.current===i&&(K(xe),Wl._currentValue=H)}var ut,we;function Et(i){if(ut===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);ut=r&&r[1]||"",we=-1E||(i.current=ae[E],ae[E]=null,E--)}function C(i,r){E++,ae[E]=i.current,i.current=r}var J=D(null),fe=D(null),de=D(null),xe=D(null);function Ne(i,r){switch(C(de,r),C(fe,i),C(J,null),r.nodeType){case 9:case 11:i=(i=r.documentElement)&&(i=i.namespaceURI)?vg(i):0;break;default:if(i=r.tagName,r=r.namespaceURI)r=vg(r),i=yg(r,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}K(J),C(J,i)}function ke(){K(J),K(fe),K(de)}function rt(i){i.memoizedState!==null&&C(xe,i);var r=J.current,l=yg(r,i.type);r!==l&&(C(fe,i),C(J,l))}function et(i){fe.current===i&&(K(J),K(fe)),xe.current===i&&(K(xe),Vl._currentValue=H)}var ct,we;function Et(i){if(ct===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);ct=r&&r[1]||"",we=-1)":-1d||N[u]!==q[d]){var ee=` `+N[u].replace(" at new "," at ");return i.displayName&&ee.includes("")&&(ee=ee.replace("",i.displayName)),ee}while(1<=u&&0<=d);break}}}finally{en=!1,Error.prepareStackTrace=l}return(l=i?i.displayName||i.name:"")?Et(l):""}function ss(i,r){switch(i.tag){case 26:case 27:case 5:return Et(i.type);case 16:return Et("Lazy");case 13:return i.child!==r&&r!==null?Et("Suspense Fallback"):Et("Suspense");case 19:return Et("SuspenseList");case 0:case 15:return Wn(i.type,!1);case 11:return Wn(i.type.render,!1);case 1:return Wn(i.type,!0);case 31:return Et("Activity");default:return""}}function Er(i){try{var r="",l=null;do r+=ss(i,l),l=i,i=i.return;while(i);return r}catch(u){return` Error generating stack: `+u.message+` -`+u.stack}}var pn=Object.prototype.hasOwnProperty,Tr=e.unstable_scheduleCallback,mn=e.unstable_cancelCallback,_n=e.unstable_shouldYield,gn=e.unstable_requestPaint,Wt=e.unstable_now,vn=e.unstable_getCurrentPriorityLevel,te=e.unstable_ImmediatePriority,X=e.unstable_UserBlockingPriority,he=e.unstable_NormalPriority,ve=e.unstable_LowPriority,Te=e.unstable_IdlePriority,vt=e.log,Yt=e.unstable_setDisableYieldValue,Tt=null,At=null;function hi(i){if(typeof vt=="function"&&Yt(i),At&&typeof At.setStrictMode=="function")try{At.setStrictMode(Tt,i)}catch{}}var $e=Math.clz32?Math.clz32:r0,Yn=Math.log,Xi=Math.LN2;function r0(i){return i>>>=0,i===0?32:31-(Yn(i)/Xi|0)|0}var Ba=256,Na=262144,La=4194304;function Ar(i){var r=i&42;if(r!==0)return r;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function za(i,r,l){var u=i.pendingLanes;if(u===0)return 0;var d=0,m=i.suspendedLanes,v=i.pingedLanes;i=i.warmLanes;var w=u&134217727;return w!==0?(u=w&~m,u!==0?d=Ar(u):(v&=w,v!==0?d=Ar(v):l||(l=w&~i,l!==0&&(d=Ar(l))))):(w=u&~m,w!==0?d=Ar(w):v!==0?d=Ar(v):l||(l=u&~i,l!==0&&(d=Ar(l)))),d===0?0:r!==0&&r!==d&&(r&m)===0&&(m=d&-d,l=r&-r,m>=l||m===32&&(l&4194048)!==0)?r:d}function nl(i,r){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&r)===0}function s0(i,r){switch(i){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Jd(){var i=La;return La<<=1,(La&62914560)===0&&(La=4194304),i}function Bu(i){for(var r=[],l=0;31>l;l++)r.push(i);return r}function rl(i,r){i.pendingLanes|=r,r!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function l0(i,r,l,u,d,m){var v=i.pendingLanes;i.pendingLanes=l,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=l,i.entangledLanes&=l,i.errorRecoveryDisabledLanes&=l,i.shellSuspendCounter=0;var w=i.entanglements,N=i.expirationTimes,q=i.hiddenUpdates;for(l=v&~l;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var f0=/[\n"\\]/g;function Li(i){return i.replace(f0,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Hu(i,r,l,u,d,m,v,w){i.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?i.type=v:i.removeAttribute("type"),r!=null?v==="number"?(r===0&&i.value===""||i.value!=r)&&(i.value=""+Ni(r)):i.value!==""+Ni(r)&&(i.value=""+Ni(r)):v!=="submit"&&v!=="reset"||i.removeAttribute("value"),r!=null?Pu(i,v,Ni(r)):l!=null?Pu(i,v,Ni(l)):u!=null&&i.removeAttribute("value"),d==null&&m!=null&&(i.defaultChecked=!!m),d!=null&&(i.checked=d&&typeof d!="function"&&typeof d!="symbol"),w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?i.name=""+Ni(w):i.removeAttribute("name")}function fp(i,r,l,u,d,m,v,w){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(i.type=m),r!=null||l!=null){if(!(m!=="submit"&&m!=="reset"||r!=null)){ju(i);return}l=l!=null?""+Ni(l):"",r=r!=null?""+Ni(r):l,w||r===i.value||(i.value=r),i.defaultValue=r}u=u??d,u=typeof u!="function"&&typeof u!="symbol"&&!!u,i.checked=w?i.checked:!!u,i.defaultChecked=!!u,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(i.name=v),ju(i)}function Pu(i,r,l){r==="number"&&Ha(i.ownerDocument)===i||i.defaultValue===""+l||(i.defaultValue=""+l)}function hs(i,r,l,u){if(i=i.options,r){r={};for(var d=0;d"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Wu=!1;if(Sn)try{var ol={};Object.defineProperty(ol,"passive",{get:function(){Wu=!0}}),window.addEventListener("test",ol,ol),window.removeEventListener("test",ol,ol)}catch{Wu=!1}var Kn=null,Yu=null,Ua=null;function yp(){if(Ua)return Ua;var i,r=Yu,l=r.length,u,d="value"in Kn?Kn.value:Kn.textContent,m=d.length;for(i=0;i=hl),kp=" ",Ep=!1;function Tp(i,r){switch(i){case"keyup":return U0.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ap(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var ms=!1;function F0(i,r){switch(i){case"compositionend":return Ap(r);case"keypress":return r.which!==32?null:(Ep=!0,kp);case"textInput":return i=r.data,i===kp&&Ep?null:i;default:return null}}function q0(i,r){if(ms)return i==="compositionend"||!$u&&Tp(i,r)?(i=yp(),Ua=Yu=Kn=null,ms=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1=r)return{node:l,offset:r-i};i=u}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Op(l)}}function Hp(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?Hp(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function Pp(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var r=Ha(i.document);r instanceof i.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)i=r.contentWindow;else break;r=Ha(i.document)}return r}function Ju(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}var Z0=Sn&&"documentMode"in document&&11>=document.documentMode,_s=null,ec=null,ml=null,tc=!1;function Up(i,r,l){var u=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;tc||_s==null||_s!==Ha(u)||(u=_s,"selectionStart"in u&&Ju(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),ml&&pl(ml,u)||(ml=u,u=Lo(ec,"onSelect"),0>=v,d-=v,tn=1<<32-$e(r)+d|l<De?(He=ge,ge=null):He=ge.sibling;var Fe=Y(P,ge,F[De],ne);if(Fe===null){ge===null&&(ge=He);break}i&&ge&&Fe.alternate===null&&r(P,ge),z=m(Fe,z,De),Ie===null?ye=Fe:Ie.sibling=Fe,Ie=Fe,ge=He}if(De===F.length)return l(P,ge),Pe&&wn(P,De),ye;if(ge===null){for(;DeDe?(He=ge,ge=null):He=ge.sibling;var mr=Y(P,ge,Fe.value,ne);if(mr===null){ge===null&&(ge=He);break}i&&ge&&mr.alternate===null&&r(P,ge),z=m(mr,z,De),Ie===null?ye=mr:Ie.sibling=mr,Ie=mr,ge=He}if(Fe.done)return l(P,ge),Pe&&wn(P,De),ye;if(ge===null){for(;!Fe.done;De++,Fe=F.next())Fe=re(P,Fe.value,ne),Fe!==null&&(z=m(Fe,z,De),Ie===null?ye=Fe:Ie.sibling=Fe,Ie=Fe);return Pe&&wn(P,De),ye}for(ge=u(ge);!Fe.done;De++,Fe=F.next())Fe=G(ge,P,De,Fe.value,ne),Fe!==null&&(i&&Fe.alternate!==null&&ge.delete(Fe.key===null?De:Fe.key),z=m(Fe,z,De),Ie===null?ye=Fe:Ie.sibling=Fe,Ie=Fe);return i&&ge.forEach(function(gx){return r(P,gx)}),Pe&&wn(P,De),ye}function Xe(P,z,F,ne){if(typeof F=="object"&&F!==null&&F.type===k&&F.key===null&&(F=F.props.children),typeof F=="object"&&F!==null){switch(F.$$typeof){case y:e:{for(var ye=F.key;z!==null;){if(z.key===ye){if(ye=F.type,ye===k){if(z.tag===7){l(P,z.sibling),ne=d(z,F.props.children),ne.return=P,P=ne;break e}}else if(z.elementType===ye||typeof ye=="object"&&ye!==null&&ye.$$typeof===ue&&Pr(ye)===z.type){l(P,z.sibling),ne=d(z,F.props),Sl(ne,F),ne.return=P,P=ne;break e}l(P,z);break}else r(P,z);z=z.sibling}F.type===k?(ne=Lr(F.props.children,P.mode,ne,F.key),ne.return=P,P=ne):(ne=$a(F.type,F.key,F.props,null,P.mode,ne),Sl(ne,F),ne.return=P,P=ne)}return v(P);case x:e:{for(ye=F.key;z!==null;){if(z.key===ye)if(z.tag===4&&z.stateNode.containerInfo===F.containerInfo&&z.stateNode.implementation===F.implementation){l(P,z.sibling),ne=d(z,F.children||[]),ne.return=P,P=ne;break e}else{l(P,z);break}else r(P,z);z=z.sibling}ne=oc(F,P.mode,ne),ne.return=P,P=ne}return v(P);case ue:return F=Pr(F),Xe(P,z,F,ne)}if(R(F))return _e(P,z,F,ne);if(V(F)){if(ye=V(F),typeof ye!="function")throw Error(s(150));return F=ye.call(F),Se(P,z,F,ne)}if(typeof F.then=="function")return Xe(P,z,no(F),ne);if(F.$$typeof===I)return Xe(P,z,Ja(P,F),ne);ro(P,F)}return typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint"?(F=""+F,z!==null&&z.tag===6?(l(P,z.sibling),ne=d(z,F),ne.return=P,P=ne):(l(P,z),ne=ac(F,P.mode,ne),ne.return=P,P=ne),v(P)):l(P,z)}return function(P,z,F,ne){try{bl=0;var ye=Xe(P,z,F,ne);return Ts=null,ye}catch(ge){if(ge===Es||ge===to)throw ge;var Ie=wi(29,ge,null,P.mode);return Ie.lanes=ne,Ie.return=P,Ie}finally{}}}var Ir=um(!0),cm=um(!1),Qn=!1;function bc(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Sc(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function Jn(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function er(i,r,l){var u=i.updateQueue;if(u===null)return null;if(u=u.shared,(qe&2)!==0){var d=u.pending;return d===null?r.next=r:(r.next=d.next,d.next=r),u.pending=r,r=Ga(i),Kp(i,null,l),r}return Xa(i,u,r,l),Ga(i)}function xl(i,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194048)!==0)){var u=r.lanes;u&=i.pendingLanes,l|=u,r.lanes=l,tp(i,l)}}function xc(i,r){var l=i.updateQueue,u=i.alternate;if(u!==null&&(u=u.updateQueue,l===u)){var d=null,m=null;if(l=l.firstBaseUpdate,l!==null){do{var v={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};m===null?d=m=v:m=m.next=v,l=l.next}while(l!==null);m===null?d=m=r:m=m.next=r}else d=m=r;l={baseState:u.baseState,firstBaseUpdate:d,lastBaseUpdate:m,shared:u.shared,callbacks:u.callbacks},i.updateQueue=l;return}i=l.lastBaseUpdate,i===null?l.firstBaseUpdate=r:i.next=r,l.lastBaseUpdate=r}var wc=!1;function wl(){if(wc){var i=ks;if(i!==null)throw i}}function Cl(i,r,l,u){wc=!1;var d=i.updateQueue;Qn=!1;var m=d.firstBaseUpdate,v=d.lastBaseUpdate,w=d.shared.pending;if(w!==null){d.shared.pending=null;var N=w,q=N.next;N.next=null,v===null?m=q:v.next=q,v=N;var ee=i.alternate;ee!==null&&(ee=ee.updateQueue,w=ee.lastBaseUpdate,w!==v&&(w===null?ee.firstBaseUpdate=q:w.next=q,ee.lastBaseUpdate=N))}if(m!==null){var re=d.baseState;v=0,ee=q=N=null,w=m;do{var Y=w.lane&-536870913,G=Y!==w.lane;if(G?(je&Y)===Y:(u&Y)===Y){Y!==0&&Y===Cs&&(wc=!0),ee!==null&&(ee=ee.next={lane:0,tag:w.tag,payload:w.payload,callback:null,next:null});e:{var _e=i,Se=w;Y=r;var Xe=l;switch(Se.tag){case 1:if(_e=Se.payload,typeof _e=="function"){re=_e.call(Xe,re,Y);break e}re=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Se.payload,Y=typeof _e=="function"?_e.call(Xe,re,Y):_e,Y==null)break e;re=_({},re,Y);break e;case 2:Qn=!0}}Y=w.callback,Y!==null&&(i.flags|=64,G&&(i.flags|=8192),G=d.callbacks,G===null?d.callbacks=[Y]:G.push(Y))}else G={lane:Y,tag:w.tag,payload:w.payload,callback:w.callback,next:null},ee===null?(q=ee=G,N=re):ee=ee.next=G,v|=Y;if(w=w.next,w===null){if(w=d.shared.pending,w===null)break;G=w,w=G.next,G.next=null,d.lastBaseUpdate=G,d.shared.pending=null}}while(!0);ee===null&&(N=re),d.baseState=N,d.firstBaseUpdate=q,d.lastBaseUpdate=ee,m===null&&(d.shared.lanes=0),sr|=v,i.lanes=v,i.memoizedState=re}}function hm(i,r){if(typeof i!="function")throw Error(s(191,i));i.call(r)}function fm(i,r){var l=i.callbacks;if(l!==null)for(i.callbacks=null,i=0;im?m:8;var v=T.T,w={};T.T=w,Fc(i,!1,r,l);try{var N=d(),q=T.S;if(q!==null&&q(w,N),N!==null&&typeof N=="object"&&typeof N.then=="function"){var ee=l1(N,u);Tl(i,r,ee,Ai(i))}else Tl(i,r,u,Ai(i))}catch(re){Tl(i,r,{then:function(){},status:"rejected",reason:re},Ai())}finally{j.p=m,v!==null&&w.types!==null&&(v.types=w.types),T.T=v}}function f1(){}function Uc(i,r,l,u){if(i.tag!==5)throw Error(s(476));var d=Wm(i).queue;qm(i,d,r,H,l===null?f1:function(){return Ym(i),l(u)})}function Wm(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:H,baseState:H,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Tn,lastRenderedState:H},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Tn,lastRenderedState:l},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function Ym(i){var r=Wm(i);r.next===null&&(r=i.alternate.memoizedState),Tl(i,r.next.queue,{},Ai())}function Ic(){return Xt(Wl)}function Vm(){return _t().memoizedState}function Km(){return _t().memoizedState}function d1(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var l=Ai();i=Jn(l);var u=er(r,i,l);u!==null&&(vi(u,r,l),xl(u,r,l)),r={cache:_c()},i.payload=r;return}r=r.return}}function p1(i,r,l){var u=Ai();l={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},mo(i)?Gm(r,l):(l=sc(i,r,l,u),l!==null&&(vi(l,i,u),$m(l,r,u)))}function Xm(i,r,l){var u=Ai();Tl(i,r,l,u)}function Tl(i,r,l,u){var d={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(mo(i))Gm(r,d);else{var m=i.alternate;if(i.lanes===0&&(m===null||m.lanes===0)&&(m=r.lastRenderedReducer,m!==null))try{var v=r.lastRenderedState,w=m(v,l);if(d.hasEagerState=!0,d.eagerState=w,xi(w,v))return Xa(i,r,d,0),Ze===null&&Ka(),!1}catch{}finally{}if(l=sc(i,r,d,u),l!==null)return vi(l,i,u),$m(l,r,u),!0}return!1}function Fc(i,r,l,u){if(u={lane:2,revertLane:bh(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},mo(i)){if(r)throw Error(s(479))}else r=sc(i,l,u,2),r!==null&&vi(r,i,2)}function mo(i){var r=i.alternate;return i===Ae||r!==null&&r===Ae}function Gm(i,r){Ds=ao=!0;var l=i.pending;l===null?r.next=r:(r.next=l.next,l.next=r),i.pending=r}function $m(i,r,l){if((l&4194048)!==0){var u=r.lanes;u&=i.pendingLanes,l|=u,r.lanes=l,tp(i,l)}}var Al={readContext:Xt,use:co,useCallback:ct,useContext:ct,useEffect:ct,useImperativeHandle:ct,useLayoutEffect:ct,useInsertionEffect:ct,useMemo:ct,useReducer:ct,useRef:ct,useState:ct,useDebugValue:ct,useDeferredValue:ct,useTransition:ct,useSyncExternalStore:ct,useId:ct,useHostTransitionStatus:ct,useFormState:ct,useActionState:ct,useOptimistic:ct,useMemoCache:ct,useCacheRefresh:ct};Al.useEffectEvent=ct;var Zm={readContext:Xt,use:co,useCallback:function(i,r){return si().memoizedState=[i,r===void 0?null:r],i},useContext:Xt,useEffect:Lm,useImperativeHandle:function(i,r,l){l=l!=null?l.concat([i]):null,fo(4194308,4,Hm.bind(null,r,i),l)},useLayoutEffect:function(i,r){return fo(4194308,4,i,r)},useInsertionEffect:function(i,r){fo(4,2,i,r)},useMemo:function(i,r){var l=si();r=r===void 0?null:r;var u=i();if(Fr){hi(!0);try{i()}finally{hi(!1)}}return l.memoizedState=[u,r],u},useReducer:function(i,r,l){var u=si();if(l!==void 0){var d=l(r);if(Fr){hi(!0);try{l(r)}finally{hi(!1)}}}else d=r;return u.memoizedState=u.baseState=d,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:d},u.queue=i,i=i.dispatch=p1.bind(null,Ae,i),[u.memoizedState,i]},useRef:function(i){var r=si();return i={current:i},r.memoizedState=i},useState:function(i){i=zc(i);var r=i.queue,l=Xm.bind(null,Ae,r);return r.dispatch=l,[i.memoizedState,l]},useDebugValue:Hc,useDeferredValue:function(i,r){var l=si();return Pc(l,i,r)},useTransition:function(){var i=zc(!1);return i=qm.bind(null,Ae,i.queue,!0,!1),si().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,l){var u=Ae,d=si();if(Pe){if(l===void 0)throw Error(s(407));l=l()}else{if(l=r(),Ze===null)throw Error(s(349));(je&127)!==0||vm(u,r,l)}d.memoizedState=l;var m={value:l,getSnapshot:r};return d.queue=m,Lm(bm.bind(null,u,m,i),[i]),u.flags|=2048,Ms(9,{destroy:void 0},ym.bind(null,u,m,l,r),null),l},useId:function(){var i=si(),r=Ze.identifierPrefix;if(Pe){var l=nn,u=tn;l=(u&~(1<<32-$e(u)-1)).toString(32)+l,r="_"+r+"R_"+l,l=oo++,0<\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof u.is=="string"?v.createElement("select",{is:u.is}):v.createElement("select"),u.multiple?m.multiple=!0:u.size&&(m.size=u.size);break;default:m=typeof u.is=="string"?v.createElement(d,{is:u.is}):v.createElement(d)}}m[Vt]=r,m[fi]=u;e:for(v=r.child;v!==null;){if(v.tag===5||v.tag===6)m.appendChild(v.stateNode);else if(v.tag!==4&&v.tag!==27&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===r)break e;for(;v.sibling===null;){if(v.return===null||v.return===r)break e;v=v.return}v.sibling.return=v.return,v=v.sibling}r.stateNode=m;e:switch($t(m,d,u),d){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&Dn(r)}}return it(r),ih(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,l),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==u&&Dn(r);else{if(typeof u!="string"&&r.stateNode===null)throw Error(s(166));if(i=de.current,xs(r)){if(i=r.stateNode,l=r.memoizedProps,u=null,d=Kt,d!==null)switch(d.tag){case 27:case 5:u=d.memoizedProps}i[Vt]=r,i=!!(i.nodeValue===l||u!==null&&u.suppressHydrationWarning===!0||_g(i.nodeValue,l)),i||$n(r,!0)}else i=zo(i).createTextNode(u),i[Vt]=r,r.stateNode=i}return it(r),null;case 31:if(l=r.memoizedState,i===null||i.memoizedState!==null){if(u=xs(r),l!==null){if(i===null){if(!u)throw Error(s(318));if(i=r.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[Vt]=r}else zr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;it(r),i=!1}else l=fc(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=l),i=!0;if(!i)return r.flags&256?(ki(r),r):(ki(r),null);if((r.flags&128)!==0)throw Error(s(558))}return it(r),null;case 13:if(u=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(d=xs(r),u!==null&&u.dehydrated!==null){if(i===null){if(!d)throw Error(s(318));if(d=r.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(s(317));d[Vt]=r}else zr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;it(r),d=!1}else d=fc(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=d),d=!0;if(!d)return r.flags&256?(ki(r),r):(ki(r),null)}return ki(r),(r.flags&128)!==0?(r.lanes=l,r):(l=u!==null,i=i!==null&&i.memoizedState!==null,l&&(u=r.child,d=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(d=u.alternate.memoizedState.cachePool.pool),m=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(m=u.memoizedState.cachePool.pool),m!==d&&(u.flags|=2048)),l!==i&&l&&(r.child.flags|=8192),bo(r,r.updateQueue),it(r),null);case 4:return Ce(),i===null&&Ch(r.stateNode.containerInfo),it(r),null;case 10:return kn(r.type),it(r),null;case 19:if(K(mt),u=r.memoizedState,u===null)return it(r),null;if(d=(r.flags&128)!==0,m=u.rendering,m===null)if(d)Rl(u,!1);else{if(ht!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(m=lo(i),m!==null){for(r.flags|=128,Rl(u,!1),i=m.updateQueue,r.updateQueue=i,bo(r,i),r.subtreeFlags=0,i=l,l=r.child;l!==null;)Xp(l,i),l=l.sibling;return C(mt,mt.current&1|2),Pe&&wn(r,u.treeForkCount),r.child}i=i.sibling}u.tail!==null&&Wt()>ko&&(r.flags|=128,d=!0,Rl(u,!1),r.lanes=4194304)}else{if(!d)if(i=lo(m),i!==null){if(r.flags|=128,d=!0,i=i.updateQueue,r.updateQueue=i,bo(r,i),Rl(u,!0),u.tail===null&&u.tailMode==="hidden"&&!m.alternate&&!Pe)return it(r),null}else 2*Wt()-u.renderingStartTime>ko&&l!==536870912&&(r.flags|=128,d=!0,Rl(u,!1),r.lanes=4194304);u.isBackwards?(m.sibling=r.child,r.child=m):(i=u.last,i!==null?i.sibling=m:r.child=m,u.last=m)}return u.tail!==null?(i=u.tail,u.rendering=i,u.tail=i.sibling,u.renderingStartTime=Wt(),i.sibling=null,l=mt.current,C(mt,d?l&1|2:l&1),Pe&&wn(r,u.treeForkCount),i):(it(r),null);case 22:case 23:return ki(r),kc(),u=r.memoizedState!==null,i!==null?i.memoizedState!==null!==u&&(r.flags|=8192):u&&(r.flags|=8192),u?(l&536870912)!==0&&(r.flags&128)===0&&(it(r),r.subtreeFlags&6&&(r.flags|=8192)):it(r),l=r.updateQueue,l!==null&&bo(r,l.retryQueue),l=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(l=i.memoizedState.cachePool.pool),u=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),u!==l&&(r.flags|=2048),i!==null&&K(Hr),null;case 24:return l=null,i!==null&&(l=i.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),kn(yt),it(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function y1(i,r){switch(cc(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return kn(yt),Ce(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return et(r),null;case 31:if(r.memoizedState!==null){if(ki(r),r.alternate===null)throw Error(s(340));zr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(ki(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(s(340));zr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return K(mt),null;case 4:return Ce(),null;case 10:return kn(r.type),null;case 22:case 23:return ki(r),kc(),i!==null&&K(Hr),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return kn(yt),null;case 25:return null;default:return null}}function S_(i,r){switch(cc(r),r.tag){case 3:kn(yt),Ce();break;case 26:case 27:case 5:et(r);break;case 4:Ce();break;case 31:r.memoizedState!==null&&ki(r);break;case 13:ki(r);break;case 19:K(mt);break;case 10:kn(r.type);break;case 22:case 23:ki(r),kc(),i!==null&&K(Hr);break;case 24:kn(yt)}}function Ml(i,r){try{var l=r.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var d=u.next;l=d;do{if((l.tag&i)===i){u=void 0;var m=l.create,v=l.inst;u=m(),v.destroy=u}l=l.next}while(l!==d)}}catch(w){Ye(r,r.return,w)}}function nr(i,r,l){try{var u=r.updateQueue,d=u!==null?u.lastEffect:null;if(d!==null){var m=d.next;u=m;do{if((u.tag&i)===i){var v=u.inst,w=v.destroy;if(w!==void 0){v.destroy=void 0,d=r;var N=l,q=w;try{q()}catch(ee){Ye(d,N,ee)}}}u=u.next}while(u!==m)}}catch(ee){Ye(r,r.return,ee)}}function x_(i){var r=i.updateQueue;if(r!==null){var l=i.stateNode;try{fm(r,l)}catch(u){Ye(i,i.return,u)}}}function w_(i,r,l){l.props=qr(i.type,i.memoizedProps),l.state=i.memoizedState;try{l.componentWillUnmount()}catch(u){Ye(i,r,u)}}function Bl(i,r){try{var l=i.ref;if(l!==null){switch(i.tag){case 26:case 27:case 5:var u=i.stateNode;break;case 30:u=i.stateNode;break;default:u=i.stateNode}typeof l=="function"?i.refCleanup=l(u):l.current=u}}catch(d){Ye(i,r,d)}}function rn(i,r){var l=i.ref,u=i.refCleanup;if(l!==null)if(typeof u=="function")try{u()}catch(d){Ye(i,r,d)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(d){Ye(i,r,d)}else l.current=null}function C_(i){var r=i.type,l=i.memoizedProps,u=i.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":l.autoFocus&&u.focus();break e;case"img":l.src?u.src=l.src:l.srcSet&&(u.srcset=l.srcSet)}}catch(d){Ye(i,i.return,d)}}function nh(i,r,l){try{var u=i.stateNode;I1(u,i.type,l,r),u[fi]=r}catch(d){Ye(i,i.return,d)}}function k_(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&cr(i.type)||i.tag===4}function rh(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||k_(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&cr(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function sh(i,r,l){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(i,r):(r=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,r.appendChild(i),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=bn));else if(u!==4&&(u===27&&cr(i.type)&&(l=i.stateNode,r=null),i=i.child,i!==null))for(sh(i,r,l),i=i.sibling;i!==null;)sh(i,r,l),i=i.sibling}function So(i,r,l){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?l.insertBefore(i,r):l.appendChild(i);else if(u!==4&&(u===27&&cr(i.type)&&(l=i.stateNode),i=i.child,i!==null))for(So(i,r,l),i=i.sibling;i!==null;)So(i,r,l),i=i.sibling}function E_(i){var r=i.stateNode,l=i.memoizedProps;try{for(var u=i.type,d=r.attributes;d.length;)r.removeAttributeNode(d[0]);$t(r,u,l),r[Vt]=i,r[fi]=l}catch(m){Ye(i,i.return,m)}}var Rn=!1,xt=!1,lh=!1,T_=typeof WeakSet=="function"?WeakSet:Set,zt=null;function b1(i,r){if(i=i.containerInfo,Th=Fo,i=Pp(i),Ju(i)){if("selectionStart"in i)var l={start:i.selectionStart,end:i.selectionEnd};else e:{l=(l=i.ownerDocument)&&l.defaultView||window;var u=l.getSelection&&l.getSelection();if(u&&u.rangeCount!==0){l=u.anchorNode;var d=u.anchorOffset,m=u.focusNode;u=u.focusOffset;try{l.nodeType,m.nodeType}catch{l=null;break e}var v=0,w=-1,N=-1,q=0,ee=0,re=i,Y=null;t:for(;;){for(var G;re!==l||d!==0&&re.nodeType!==3||(w=v+d),re!==m||u!==0&&re.nodeType!==3||(N=v+u),re.nodeType===3&&(v+=re.nodeValue.length),(G=re.firstChild)!==null;)Y=re,re=G;for(;;){if(re===i)break t;if(Y===l&&++q===d&&(w=v),Y===m&&++ee===u&&(N=v),(G=re.nextSibling)!==null)break;re=Y,Y=re.parentNode}re=G}l=w===-1||N===-1?null:{start:w,end:N}}else l=null}l=l||{start:0,end:0}}else l=null;for(Ah={focusedElem:i,selectionRange:l},Fo=!1,zt=r;zt!==null;)if(r=zt,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,zt=i;else for(;zt!==null;){switch(r=zt,m=r.alternate,i=r.flags,r.tag){case 0:if((i&4)!==0&&(i=r.updateQueue,i=i!==null?i.events:null,i!==null))for(l=0;l title"))),$t(m,u,l),m[Vt]=i,Lt(m),u=m;break e;case"link":var v=Ng("link","href",d).get(u+(l.href||""));if(v){for(var w=0;wXe&&(v=Xe,Xe=Se,Se=v);var P=jp(w,Se),z=jp(w,Xe);if(P&&z&&(G.rangeCount!==1||G.anchorNode!==P.node||G.anchorOffset!==P.offset||G.focusNode!==z.node||G.focusOffset!==z.offset)){var F=re.createRange();F.setStart(P.node,P.offset),G.removeAllRanges(),Se>Xe?(G.addRange(F),G.extend(z.node,z.offset)):(F.setEnd(z.node,z.offset),G.addRange(F))}}}}for(re=[],G=w;G=G.parentNode;)G.nodeType===1&&re.push({element:G,left:G.scrollLeft,top:G.scrollTop});for(typeof w.focus=="function"&&w.focus(),w=0;wl?32:l,T.T=null,l=dh,dh=null;var m=ar,v=zn;if(Dt=0,Os=ar=null,zn=0,(qe&6)!==0)throw Error(s(331));var w=qe;if(qe|=4,H_(m.current),z_(m,m.current,v,l),qe=w,Hl(0,!1),At&&typeof At.onPostCommitFiberRoot=="function")try{At.onPostCommitFiberRoot(Tt,m)}catch{}return!0}finally{j.p=d,T.T=u,ig(i,r)}}function rg(i,r,l){r=Oi(l,r),r=Vc(i.stateNode,r,2),i=er(i,r,2),i!==null&&(rl(i,2),sn(i))}function Ye(i,r,l){if(i.tag===3)rg(i,i,l);else for(;r!==null;){if(r.tag===3){rg(r,i,l);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(lr===null||!lr.has(u))){i=Oi(l,i),l=s_(2),u=er(r,l,2),u!==null&&(l_(l,u,r,i),rl(u,2),sn(u));break}}r=r.return}}function gh(i,r,l){var u=i.pingCache;if(u===null){u=i.pingCache=new w1;var d=new Set;u.set(r,d)}else d=u.get(r),d===void 0&&(d=new Set,u.set(r,d));d.has(l)||(uh=!0,d.add(l),i=A1.bind(null,i,r,l),r.then(i,i))}function A1(i,r,l){var u=i.pingCache;u!==null&&u.delete(r),i.pingedLanes|=i.suspendedLanes&l,i.warmLanes&=~l,Ze===i&&(je&l)===l&&(ht===4||ht===3&&(je&62914560)===je&&300>Wt()-Co?(qe&2)===0&&js(i,0):ch|=l,zs===je&&(zs=0)),sn(i)}function sg(i,r){r===0&&(r=Jd()),i=Nr(i,r),i!==null&&(rl(i,r),sn(i))}function D1(i){var r=i.memoizedState,l=0;r!==null&&(l=r.retryLane),sg(i,l)}function R1(i,r){var l=0;switch(i.tag){case 31:case 13:var u=i.stateNode,d=i.memoizedState;d!==null&&(l=d.retryLane);break;case 19:u=i.stateNode;break;case 22:u=i.stateNode._retryCache;break;default:throw Error(s(314))}u!==null&&u.delete(r),sg(i,l)}function M1(i,r){return Tr(i,r)}var Mo=null,Ps=null,vh=!1,Bo=!1,yh=!1,ur=0;function sn(i){i!==Ps&&i.next===null&&(Ps===null?Mo=Ps=i:Ps=Ps.next=i),Bo=!0,vh||(vh=!0,N1())}function Hl(i,r){if(!yh&&Bo){yh=!0;do for(var l=!1,u=Mo;u!==null;){if(i!==0){var d=u.pendingLanes;if(d===0)var m=0;else{var v=u.suspendedLanes,w=u.pingedLanes;m=(1<<31-$e(42|i)+1)-1,m&=d&~(v&~w),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(l=!0,ug(u,m))}else m=je,m=za(u,u===Ze?m:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(m&3)===0||nl(u,m)||(l=!0,ug(u,m));u=u.next}while(l);yh=!1}}function B1(){lg()}function lg(){Bo=vh=!1;var i=0;ur!==0&&q1()&&(i=ur);for(var r=Wt(),l=null,u=Mo;u!==null;){var d=u.next,m=ag(u,r);m===0?(u.next=null,l===null?Mo=d:l.next=d,d===null&&(Ps=l)):(l=u,(i!==0||(m&3)!==0)&&(Bo=!0)),u=d}Dt!==0&&Dt!==5||Hl(i),ur!==0&&(ur=0)}function ag(i,r){for(var l=i.suspendedLanes,u=i.pingedLanes,d=i.expirationTimes,m=i.pendingLanes&-62914561;0w)break;var ee=N.transferSize,re=N.initiatorType;ee&&gg(re)&&(N=N.responseEnd,v+=ee*(N"u"?null:document;function Dg(i,r,l){var u=Us;if(u&&typeof r=="string"&&r){var d=Li(r);d='link[rel="'+i+'"][href="'+d+'"]',typeof l=="string"&&(d+='[crossorigin="'+l+'"]'),Ag.has(d)||(Ag.add(d),i={rel:i,crossOrigin:l,href:r},u.querySelector(d)===null&&(r=u.createElement("link"),$t(r,"link",i),Lt(r),u.head.appendChild(r)))}}function Q1(i){On.D(i),Dg("dns-prefetch",i,null)}function J1(i,r){On.C(i,r),Dg("preconnect",i,r)}function ex(i,r,l){On.L(i,r,l);var u=Us;if(u&&i&&r){var d='link[rel="preload"][as="'+Li(r)+'"]';r==="image"&&l&&l.imageSrcSet?(d+='[imagesrcset="'+Li(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(d+='[imagesizes="'+Li(l.imageSizes)+'"]')):d+='[href="'+Li(i)+'"]';var m=d;switch(r){case"style":m=Is(i);break;case"script":m=Fs(i)}Fi.has(m)||(i=_({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:i,as:r},l),Fi.set(m,i),u.querySelector(d)!==null||r==="style"&&u.querySelector(Fl(m))||r==="script"&&u.querySelector(ql(m))||(r=u.createElement("link"),$t(r,"link",i),Lt(r),u.head.appendChild(r)))}}function tx(i,r){On.m(i,r);var l=Us;if(l&&i){var u=r&&typeof r.as=="string"?r.as:"script",d='link[rel="modulepreload"][as="'+Li(u)+'"][href="'+Li(i)+'"]',m=d;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=Fs(i)}if(!Fi.has(m)&&(i=_({rel:"modulepreload",href:i},r),Fi.set(m,i),l.querySelector(d)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(ql(m)))return}u=l.createElement("link"),$t(u,"link",i),Lt(u),l.head.appendChild(u)}}}function ix(i,r,l){On.S(i,r,l);var u=Us;if(u&&i){var d=us(u).hoistableStyles,m=Is(i);r=r||"default";var v=d.get(m);if(!v){var w={loading:0,preload:null};if(v=u.querySelector(Fl(m)))w.loading=5;else{i=_({rel:"stylesheet",href:i,"data-precedence":r},l),(l=Fi.get(m))&&zh(i,l);var N=v=u.createElement("link");Lt(N),$t(N,"link",i),N._p=new Promise(function(q,ee){N.onload=q,N.onerror=ee}),N.addEventListener("load",function(){w.loading|=1}),N.addEventListener("error",function(){w.loading|=2}),w.loading|=4,jo(v,r,u)}v={type:"stylesheet",instance:v,count:1,state:w},d.set(m,v)}}}function nx(i,r){On.X(i,r);var l=Us;if(l&&i){var u=us(l).hoistableScripts,d=Fs(i),m=u.get(d);m||(m=l.querySelector(ql(d)),m||(i=_({src:i,async:!0},r),(r=Fi.get(d))&&Oh(i,r),m=l.createElement("script"),Lt(m),$t(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(d,m))}}function rx(i,r){On.M(i,r);var l=Us;if(l&&i){var u=us(l).hoistableScripts,d=Fs(i),m=u.get(d);m||(m=l.querySelector(ql(d)),m||(i=_({src:i,async:!0,type:"module"},r),(r=Fi.get(d))&&Oh(i,r),m=l.createElement("script"),Lt(m),$t(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(d,m))}}function Rg(i,r,l,u){var d=(d=de.current)?Oo(d):null;if(!d)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(r=Is(l.href),l=us(d).hoistableStyles,u=l.get(r),u||(u={type:"style",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){i=Is(l.href);var m=us(d).hoistableStyles,v=m.get(i);if(v||(d=d.ownerDocument||d,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(i,v),(m=d.querySelector(Fl(i)))&&!m._p&&(v.instance=m,v.state.loading=5),Fi.has(i)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Fi.set(i,l),m||sx(d,i,l,v.state))),r&&u===null)throw Error(s(528,""));return v}if(r&&u!==null)throw Error(s(529,""));return null;case"script":return r=l.async,l=l.src,typeof l=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Fs(l),l=us(d).hoistableScripts,u=l.get(r),u||(u={type:"script",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,i))}}function Is(i){return'href="'+Li(i)+'"'}function Fl(i){return'link[rel="stylesheet"]['+i+"]"}function Mg(i){return _({},i,{"data-precedence":i.precedence,precedence:null})}function sx(i,r,l,u){i.querySelector('link[rel="preload"][as="style"]['+r+"]")?u.loading=1:(r=i.createElement("link"),u.preload=r,r.addEventListener("load",function(){return u.loading|=1}),r.addEventListener("error",function(){return u.loading|=2}),$t(r,"link",l),Lt(r),i.head.appendChild(r))}function Fs(i){return'[src="'+Li(i)+'"]'}function ql(i){return"script[async]"+i}function Bg(i,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var u=i.querySelector('style[data-href~="'+Li(l.href)+'"]');if(u)return r.instance=u,Lt(u),u;var d=_({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return u=(i.ownerDocument||i).createElement("style"),Lt(u),$t(u,"style",d),jo(u,l.precedence,i),r.instance=u;case"stylesheet":d=Is(l.href);var m=i.querySelector(Fl(d));if(m)return r.state.loading|=4,r.instance=m,Lt(m),m;u=Mg(l),(d=Fi.get(d))&&zh(u,d),m=(i.ownerDocument||i).createElement("link"),Lt(m);var v=m;return v._p=new Promise(function(w,N){v.onload=w,v.onerror=N}),$t(m,"link",u),r.state.loading|=4,jo(m,l.precedence,i),r.instance=m;case"script":return m=Fs(l.src),(d=i.querySelector(ql(m)))?(r.instance=d,Lt(d),d):(u=l,(d=Fi.get(m))&&(u=_({},l),Oh(u,d)),i=i.ownerDocument||i,d=i.createElement("script"),Lt(d),$t(d,"link",u),i.head.appendChild(d),r.instance=d);case"void":return null;default:throw Error(s(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(u=r.instance,r.state.loading|=4,jo(u,l.precedence,i));return r.instance}function jo(i,r,l){for(var u=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=u.length?u[u.length-1]:null,m=d,v=0;v title"):null)}function lx(i,r,l){if(l===1||r.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return i=r.disabled,typeof r.precedence=="string"&&i==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function zg(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function ax(i,r,l,u){if(l.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var d=Is(u.href),m=r.querySelector(Fl(d));if(m){r=m._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=Po.bind(i),r.then(i,i)),l.state.loading|=4,l.instance=m,Lt(m);return}m=r.ownerDocument||r,u=Mg(u),(d=Fi.get(d))&&zh(u,d),m=m.createElement("link"),Lt(m);var v=m;v._p=new Promise(function(w,N){v.onload=w,v.onerror=N}),$t(m,"link",u),l.instance=m}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(l,r),(r=l.state.preload)&&(l.state.loading&3)===0&&(i.count++,l=Po.bind(i),r.addEventListener("load",l),r.addEventListener("error",l))}}var jh=0;function ox(i,r){return i.stylesheets&&i.count===0&&Io(i,i.stylesheets),0jh?50:800)+r);return i.unsuspend=l,function(){i.unsuspend=null,clearTimeout(u),clearTimeout(d)}}:null}function Po(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Io(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Uo=null;function Io(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Uo=new Map,r.forEach(ux,i),Uo=null,Po.call(i))}function ux(i,r){if(!(r.state.loading&4)){var l=Uo.get(i);if(l)var u=l.get(null);else{l=new Map,Uo.set(i,l);for(var d=i.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Vh.exports=Ex(),Vh.exports}var Ax=Tx();const Dx=xu(Ax);function Rx({onLogin:e}){const[t,n]=$.useState(""),[s,a]=$.useState(null),[o,c]=$.useState(!1),f=async p=>{if(p.preventDefault(),!t.trim())return;c(!0),a(null);const h=await e(t);h&&a(h),c(!1)};return S.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:S.jsxs("div",{className:"w-full max-w-sm",children:[S.jsxs("div",{className:"border-border rounded border p-6",children:[S.jsxs("div",{className:"mb-6 text-center",children:[S.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),S.jsx("p",{className:"text-muted mt-1 text-xs",children:"local writer agent"})]}),S.jsxs("form",{onSubmit:f,className:"space-y-4",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),S.jsx("input",{type:"password",value:t,onChange:p=>n(p.target.value),placeholder:"enter your passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),s&&S.jsx("p",{className:"text-error text-xs",children:s}),S.jsx("button",{type:"submit",disabled:o||!t.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:o?"authenticating...":"unlock"})]})]}),S.jsx("p",{className:"text-muted mt-4 text-center text-[10px]",children:"enter your passphrase to unlock"})]})})}function Mx({onSetup:e}){const[t,n]=$.useState(""),[s,a]=$.useState(""),[o,c]=$.useState(null),[f,p]=$.useState(!1),h=async g=>{if(g.preventDefault(),!t.trim()||t.length<4){c("Passphrase must be at least 4 characters");return}if(t!==s){c("Passphrases do not match");return}p(!0),c(null);const _=await e(t);_&&c(_),p(!1)};return S.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:S.jsx("div",{className:"w-full max-w-sm",children:S.jsxs("div",{className:"border-border rounded border p-6",children:[S.jsxs("div",{className:"mb-6 text-center",children:[S.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),S.jsx("p",{className:"text-muted mt-1 text-xs",children:"first-time setup"})]}),S.jsx("p",{className:"text-muted mb-4 text-xs leading-relaxed",children:"Choose a passphrase to protect your local writer agent. This will be used to unlock the app and secure your OWS wallet."}),S.jsxs("form",{onSubmit:h,className:"space-y-4",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),S.jsx("input",{type:"password",value:t,onChange:g=>n(g.target.value),placeholder:"choose a passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Confirm"}),S.jsx("input",{type:"password",value:s,onChange:g=>a(g.target.value),placeholder:"repeat passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),o&&S.jsx("p",{className:"text-error text-xs",children:o}),S.jsx("button",{type:"submit",disabled:f||!t.trim()||!s.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:f?"setting up...":"create passphrase"})]})]})})})}const sv="http://localhost:7777";function eb({token:e}){const[t,n]=$.useState(null),[s,a]=$.useState(!1),[o,c]=$.useState(!1),[f,p]=$.useState(null),h=(x,k)=>fetch(x,{...k,headers:{...k==null?void 0:k.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),g=()=>{h(`${sv}/api/wallet`).then(x=>x.json()).then(x=>n(x)).catch(()=>n({exists:!1,error:"Failed to load wallet"}))};$.useEffect(()=>{g()},[]);const _=async()=>{a(!0),p(null);try{const x=await h(`${sv}/api/wallet/create`,{method:"POST"}),k=await x.json();if(!x.ok)throw new Error(k.error||"Creation failed");g()}catch(x){p(x instanceof Error?x.message:"Failed to create wallet")}a(!1)},b=()=>{t!=null&&t.address&&(navigator.clipboard.writeText(t.address),c(!0),setTimeout(()=>c(!1),2e3))},y=x=>`${x.slice(0,6)}...${x.slice(-4)}`;return S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"OWS Wallet"}),!t&&S.jsx("p",{className:"text-muted text-xs",children:"loading..."}),t&&!t.exists&&S.jsxs("div",{className:"space-y-3",children:[S.jsx("p",{className:"text-muted text-xs",children:"No wallet created yet. Create one to enable autonomous transactions."}),f&&S.jsx("p",{className:"text-error text-xs",children:f}),S.jsx("button",{onClick:_,disabled:s,className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 rounded border px-4 py-2 text-xs font-medium transition-colors",children:s?"creating...":"create wallet"})]}),t&&t.exists&&t.address&&S.jsxs("div",{className:"space-y-3",children:[S.jsxs("div",{className:"flex items-center justify-between",children:[S.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"Address (Base)"}),S.jsx("span",{className:`rounded border px-1.5 py-0.5 text-[9px] ${t.ethBalance&&parseFloat(t.ethBalance)>0?"border-accent/30 text-accent":"border-accent-dim/30 text-accent-dim"}`,children:t.ethBalance&&parseFloat(t.ethBalance)>0?"active":"no balance"})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("code",{className:"text-foreground bg-surface rounded px-2 py-1 text-xs font-mono",children:y(t.address)}),S.jsx("button",{onClick:b,className:"text-muted hover:text-accent text-xs transition-colors",children:o?"copied":"copy"})]}),S.jsxs("div",{className:"border-border space-y-1 border-t pt-3",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"ETH"}),S.jsxs("span",{className:"text-foreground font-medium",children:[t.ethBalance||"0.000000"," ETH"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"USDC"}),S.jsxs("span",{className:"text-foreground font-medium",children:["$",t.usdcBalance||"0.00"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"PLOT"}),S.jsxs("span",{className:"text-foreground font-medium",children:[t.plotBalance||"0.0000"," PLOT"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Network"}),S.jsx("span",{className:"text-foreground",children:"Base"})]})]}),S.jsxs("div",{className:"border-border border-t pt-3",children:[S.jsx("p",{className:"text-muted mb-2 text-[10px] font-medium uppercase tracking-wider",children:"Fund Wallet"}),S.jsx("p",{className:"text-muted text-[10px]",children:"Send ETH on Base for gas (~$0.01 per publish):"}),S.jsx("code",{className:"text-foreground bg-surface mt-1 block break-all rounded px-2 py-1.5 text-[10px] font-mono",children:t.address})]})]})]})}function Bx({token:e,onLogout:t}){const[n,s]=$.useState(""),[a,o]=$.useState(""),[c,f]=$.useState(null),[p,h]=$.useState(!1),[g,_]=$.useState(!1),[b,y]=$.useState(null),[x,k]=$.useState("AI Writer"),[L,M]=$.useState(""),[Z,I]=$.useState(""),[Q,W]=$.useState(!1),[O,ie]=$.useState(null),[ue,me]=$.useState(""),[U,le]=$.useState(null),[V,B]=$.useState(!1),[A,R]=$.useState(null),[T,j]=$.useState(null),H=$.useCallback((C,J)=>fetch(C,{...J,headers:{...J==null?void 0:J.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]);$.useEffect(()=>{H("/api/settings/link-status").then(C=>C.json()).then(C=>y(C)).catch(()=>y({linked:!1}))},[]);const oe=async()=>{if(!x.trim()){ie("Agent name is required");return}if(!L.trim()){ie("Description is required");return}W(!0),ie(null);try{const C=await H("/api/settings/register-agent",{method:"POST",body:JSON.stringify({name:x,description:L,...Z.trim()&&{genre:Z}})}),J=await C.json();if(!C.ok)throw new Error(J.error||"Registration failed");y({linked:!0,agentId:J.agentId,owsWallet:J.owsWallet,txHash:J.txHash})}catch(C){ie(C instanceof Error?C.message:"Registration failed")}W(!1)},E=async()=>{if(!ue.trim()||!/^0x[a-fA-F0-9]{40}$/.test(ue)){R("Enter a valid wallet address (0x...)");return}B(!0),R(null),le(null);try{const C=await H("/api/settings/generate-binding",{method:"POST",body:JSON.stringify({humanWallet:ue})}),J=await C.json();if(!C.ok)throw new Error(J.error||"Failed to generate binding code");le(J)}catch(C){R(C instanceof Error?C.message:"Failed to generate binding code")}B(!1)},D=async(C,J)=>{await navigator.clipboard.writeText(C),j(J),setTimeout(()=>j(null),2e3)},K=async()=>{if(f(null),h(!1),!n||n.length<4){f("Passphrase must be at least 4 characters");return}if(n!==a){f("Passphrases do not match");return}_(!0);try{const C=await H("/api/auth/reset-passphrase",{method:"POST",body:JSON.stringify({passphrase:n})});if(!C.ok){const J=await C.json();throw new Error(J.error||"Reset failed")}h(!0),s(""),o(""),setTimeout(()=>h(!1),3e3)}catch(C){f(C instanceof Error?C.message:"Reset failed")}_(!1)};return S.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-6",children:[S.jsx("h2",{className:"text-accent text-lg font-bold",children:"Settings"}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Identity"}),b!=null&&b.linked?S.jsxs("div",{className:"space-y-2",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"text-sm font-medium text-accent",children:"Registered"}),S.jsxs("span",{className:"text-muted text-xs",children:["Agent #",b.agentId]})]}),b.owsWallet&&S.jsxs("p",{className:"text-muted text-xs font-mono",children:["Wallet: ",b.owsWallet.slice(0,6),"...",b.owsWallet.slice(-4)]}),b.owner&&S.jsxs("p",{className:"text-muted text-xs font-mono",children:["Owner: ",b.owner.slice(0,6),"...",b.owner.slice(-4)]}),b.txHash&&S.jsx("p",{className:"text-muted text-xs",children:S.jsx("a",{href:`https://basescan.org/tx/${b.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View transaction on BaseScan"})}),S.jsx("p",{className:"text-muted text-xs",children:S.jsx("a",{href:`https://plotlink.xyz/profile/${b.owsWallet}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View agent profile on plotlink.xyz"})})]}):S.jsxs("div",{className:"space-y-3",children:[S.jsx("p",{className:"text-muted text-xs",children:"Register this AI writer on-chain via ERC-8004. Uses your OWS wallet's existing ETH balance for gas."}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Name"}),S.jsx("input",{value:x,onChange:C=>k(C.target.value),placeholder:"AI Writer",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Description"}),S.jsx("input",{value:L,onChange:C=>M(C.target.value),placeholder:"An AI writing assistant for fiction stories",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Genre (optional)"}),S.jsx("input",{value:Z,onChange:C=>I(C.target.value),placeholder:"e.g. Fiction, Sci-Fi, Fantasy",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),O&&S.jsx("p",{className:"text-error text-xs",children:O}),S.jsx("button",{onClick:oe,disabled:Q||!x.trim()||!L.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:Q?"Registering...":"Register Agent Identity"})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Link to PlotLink"}),b!=null&&b.owner?S.jsxs("p",{className:"text-muted text-xs",children:["Linked to owner ",S.jsxs("span",{className:"font-mono",children:[b.owner.slice(0,6),"...",b.owner.slice(-4)]})]}):S.jsxs("div",{className:"space-y-3",children:[S.jsx("p",{className:"text-muted text-xs",children:"Link this OWS wallet to your PlotLink account so your stories appear under your profile on plotlink.xyz."}),S.jsxs("div",{className:"text-muted text-xs space-y-1 pl-3",children:[S.jsx("p",{children:"1. Enter your PlotLink wallet address below"}),S.jsx("p",{children:'2. Click "Generate Binding Code"'}),S.jsx("p",{children:"3. Copy the code and paste it on plotlink.xyz → Agents → Link AI Writer"})]}),S.jsx("input",{value:ue,onChange:C=>me(C.target.value),placeholder:"Your PlotLink wallet address (0x...)",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent font-mono"}),A&&S.jsx("p",{className:"text-error text-xs",children:A}),S.jsx("button",{onClick:E,disabled:V||!ue.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:V?"Generating...":"Generate Binding Code"}),U&&S.jsxs("div",{className:"space-y-3 mt-3",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Binding Code (signature)"}),S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:U.signature}),S.jsx("button",{onClick:()=>D(U.signature,"signature"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:T==="signature"?"Copied!":"Copy"})]})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"OWS Wallet Address"}),S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:U.owsWallet}),S.jsx("button",{onClick:()=>D(U.owsWallet,"wallet"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:T==="wallet"?"Copied!":"Copy"})]})]}),U.agentId&&S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Agent ID"}),S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono text-foreground pr-16",children:U.agentId}),S.jsx("button",{onClick:()=>D(String(U.agentId),"agentId"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:T==="agentId"?"Copied!":"Copy"})]})]}),S.jsx("p",{className:"text-xs text-accent",children:'Now go to plotlink.xyz/agents and paste the values in the "Link AI Writer" section.'})]})]})]}),S.jsx(eb,{token:e}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Reset Passphrase"}),S.jsxs("div",{className:"space-y-3",children:[S.jsx("input",{type:"password",value:n,onChange:C=>s(C.target.value),placeholder:"new passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),S.jsx("input",{type:"password",value:a,onChange:C=>o(C.target.value),placeholder:"confirm passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),c&&S.jsx("p",{className:"text-error text-xs",children:c}),p&&S.jsx("p",{className:"text-xs text-accent",children:"passphrase updated"}),S.jsx("button",{onClick:K,disabled:g||!n.trim(),className:"border-border text-muted hover:border-accent hover:text-accent disabled:opacity-40 w-full rounded border px-4 py-2 text-xs font-medium transition-colors",children:g?"updating...":"update passphrase"})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Session"}),S.jsx("button",{onClick:t,className:"border-border text-muted hover:border-error hover:text-error rounded border px-4 py-2 text-xs font-medium transition-colors",children:"logout"})]})]})}const Nx="http://localhost:7777";function Lx({token:e}){const[t,n]=$.useState(null),s=(f,p)=>fetch(f,{...p,headers:{...p==null?void 0:p.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),a=()=>{s(`${Nx}/api/dashboard`).then(f=>f.json()).then(n)};$.useEffect(()=>{a()},[]);const o=f=>`${f.slice(0,6)}...${f.slice(-4)}`,c=f=>{if(!f)return"Unknown date";const p=new Date(f);return isNaN(p.getTime())?"Unknown date":p.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})};return t?S.jsxs("div",{className:"mx-auto max-w-2xl space-y-6 p-6",children:[S.jsx("h2",{className:"text-accent text-lg font-bold",children:"Writer Dashboard"}),S.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-accent text-lg font-bold",children:t.stories.totalPublished}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"published"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.pendingFiles}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"pending"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalStories}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"stories"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalFiles}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"files"})]})]}),t.wallet&&S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Wallet"}),S.jsxs("div",{className:"space-y-1.5",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Address"}),S.jsx("code",{className:"text-foreground font-mono text-[10px]",children:o(t.wallet.address)})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"ETH Balance"}),S.jsxs("span",{className:"text-foreground",children:[t.wallet.ethFormatted," ETH"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"USDC Balance"}),S.jsxs("span",{className:"text-foreground",children:["$",t.wallet.usdcBalance]})]})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Profit & Loss"}),S.jsxs("div",{className:"space-y-1.5",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Total costs (gas)"}),S.jsxs("span",{className:"text-error",children:["-",t.pnl.totalCostsEth," ETH (~$",t.pnl.totalCostsUsd,")"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Royalties earned"}),S.jsxs("span",{className:"text-accent",children:["+",t.pnl.totalRoyaltiesPlot," PLOT"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Unclaimed royalties"}),S.jsxs("span",{className:"text-foreground",children:[t.royalties.unclaimed," PLOT"]})]}),S.jsxs("div",{className:"border-border flex justify-between border-t pt-1.5 text-xs font-medium",children:[S.jsx("span",{className:"text-muted",children:"Net P&L (USD)"}),S.jsxs("span",{className:parseFloat(t.pnl.netPnlUsd)>=0?"text-accent":"text-error",children:[parseFloat(t.pnl.netPnlUsd)>=0?"+":"","$",t.pnl.netPnlUsd]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Stories published"}),S.jsx("span",{className:"text-foreground",children:t.costs.storiesPublished})]})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Published Stories"}),t.stories.published.length===0?S.jsx("p",{className:"text-muted text-xs",children:"no published stories yet"}):S.jsx("div",{className:"space-y-3",children:t.stories.published.map(f=>S.jsxs("div",{className:"bg-surface rounded border border-border p-4",children:[S.jsxs("div",{className:"flex items-start justify-between",children:[S.jsxs("div",{children:[f.genre&&S.jsx("span",{className:"bg-accent/10 text-accent rounded px-2 py-0.5 text-[10px] font-medium",children:f.genre}),S.jsx("h4",{className:"text-foreground mt-1 text-sm font-serif font-medium",children:f.title}),S.jsx("p",{className:"text-muted mt-0.5 text-[10px] font-mono",children:f.storyName})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[f.hasNotIndexed&&S.jsx("span",{className:"rounded border border-amber-600/30 px-1.5 py-0.5 text-[9px] text-amber-700",children:"not indexed"}),S.jsxs("span",{className:"rounded border border-green-700/30 px-1.5 py-0.5 text-[9px] text-green-700",children:[f.publishedFiles," published"]})]})]}),S.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-center",children:[S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium",children:f.plotCount}),S.jsx("div",{className:"text-muted text-[9px]",children:"Plots"})]}),S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium font-mono",children:f.storylineId?`#${f.storylineId}`:"—"}),S.jsx("div",{className:"text-muted text-[9px]",children:"Storyline"})]}),S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium",children:f.totalGasCostEth??"—"}),S.jsx("div",{className:"text-muted text-[9px]",children:"Gas (ETH)"})]})]}),S.jsx("div",{className:"mt-2 space-y-1",children:f.files.map(p=>S.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[S.jsxs("div",{className:"flex items-center gap-1.5",children:[S.jsx("span",{className:p.status==="published-not-indexed"?"text-amber-700":"text-green-700",children:p.status==="published-not-indexed"?"⚠":"✓"}),S.jsx("span",{className:"text-muted font-mono",children:p.file})]}),p.txHash&&S.jsxs("a",{href:`https://basescan.org/tx/${p.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-accent font-mono",children:["tx:",p.txHash.slice(0,8),"..."]})]},p.file))}),S.jsxs("div",{className:"mt-2 flex items-center justify-between text-[10px]",children:[S.jsx("span",{className:"text-muted",children:c(f.latestPublishedAt)}),f.storylineId&&S.jsx("a",{href:`https://plotlink.xyz/story/${f.storylineId}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"})]})]},f.id))})]}),t.stories.pendingFiles>0&&S.jsx("div",{className:"border-border rounded border p-4",children:S.jsxs("p",{className:"text-muted text-xs",children:[t.stories.pendingFiles," file(s) pending publish — go to Stories to publish them."]})})]}):S.jsx("div",{className:"flex h-full items-center justify-center",children:S.jsx("span",{className:"text-muted text-sm",children:"loading dashboard..."})})}const zx={published:"✓","published-not-indexed":"⚠",pending:"⏳",draft:"📝"},Ox={published:"text-green-700","published-not-indexed":"text-amber-700",pending:"text-amber-700",draft:"text-muted"};function jx({authFetch:e,selectedStory:t,selectedFile:n,onSelectFile:s,onNewStory:a,untitledSessions:o=[]}){const[c,f]=$.useState([]),[p,h]=$.useState([]),[g,_]=$.useState(new Set),[b,y]=$.useState(!1),x=$.useCallback(async()=>{try{const W=await e("/api/stories");if(W.ok){const O=await W.json();f(O.stories)}}catch{}},[e]),k=$.useCallback(async()=>{try{const W=await e("/api/stories/archived");if(W.ok){const O=await W.json();h(O.stories)}}catch{}},[e]),L=$.useCallback(async W=>{try{(await e("/api/stories/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:W})})).ok&&(k(),x())}catch{}},[e,k,x]);$.useEffect(()=>{x();const W=setInterval(x,5e3);return()=>clearInterval(W)},[x]),$.useEffect(()=>{b&&k()},[b,k]),$.useEffect(()=>{t&&_(W=>new Set(W).add(t))},[t]);const M=W=>{var ie;const O=W.map(ue=>{var me;return{file:ue.file,num:(me=ue.file.match(/^plot-(\d+)\.md$/))==null?void 0:me[1]}}).filter(ue=>ue.num!=null).sort((ue,me)=>parseInt(me.num)-parseInt(ue.num));return O.length>0?O[0].file:W.some(ue=>ue.file==="genesis.md")?"genesis.md":W.some(ue=>ue.file==="structure.md")?"structure.md":((ie=W[0])==null?void 0:ie.file)??null},Z=W=>{_(O=>{const ie=new Set(O);return ie.has(W)?ie.delete(W):ie.add(W),ie})},I=W=>{if(Z(W.name),!g.has(W.name)){const O=M(W.files);O&&s(W.name,O)}},Q=W=>{const O=ie=>{if(ie==="structure.md")return 0;if(ie==="genesis.md")return 1;const ue=ie.match(/^plot-(\d+)\.md$/);return ue?2+parseInt(ue[1]):100};return[...W].sort((ie,ue)=>O(ie.file)-O(ue.file))};return b?S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs font-mono text-muted",children:"Archives"}),S.jsx("span",{className:"text-xs text-muted",children:p.length})]}),S.jsx("div",{className:"px-3 py-2 border-b border-border",children:S.jsxs("button",{onClick:()=>y(!1),className:"w-full px-3 py-1.5 text-sm text-muted hover:text-foreground hover:bg-surface rounded flex items-center gap-1.5",children:[S.jsx("span",{children:"←"}),S.jsx("span",{children:"Back"})]})}),S.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:p.length===0?S.jsx("div",{className:"p-3 text-sm text-muted",children:S.jsx("p",{children:"No archived stories."})}):p.map(W=>S.jsxs("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-surface",children:[S.jsx("span",{className:"text-sm font-medium truncate",title:W.name,children:W.title||W.name}),S.jsx("button",{onClick:()=>L(W.name),className:"text-xs text-accent hover:text-accent-dim flex-shrink-0 ml-2",children:"Restore"})]},W.name))})]}):S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs font-mono text-muted",children:"Stories"}),S.jsx("span",{className:"text-xs text-muted",children:c.length})]}),a&&S.jsx("div",{className:"px-3 py-2 border-b border-border",children:S.jsxs("button",{onClick:a,className:"w-full px-3 py-1.5 text-sm bg-accent text-white rounded hover:bg-accent-dim flex items-center justify-center gap-1.5",children:[S.jsx("span",{children:"+"}),S.jsx("span",{children:"New Story"})]})}),S.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[o.map(W=>S.jsx("div",{children:S.jsxs("button",{onClick:()=>s(W,""),className:`w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm ${t===W?"bg-surface":""}`,children:[S.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-600 flex-shrink-0"}),S.jsx("span",{className:"font-medium italic text-muted",children:"Untitled"})]})},W)),c.length===0&&o.length===0?S.jsxs("div",{className:"p-3 text-sm text-muted",children:[S.jsx("p",{children:"No stories yet."}),S.jsx("p",{className:"mt-1 text-xs",children:'Click "+ New Story" above to start writing.'})]}):c.filter(W=>W.name!=="_example").map(W=>S.jsxs("div",{children:[S.jsxs("button",{onClick:()=>I(W),className:"w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm",children:[S.jsx("span",{className:"text-xs text-muted",children:g.has(W.name)?"▼":"▶"}),S.jsx("span",{className:"font-medium truncate",title:W.name,children:W.title||W.name}),S.jsxs("span",{className:"ml-auto text-xs text-muted",children:[W.publishedCount,"/",W.files.length]})]}),g.has(W.name)&&S.jsx("div",{className:"pl-4",children:Q(W.files).map(O=>{const ie=t===W.name&&n===O.file;return S.jsxs("button",{onClick:()=>s(W.name,O.file),className:`w-full px-3 py-1.5 text-left flex items-center gap-2 text-xs hover:bg-surface ${ie?"bg-surface font-medium":""}`,children:[S.jsx("span",{className:Ox[O.status],children:zx[O.status]}),S.jsx("span",{className:"truncate font-mono",children:O.file})]},O.file)})})]},W.name))]}),S.jsx("div",{className:"px-3 py-2 border-t border-border",children:S.jsx("button",{onClick:()=>y(!0),className:"w-full px-3 py-1.5 text-xs text-muted hover:text-foreground hover:bg-surface rounded flex items-center justify-center gap-1.5",children:S.jsx("span",{children:"Archives"})})})]})}/** +`+u.stack}}var pn=Object.prototype.hasOwnProperty,Tr=e.unstable_scheduleCallback,mn=e.unstable_cancelCallback,_n=e.unstable_shouldYield,gn=e.unstable_requestPaint,Wt=e.unstable_now,vn=e.unstable_getCurrentPriorityLevel,te=e.unstable_ImmediatePriority,X=e.unstable_UserBlockingPriority,ce=e.unstable_NormalPriority,_e=e.unstable_LowPriority,Ce=e.unstable_IdlePriority,st=e.log,Yt=e.unstable_setDisableYieldValue,Tt=null,At=null;function hi(i){if(typeof st=="function"&&Yt(i),At&&typeof At.setStrictMode=="function")try{At.setStrictMode(Tt,i)}catch{}}var Ge=Math.clz32?Math.clz32:r0,Yn=Math.log,Xi=Math.LN2;function r0(i){return i>>>=0,i===0?32:31-(Yn(i)/Xi|0)|0}var Ba=256,Na=262144,La=4194304;function Ar(i){var r=i&42;if(r!==0)return r;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function za(i,r,l){var u=i.pendingLanes;if(u===0)return 0;var d=0,m=i.suspendedLanes,v=i.pingedLanes;i=i.warmLanes;var w=u&134217727;return w!==0?(u=w&~m,u!==0?d=Ar(u):(v&=w,v!==0?d=Ar(v):l||(l=w&~i,l!==0&&(d=Ar(l))))):(w=u&~m,w!==0?d=Ar(w):v!==0?d=Ar(v):l||(l=u&~i,l!==0&&(d=Ar(l)))),d===0?0:r!==0&&r!==d&&(r&m)===0&&(m=d&-d,l=r&-r,m>=l||m===32&&(l&4194048)!==0)?r:d}function sl(i,r){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&r)===0}function s0(i,r){switch(i){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Jd(){var i=La;return La<<=1,(La&62914560)===0&&(La=4194304),i}function Bu(i){for(var r=[],l=0;31>l;l++)r.push(i);return r}function ll(i,r){i.pendingLanes|=r,r!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function l0(i,r,l,u,d,m){var v=i.pendingLanes;i.pendingLanes=l,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=l,i.entangledLanes&=l,i.errorRecoveryDisabledLanes&=l,i.shellSuspendCounter=0;var w=i.entanglements,N=i.expirationTimes,q=i.hiddenUpdates;for(l=v&~l;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var f0=/[\n"\\]/g;function Li(i){return i.replace(f0,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Hu(i,r,l,u,d,m,v,w){i.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?i.type=v:i.removeAttribute("type"),r!=null?v==="number"?(r===0&&i.value===""||i.value!=r)&&(i.value=""+Ni(r)):i.value!==""+Ni(r)&&(i.value=""+Ni(r)):v!=="submit"&&v!=="reset"||i.removeAttribute("value"),r!=null?Pu(i,v,Ni(r)):l!=null?Pu(i,v,Ni(l)):u!=null&&i.removeAttribute("value"),d==null&&m!=null&&(i.defaultChecked=!!m),d!=null&&(i.checked=d&&typeof d!="function"&&typeof d!="symbol"),w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?i.name=""+Ni(w):i.removeAttribute("name")}function fp(i,r,l,u,d,m,v,w){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(i.type=m),r!=null||l!=null){if(!(m!=="submit"&&m!=="reset"||r!=null)){ju(i);return}l=l!=null?""+Ni(l):"",r=r!=null?""+Ni(r):l,w||r===i.value||(i.value=r),i.defaultValue=r}u=u??d,u=typeof u!="function"&&typeof u!="symbol"&&!!u,i.checked=w?i.checked:!!u,i.defaultChecked=!!u,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(i.name=v),ju(i)}function Pu(i,r,l){r==="number"&&Ha(i.ownerDocument)===i||i.defaultValue===""+l||(i.defaultValue=""+l)}function hs(i,r,l,u){if(i=i.options,r){r={};for(var d=0;d"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Wu=!1;if(Sn)try{var cl={};Object.defineProperty(cl,"passive",{get:function(){Wu=!0}}),window.addEventListener("test",cl,cl),window.removeEventListener("test",cl,cl)}catch{Wu=!1}var Kn=null,Yu=null,Ua=null;function yp(){if(Ua)return Ua;var i,r=Yu,l=r.length,u,d="value"in Kn?Kn.value:Kn.textContent,m=d.length;for(i=0;i=dl),kp=" ",Ep=!1;function Tp(i,r){switch(i){case"keyup":return U0.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ap(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var ms=!1;function F0(i,r){switch(i){case"compositionend":return Ap(r);case"keypress":return r.which!==32?null:(Ep=!0,kp);case"textInput":return i=r.data,i===kp&&Ep?null:i;default:return null}}function q0(i,r){if(ms)return i==="compositionend"||!Gu&&Tp(i,r)?(i=yp(),Ua=Yu=Kn=null,ms=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1=r)return{node:l,offset:r-i};i=u}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Op(l)}}function Hp(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?Hp(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function Pp(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var r=Ha(i.document);r instanceof i.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)i=r.contentWindow;else break;r=Ha(i.document)}return r}function Ju(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}var Z0=Sn&&"documentMode"in document&&11>=document.documentMode,_s=null,ec=null,gl=null,tc=!1;function Up(i,r,l){var u=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;tc||_s==null||_s!==Ha(u)||(u=_s,"selectionStart"in u&&Ju(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),gl&&_l(gl,u)||(gl=u,u=Lo(ec,"onSelect"),0>=v,d-=v,tn=1<<32-Ge(r)+d|l<De?(He=ve,ve=null):He=ve.sibling;var Fe=Y(P,ve,F[De],ne);if(Fe===null){ve===null&&(ve=He);break}i&&ve&&Fe.alternate===null&&r(P,ve),z=m(Fe,z,De),Ie===null?ye=Fe:Ie.sibling=Fe,Ie=Fe,ve=He}if(De===F.length)return l(P,ve),Pe&&wn(P,De),ye;if(ve===null){for(;DeDe?(He=ve,ve=null):He=ve.sibling;var mr=Y(P,ve,Fe.value,ne);if(mr===null){ve===null&&(ve=He);break}i&&ve&&mr.alternate===null&&r(P,ve),z=m(mr,z,De),Ie===null?ye=mr:Ie.sibling=mr,Ie=mr,ve=He}if(Fe.done)return l(P,ve),Pe&&wn(P,De),ye;if(ve===null){for(;!Fe.done;De++,Fe=F.next())Fe=re(P,Fe.value,ne),Fe!==null&&(z=m(Fe,z,De),Ie===null?ye=Fe:Ie.sibling=Fe,Ie=Fe);return Pe&&wn(P,De),ye}for(ve=u(ve);!Fe.done;De++,Fe=F.next())Fe=$(ve,P,De,Fe.value,ne),Fe!==null&&(i&&Fe.alternate!==null&&ve.delete(Fe.key===null?De:Fe.key),z=m(Fe,z,De),Ie===null?ye=Fe:Ie.sibling=Fe,Ie=Fe);return i&&ve.forEach(function(gx){return r(P,gx)}),Pe&&wn(P,De),ye}function Xe(P,z,F,ne){if(typeof F=="object"&&F!==null&&F.type===k&&F.key===null&&(F=F.props.children),typeof F=="object"&&F!==null){switch(F.$$typeof){case y:e:{for(var ye=F.key;z!==null;){if(z.key===ye){if(ye=F.type,ye===k){if(z.tag===7){l(P,z.sibling),ne=d(z,F.props.children),ne.return=P,P=ne;break e}}else if(z.elementType===ye||typeof ye=="object"&&ye!==null&&ye.$$typeof===ue&&Pr(ye)===z.type){l(P,z.sibling),ne=d(z,F.props),wl(ne,F),ne.return=P,P=ne;break e}l(P,z);break}else r(P,z);z=z.sibling}F.type===k?(ne=Lr(F.props.children,P.mode,ne,F.key),ne.return=P,P=ne):(ne=Ga(F.type,F.key,F.props,null,P.mode,ne),wl(ne,F),ne.return=P,P=ne)}return v(P);case x:e:{for(ye=F.key;z!==null;){if(z.key===ye)if(z.tag===4&&z.stateNode.containerInfo===F.containerInfo&&z.stateNode.implementation===F.implementation){l(P,z.sibling),ne=d(z,F.children||[]),ne.return=P,P=ne;break e}else{l(P,z);break}else r(P,z);z=z.sibling}ne=oc(F,P.mode,ne),ne.return=P,P=ne}return v(P);case ue:return F=Pr(F),Xe(P,z,F,ne)}if(R(F))return ge(P,z,F,ne);if(V(F)){if(ye=V(F),typeof ye!="function")throw Error(s(150));return F=ye.call(F),Se(P,z,F,ne)}if(typeof F.then=="function")return Xe(P,z,no(F),ne);if(F.$$typeof===I)return Xe(P,z,Ja(P,F),ne);ro(P,F)}return typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint"?(F=""+F,z!==null&&z.tag===6?(l(P,z.sibling),ne=d(z,F),ne.return=P,P=ne):(l(P,z),ne=ac(F,P.mode,ne),ne.return=P,P=ne),v(P)):l(P,z)}return function(P,z,F,ne){try{xl=0;var ye=Xe(P,z,F,ne);return Ts=null,ye}catch(ve){if(ve===Es||ve===to)throw ve;var Ie=wi(29,ve,null,P.mode);return Ie.lanes=ne,Ie.return=P,Ie}finally{}}}var Ir=um(!0),cm=um(!1),Qn=!1;function bc(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Sc(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function Jn(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function er(i,r,l){var u=i.updateQueue;if(u===null)return null;if(u=u.shared,(qe&2)!==0){var d=u.pending;return d===null?r.next=r:(r.next=d.next,d.next=r),u.pending=r,r=$a(i),Kp(i,null,l),r}return Xa(i,u,r,l),$a(i)}function Cl(i,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194048)!==0)){var u=r.lanes;u&=i.pendingLanes,l|=u,r.lanes=l,tp(i,l)}}function xc(i,r){var l=i.updateQueue,u=i.alternate;if(u!==null&&(u=u.updateQueue,l===u)){var d=null,m=null;if(l=l.firstBaseUpdate,l!==null){do{var v={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};m===null?d=m=v:m=m.next=v,l=l.next}while(l!==null);m===null?d=m=r:m=m.next=r}else d=m=r;l={baseState:u.baseState,firstBaseUpdate:d,lastBaseUpdate:m,shared:u.shared,callbacks:u.callbacks},i.updateQueue=l;return}i=l.lastBaseUpdate,i===null?l.firstBaseUpdate=r:i.next=r,l.lastBaseUpdate=r}var wc=!1;function kl(){if(wc){var i=ks;if(i!==null)throw i}}function El(i,r,l,u){wc=!1;var d=i.updateQueue;Qn=!1;var m=d.firstBaseUpdate,v=d.lastBaseUpdate,w=d.shared.pending;if(w!==null){d.shared.pending=null;var N=w,q=N.next;N.next=null,v===null?m=q:v.next=q,v=N;var ee=i.alternate;ee!==null&&(ee=ee.updateQueue,w=ee.lastBaseUpdate,w!==v&&(w===null?ee.firstBaseUpdate=q:w.next=q,ee.lastBaseUpdate=N))}if(m!==null){var re=d.baseState;v=0,ee=q=N=null,w=m;do{var Y=w.lane&-536870913,$=Y!==w.lane;if($?(je&Y)===Y:(u&Y)===Y){Y!==0&&Y===Cs&&(wc=!0),ee!==null&&(ee=ee.next={lane:0,tag:w.tag,payload:w.payload,callback:null,next:null});e:{var ge=i,Se=w;Y=r;var Xe=l;switch(Se.tag){case 1:if(ge=Se.payload,typeof ge=="function"){re=ge.call(Xe,re,Y);break e}re=ge;break e;case 3:ge.flags=ge.flags&-65537|128;case 0:if(ge=Se.payload,Y=typeof ge=="function"?ge.call(Xe,re,Y):ge,Y==null)break e;re=_({},re,Y);break e;case 2:Qn=!0}}Y=w.callback,Y!==null&&(i.flags|=64,$&&(i.flags|=8192),$=d.callbacks,$===null?d.callbacks=[Y]:$.push(Y))}else $={lane:Y,tag:w.tag,payload:w.payload,callback:w.callback,next:null},ee===null?(q=ee=$,N=re):ee=ee.next=$,v|=Y;if(w=w.next,w===null){if(w=d.shared.pending,w===null)break;$=w,w=$.next,$.next=null,d.lastBaseUpdate=$,d.shared.pending=null}}while(!0);ee===null&&(N=re),d.baseState=N,d.firstBaseUpdate=q,d.lastBaseUpdate=ee,m===null&&(d.shared.lanes=0),sr|=v,i.lanes=v,i.memoizedState=re}}function hm(i,r){if(typeof i!="function")throw Error(s(191,i));i.call(r)}function fm(i,r){var l=i.callbacks;if(l!==null)for(i.callbacks=null,i=0;im?m:8;var v=T.T,w={};T.T=w,Fc(i,!1,r,l);try{var N=d(),q=T.S;if(q!==null&&q(w,N),N!==null&&typeof N=="object"&&typeof N.then=="function"){var ee=l1(N,u);Dl(i,r,ee,Ai(i))}else Dl(i,r,u,Ai(i))}catch(re){Dl(i,r,{then:function(){},status:"rejected",reason:re},Ai())}finally{j.p=m,v!==null&&w.types!==null&&(v.types=w.types),T.T=v}}function f1(){}function Uc(i,r,l,u){if(i.tag!==5)throw Error(s(476));var d=Wm(i).queue;qm(i,d,r,H,l===null?f1:function(){return Ym(i),l(u)})}function Wm(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:H,baseState:H,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Tn,lastRenderedState:H},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Tn,lastRenderedState:l},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function Ym(i){var r=Wm(i);r.next===null&&(r=i.alternate.memoizedState),Dl(i,r.next.queue,{},Ai())}function Ic(){return Xt(Vl)}function Vm(){return gt().memoizedState}function Km(){return gt().memoizedState}function d1(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var l=Ai();i=Jn(l);var u=er(r,i,l);u!==null&&(vi(u,r,l),Cl(u,r,l)),r={cache:_c()},i.payload=r;return}r=r.return}}function p1(i,r,l){var u=Ai();l={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},mo(i)?$m(r,l):(l=sc(i,r,l,u),l!==null&&(vi(l,i,u),Gm(l,r,u)))}function Xm(i,r,l){var u=Ai();Dl(i,r,l,u)}function Dl(i,r,l,u){var d={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(mo(i))$m(r,d);else{var m=i.alternate;if(i.lanes===0&&(m===null||m.lanes===0)&&(m=r.lastRenderedReducer,m!==null))try{var v=r.lastRenderedState,w=m(v,l);if(d.hasEagerState=!0,d.eagerState=w,xi(w,v))return Xa(i,r,d,0),Ze===null&&Ka(),!1}catch{}finally{}if(l=sc(i,r,d,u),l!==null)return vi(l,i,u),Gm(l,r,u),!0}return!1}function Fc(i,r,l,u){if(u={lane:2,revertLane:bh(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},mo(i)){if(r)throw Error(s(479))}else r=sc(i,l,u,2),r!==null&&vi(r,i,2)}function mo(i){var r=i.alternate;return i===Ae||r!==null&&r===Ae}function $m(i,r){Ds=ao=!0;var l=i.pending;l===null?r.next=r:(r.next=l.next,l.next=r),i.pending=r}function Gm(i,r,l){if((l&4194048)!==0){var u=r.lanes;u&=i.pendingLanes,l|=u,r.lanes=l,tp(i,l)}}var Rl={readContext:Xt,use:co,useCallback:ht,useContext:ht,useEffect:ht,useImperativeHandle:ht,useLayoutEffect:ht,useInsertionEffect:ht,useMemo:ht,useReducer:ht,useRef:ht,useState:ht,useDebugValue:ht,useDeferredValue:ht,useTransition:ht,useSyncExternalStore:ht,useId:ht,useHostTransitionStatus:ht,useFormState:ht,useActionState:ht,useOptimistic:ht,useMemoCache:ht,useCacheRefresh:ht};Rl.useEffectEvent=ht;var Zm={readContext:Xt,use:co,useCallback:function(i,r){return si().memoizedState=[i,r===void 0?null:r],i},useContext:Xt,useEffect:Lm,useImperativeHandle:function(i,r,l){l=l!=null?l.concat([i]):null,fo(4194308,4,Hm.bind(null,r,i),l)},useLayoutEffect:function(i,r){return fo(4194308,4,i,r)},useInsertionEffect:function(i,r){fo(4,2,i,r)},useMemo:function(i,r){var l=si();r=r===void 0?null:r;var u=i();if(Fr){hi(!0);try{i()}finally{hi(!1)}}return l.memoizedState=[u,r],u},useReducer:function(i,r,l){var u=si();if(l!==void 0){var d=l(r);if(Fr){hi(!0);try{l(r)}finally{hi(!1)}}}else d=r;return u.memoizedState=u.baseState=d,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:d},u.queue=i,i=i.dispatch=p1.bind(null,Ae,i),[u.memoizedState,i]},useRef:function(i){var r=si();return i={current:i},r.memoizedState=i},useState:function(i){i=zc(i);var r=i.queue,l=Xm.bind(null,Ae,r);return r.dispatch=l,[i.memoizedState,l]},useDebugValue:Hc,useDeferredValue:function(i,r){var l=si();return Pc(l,i,r)},useTransition:function(){var i=zc(!1);return i=qm.bind(null,Ae,i.queue,!0,!1),si().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,l){var u=Ae,d=si();if(Pe){if(l===void 0)throw Error(s(407));l=l()}else{if(l=r(),Ze===null)throw Error(s(349));(je&127)!==0||vm(u,r,l)}d.memoizedState=l;var m={value:l,getSnapshot:r};return d.queue=m,Lm(bm.bind(null,u,m,i),[i]),u.flags|=2048,Ms(9,{destroy:void 0},ym.bind(null,u,m,l,r),null),l},useId:function(){var i=si(),r=Ze.identifierPrefix;if(Pe){var l=nn,u=tn;l=(u&~(1<<32-Ge(u)-1)).toString(32)+l,r="_"+r+"R_"+l,l=oo++,0<\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof u.is=="string"?v.createElement("select",{is:u.is}):v.createElement("select"),u.multiple?m.multiple=!0:u.size&&(m.size=u.size);break;default:m=typeof u.is=="string"?v.createElement(d,{is:u.is}):v.createElement(d)}}m[Vt]=r,m[fi]=u;e:for(v=r.child;v!==null;){if(v.tag===5||v.tag===6)m.appendChild(v.stateNode);else if(v.tag!==4&&v.tag!==27&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===r)break e;for(;v.sibling===null;){if(v.return===null||v.return===r)break e;v=v.return}v.sibling.return=v.return,v=v.sibling}r.stateNode=m;e:switch(Gt(m,d,u),d){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&Dn(r)}}return it(r),ih(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,l),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==u&&Dn(r);else{if(typeof u!="string"&&r.stateNode===null)throw Error(s(166));if(i=de.current,xs(r)){if(i=r.stateNode,l=r.memoizedProps,u=null,d=Kt,d!==null)switch(d.tag){case 27:case 5:u=d.memoizedProps}i[Vt]=r,i=!!(i.nodeValue===l||u!==null&&u.suppressHydrationWarning===!0||_g(i.nodeValue,l)),i||Gn(r,!0)}else i=zo(i).createTextNode(u),i[Vt]=r,r.stateNode=i}return it(r),null;case 31:if(l=r.memoizedState,i===null||i.memoizedState!==null){if(u=xs(r),l!==null){if(i===null){if(!u)throw Error(s(318));if(i=r.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[Vt]=r}else zr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;it(r),i=!1}else l=fc(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=l),i=!0;if(!i)return r.flags&256?(ki(r),r):(ki(r),null);if((r.flags&128)!==0)throw Error(s(558))}return it(r),null;case 13:if(u=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(d=xs(r),u!==null&&u.dehydrated!==null){if(i===null){if(!d)throw Error(s(318));if(d=r.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(s(317));d[Vt]=r}else zr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;it(r),d=!1}else d=fc(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=d),d=!0;if(!d)return r.flags&256?(ki(r),r):(ki(r),null)}return ki(r),(r.flags&128)!==0?(r.lanes=l,r):(l=u!==null,i=i!==null&&i.memoizedState!==null,l&&(u=r.child,d=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(d=u.alternate.memoizedState.cachePool.pool),m=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(m=u.memoizedState.cachePool.pool),m!==d&&(u.flags|=2048)),l!==i&&l&&(r.child.flags|=8192),bo(r,r.updateQueue),it(r),null);case 4:return ke(),i===null&&Ch(r.stateNode.containerInfo),it(r),null;case 10:return kn(r.type),it(r),null;case 19:if(K(_t),u=r.memoizedState,u===null)return it(r),null;if(d=(r.flags&128)!==0,m=u.rendering,m===null)if(d)Bl(u,!1);else{if(ft!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(m=lo(i),m!==null){for(r.flags|=128,Bl(u,!1),i=m.updateQueue,r.updateQueue=i,bo(r,i),r.subtreeFlags=0,i=l,l=r.child;l!==null;)Xp(l,i),l=l.sibling;return C(_t,_t.current&1|2),Pe&&wn(r,u.treeForkCount),r.child}i=i.sibling}u.tail!==null&&Wt()>ko&&(r.flags|=128,d=!0,Bl(u,!1),r.lanes=4194304)}else{if(!d)if(i=lo(m),i!==null){if(r.flags|=128,d=!0,i=i.updateQueue,r.updateQueue=i,bo(r,i),Bl(u,!0),u.tail===null&&u.tailMode==="hidden"&&!m.alternate&&!Pe)return it(r),null}else 2*Wt()-u.renderingStartTime>ko&&l!==536870912&&(r.flags|=128,d=!0,Bl(u,!1),r.lanes=4194304);u.isBackwards?(m.sibling=r.child,r.child=m):(i=u.last,i!==null?i.sibling=m:r.child=m,u.last=m)}return u.tail!==null?(i=u.tail,u.rendering=i,u.tail=i.sibling,u.renderingStartTime=Wt(),i.sibling=null,l=_t.current,C(_t,d?l&1|2:l&1),Pe&&wn(r,u.treeForkCount),i):(it(r),null);case 22:case 23:return ki(r),kc(),u=r.memoizedState!==null,i!==null?i.memoizedState!==null!==u&&(r.flags|=8192):u&&(r.flags|=8192),u?(l&536870912)!==0&&(r.flags&128)===0&&(it(r),r.subtreeFlags&6&&(r.flags|=8192)):it(r),l=r.updateQueue,l!==null&&bo(r,l.retryQueue),l=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(l=i.memoizedState.cachePool.pool),u=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),u!==l&&(r.flags|=2048),i!==null&&K(Hr),null;case 24:return l=null,i!==null&&(l=i.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),kn(yt),it(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function y1(i,r){switch(cc(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return kn(yt),ke(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return et(r),null;case 31:if(r.memoizedState!==null){if(ki(r),r.alternate===null)throw Error(s(340));zr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(ki(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(s(340));zr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return K(_t),null;case 4:return ke(),null;case 10:return kn(r.type),null;case 22:case 23:return ki(r),kc(),i!==null&&K(Hr),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return kn(yt),null;case 25:return null;default:return null}}function S_(i,r){switch(cc(r),r.tag){case 3:kn(yt),ke();break;case 26:case 27:case 5:et(r);break;case 4:ke();break;case 31:r.memoizedState!==null&&ki(r);break;case 13:ki(r);break;case 19:K(_t);break;case 10:kn(r.type);break;case 22:case 23:ki(r),kc(),i!==null&&K(Hr);break;case 24:kn(yt)}}function Nl(i,r){try{var l=r.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var d=u.next;l=d;do{if((l.tag&i)===i){u=void 0;var m=l.create,v=l.inst;u=m(),v.destroy=u}l=l.next}while(l!==d)}}catch(w){Ye(r,r.return,w)}}function nr(i,r,l){try{var u=r.updateQueue,d=u!==null?u.lastEffect:null;if(d!==null){var m=d.next;u=m;do{if((u.tag&i)===i){var v=u.inst,w=v.destroy;if(w!==void 0){v.destroy=void 0,d=r;var N=l,q=w;try{q()}catch(ee){Ye(d,N,ee)}}}u=u.next}while(u!==m)}}catch(ee){Ye(r,r.return,ee)}}function x_(i){var r=i.updateQueue;if(r!==null){var l=i.stateNode;try{fm(r,l)}catch(u){Ye(i,i.return,u)}}}function w_(i,r,l){l.props=qr(i.type,i.memoizedProps),l.state=i.memoizedState;try{l.componentWillUnmount()}catch(u){Ye(i,r,u)}}function Ll(i,r){try{var l=i.ref;if(l!==null){switch(i.tag){case 26:case 27:case 5:var u=i.stateNode;break;case 30:u=i.stateNode;break;default:u=i.stateNode}typeof l=="function"?i.refCleanup=l(u):l.current=u}}catch(d){Ye(i,r,d)}}function rn(i,r){var l=i.ref,u=i.refCleanup;if(l!==null)if(typeof u=="function")try{u()}catch(d){Ye(i,r,d)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(d){Ye(i,r,d)}else l.current=null}function C_(i){var r=i.type,l=i.memoizedProps,u=i.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":l.autoFocus&&u.focus();break e;case"img":l.src?u.src=l.src:l.srcSet&&(u.srcset=l.srcSet)}}catch(d){Ye(i,i.return,d)}}function nh(i,r,l){try{var u=i.stateNode;I1(u,i.type,l,r),u[fi]=r}catch(d){Ye(i,i.return,d)}}function k_(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&cr(i.type)||i.tag===4}function rh(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||k_(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&cr(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function sh(i,r,l){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(i,r):(r=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,r.appendChild(i),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=bn));else if(u!==4&&(u===27&&cr(i.type)&&(l=i.stateNode,r=null),i=i.child,i!==null))for(sh(i,r,l),i=i.sibling;i!==null;)sh(i,r,l),i=i.sibling}function So(i,r,l){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?l.insertBefore(i,r):l.appendChild(i);else if(u!==4&&(u===27&&cr(i.type)&&(l=i.stateNode),i=i.child,i!==null))for(So(i,r,l),i=i.sibling;i!==null;)So(i,r,l),i=i.sibling}function E_(i){var r=i.stateNode,l=i.memoizedProps;try{for(var u=i.type,d=r.attributes;d.length;)r.removeAttributeNode(d[0]);Gt(r,u,l),r[Vt]=i,r[fi]=l}catch(m){Ye(i,i.return,m)}}var Rn=!1,xt=!1,lh=!1,T_=typeof WeakSet=="function"?WeakSet:Set,zt=null;function b1(i,r){if(i=i.containerInfo,Th=Fo,i=Pp(i),Ju(i)){if("selectionStart"in i)var l={start:i.selectionStart,end:i.selectionEnd};else e:{l=(l=i.ownerDocument)&&l.defaultView||window;var u=l.getSelection&&l.getSelection();if(u&&u.rangeCount!==0){l=u.anchorNode;var d=u.anchorOffset,m=u.focusNode;u=u.focusOffset;try{l.nodeType,m.nodeType}catch{l=null;break e}var v=0,w=-1,N=-1,q=0,ee=0,re=i,Y=null;t:for(;;){for(var $;re!==l||d!==0&&re.nodeType!==3||(w=v+d),re!==m||u!==0&&re.nodeType!==3||(N=v+u),re.nodeType===3&&(v+=re.nodeValue.length),($=re.firstChild)!==null;)Y=re,re=$;for(;;){if(re===i)break t;if(Y===l&&++q===d&&(w=v),Y===m&&++ee===u&&(N=v),($=re.nextSibling)!==null)break;re=Y,Y=re.parentNode}re=$}l=w===-1||N===-1?null:{start:w,end:N}}else l=null}l=l||{start:0,end:0}}else l=null;for(Ah={focusedElem:i,selectionRange:l},Fo=!1,zt=r;zt!==null;)if(r=zt,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,zt=i;else for(;zt!==null;){switch(r=zt,m=r.alternate,i=r.flags,r.tag){case 0:if((i&4)!==0&&(i=r.updateQueue,i=i!==null?i.events:null,i!==null))for(l=0;l title"))),Gt(m,u,l),m[Vt]=i,Lt(m),u=m;break e;case"link":var v=Ng("link","href",d).get(u+(l.href||""));if(v){for(var w=0;wXe&&(v=Xe,Xe=Se,Se=v);var P=jp(w,Se),z=jp(w,Xe);if(P&&z&&($.rangeCount!==1||$.anchorNode!==P.node||$.anchorOffset!==P.offset||$.focusNode!==z.node||$.focusOffset!==z.offset)){var F=re.createRange();F.setStart(P.node,P.offset),$.removeAllRanges(),Se>Xe?($.addRange(F),$.extend(z.node,z.offset)):(F.setEnd(z.node,z.offset),$.addRange(F))}}}}for(re=[],$=w;$=$.parentNode;)$.nodeType===1&&re.push({element:$,left:$.scrollLeft,top:$.scrollTop});for(typeof w.focus=="function"&&w.focus(),w=0;wl?32:l,T.T=null,l=dh,dh=null;var m=ar,v=zn;if(Dt=0,Os=ar=null,zn=0,(qe&6)!==0)throw Error(s(331));var w=qe;if(qe|=4,H_(m.current),z_(m,m.current,v,l),qe=w,Ul(0,!1),At&&typeof At.onPostCommitFiberRoot=="function")try{At.onPostCommitFiberRoot(Tt,m)}catch{}return!0}finally{j.p=d,T.T=u,ig(i,r)}}function rg(i,r,l){r=Oi(l,r),r=Vc(i.stateNode,r,2),i=er(i,r,2),i!==null&&(ll(i,2),sn(i))}function Ye(i,r,l){if(i.tag===3)rg(i,i,l);else for(;r!==null;){if(r.tag===3){rg(r,i,l);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(lr===null||!lr.has(u))){i=Oi(l,i),l=s_(2),u=er(r,l,2),u!==null&&(l_(l,u,r,i),ll(u,2),sn(u));break}}r=r.return}}function gh(i,r,l){var u=i.pingCache;if(u===null){u=i.pingCache=new w1;var d=new Set;u.set(r,d)}else d=u.get(r),d===void 0&&(d=new Set,u.set(r,d));d.has(l)||(uh=!0,d.add(l),i=A1.bind(null,i,r,l),r.then(i,i))}function A1(i,r,l){var u=i.pingCache;u!==null&&u.delete(r),i.pingedLanes|=i.suspendedLanes&l,i.warmLanes&=~l,Ze===i&&(je&l)===l&&(ft===4||ft===3&&(je&62914560)===je&&300>Wt()-Co?(qe&2)===0&&js(i,0):ch|=l,zs===je&&(zs=0)),sn(i)}function sg(i,r){r===0&&(r=Jd()),i=Nr(i,r),i!==null&&(ll(i,r),sn(i))}function D1(i){var r=i.memoizedState,l=0;r!==null&&(l=r.retryLane),sg(i,l)}function R1(i,r){var l=0;switch(i.tag){case 31:case 13:var u=i.stateNode,d=i.memoizedState;d!==null&&(l=d.retryLane);break;case 19:u=i.stateNode;break;case 22:u=i.stateNode._retryCache;break;default:throw Error(s(314))}u!==null&&u.delete(r),sg(i,l)}function M1(i,r){return Tr(i,r)}var Mo=null,Ps=null,vh=!1,Bo=!1,yh=!1,ur=0;function sn(i){i!==Ps&&i.next===null&&(Ps===null?Mo=Ps=i:Ps=Ps.next=i),Bo=!0,vh||(vh=!0,N1())}function Ul(i,r){if(!yh&&Bo){yh=!0;do for(var l=!1,u=Mo;u!==null;){if(i!==0){var d=u.pendingLanes;if(d===0)var m=0;else{var v=u.suspendedLanes,w=u.pingedLanes;m=(1<<31-Ge(42|i)+1)-1,m&=d&~(v&~w),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(l=!0,ug(u,m))}else m=je,m=za(u,u===Ze?m:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(m&3)===0||sl(u,m)||(l=!0,ug(u,m));u=u.next}while(l);yh=!1}}function B1(){lg()}function lg(){Bo=vh=!1;var i=0;ur!==0&&q1()&&(i=ur);for(var r=Wt(),l=null,u=Mo;u!==null;){var d=u.next,m=ag(u,r);m===0?(u.next=null,l===null?Mo=d:l.next=d,d===null&&(Ps=l)):(l=u,(i!==0||(m&3)!==0)&&(Bo=!0)),u=d}Dt!==0&&Dt!==5||Ul(i),ur!==0&&(ur=0)}function ag(i,r){for(var l=i.suspendedLanes,u=i.pingedLanes,d=i.expirationTimes,m=i.pendingLanes&-62914561;0w)break;var ee=N.transferSize,re=N.initiatorType;ee&&gg(re)&&(N=N.responseEnd,v+=ee*(N"u"?null:document;function Dg(i,r,l){var u=Us;if(u&&typeof r=="string"&&r){var d=Li(r);d='link[rel="'+i+'"][href="'+d+'"]',typeof l=="string"&&(d+='[crossorigin="'+l+'"]'),Ag.has(d)||(Ag.add(d),i={rel:i,crossOrigin:l,href:r},u.querySelector(d)===null&&(r=u.createElement("link"),Gt(r,"link",i),Lt(r),u.head.appendChild(r)))}}function Q1(i){On.D(i),Dg("dns-prefetch",i,null)}function J1(i,r){On.C(i,r),Dg("preconnect",i,r)}function ex(i,r,l){On.L(i,r,l);var u=Us;if(u&&i&&r){var d='link[rel="preload"][as="'+Li(r)+'"]';r==="image"&&l&&l.imageSrcSet?(d+='[imagesrcset="'+Li(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(d+='[imagesizes="'+Li(l.imageSizes)+'"]')):d+='[href="'+Li(i)+'"]';var m=d;switch(r){case"style":m=Is(i);break;case"script":m=Fs(i)}Fi.has(m)||(i=_({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:i,as:r},l),Fi.set(m,i),u.querySelector(d)!==null||r==="style"&&u.querySelector(Wl(m))||r==="script"&&u.querySelector(Yl(m))||(r=u.createElement("link"),Gt(r,"link",i),Lt(r),u.head.appendChild(r)))}}function tx(i,r){On.m(i,r);var l=Us;if(l&&i){var u=r&&typeof r.as=="string"?r.as:"script",d='link[rel="modulepreload"][as="'+Li(u)+'"][href="'+Li(i)+'"]',m=d;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=Fs(i)}if(!Fi.has(m)&&(i=_({rel:"modulepreload",href:i},r),Fi.set(m,i),l.querySelector(d)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Yl(m)))return}u=l.createElement("link"),Gt(u,"link",i),Lt(u),l.head.appendChild(u)}}}function ix(i,r,l){On.S(i,r,l);var u=Us;if(u&&i){var d=us(u).hoistableStyles,m=Is(i);r=r||"default";var v=d.get(m);if(!v){var w={loading:0,preload:null};if(v=u.querySelector(Wl(m)))w.loading=5;else{i=_({rel:"stylesheet",href:i,"data-precedence":r},l),(l=Fi.get(m))&&zh(i,l);var N=v=u.createElement("link");Lt(N),Gt(N,"link",i),N._p=new Promise(function(q,ee){N.onload=q,N.onerror=ee}),N.addEventListener("load",function(){w.loading|=1}),N.addEventListener("error",function(){w.loading|=2}),w.loading|=4,jo(v,r,u)}v={type:"stylesheet",instance:v,count:1,state:w},d.set(m,v)}}}function nx(i,r){On.X(i,r);var l=Us;if(l&&i){var u=us(l).hoistableScripts,d=Fs(i),m=u.get(d);m||(m=l.querySelector(Yl(d)),m||(i=_({src:i,async:!0},r),(r=Fi.get(d))&&Oh(i,r),m=l.createElement("script"),Lt(m),Gt(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(d,m))}}function rx(i,r){On.M(i,r);var l=Us;if(l&&i){var u=us(l).hoistableScripts,d=Fs(i),m=u.get(d);m||(m=l.querySelector(Yl(d)),m||(i=_({src:i,async:!0,type:"module"},r),(r=Fi.get(d))&&Oh(i,r),m=l.createElement("script"),Lt(m),Gt(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(d,m))}}function Rg(i,r,l,u){var d=(d=de.current)?Oo(d):null;if(!d)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(r=Is(l.href),l=us(d).hoistableStyles,u=l.get(r),u||(u={type:"style",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){i=Is(l.href);var m=us(d).hoistableStyles,v=m.get(i);if(v||(d=d.ownerDocument||d,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(i,v),(m=d.querySelector(Wl(i)))&&!m._p&&(v.instance=m,v.state.loading=5),Fi.has(i)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Fi.set(i,l),m||sx(d,i,l,v.state))),r&&u===null)throw Error(s(528,""));return v}if(r&&u!==null)throw Error(s(529,""));return null;case"script":return r=l.async,l=l.src,typeof l=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Fs(l),l=us(d).hoistableScripts,u=l.get(r),u||(u={type:"script",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,i))}}function Is(i){return'href="'+Li(i)+'"'}function Wl(i){return'link[rel="stylesheet"]['+i+"]"}function Mg(i){return _({},i,{"data-precedence":i.precedence,precedence:null})}function sx(i,r,l,u){i.querySelector('link[rel="preload"][as="style"]['+r+"]")?u.loading=1:(r=i.createElement("link"),u.preload=r,r.addEventListener("load",function(){return u.loading|=1}),r.addEventListener("error",function(){return u.loading|=2}),Gt(r,"link",l),Lt(r),i.head.appendChild(r))}function Fs(i){return'[src="'+Li(i)+'"]'}function Yl(i){return"script[async]"+i}function Bg(i,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var u=i.querySelector('style[data-href~="'+Li(l.href)+'"]');if(u)return r.instance=u,Lt(u),u;var d=_({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return u=(i.ownerDocument||i).createElement("style"),Lt(u),Gt(u,"style",d),jo(u,l.precedence,i),r.instance=u;case"stylesheet":d=Is(l.href);var m=i.querySelector(Wl(d));if(m)return r.state.loading|=4,r.instance=m,Lt(m),m;u=Mg(l),(d=Fi.get(d))&&zh(u,d),m=(i.ownerDocument||i).createElement("link"),Lt(m);var v=m;return v._p=new Promise(function(w,N){v.onload=w,v.onerror=N}),Gt(m,"link",u),r.state.loading|=4,jo(m,l.precedence,i),r.instance=m;case"script":return m=Fs(l.src),(d=i.querySelector(Yl(m)))?(r.instance=d,Lt(d),d):(u=l,(d=Fi.get(m))&&(u=_({},l),Oh(u,d)),i=i.ownerDocument||i,d=i.createElement("script"),Lt(d),Gt(d,"link",u),i.head.appendChild(d),r.instance=d);case"void":return null;default:throw Error(s(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(u=r.instance,r.state.loading|=4,jo(u,l.precedence,i));return r.instance}function jo(i,r,l){for(var u=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=u.length?u[u.length-1]:null,m=d,v=0;v title"):null)}function lx(i,r,l){if(l===1||r.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return i=r.disabled,typeof r.precedence=="string"&&i==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function zg(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function ax(i,r,l,u){if(l.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var d=Is(u.href),m=r.querySelector(Wl(d));if(m){r=m._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=Po.bind(i),r.then(i,i)),l.state.loading|=4,l.instance=m,Lt(m);return}m=r.ownerDocument||r,u=Mg(u),(d=Fi.get(d))&&zh(u,d),m=m.createElement("link"),Lt(m);var v=m;v._p=new Promise(function(w,N){v.onload=w,v.onerror=N}),Gt(m,"link",u),l.instance=m}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(l,r),(r=l.state.preload)&&(l.state.loading&3)===0&&(i.count++,l=Po.bind(i),r.addEventListener("load",l),r.addEventListener("error",l))}}var jh=0;function ox(i,r){return i.stylesheets&&i.count===0&&Io(i,i.stylesheets),0jh?50:800)+r);return i.unsuspend=l,function(){i.unsuspend=null,clearTimeout(u),clearTimeout(d)}}:null}function Po(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Io(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Uo=null;function Io(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Uo=new Map,r.forEach(ux,i),Uo=null,Po.call(i))}function ux(i,r){if(!(r.state.loading&4)){var l=Uo.get(i);if(l)var u=l.get(null);else{l=new Map,Uo.set(i,l);for(var d=i.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Vh.exports=Ex(),Vh.exports}var Ax=Tx();const Dx=xu(Ax);function Rx({onLogin:e}){const[t,n]=G.useState(""),[s,a]=G.useState(null),[o,c]=G.useState(!1),f=async p=>{if(p.preventDefault(),!t.trim())return;c(!0),a(null);const h=await e(t);h&&a(h),c(!1)};return S.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:S.jsxs("div",{className:"w-full max-w-sm",children:[S.jsxs("div",{className:"border-border rounded border p-6",children:[S.jsxs("div",{className:"mb-6 text-center",children:[S.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),S.jsx("p",{className:"text-muted mt-1 text-xs",children:"local writer agent"})]}),S.jsxs("form",{onSubmit:f,className:"space-y-4",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),S.jsx("input",{type:"password",value:t,onChange:p=>n(p.target.value),placeholder:"enter your passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),s&&S.jsx("p",{className:"text-error text-xs",children:s}),S.jsx("button",{type:"submit",disabled:o||!t.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:o?"authenticating...":"unlock"})]})]}),S.jsx("p",{className:"text-muted mt-4 text-center text-[10px]",children:"enter your passphrase to unlock"})]})})}function Mx({onSetup:e}){const[t,n]=G.useState(""),[s,a]=G.useState(""),[o,c]=G.useState(null),[f,p]=G.useState(!1),h=async g=>{if(g.preventDefault(),!t.trim()||t.length<4){c("Passphrase must be at least 4 characters");return}if(t!==s){c("Passphrases do not match");return}p(!0),c(null);const _=await e(t);_&&c(_),p(!1)};return S.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:S.jsx("div",{className:"w-full max-w-sm",children:S.jsxs("div",{className:"border-border rounded border p-6",children:[S.jsxs("div",{className:"mb-6 text-center",children:[S.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),S.jsx("p",{className:"text-muted mt-1 text-xs",children:"first-time setup"})]}),S.jsx("p",{className:"text-muted mb-4 text-xs leading-relaxed",children:"Choose a passphrase to protect your local writer agent. This will be used to unlock the app and secure your OWS wallet."}),S.jsxs("form",{onSubmit:h,className:"space-y-4",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),S.jsx("input",{type:"password",value:t,onChange:g=>n(g.target.value),placeholder:"choose a passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Confirm"}),S.jsx("input",{type:"password",value:s,onChange:g=>a(g.target.value),placeholder:"repeat passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),o&&S.jsx("p",{className:"text-error text-xs",children:o}),S.jsx("button",{type:"submit",disabled:f||!t.trim()||!s.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:f?"setting up...":"create passphrase"})]})]})})})}const sv="http://localhost:7777";function eb({token:e}){const[t,n]=G.useState(null),[s,a]=G.useState(!1),[o,c]=G.useState(!1),[f,p]=G.useState(null),h=(x,k)=>fetch(x,{...k,headers:{...k==null?void 0:k.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),g=()=>{h(`${sv}/api/wallet`).then(x=>x.json()).then(x=>n(x)).catch(()=>n({exists:!1,error:"Failed to load wallet"}))};G.useEffect(()=>{g()},[]);const _=async()=>{a(!0),p(null);try{const x=await h(`${sv}/api/wallet/create`,{method:"POST"}),k=await x.json();if(!x.ok)throw new Error(k.error||"Creation failed");g()}catch(x){p(x instanceof Error?x.message:"Failed to create wallet")}a(!1)},b=()=>{t!=null&&t.address&&(navigator.clipboard.writeText(t.address),c(!0),setTimeout(()=>c(!1),2e3))},y=x=>`${x.slice(0,6)}...${x.slice(-4)}`;return S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"OWS Wallet"}),!t&&S.jsx("p",{className:"text-muted text-xs",children:"loading..."}),t&&!t.exists&&S.jsxs("div",{className:"space-y-3",children:[S.jsx("p",{className:"text-muted text-xs",children:"No wallet created yet. Create one to enable autonomous transactions."}),f&&S.jsx("p",{className:"text-error text-xs",children:f}),S.jsx("button",{onClick:_,disabled:s,className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 rounded border px-4 py-2 text-xs font-medium transition-colors",children:s?"creating...":"create wallet"})]}),t&&t.exists&&t.address&&S.jsxs("div",{className:"space-y-3",children:[S.jsxs("div",{className:"flex items-center justify-between",children:[S.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"Address (Base)"}),S.jsx("span",{className:`rounded border px-1.5 py-0.5 text-[9px] ${t.ethBalance&&parseFloat(t.ethBalance)>0?"border-accent/30 text-accent":"border-accent-dim/30 text-accent-dim"}`,children:t.ethBalance&&parseFloat(t.ethBalance)>0?"active":"no balance"})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("code",{className:"text-foreground bg-surface rounded px-2 py-1 text-xs font-mono",children:y(t.address)}),S.jsx("button",{onClick:b,className:"text-muted hover:text-accent text-xs transition-colors",children:o?"copied":"copy"})]}),S.jsxs("div",{className:"border-border space-y-1 border-t pt-3",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"ETH"}),S.jsxs("span",{className:"text-foreground font-medium",children:[t.ethBalance||"0.000000"," ETH"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"USDC"}),S.jsxs("span",{className:"text-foreground font-medium",children:["$",t.usdcBalance||"0.00"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"PLOT"}),S.jsxs("span",{className:"text-foreground font-medium",children:[t.plotBalance||"0.0000"," PLOT"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Network"}),S.jsx("span",{className:"text-foreground",children:"Base"})]})]}),S.jsxs("div",{className:"border-border border-t pt-3",children:[S.jsx("p",{className:"text-muted mb-2 text-[10px] font-medium uppercase tracking-wider",children:"Fund Wallet"}),S.jsx("p",{className:"text-muted text-[10px]",children:"Send ETH on Base for gas (~$0.01 per publish):"}),S.jsx("code",{className:"text-foreground bg-surface mt-1 block break-all rounded px-2 py-1.5 text-[10px] font-mono",children:t.address})]})]})]})}function Bx({token:e,onLogout:t}){const[n,s]=G.useState(""),[a,o]=G.useState(""),[c,f]=G.useState(null),[p,h]=G.useState(!1),[g,_]=G.useState(!1),[b,y]=G.useState(null),[x,k]=G.useState("AI Writer"),[L,M]=G.useState(""),[Z,I]=G.useState(""),[Q,W]=G.useState(!1),[O,ie]=G.useState(null),[ue,me]=G.useState(""),[U,le]=G.useState(null),[V,B]=G.useState(!1),[A,R]=G.useState(null),[T,j]=G.useState(null),H=G.useCallback((C,J)=>fetch(C,{...J,headers:{...J==null?void 0:J.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]);G.useEffect(()=>{H("/api/settings/link-status").then(C=>C.json()).then(C=>y(C)).catch(()=>y({linked:!1}))},[]);const ae=async()=>{if(!x.trim()){ie("Agent name is required");return}if(!L.trim()){ie("Description is required");return}W(!0),ie(null);try{const C=await H("/api/settings/register-agent",{method:"POST",body:JSON.stringify({name:x,description:L,...Z.trim()&&{genre:Z}})}),J=await C.json();if(!C.ok)throw new Error(J.error||"Registration failed");y({linked:!0,agentId:J.agentId,owsWallet:J.owsWallet,txHash:J.txHash})}catch(C){ie(C instanceof Error?C.message:"Registration failed")}W(!1)},E=async()=>{if(!ue.trim()||!/^0x[a-fA-F0-9]{40}$/.test(ue)){R("Enter a valid wallet address (0x...)");return}B(!0),R(null),le(null);try{const C=await H("/api/settings/generate-binding",{method:"POST",body:JSON.stringify({humanWallet:ue})}),J=await C.json();if(!C.ok)throw new Error(J.error||"Failed to generate binding code");le(J)}catch(C){R(C instanceof Error?C.message:"Failed to generate binding code")}B(!1)},D=async(C,J)=>{await navigator.clipboard.writeText(C),j(J),setTimeout(()=>j(null),2e3)},K=async()=>{if(f(null),h(!1),!n||n.length<4){f("Passphrase must be at least 4 characters");return}if(n!==a){f("Passphrases do not match");return}_(!0);try{const C=await H("/api/auth/reset-passphrase",{method:"POST",body:JSON.stringify({passphrase:n})});if(!C.ok){const J=await C.json();throw new Error(J.error||"Reset failed")}h(!0),s(""),o(""),setTimeout(()=>h(!1),3e3)}catch(C){f(C instanceof Error?C.message:"Reset failed")}_(!1)};return S.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-6",children:[S.jsx("h2",{className:"text-accent text-lg font-bold",children:"Settings"}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Identity"}),b!=null&&b.linked?S.jsxs("div",{className:"space-y-2",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"text-sm font-medium text-accent",children:"Registered"}),S.jsxs("span",{className:"text-muted text-xs",children:["Agent #",b.agentId]})]}),b.owsWallet&&S.jsxs("p",{className:"text-muted text-xs font-mono",children:["Wallet: ",b.owsWallet.slice(0,6),"...",b.owsWallet.slice(-4)]}),b.owner&&S.jsxs("p",{className:"text-muted text-xs font-mono",children:["Owner: ",b.owner.slice(0,6),"...",b.owner.slice(-4)]}),b.txHash&&S.jsx("p",{className:"text-muted text-xs",children:S.jsx("a",{href:`https://basescan.org/tx/${b.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View transaction on BaseScan"})}),S.jsx("p",{className:"text-muted text-xs",children:S.jsx("a",{href:`https://plotlink.xyz/profile/${b.owsWallet}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View agent profile on plotlink.xyz"})})]}):S.jsxs("div",{className:"space-y-3",children:[S.jsx("p",{className:"text-muted text-xs",children:"Register this AI writer on-chain via ERC-8004. Uses your OWS wallet's existing ETH balance for gas."}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Name"}),S.jsx("input",{value:x,onChange:C=>k(C.target.value),placeholder:"AI Writer",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Description"}),S.jsx("input",{value:L,onChange:C=>M(C.target.value),placeholder:"An AI writing assistant for fiction stories",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Genre (optional)"}),S.jsx("input",{value:Z,onChange:C=>I(C.target.value),placeholder:"e.g. Fiction, Sci-Fi, Fantasy",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),O&&S.jsx("p",{className:"text-error text-xs",children:O}),S.jsx("button",{onClick:ae,disabled:Q||!x.trim()||!L.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:Q?"Registering...":"Register Agent Identity"})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Link to PlotLink"}),b!=null&&b.owner?S.jsxs("p",{className:"text-muted text-xs",children:["Linked to owner ",S.jsxs("span",{className:"font-mono",children:[b.owner.slice(0,6),"...",b.owner.slice(-4)]})]}):S.jsxs("div",{className:"space-y-3",children:[S.jsx("p",{className:"text-muted text-xs",children:"Link this OWS wallet to your PlotLink account so your stories appear under your profile on plotlink.xyz."}),S.jsxs("div",{className:"text-muted text-xs space-y-1 pl-3",children:[S.jsx("p",{children:"1. Enter your PlotLink wallet address below"}),S.jsx("p",{children:'2. Click "Generate Binding Code"'}),S.jsx("p",{children:"3. Copy the code and paste it on plotlink.xyz → Agents → Link AI Writer"})]}),S.jsx("input",{value:ue,onChange:C=>me(C.target.value),placeholder:"Your PlotLink wallet address (0x...)",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent font-mono"}),A&&S.jsx("p",{className:"text-error text-xs",children:A}),S.jsx("button",{onClick:E,disabled:V||!ue.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:V?"Generating...":"Generate Binding Code"}),U&&S.jsxs("div",{className:"space-y-3 mt-3",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Binding Code (signature)"}),S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:U.signature}),S.jsx("button",{onClick:()=>D(U.signature,"signature"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:T==="signature"?"Copied!":"Copy"})]})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"OWS Wallet Address"}),S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:U.owsWallet}),S.jsx("button",{onClick:()=>D(U.owsWallet,"wallet"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:T==="wallet"?"Copied!":"Copy"})]})]}),U.agentId&&S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Agent ID"}),S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono text-foreground pr-16",children:U.agentId}),S.jsx("button",{onClick:()=>D(String(U.agentId),"agentId"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:T==="agentId"?"Copied!":"Copy"})]})]}),S.jsx("p",{className:"text-xs text-accent",children:'Now go to plotlink.xyz/agents and paste the values in the "Link AI Writer" section.'})]})]})]}),S.jsx(eb,{token:e}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Reset Passphrase"}),S.jsxs("div",{className:"space-y-3",children:[S.jsx("input",{type:"password",value:n,onChange:C=>s(C.target.value),placeholder:"new passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),S.jsx("input",{type:"password",value:a,onChange:C=>o(C.target.value),placeholder:"confirm passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),c&&S.jsx("p",{className:"text-error text-xs",children:c}),p&&S.jsx("p",{className:"text-xs text-accent",children:"passphrase updated"}),S.jsx("button",{onClick:K,disabled:g||!n.trim(),className:"border-border text-muted hover:border-accent hover:text-accent disabled:opacity-40 w-full rounded border px-4 py-2 text-xs font-medium transition-colors",children:g?"updating...":"update passphrase"})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Session"}),S.jsx("button",{onClick:t,className:"border-border text-muted hover:border-error hover:text-error rounded border px-4 py-2 text-xs font-medium transition-colors",children:"logout"})]})]})}const Nx="http://localhost:7777";function Lx({token:e}){const[t,n]=G.useState(null),s=(f,p)=>fetch(f,{...p,headers:{...p==null?void 0:p.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),a=()=>{s(`${Nx}/api/dashboard`).then(f=>f.json()).then(n)};G.useEffect(()=>{a()},[]);const o=f=>`${f.slice(0,6)}...${f.slice(-4)}`,c=f=>{if(!f)return"Unknown date";const p=new Date(f);return isNaN(p.getTime())?"Unknown date":p.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})};return t?S.jsxs("div",{className:"mx-auto max-w-2xl space-y-6 p-6",children:[S.jsx("h2",{className:"text-accent text-lg font-bold",children:"Writer Dashboard"}),S.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-accent text-lg font-bold",children:t.stories.totalPublished}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"published"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.pendingFiles}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"pending"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalStories}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"stories"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalFiles}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"files"})]})]}),t.wallet&&S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Wallet"}),S.jsxs("div",{className:"space-y-1.5",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Address"}),S.jsx("code",{className:"text-foreground font-mono text-[10px]",children:o(t.wallet.address)})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"ETH Balance"}),S.jsxs("span",{className:"text-foreground",children:[t.wallet.ethFormatted," ETH"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"USDC Balance"}),S.jsxs("span",{className:"text-foreground",children:["$",t.wallet.usdcBalance]})]})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Profit & Loss"}),S.jsxs("div",{className:"space-y-1.5",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Total costs (gas)"}),S.jsxs("span",{className:"text-error",children:["-",t.pnl.totalCostsEth," ETH (~$",t.pnl.totalCostsUsd,")"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Royalties earned"}),S.jsxs("span",{className:"text-accent",children:["+",t.pnl.totalRoyaltiesPlot," PLOT"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Unclaimed royalties"}),S.jsxs("span",{className:"text-foreground",children:[t.royalties.unclaimed," PLOT"]})]}),S.jsxs("div",{className:"border-border flex justify-between border-t pt-1.5 text-xs font-medium",children:[S.jsx("span",{className:"text-muted",children:"Net P&L (USD)"}),S.jsxs("span",{className:parseFloat(t.pnl.netPnlUsd)>=0?"text-accent":"text-error",children:[parseFloat(t.pnl.netPnlUsd)>=0?"+":"","$",t.pnl.netPnlUsd]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Stories published"}),S.jsx("span",{className:"text-foreground",children:t.costs.storiesPublished})]})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Published Stories"}),t.stories.published.length===0?S.jsx("p",{className:"text-muted text-xs",children:"no published stories yet"}):S.jsx("div",{className:"space-y-3",children:t.stories.published.map(f=>S.jsxs("div",{className:"bg-surface rounded border border-border p-4",children:[S.jsxs("div",{className:"flex items-start justify-between",children:[S.jsxs("div",{children:[f.genre&&S.jsx("span",{className:"bg-accent/10 text-accent rounded px-2 py-0.5 text-[10px] font-medium",children:f.genre}),S.jsx("h4",{className:"text-foreground mt-1 text-sm font-serif font-medium",children:f.title}),S.jsx("p",{className:"text-muted mt-0.5 text-[10px] font-mono",children:f.storyName})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[f.hasNotIndexed&&S.jsx("span",{className:"rounded border border-amber-600/30 px-1.5 py-0.5 text-[9px] text-amber-700",children:"not indexed"}),S.jsxs("span",{className:"rounded border border-green-700/30 px-1.5 py-0.5 text-[9px] text-green-700",children:[f.publishedFiles," published"]})]})]}),S.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-center",children:[S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium",children:f.plotCount}),S.jsx("div",{className:"text-muted text-[9px]",children:"Plots"})]}),S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium font-mono",children:f.storylineId?`#${f.storylineId}`:"—"}),S.jsx("div",{className:"text-muted text-[9px]",children:"Storyline"})]}),S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium",children:f.totalGasCostEth??"—"}),S.jsx("div",{className:"text-muted text-[9px]",children:"Gas (ETH)"})]})]}),S.jsx("div",{className:"mt-2 space-y-1",children:f.files.map(p=>S.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[S.jsxs("div",{className:"flex items-center gap-1.5",children:[S.jsx("span",{className:p.status==="published-not-indexed"?"text-amber-700":"text-green-700",children:p.status==="published-not-indexed"?"⚠":"✓"}),S.jsx("span",{className:"text-muted font-mono",children:p.file})]}),p.txHash&&S.jsxs("a",{href:`https://basescan.org/tx/${p.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-accent font-mono",children:["tx:",p.txHash.slice(0,8),"..."]})]},p.file))}),S.jsxs("div",{className:"mt-2 flex items-center justify-between text-[10px]",children:[S.jsx("span",{className:"text-muted",children:c(f.latestPublishedAt)}),f.storylineId&&S.jsx("a",{href:`https://plotlink.xyz/story/${f.storylineId}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"})]})]},f.id))})]}),t.stories.pendingFiles>0&&S.jsx("div",{className:"border-border rounded border p-4",children:S.jsxs("p",{className:"text-muted text-xs",children:[t.stories.pendingFiles," file(s) pending publish — go to Stories to publish them."]})})]}):S.jsx("div",{className:"flex h-full items-center justify-center",children:S.jsx("span",{className:"text-muted text-sm",children:"loading dashboard..."})})}const zx={published:"✓","published-not-indexed":"⚠",pending:"⏳",draft:"📝"},Ox={published:"text-green-700","published-not-indexed":"text-amber-700",pending:"text-amber-700",draft:"text-muted"};function jx({authFetch:e,selectedStory:t,selectedFile:n,onSelectFile:s,onNewStory:a,untitledSessions:o=[]}){const[c,f]=G.useState([]),[p,h]=G.useState([]),[g,_]=G.useState(new Set),[b,y]=G.useState(!1),x=G.useCallback(async()=>{try{const W=await e("/api/stories");if(W.ok){const O=await W.json();f(O.stories)}}catch{}},[e]),k=G.useCallback(async()=>{try{const W=await e("/api/stories/archived");if(W.ok){const O=await W.json();h(O.stories)}}catch{}},[e]),L=G.useCallback(async W=>{try{(await e("/api/stories/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:W})})).ok&&(k(),x())}catch{}},[e,k,x]);G.useEffect(()=>{x();const W=setInterval(x,5e3);return()=>clearInterval(W)},[x]),G.useEffect(()=>{b&&k()},[b,k]),G.useEffect(()=>{t&&_(W=>new Set(W).add(t))},[t]);const M=W=>{var ie;const O=W.map(ue=>{var me;return{file:ue.file,num:(me=ue.file.match(/^plot-(\d+)\.md$/))==null?void 0:me[1]}}).filter(ue=>ue.num!=null).sort((ue,me)=>parseInt(me.num)-parseInt(ue.num));return O.length>0?O[0].file:W.some(ue=>ue.file==="genesis.md")?"genesis.md":W.some(ue=>ue.file==="structure.md")?"structure.md":((ie=W[0])==null?void 0:ie.file)??null},Z=W=>{_(O=>{const ie=new Set(O);return ie.has(W)?ie.delete(W):ie.add(W),ie})},I=W=>{if(Z(W.name),!g.has(W.name)){const O=M(W.files);O&&s(W.name,O)}},Q=W=>{const O=ie=>{if(ie==="structure.md")return 0;if(ie==="genesis.md")return 1;const ue=ie.match(/^plot-(\d+)\.md$/);return ue?2+parseInt(ue[1]):100};return[...W].sort((ie,ue)=>O(ie.file)-O(ue.file))};return b?S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs font-mono text-muted",children:"Archives"}),S.jsx("span",{className:"text-xs text-muted",children:p.length})]}),S.jsx("div",{className:"px-3 py-2 border-b border-border",children:S.jsxs("button",{onClick:()=>y(!1),className:"w-full px-3 py-1.5 text-sm text-muted hover:text-foreground hover:bg-surface rounded flex items-center gap-1.5",children:[S.jsx("span",{children:"←"}),S.jsx("span",{children:"Back"})]})}),S.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:p.length===0?S.jsx("div",{className:"p-3 text-sm text-muted",children:S.jsx("p",{children:"No archived stories."})}):p.map(W=>S.jsxs("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-surface",children:[S.jsx("span",{className:"text-sm font-medium truncate",title:W.name,children:W.title||W.name}),S.jsx("button",{onClick:()=>L(W.name),className:"text-xs text-accent hover:text-accent-dim flex-shrink-0 ml-2",children:"Restore"})]},W.name))})]}):S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs font-mono text-muted",children:"Stories"}),S.jsx("span",{className:"text-xs text-muted",children:c.length})]}),a&&S.jsx("div",{className:"px-3 py-2 border-b border-border",children:S.jsxs("button",{onClick:a,className:"w-full px-3 py-1.5 text-sm bg-accent text-white rounded hover:bg-accent-dim flex items-center justify-center gap-1.5",children:[S.jsx("span",{children:"+"}),S.jsx("span",{children:"New Story"})]})}),S.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[o.map(W=>S.jsx("div",{children:S.jsxs("button",{onClick:()=>s(W,""),className:`w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm ${t===W?"bg-surface":""}`,children:[S.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-600 flex-shrink-0"}),S.jsx("span",{className:"font-medium italic text-muted",children:"Untitled"})]})},W)),c.length===0&&o.length===0?S.jsxs("div",{className:"p-3 text-sm text-muted",children:[S.jsx("p",{children:"No stories yet."}),S.jsx("p",{className:"mt-1 text-xs",children:'Click "+ New Story" above to start writing.'})]}):c.filter(W=>W.name!=="_example").map(W=>S.jsxs("div",{children:[S.jsxs("button",{onClick:()=>I(W),className:"w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm",children:[S.jsx("span",{className:"text-xs text-muted",children:g.has(W.name)?"▼":"▶"}),S.jsx("span",{className:"font-medium truncate",title:W.name,children:W.title||W.name}),S.jsxs("span",{className:"ml-auto text-xs text-muted",children:[W.publishedCount,"/",W.files.length]})]}),g.has(W.name)&&S.jsx("div",{className:"pl-4",children:Q(W.files).map(O=>{const ie=t===W.name&&n===O.file;return S.jsxs("button",{onClick:()=>s(W.name,O.file),className:`w-full px-3 py-1.5 text-left flex items-center gap-2 text-xs hover:bg-surface ${ie?"bg-surface font-medium":""}`,children:[S.jsx("span",{className:Ox[O.status],children:zx[O.status]}),S.jsx("span",{className:"truncate font-mono",children:O.file})]},O.file)})})]},W.name))]}),S.jsx("div",{className:"px-3 py-2 border-t border-border",children:S.jsx("button",{onClick:()=>y(!0),className:"w-full px-3 py-1.5 text-xs text-muted hover:text-foreground hover:bg-surface rounded flex items-center justify-center gap-1.5",children:S.jsx("span",{children:"Archives"})})})]})}/** * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. * @license MIT * @@ -57,21 +57,21 @@ Error generating stack: `+u.message+` * Fabrice Bellard's javascript vt100 for jslinux: * http://bellard.org/jslinux/ * Copyright (c) 2011 Fabrice Bellard - */var tb=Object.defineProperty,Hx=Object.getOwnPropertyDescriptor,Px=(e,t)=>{for(var n in t)tb(e,n,{get:t[n],enumerable:!0})},pt=(e,t,n,s)=>{for(var a=s>1?void 0:s?Hx(t,n):t,o=e.length-1,c;o>=0;o--)(c=e[o])&&(a=(s?c(t,n,a):c(a))||a);return s&&a&&tb(t,n,a),a},pe=(e,t)=>(n,s)=>t(n,s,e),lv="Terminal input",Df={get:()=>lv,set:e=>lv=e},av="Too much output to announce, navigate to rows manually to read",Rf={get:()=>av,set:e=>av=e};function Ux(e){return e.replace(/\r?\n/g,"\r")}function Ix(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Fx(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function qx(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let a=e.clipboardData.getData("text/plain");ib(a,t,n,s)}}function ib(e,t,n,s){e=Ux(e),e=Ix(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function nb(e,t,n){let s=n.getBoundingClientRect(),a=e.clientX-s.left-10,o=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${a}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function ov(e,t,n,s,a){nb(e,t,n),a&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function br(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function wu(e,t=0,n=e.length){let s="";for(let a=t;a65535?(o-=65536,s+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):s+=String.fromCharCode(o)}return s}var Wx=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let s=0,a=0;if(this._interim){let o=e.charCodeAt(a++);56320<=o&&o<=57343?t[s++]=(this._interim-55296)*1024+o-56320+65536:(t[s++]=this._interim,t[s++]=o),this._interim=0}for(let o=a;o=n)return this._interim=c,s;let f=e.charCodeAt(o);56320<=f&&f<=57343?t[s++]=(c-55296)*1024+f-56320+65536:(t[s++]=c,t[s++]=f);continue}c!==65279&&(t[s++]=c)}return s}},Yx=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let s=0,a,o,c,f,p=0,h=0;if(this.interim[0]){let b=!1,y=this.interim[0];y&=(y&224)===192?31:(y&240)===224?15:7;let x=0,k;for(;(k=this.interim[++x]&63)&&x<4;)y<<=6,y|=k;let L=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,M=L-x;for(;h=n)return 0;if(k=e[h++],(k&192)!==128){h--,b=!0;break}else this.interim[x++]=k,y<<=6,y|=k&63}b||(L===2?y<128?h--:t[s++]=y:L===3?y<2048||y>=55296&&y<=57343||y===65279||(t[s++]=y):y<65536||y>1114111||(t[s++]=y)),this.interim.fill(0)}let g=n-4,_=h;for(;_=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(p=(a&31)<<6|o&63,p<128){_--;continue}t[s++]=p}else if((a&240)===224){if(_>=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[_++],(c&192)!==128){_--;continue}if(p=(a&15)<<12|(o&63)<<6|c&63,p<2048||p>=55296&&p<=57343||p===65279)continue;t[s++]=p}else if((a&248)===240){if(_>=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[_++],(c&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,this.interim[2]=c,s;if(f=e[_++],(f&192)!==128){_--;continue}if(p=(a&7)<<18|(o&63)<<12|(c&63)<<6|f&63,p<65536||p>1114111)continue;t[s++]=p}}return s}},rb="",xr=" ",Ca=class sb{constructor(){this.fg=0,this.bg=0,this.extended=new du}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new sb;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},du=class lb{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new lb(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ki=class ab extends Ca{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new du,this.combinedData=""}static fromCharData(t){let n=new ab;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?br(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let a=t[1].charCodeAt(1);56320<=a&&a<=57343?this.content=(s-55296)*1024+a-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},uv="di$target",Mf="di$dependencies",$h=new Map;function Vx(e){return e[Mf]||[]}function qt(e){if($h.has(e))return $h.get(e);let t=function(n,s,a){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Kx(t,n,a)};return t._id=e,$h.set(e,t),t}function Kx(e,t,n){t[uv]===t?t[Mf].push({id:e,index:n}):(t[Mf]=[{id:e,index:n}],t[uv]=t)}var ui=qt("BufferService"),ob=qt("CoreMouseService"),ns=qt("CoreService"),Xx=qt("CharsetService"),Cd=qt("InstantiationService"),ub=qt("LogService"),ci=qt("OptionsService"),cb=qt("OscLinkService"),Gx=qt("UnicodeService"),ka=qt("DecorationService"),Bf=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var g;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],a=this._optionsService.rawOptions.linkHandler,o=new Ki,c=n.getTrimmedLength(),f=-1,p=-1,h=!1;for(let _=0;_a?a.activate(k,L,y):$x(k,L),hover:(k,L)=>{var M;return(M=a==null?void 0:a.hover)==null?void 0:M.call(a,k,L,y)},leave:(k,L)=>{var M;return(M=a==null?void 0:a.leave)==null?void 0:M.call(a,k,L,y)}})}h=!1,o.hasExtendedAttrs()&&o.extended.urlId?(p=_,f=o.extended.urlId):(p=-1,f=-1)}}t(s)}};Bf=pt([pe(0,ui),pe(1,ci),pe(2,cb)],Bf);function $x(e,t){if(confirm(`Do you want to navigate to ${t}? + */var tb=Object.defineProperty,Hx=Object.getOwnPropertyDescriptor,Px=(e,t)=>{for(var n in t)tb(e,n,{get:t[n],enumerable:!0})},mt=(e,t,n,s)=>{for(var a=s>1?void 0:s?Hx(t,n):t,o=e.length-1,c;o>=0;o--)(c=e[o])&&(a=(s?c(t,n,a):c(a))||a);return s&&a&&tb(t,n,a),a},pe=(e,t)=>(n,s)=>t(n,s,e),lv="Terminal input",Df={get:()=>lv,set:e=>lv=e},av="Too much output to announce, navigate to rows manually to read",Rf={get:()=>av,set:e=>av=e};function Ux(e){return e.replace(/\r?\n/g,"\r")}function Ix(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Fx(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function qx(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let a=e.clipboardData.getData("text/plain");ib(a,t,n,s)}}function ib(e,t,n,s){e=Ux(e),e=Ix(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function nb(e,t,n){let s=n.getBoundingClientRect(),a=e.clientX-s.left-10,o=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${a}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function ov(e,t,n,s,a){nb(e,t,n),a&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function br(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function wu(e,t=0,n=e.length){let s="";for(let a=t;a65535?(o-=65536,s+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):s+=String.fromCharCode(o)}return s}var Wx=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let s=0,a=0;if(this._interim){let o=e.charCodeAt(a++);56320<=o&&o<=57343?t[s++]=(this._interim-55296)*1024+o-56320+65536:(t[s++]=this._interim,t[s++]=o),this._interim=0}for(let o=a;o=n)return this._interim=c,s;let f=e.charCodeAt(o);56320<=f&&f<=57343?t[s++]=(c-55296)*1024+f-56320+65536:(t[s++]=c,t[s++]=f);continue}c!==65279&&(t[s++]=c)}return s}},Yx=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let s=0,a,o,c,f,p=0,h=0;if(this.interim[0]){let b=!1,y=this.interim[0];y&=(y&224)===192?31:(y&240)===224?15:7;let x=0,k;for(;(k=this.interim[++x]&63)&&x<4;)y<<=6,y|=k;let L=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,M=L-x;for(;h=n)return 0;if(k=e[h++],(k&192)!==128){h--,b=!0;break}else this.interim[x++]=k,y<<=6,y|=k&63}b||(L===2?y<128?h--:t[s++]=y:L===3?y<2048||y>=55296&&y<=57343||y===65279||(t[s++]=y):y<65536||y>1114111||(t[s++]=y)),this.interim.fill(0)}let g=n-4,_=h;for(;_=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(p=(a&31)<<6|o&63,p<128){_--;continue}t[s++]=p}else if((a&240)===224){if(_>=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[_++],(c&192)!==128){_--;continue}if(p=(a&15)<<12|(o&63)<<6|c&63,p<2048||p>=55296&&p<=57343||p===65279)continue;t[s++]=p}else if((a&248)===240){if(_>=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[_++],(c&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,this.interim[2]=c,s;if(f=e[_++],(f&192)!==128){_--;continue}if(p=(a&7)<<18|(o&63)<<12|(c&63)<<6|f&63,p<65536||p>1114111)continue;t[s++]=p}}return s}},rb="",xr=" ",Ca=class sb{constructor(){this.fg=0,this.bg=0,this.extended=new du}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new sb;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},du=class lb{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new lb(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ki=class ab extends Ca{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new du,this.combinedData=""}static fromCharData(t){let n=new ab;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?br(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let a=t[1].charCodeAt(1);56320<=a&&a<=57343?this.content=(s-55296)*1024+a-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},uv="di$target",Mf="di$dependencies",Gh=new Map;function Vx(e){return e[Mf]||[]}function qt(e){if(Gh.has(e))return Gh.get(e);let t=function(n,s,a){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Kx(t,n,a)};return t._id=e,Gh.set(e,t),t}function Kx(e,t,n){t[uv]===t?t[Mf].push({id:e,index:n}):(t[Mf]=[{id:e,index:n}],t[uv]=t)}var ui=qt("BufferService"),ob=qt("CoreMouseService"),ns=qt("CoreService"),Xx=qt("CharsetService"),Cd=qt("InstantiationService"),ub=qt("LogService"),ci=qt("OptionsService"),cb=qt("OscLinkService"),$x=qt("UnicodeService"),ka=qt("DecorationService"),Bf=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var g;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],a=this._optionsService.rawOptions.linkHandler,o=new Ki,c=n.getTrimmedLength(),f=-1,p=-1,h=!1;for(let _=0;_a?a.activate(k,L,y):Gx(k,L),hover:(k,L)=>{var M;return(M=a==null?void 0:a.hover)==null?void 0:M.call(a,k,L,y)},leave:(k,L)=>{var M;return(M=a==null?void 0:a.leave)==null?void 0:M.call(a,k,L,y)}})}h=!1,o.hasExtendedAttrs()&&o.extended.urlId?(p=_,f=o.extended.urlId):(p=-1,f=-1)}}t(s)}};Bf=mt([pe(0,ui),pe(1,ci),pe(2,cb)],Bf);function Gx(e,t){if(confirm(`Do you want to navigate to ${t}? -WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Cu=qt("CharSizeService"),In=qt("CoreBrowserService"),kd=qt("MouseService"),Fn=qt("RenderService"),Zx=qt("SelectionService"),hb=qt("CharacterJoinerService"),Js=qt("ThemeService"),fb=qt("LinkProviderService"),Qx=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?cv.isErrorNoTelemetry(e)?new cv(e.message+` +WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Cu=qt("CharSizeService"),In=qt("CoreBrowserService"),kd=qt("MouseService"),Fn=qt("RenderService"),Zx=qt("SelectionService"),hb=qt("CharacterJoinerService"),tl=qt("ThemeService"),fb=qt("LinkProviderService"),Qx=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?cv.isErrorNoTelemetry(e)?new cv(e.message+` `+e.stack):new Error(e.message+` -`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},Jx=new Qx;function su(e){ew(e)||Jx.onUnexpectedError(e)}var Nf="Canceled";function ew(e){return e instanceof tw?!0:e instanceof Error&&e.name===Nf&&e.message===Nf}var tw=class extends Error{constructor(){super(Nf),this.name=this.message}};function iw(e){return new Error(`Illegal argument: ${e}`)}var cv=class Lf extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Lf)return t;let n=new Lf;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},zf=class db extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,db.prototype)}};function Di(e,t=0){return e[e.length-(1+t)]}var nw;(e=>{function t(o){return o<0}e.isLessThan=t;function n(o){return o<=0}e.isLessThanOrEqual=n;function s(o){return o>0}e.isGreaterThan=s;function a(o){return o===0}e.isNeitherLessOrGreaterThan=a,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(nw||(nw={}));function rw(e,t){let n=this,s=!1,a;return function(){return s||(s=!0,t||(a=e.apply(n,arguments))),a}}var pb;(e=>{function t(Q){return Q&&typeof Q=="object"&&typeof Q[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*a(Q){yield Q}e.single=a;function o(Q){return t(Q)?Q:a(Q)}e.wrap=o;function c(Q){return Q||n}e.from=c;function*f(Q){for(let W=Q.length-1;W>=0;W--)yield Q[W]}e.reverse=f;function p(Q){return!Q||Q[Symbol.iterator]().next().done===!0}e.isEmpty=p;function h(Q){return Q[Symbol.iterator]().next().value}e.first=h;function g(Q,W){let O=0;for(let ie of Q)if(W(ie,O++))return!0;return!1}e.some=g;function _(Q,W){for(let O of Q)if(W(O))return O}e.find=_;function*b(Q,W){for(let O of Q)W(O)&&(yield O)}e.filter=b;function*y(Q,W){let O=0;for(let ie of Q)yield W(ie,O++)}e.map=y;function*x(Q,W){let O=0;for(let ie of Q)yield*W(ie,O++)}e.flatMap=x;function*k(...Q){for(let W of Q)yield*W}e.concat=k;function L(Q,W,O){let ie=O;for(let ue of Q)ie=W(ie,ue);return ie}e.reduce=L;function*M(Q,W,O=Q.length){for(W<0&&(W+=Q.length),O<0?O+=Q.length:O>Q.length&&(O=Q.length);W1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function sw(...e){return lt(()=>es(e))}function lt(e){return{dispose:rw(()=>{e()})}}var mb=class _b{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{es(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?_b.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};mb.DISABLE_DISPOSED_WARNING=!1;var wr=mb,Be=class{constructor(){this._store=new wr,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Be.None=Object.freeze({dispose(){}});var Zs=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Un=typeof window=="object"?window:globalThis,Of=class jf{constructor(t){this.element=t,this.next=jf.Undefined,this.prev=jf.Undefined}};Of.Undefined=new Of(void 0);var at=Of,hv=class{constructor(){this._first=at.Undefined,this._last=at.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===at.Undefined}clear(){let e=this._first;for(;e!==at.Undefined;){let t=e.next;e.prev=at.Undefined,e.next=at.Undefined,e=t}this._first=at.Undefined,this._last=at.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new at(e);if(this._first===at.Undefined)this._first=n,this._last=n;else if(t){let a=this._last;this._last=n,n.prev=a,a.next=n}else{let a=this._first;this._first=n,n.next=a,a.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first!==at.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==at.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==at.Undefined&&e.next!==at.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===at.Undefined&&e.next===at.Undefined?(this._first=at.Undefined,this._last=at.Undefined):e.next===at.Undefined?(this._last=this._last.prev,this._last.next=at.Undefined):e.prev===at.Undefined&&(this._first=this._first.next,this._first.prev=at.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==at.Undefined;)yield e.element,e=e.next}},lw=globalThis.performance&&typeof globalThis.performance.now=="function",aw=class gb{static create(t){return new gb(t)}constructor(t){this._now=lw&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Jt;(e=>{e.None=()=>Be.None;function t(V,B){return _(V,()=>{},0,void 0,!0,void 0,B)}e.defer=t;function n(V){return(B,A=null,R)=>{let T=!1,j;return j=V(H=>{if(!T)return j?j.dispose():T=!0,B.call(A,H)},null,R),T&&j.dispose(),j}}e.once=n;function s(V,B,A){return h((R,T=null,j)=>V(H=>R.call(T,B(H)),null,j),A)}e.map=s;function a(V,B,A){return h((R,T=null,j)=>V(H=>{B(H),R.call(T,H)},null,j),A)}e.forEach=a;function o(V,B,A){return h((R,T=null,j)=>V(H=>B(H)&&R.call(T,H),null,j),A)}e.filter=o;function c(V){return V}e.signal=c;function f(...V){return(B,A=null,R)=>{let T=sw(...V.map(j=>j(H=>B.call(A,H))));return g(T,R)}}e.any=f;function p(V,B,A,R){let T=A;return s(V,j=>(T=B(T,j),T),R)}e.reduce=p;function h(V,B){let A,R={onWillAddFirstListener(){A=V(T.fire,T)},onDidRemoveLastListener(){A==null||A.dispose()}},T=new ce(R);return B==null||B.add(T),T.event}function g(V,B){return B instanceof Array?B.push(V):B&&B.add(V),V}function _(V,B,A=100,R=!1,T=!1,j,H){let oe,E,D,K=0,C,J={leakWarningThreshold:j,onWillAddFirstListener(){oe=V(de=>{K++,E=B(E,de),R&&!D&&(fe.fire(E),E=void 0),C=()=>{let xe=E;E=void 0,D=void 0,(!R||K>1)&&fe.fire(xe),K=0},typeof A=="number"?(clearTimeout(D),D=setTimeout(C,A)):D===void 0&&(D=0,queueMicrotask(C))})},onWillRemoveListener(){T&&K>0&&(C==null||C())},onDidRemoveLastListener(){C=void 0,oe.dispose()}},fe=new ce(J);return H==null||H.add(fe),fe.event}e.debounce=_;function b(V,B=0,A){return e.debounce(V,(R,T)=>R?(R.push(T),R):[T],B,void 0,!0,void 0,A)}e.accumulate=b;function y(V,B=(R,T)=>R===T,A){let R=!0,T;return o(V,j=>{let H=R||!B(j,T);return R=!1,T=j,H},A)}e.latch=y;function x(V,B,A){return[e.filter(V,B,A),e.filter(V,R=>!B(R),A)]}e.split=x;function k(V,B=!1,A=[],R){let T=A.slice(),j=V(E=>{T?T.push(E):oe.fire(E)});R&&R.add(j);let H=()=>{T==null||T.forEach(E=>oe.fire(E)),T=null},oe=new ce({onWillAddFirstListener(){j||(j=V(E=>oe.fire(E)),R&&R.add(j))},onDidAddFirstListener(){T&&(B?setTimeout(H):H())},onDidRemoveLastListener(){j&&j.dispose(),j=null}});return R&&R.add(oe),oe.event}e.buffer=k;function L(V,B){return(A,R,T)=>{let j=B(new Z);return V(function(H){let oe=j.evaluate(H);oe!==M&&A.call(R,oe)},void 0,T)}}e.chain=L;let M=Symbol("HaltChainable");class Z{constructor(){this.steps=[]}map(B){return this.steps.push(B),this}forEach(B){return this.steps.push(A=>(B(A),A)),this}filter(B){return this.steps.push(A=>B(A)?A:M),this}reduce(B,A){let R=A;return this.steps.push(T=>(R=B(R,T),R)),this}latch(B=(A,R)=>A===R){let A=!0,R;return this.steps.push(T=>{let j=A||!B(T,R);return A=!1,R=T,j?T:M}),this}evaluate(B){for(let A of this.steps)if(B=A(B),B===M)break;return B}}function I(V,B,A=R=>R){let R=(...oe)=>H.fire(A(...oe)),T=()=>V.on(B,R),j=()=>V.removeListener(B,R),H=new ce({onWillAddFirstListener:T,onDidRemoveLastListener:j});return H.event}e.fromNodeEventEmitter=I;function Q(V,B,A=R=>R){let R=(...oe)=>H.fire(A(...oe)),T=()=>V.addEventListener(B,R),j=()=>V.removeEventListener(B,R),H=new ce({onWillAddFirstListener:T,onDidRemoveLastListener:j});return H.event}e.fromDOMEventEmitter=Q;function W(V){return new Promise(B=>n(V)(B))}e.toPromise=W;function O(V){let B=new ce;return V.then(A=>{B.fire(A)},()=>{B.fire(void 0)}).finally(()=>{B.dispose()}),B.event}e.fromPromise=O;function ie(V,B){return V(A=>B.fire(A))}e.forward=ie;function ue(V,B,A){return B(A),V(R=>B(R))}e.runAndSubscribe=ue;class me{constructor(B,A){this._observable=B,this._counter=0,this._hasChanged=!1;let R={onWillAddFirstListener:()=>{B.addObserver(this)},onDidRemoveLastListener:()=>{B.removeObserver(this)}};this.emitter=new ce(R),A&&A.add(this.emitter)}beginUpdate(B){this._counter++}handlePossibleChange(B){}handleChange(B,A){this._hasChanged=!0}endUpdate(B){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function U(V,B){return new me(V,B).emitter.event}e.fromObservable=U;function le(V){return(B,A,R)=>{let T=0,j=!1,H={beginUpdate(){T++},endUpdate(){T--,T===0&&(V.reportChanges(),j&&(j=!1,B.call(A)))},handlePossibleChange(){},handleChange(){j=!0}};V.addObserver(H),V.reportChanges();let oe={dispose(){V.removeObserver(H)}};return R instanceof wr?R.add(oe):Array.isArray(R)&&R.push(oe),oe}}e.fromObservableLight=le})(Jt||(Jt={}));var Hf=class Pf{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Pf._idPool++}`,Pf.all.add(this)}start(t){this._stopWatch=new aw,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Hf.all=new Set,Hf._idPool=0;var ow=Hf,uw=-1,vb=class yb{constructor(t,n,s=(yb._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let s=this.threshold;if(s<=0||n{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[s,a]of this._stacks)(!t||n{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},Jx=new Qx;function su(e){ew(e)||Jx.onUnexpectedError(e)}var Nf="Canceled";function ew(e){return e instanceof tw?!0:e instanceof Error&&e.name===Nf&&e.message===Nf}var tw=class extends Error{constructor(){super(Nf),this.name=this.message}};function iw(e){return new Error(`Illegal argument: ${e}`)}var cv=class Lf extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Lf)return t;let n=new Lf;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},zf=class db extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,db.prototype)}};function Di(e,t=0){return e[e.length-(1+t)]}var nw;(e=>{function t(o){return o<0}e.isLessThan=t;function n(o){return o<=0}e.isLessThanOrEqual=n;function s(o){return o>0}e.isGreaterThan=s;function a(o){return o===0}e.isNeitherLessOrGreaterThan=a,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(nw||(nw={}));function rw(e,t){let n=this,s=!1,a;return function(){return s||(s=!0,t||(a=e.apply(n,arguments))),a}}var pb;(e=>{function t(Q){return Q&&typeof Q=="object"&&typeof Q[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*a(Q){yield Q}e.single=a;function o(Q){return t(Q)?Q:a(Q)}e.wrap=o;function c(Q){return Q||n}e.from=c;function*f(Q){for(let W=Q.length-1;W>=0;W--)yield Q[W]}e.reverse=f;function p(Q){return!Q||Q[Symbol.iterator]().next().done===!0}e.isEmpty=p;function h(Q){return Q[Symbol.iterator]().next().value}e.first=h;function g(Q,W){let O=0;for(let ie of Q)if(W(ie,O++))return!0;return!1}e.some=g;function _(Q,W){for(let O of Q)if(W(O))return O}e.find=_;function*b(Q,W){for(let O of Q)W(O)&&(yield O)}e.filter=b;function*y(Q,W){let O=0;for(let ie of Q)yield W(ie,O++)}e.map=y;function*x(Q,W){let O=0;for(let ie of Q)yield*W(ie,O++)}e.flatMap=x;function*k(...Q){for(let W of Q)yield*W}e.concat=k;function L(Q,W,O){let ie=O;for(let ue of Q)ie=W(ie,ue);return ie}e.reduce=L;function*M(Q,W,O=Q.length){for(W<0&&(W+=Q.length),O<0?O+=Q.length:O>Q.length&&(O=Q.length);W1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function sw(...e){return at(()=>es(e))}function at(e){return{dispose:rw(()=>{e()})}}var mb=class _b{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{es(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?_b.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};mb.DISABLE_DISPOSED_WARNING=!1;var wr=mb,Be=class{constructor(){this._store=new wr,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Be.None=Object.freeze({dispose(){}});var Js=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Un=typeof window=="object"?window:globalThis,Of=class jf{constructor(t){this.element=t,this.next=jf.Undefined,this.prev=jf.Undefined}};Of.Undefined=new Of(void 0);var ot=Of,hv=class{constructor(){this._first=ot.Undefined,this._last=ot.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ot.Undefined}clear(){let e=this._first;for(;e!==ot.Undefined;){let t=e.next;e.prev=ot.Undefined,e.next=ot.Undefined,e=t}this._first=ot.Undefined,this._last=ot.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new ot(e);if(this._first===ot.Undefined)this._first=n,this._last=n;else if(t){let a=this._last;this._last=n,n.prev=a,a.next=n}else{let a=this._first;this._first=n,n.next=a,a.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first!==ot.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ot.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ot.Undefined&&e.next!==ot.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ot.Undefined&&e.next===ot.Undefined?(this._first=ot.Undefined,this._last=ot.Undefined):e.next===ot.Undefined?(this._last=this._last.prev,this._last.next=ot.Undefined):e.prev===ot.Undefined&&(this._first=this._first.next,this._first.prev=ot.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ot.Undefined;)yield e.element,e=e.next}},lw=globalThis.performance&&typeof globalThis.performance.now=="function",aw=class gb{static create(t){return new gb(t)}constructor(t){this._now=lw&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Jt;(e=>{e.None=()=>Be.None;function t(V,B){return _(V,()=>{},0,void 0,!0,void 0,B)}e.defer=t;function n(V){return(B,A=null,R)=>{let T=!1,j;return j=V(H=>{if(!T)return j?j.dispose():T=!0,B.call(A,H)},null,R),T&&j.dispose(),j}}e.once=n;function s(V,B,A){return h((R,T=null,j)=>V(H=>R.call(T,B(H)),null,j),A)}e.map=s;function a(V,B,A){return h((R,T=null,j)=>V(H=>{B(H),R.call(T,H)},null,j),A)}e.forEach=a;function o(V,B,A){return h((R,T=null,j)=>V(H=>B(H)&&R.call(T,H),null,j),A)}e.filter=o;function c(V){return V}e.signal=c;function f(...V){return(B,A=null,R)=>{let T=sw(...V.map(j=>j(H=>B.call(A,H))));return g(T,R)}}e.any=f;function p(V,B,A,R){let T=A;return s(V,j=>(T=B(T,j),T),R)}e.reduce=p;function h(V,B){let A,R={onWillAddFirstListener(){A=V(T.fire,T)},onDidRemoveLastListener(){A==null||A.dispose()}},T=new he(R);return B==null||B.add(T),T.event}function g(V,B){return B instanceof Array?B.push(V):B&&B.add(V),V}function _(V,B,A=100,R=!1,T=!1,j,H){let ae,E,D,K=0,C,J={leakWarningThreshold:j,onWillAddFirstListener(){ae=V(de=>{K++,E=B(E,de),R&&!D&&(fe.fire(E),E=void 0),C=()=>{let xe=E;E=void 0,D=void 0,(!R||K>1)&&fe.fire(xe),K=0},typeof A=="number"?(clearTimeout(D),D=setTimeout(C,A)):D===void 0&&(D=0,queueMicrotask(C))})},onWillRemoveListener(){T&&K>0&&(C==null||C())},onDidRemoveLastListener(){C=void 0,ae.dispose()}},fe=new he(J);return H==null||H.add(fe),fe.event}e.debounce=_;function b(V,B=0,A){return e.debounce(V,(R,T)=>R?(R.push(T),R):[T],B,void 0,!0,void 0,A)}e.accumulate=b;function y(V,B=(R,T)=>R===T,A){let R=!0,T;return o(V,j=>{let H=R||!B(j,T);return R=!1,T=j,H},A)}e.latch=y;function x(V,B,A){return[e.filter(V,B,A),e.filter(V,R=>!B(R),A)]}e.split=x;function k(V,B=!1,A=[],R){let T=A.slice(),j=V(E=>{T?T.push(E):ae.fire(E)});R&&R.add(j);let H=()=>{T==null||T.forEach(E=>ae.fire(E)),T=null},ae=new he({onWillAddFirstListener(){j||(j=V(E=>ae.fire(E)),R&&R.add(j))},onDidAddFirstListener(){T&&(B?setTimeout(H):H())},onDidRemoveLastListener(){j&&j.dispose(),j=null}});return R&&R.add(ae),ae.event}e.buffer=k;function L(V,B){return(A,R,T)=>{let j=B(new Z);return V(function(H){let ae=j.evaluate(H);ae!==M&&A.call(R,ae)},void 0,T)}}e.chain=L;let M=Symbol("HaltChainable");class Z{constructor(){this.steps=[]}map(B){return this.steps.push(B),this}forEach(B){return this.steps.push(A=>(B(A),A)),this}filter(B){return this.steps.push(A=>B(A)?A:M),this}reduce(B,A){let R=A;return this.steps.push(T=>(R=B(R,T),R)),this}latch(B=(A,R)=>A===R){let A=!0,R;return this.steps.push(T=>{let j=A||!B(T,R);return A=!1,R=T,j?T:M}),this}evaluate(B){for(let A of this.steps)if(B=A(B),B===M)break;return B}}function I(V,B,A=R=>R){let R=(...ae)=>H.fire(A(...ae)),T=()=>V.on(B,R),j=()=>V.removeListener(B,R),H=new he({onWillAddFirstListener:T,onDidRemoveLastListener:j});return H.event}e.fromNodeEventEmitter=I;function Q(V,B,A=R=>R){let R=(...ae)=>H.fire(A(...ae)),T=()=>V.addEventListener(B,R),j=()=>V.removeEventListener(B,R),H=new he({onWillAddFirstListener:T,onDidRemoveLastListener:j});return H.event}e.fromDOMEventEmitter=Q;function W(V){return new Promise(B=>n(V)(B))}e.toPromise=W;function O(V){let B=new he;return V.then(A=>{B.fire(A)},()=>{B.fire(void 0)}).finally(()=>{B.dispose()}),B.event}e.fromPromise=O;function ie(V,B){return V(A=>B.fire(A))}e.forward=ie;function ue(V,B,A){return B(A),V(R=>B(R))}e.runAndSubscribe=ue;class me{constructor(B,A){this._observable=B,this._counter=0,this._hasChanged=!1;let R={onWillAddFirstListener:()=>{B.addObserver(this)},onDidRemoveLastListener:()=>{B.removeObserver(this)}};this.emitter=new he(R),A&&A.add(this.emitter)}beginUpdate(B){this._counter++}handlePossibleChange(B){}handleChange(B,A){this._hasChanged=!0}endUpdate(B){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function U(V,B){return new me(V,B).emitter.event}e.fromObservable=U;function le(V){return(B,A,R)=>{let T=0,j=!1,H={beginUpdate(){T++},endUpdate(){T--,T===0&&(V.reportChanges(),j&&(j=!1,B.call(A)))},handlePossibleChange(){},handleChange(){j=!0}};V.addObserver(H),V.reportChanges();let ae={dispose(){V.removeObserver(H)}};return R instanceof wr?R.add(ae):Array.isArray(R)&&R.push(ae),ae}}e.fromObservableLight=le})(Jt||(Jt={}));var Hf=class Pf{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Pf._idPool++}`,Pf.all.add(this)}start(t){this._stopWatch=new aw,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Hf.all=new Set,Hf._idPool=0;var ow=Hf,uw=-1,vb=class yb{constructor(t,n,s=(yb._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let s=this.threshold;if(s<=0||n{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[s,a]of this._stacks)(!t||n{var f,p,h,g,_;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let b=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(b);let y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],x=new dw(`${b}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((f=this._options)==null?void 0:f.onListenerError)||su)(x),Be.None}if(this._disposed)return Be.None;n&&(t=t.bind(n));let a=new Zh(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(a.stack=hw.create(),o=this._leakageMon.check(a.stack,this._size+1)),this._listeners?this._listeners instanceof Zh?(this._deliveryQueue??(this._deliveryQueue=new gw),this._listeners=[this._listeners,a]):this._listeners.push(a):((h=(p=this._options)==null?void 0:p.onWillAddFirstListener)==null||h.call(p,this),this._listeners=a,(_=(g=this._options)==null?void 0:g.onDidAddFirstListener)==null||_.call(g,this)),this._size++;let c=lt(()=>{o==null||o(),this._removeListener(a)});return s instanceof wr?s.add(c):Array.isArray(s)&&s.push(c),c}),this._event}_removeListener(t){var o,c,f,p;if((c=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||c.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(p=(f=this._options)==null?void 0:f.onDidRemoveLastListener)==null||p.call(f,this),this._size=0;return}let n=this._listeners,s=n.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,n[s]=void 0;let a=this._deliveryQueue.current===this;if(this._size*mw<=n.length){let h=0;for(let g=0;g0}},gw=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Uf=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ce,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ce,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Uf.INSTANCE=new Uf;var Ed=Uf;function vw(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Ed.INSTANCE.onDidChangeZoomLevel;function yw(e){return Ed.INSTANCE.getZoomFactor(e)}Ed.INSTANCE.onDidChangeFullscreen;var el=typeof navigator=="object"?navigator.userAgent:"",If=el.indexOf("Firefox")>=0,bw=el.indexOf("AppleWebKit")>=0,Td=el.indexOf("Chrome")>=0,Sw=!Td&&el.indexOf("Safari")>=0;el.indexOf("Electron/")>=0;el.indexOf("Android")>=0;var Qh=!1;if(typeof Un.matchMedia=="function"){let e=Un.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Un.matchMedia("(display-mode: fullscreen)");Qh=e.matches,vw(Un,e,({matches:n})=>{Qh&&t.matches||(Qh=n)})}var Gs="en",Ff=!1,qf=!1,lu=!1,Sb=!1,Go,au=Gs,fv=Gs,xw,Qi,Jr=globalThis,Qt,Zy;typeof Jr.vscode<"u"&&typeof Jr.vscode.process<"u"?Qt=Jr.vscode.process:typeof process<"u"&&typeof((Zy=process==null?void 0:process.versions)==null?void 0:Zy.node)=="string"&&(Qt=process);var Qy,ww=typeof((Qy=Qt==null?void 0:Qt.versions)==null?void 0:Qy.electron)=="string",Cw=ww&&(Qt==null?void 0:Qt.type)==="renderer",Jy;if(typeof Qt=="object"){Ff=Qt.platform==="win32",qf=Qt.platform==="darwin",lu=Qt.platform==="linux",lu&&Qt.env.SNAP&&Qt.env.SNAP_REVISION,Qt.env.CI||Qt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Go=Gs,au=Gs;let e=Qt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Go=t.userLocale,fv=t.osLocale,au=t.resolvedLanguage||Gs,xw=(Jy=t.languagePack)==null?void 0:Jy.translationsConfigFile}catch{}Sb=!0}else typeof navigator=="object"&&!Cw?(Qi=navigator.userAgent,Ff=Qi.indexOf("Windows")>=0,qf=Qi.indexOf("Macintosh")>=0,(Qi.indexOf("Macintosh")>=0||Qi.indexOf("iPad")>=0||Qi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,lu=Qi.indexOf("Linux")>=0,(Qi==null?void 0:Qi.indexOf("Mobi"))>=0,au=globalThis._VSCODE_NLS_LANGUAGE||Gs,Go=navigator.language.toLowerCase(),fv=Go):console.error("Unable to resolve platform.");var xb=Ff,hn=qf,kw=lu,dv=Sb,fn=Qi,_r=au,Ew;(e=>{function t(){return _r}e.value=t;function n(){return _r.length===2?_r==="en":_r.length>=3?_r[0]==="e"&&_r[1]==="n"&&_r[2]==="-":!1}e.isDefaultVariant=n;function s(){return _r==="en"}e.isDefault=s})(Ew||(Ew={}));var Tw=typeof Jr.postMessage=="function"&&!Jr.importScripts;(()=>{if(Tw){let e=[];Jr.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,a=e.length;s{let s=++t;e.push({id:s,callback:n}),Jr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var Aw=!!(fn&&fn.indexOf("Chrome")>=0);fn&&fn.indexOf("Firefox")>=0;!Aw&&fn&&fn.indexOf("Safari")>=0;fn&&fn.indexOf("Edg/")>=0;fn&&fn.indexOf("Android")>=0;var Ws=typeof navigator=="object"?navigator:{};dv||document.queryCommandSupported&&document.queryCommandSupported("copy")||Ws&&Ws.clipboard&&Ws.clipboard.writeText,dv||Ws&&Ws.clipboard&&Ws.clipboard.readText;var Ad=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Jh=new Ad,pv=new Ad,mv=new Ad,Dw=new Array(230),wb;(e=>{function t(f){return Jh.keyCodeToStr(f)}e.toString=t;function n(f){return Jh.strToKeyCode(f)}e.fromString=n;function s(f){return pv.keyCodeToStr(f)}e.toUserSettingsUS=s;function a(f){return mv.keyCodeToStr(f)}e.toUserSettingsGeneral=a;function o(f){return pv.strToKeyCode(f)||mv.strToKeyCode(f)}e.fromUserSettings=o;function c(f){if(f>=98&&f<=113)return null;switch(f){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Jh.keyCodeToStr(f)}e.toElectronAccelerator=c})(wb||(wb={}));var Rw=class Cb{constructor(t,n,s,a,o){this.ctrlKey=t,this.shiftKey=n,this.altKey=s,this.metaKey=a,this.keyCode=o}equals(t){return t instanceof Cb&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",s=this.altKey?"1":"0",a=this.metaKey?"1":"0";return`K${t}${n}${s}${a}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Mw([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Mw=class{constructor(e){if(e.length===0)throw iw("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t{function t(n){return n===e.None||n===e.Cancelled||n instanceof Uw?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Jt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:kb})})(Pw||(Pw={}));var Uw=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?kb:(this._emitter||(this._emitter=new ce),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Dd=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new zf("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new zf("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Iw=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new zf("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=lt(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Fw;(e=>{async function t(s){let a,o=await Promise.all(s.map(c=>c.then(f=>f,f=>{a||(a=f)})));if(typeof a<"u")throw a;return o}e.settled=t;function n(s){return new Promise(async(a,o)=>{try{await s(a,o)}catch(c){o(c)}})}e.withAsyncBody=n})(Fw||(Fw={}));var yv=class Wi{static fromArray(t){return new Wi(n=>{n.emitMany(t)})}static fromPromise(t){return new Wi(async n=>{n.emitMany(await t)})}static fromPromises(t){return new Wi(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new Wi(async n=>{await Promise.all(t.map(async s=>{for await(let a of s)n.emitOne(a)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new ce,queueMicrotask(async()=>{let s={emitOne:a=>this.emitOne(a),emitMany:a=>this.emitMany(a),reject:a=>this.reject(a)};try{await Promise.resolve(t(s)),this.resolve()}catch(a){this.reject(a)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(t,n){return new Wi(async s=>{for await(let a of t)s.emitOne(n(a))})}map(t){return Wi.map(this,t)}static filter(t,n){return new Wi(async s=>{for await(let a of t)n(a)&&s.emitOne(a)})}filter(t){return Wi.filter(this,t)}static coalesce(t){return Wi.filter(t,n=>!!n)}coalesce(){return Wi.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return Wi.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};yv.EMPTY=yv.fromArray([]);var{getWindow:cn,getWindowId:qw,onDidRegisterWindow:Ww}=(function(){let e=new Map,t={window:Un,disposables:new wr};e.set(Un.vscodeWindowId,t);let n=new ce,s=new ce,a=new ce;function o(c,f){return(typeof c=="number"?e.get(c):void 0)??(f?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:a.event,onDidUnregisterWindow:s.event,registerWindow(c){if(e.has(c.vscodeWindowId))return Be.None;let f=new wr,p={window:c,disposables:f.add(new wr)};return e.set(c.vscodeWindowId,p),f.add(lt(()=>{e.delete(c.vscodeWindowId),s.fire(c)})),f.add(ke(c,Ot.BEFORE_UNLOAD,()=>{a.fire(c)})),n.fire(p),f},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return e.has(c)},getWindowById:o,getWindow(c){var h;let f=c;if((h=f==null?void 0:f.ownerDocument)!=null&&h.defaultView)return f.ownerDocument.defaultView.window;let p=c;return p!=null&&p.view?p.view.window:Un},getDocument(c){return cn(c).document}}})(),Yw=class{constructor(e,t,n,s){this._node=e,this._type=t,this._handler=n,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function ke(e,t,n,s){return new Yw(e,t,n,s)}var bv=function(e,t,n,s){return ke(e,t,n,s)},Rd,Vw=class extends Iw{constructor(e){super(),this.defaultTarget=e&&cn(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Sv=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){su(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,s=new Map,a=o=>{n.set(o,!1);let c=e.get(o)??[];for(t.set(o,c),e.set(o,[]),s.set(o,!0);c.length>0;)c.sort(Sv.sort),c.shift().execute();s.set(o,!1)};Rd=(o,c,f=0)=>{let p=qw(o),h=new Sv(c,f),g=e.get(p);return g||(g=[],e.set(p,g)),g.push(h),n.get(p)||(n.set(p,!0),o.requestAnimationFrame(()=>a(p))),h}})();function Kw(e){let t=e.getBoundingClientRect(),n=cn(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Ot={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Xw=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=yi(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=yi(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=yi(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=yi(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=yi(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=yi(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=yi(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=yi(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=yi(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=yi(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=yi(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=yi(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=yi(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=yi(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function yi(e){return typeof e=="number"?`${e}px`:e}function pa(e){return new Xw(e)}var Eb=class{constructor(){this._hooks=new wr,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,s,a){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=a;let o=e;try{e.setPointerCapture(t),this._hooks.add(lt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=cn(e)}this._hooks.add(ke(o,Ot.POINTER_MOVE,c=>{if(c.buttons!==n){this.stopMonitoring(!0);return}c.preventDefault(),this._pointerMoveCallback(c)})),this._hooks.add(ke(o,Ot.POINTER_UP,c=>this.stopMonitoring(!0)))}};function Gw(e,t,n){let s=null,a=null;if(typeof n.value=="function"?(s="value",a=n.value,a.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",a=n.get),!a)throw new Error("not supported");let o=`$memoize$${t}`;n[s]=function(...c){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:a.apply(this,c)}),this[o]}}var on;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(on||(on={}));var ua=class ti extends Be{constructor(){super(),this.dispatched=!1,this.targets=new hv,this.ignoreTargets=new hv,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Jt.runAndSubscribe(Ww,({window:t,disposables:n})=>{n.add(ke(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(ke(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(ke(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Un,disposables:this._store}))}static addTarget(t){if(!ti.isTouchDevice())return Be.None;ti.INSTANCE||(ti.INSTANCE=new ti);let n=ti.INSTANCE.targets.push(t);return lt(n)}static ignoreTarget(t){if(!ti.isTouchDevice())return Be.None;ti.INSTANCE||(ti.INSTANCE=new ti);let n=ti.INSTANCE.ignoreTargets.push(t);return lt(n)}static isTouchDevice(){return"ontouchstart"in Un||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,a=t.targetTouches.length;s=ti.HOLD_DELAY&&Math.abs(p.initialPageX-Di(p.rollingPageX))<30&&Math.abs(p.initialPageY-Di(p.rollingPageY))<30){let g=this.newGestureEvent(on.Contextmenu,p.initialTarget);g.pageX=Di(p.rollingPageX),g.pageY=Di(p.rollingPageY),this.dispatchEvent(g)}else if(a===1){let g=Di(p.rollingPageX),_=Di(p.rollingPageY),b=Di(p.rollingTimestamps)-p.rollingTimestamps[0],y=g-p.rollingPageX[0],x=_-p.rollingPageY[0],k=[...this.targets].filter(L=>p.initialTarget instanceof Node&&L.contains(p.initialTarget));this.inertia(t,k,s,Math.abs(y)/b,y>0?1:-1,g,Math.abs(x)/b,x>0?1:-1,_)}this.dispatchEvent(this.newGestureEvent(on.End,p.initialTarget)),delete this.activeTouches[f.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(t){if(t.type===on.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>ti.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===on.Change||t.type===on.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let n=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let a=0,o=t.initialTarget;for(;o&&o!==s;)a++,o=o.parentElement;n.push([a,s])}n.sort((s,a)=>s[0]-a[0]);for(let[s,a]of n)a.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,s,a,o,c,f,p,h){this.handle=Rd(t,()=>{let g=Date.now(),_=g-s,b=0,y=0,x=!0;a+=ti.SCROLL_FRICTION*_,f+=ti.SCROLL_FRICTION*_,a>0&&(x=!1,b=o*a*_),f>0&&(x=!1,y=p*f*_);let k=this.newGestureEvent(on.Change);k.translationX=b,k.translationY=y,n.forEach(L=>L.dispatchEvent(k)),x||this.inertia(t,n,g,a,o,c+b,f,p,h+y)})}onTouchMove(t){let n=Date.now();for(let s=0,a=t.changedTouches.length;s3&&(c.rollingPageX.shift(),c.rollingPageY.shift(),c.rollingTimestamps.shift()),c.rollingPageX.push(o.pageX),c.rollingPageY.push(o.pageY),c.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};ua.SCROLL_FRICTION=-.005,ua.HOLD_DELAY=700,ua.CLEAR_TAP_COUNT_TIME=400,pt([Gw],ua,"isTouchDevice",1);var $w=ua,Md=class extends Be{onclick(e,t){this._register(ke(e,Ot.CLICK,n=>t(new $o(cn(e),n))))}onmousedown(e,t){this._register(ke(e,Ot.MOUSE_DOWN,n=>t(new $o(cn(e),n))))}onmouseover(e,t){this._register(ke(e,Ot.MOUSE_OVER,n=>t(new $o(cn(e),n))))}onmouseleave(e,t){this._register(ke(e,Ot.MOUSE_LEAVE,n=>t(new $o(cn(e),n))))}onkeydown(e,t){this._register(ke(e,Ot.KEY_DOWN,n=>t(new _v(n))))}onkeyup(e,t){this._register(ke(e,Ot.KEY_UP,n=>t(new _v(n))))}oninput(e,t){this._register(ke(e,Ot.INPUT,t))}onblur(e,t){this._register(ke(e,Ot.BLUR,t))}onfocus(e,t){this._register(ke(e,Ot.FOCUS,t))}onchange(e,t){this._register(ke(e,Ot.CHANGE,t))}ignoreGesture(e){return $w.ignoreTarget(e)}},xv=11,Zw=class extends Md{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=xv+"px",this.domNode.style.height=xv+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new Eb),this._register(bv(this.bgDomNode,Ot.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(bv(this.domNode,Ot.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Vw),this._pointerdownScheduleRepeatTimer=this._register(new Dd)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,cn(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Qw=class Wf{constructor(t,n,s,a,o,c,f){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,a=a|0,o=o|0,c=c|0,f=f|0),this.rawScrollLeft=a,this.rawScrollTop=f,n<0&&(n=0),a+n>s&&(a=s-n),a<0&&(a=0),o<0&&(o=0),f+o>c&&(f=c-o),f<0&&(f=0),this.width=n,this.scrollWidth=s,this.scrollLeft=a,this.height=o,this.scrollHeight=c,this.scrollTop=f}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new Wf(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Wf(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let s=this.width!==t.width,a=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,c=this.height!==t.height,f=this.scrollHeight!==t.scrollHeight,p=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:a,scrollLeftChanged:o,heightChanged:c,scrollHeightChanged:f,scrollTopChanged:p}}},Jw=class extends Be{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new ce),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Qw(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let s;t?s=new Cv(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=Cv.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},wv=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function ef(e,t){let n=t-e;return function(s){return e+n*iC(s)}}function eC(e,t,n){return function(s){return s2.5*s){let a,o;return t{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},rC=140,Tb=class extends Md{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new nC(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Eb),this._shouldRender=!0,this.domNode=pa(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(ke(this.domNode.domNode,Ot.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Zw(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=pa(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(ke(this.slider.domNode,Ot.POINTER_DOWN,a=>{a.button===0&&(a.preventDefault(),this._sliderPointerDown(a))})),this.onclick(this.slider.domNode,a=>{a.leftButton&&a.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),a=this._sliderPointerPosition(e);n<=a&&a<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let a=Kw(this.domNode.domNode);t=e.pageX-a.left,n=e.pageY-a.top}let s=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,a=>{let o=this._sliderOrthogonalPointerPosition(a),c=Math.abs(o-n);if(xb&&c>rC){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let f=this._sliderPointerPosition(a)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(f))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Ab=class Vf{constructor(t,n,s,a,o,c){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=a,this._scrollSize=o,this._scrollPosition=c,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Vf(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,s,a,o){let c=Math.max(0,s-t),f=Math.max(0,c-2*n),p=a>0&&a>s;if(!p)return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(f),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(s*f/a))),g=(f-h)/(a-s),_=o*g;return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(h),computedSliderRatio:g,computedSliderPosition:Math.round(_)}}_refreshComputedValues(){let t=Vf._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,s=this._scrollPosition;return n0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),n){let a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),c=Math.abs(n.deltaX),f=Math.abs(n.deltaY),p=Math.max(Math.min(a,c),1),h=Math.max(Math.min(o,f),1),g=Math.max(a,c),_=Math.max(o,f);g%p===0&&_%h===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Kf.INSTANCE=new Kf;var uC=Kf,cC=class extends Md{constructor(e,t,n){super(),this._onScroll=this._register(new ce),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new ce),this.onWillScroll=this._onWillScroll.event,this._options=fC(t),this._scrollable=n,this._register(this._scrollable.onScroll(a=>{this._onWillScroll.fire(a),this._onDidScroll(a),this._onScroll.fire(a)}));let s={onMouseWheel:a=>this._onMouseWheel(a),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new lC(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new sC(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=pa(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=pa(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=pa(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,a=>this._onMouseOver(a)),this.onmouseleave(this._listenOnDomNode,a=>this._onMouseLeave(a)),this._hideTimeout=this._register(new Dd),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=es(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,hn&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new vv(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=es(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new vv(n))};this._mouseWheelToDispose.push(ke(this._listenOnDomNode,Ot.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var a;if((a=e.browserEvent)!=null&&a.defaultPrevented)return;let t=uC.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+o===0?c=o=0:Math.abs(o)>=Math.abs(c)?c=0:o=0),this._options.flipAxes&&([o,c]=[c,o]);let f=!hn&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||f)&&!c&&(c=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),h={};if(o){let g=kv*o,_=p.scrollTop-(g<0?Math.floor(g):Math.ceil(g));this._verticalScrollbar.writeScrollPosition(h,_)}if(c){let g=kv*c,_=p.scrollLeft-(g<0?Math.floor(g):Math.ceil(g));this._horizontalScrollbar.writeScrollPosition(h,_)}h=this._scrollable.validateScrollPosition(h),(p.scrollLeft!==h.scrollLeft||p.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),n=!0)}let s=n;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,s=n?" left":"",a=t?" top":"",o=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${a}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${a}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),aC)}},hC=class extends cC{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function fC(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,hn&&(t.className+=" mac"),t}var Xf=class extends Be{constructor(e,t,n,s,a,o,c,f){super(),this._bufferService=n,this._optionsService=c,this._renderService=f,this._onRequestScrollLines=this._register(new ce),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new Jw({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Rd(s.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new hC(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},p)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(a.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Jt.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(lt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(lt(()=>this._styleElement.remove())),this._register(Jt.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(` -`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(h=>this._handleScroll(h)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};Xf=pt([pe(2,ui),pe(3,In),pe(4,ob),pe(5,Js),pe(6,ci),pe(7,Fn)],Xf);var Gf=class extends Be{constructor(e,t,n,s,a){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=s,this._renderService=a,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(lt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Gf=pt([pe(1,ui),pe(2,In),pe(3,ka),pe(4,Fn)],Gf);var dC=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},ln={full:0,left:0,center:0,right:0},gr={full:0,left:0,center:0,right:0},$l={full:0,left:0,center:0,right:0},pu=class extends Be{constructor(e,t,n,s,a,o,c,f){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=a,this._optionsService=o,this._themeService=c,this._coreBrowserService=f,this._colorZoneStore=new dC,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(h=this._viewportElement.parentElement)==null||h.insertBefore(this._canvas,this._viewportElement),this._register(lt(()=>{var g;return(g=this._canvas)==null?void 0:g.remove()}));let p=this._canvas.getContext("2d");if(p)this._ctx=p;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);gr.full=this._canvas.width,gr.left=e,gr.center=t,gr.right=e,this._refreshDrawHeightConstants(),$l.full=1,$l.left=1,$l.center=1+gr.left,$l.right=1+gr.left+gr.center}_refreshDrawHeightConstants(){ln.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);ln.left=t,ln.center=t,ln.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect($l[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ln[e.position||"full"]/2),gr[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ln[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};pu=pt([pe(2,ui),pe(3,ka),pe(4,Fn),pe(5,ci),pe(6,Js),pe(7,In)],pu);var se;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=` -`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(se||(se={}));var ou;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(ou||(ou={}));var Db;(e=>e.ST=`${se.ESC}\\`)(Db||(Db={}));var $f=class{constructor(e,t,n,s,a,o){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=s,this._coreService=a,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.lengththis.updateCompositionElements(!0),0)}}};$f=pt([pe(2,ui),pe(3,ci),pe(4,ns),pe(5,Fn)],$f);var jt=0,Ht=0,Pt=0,ft=0,Ev={css:"#00000000",rgba:0},kt;(e=>{function t(a,o,c,f){return f!==void 0?`#${Vr(a)}${Vr(o)}${Vr(c)}${Vr(f)}`:`#${Vr(a)}${Vr(o)}${Vr(c)}`}e.toCss=t;function n(a,o,c,f=255){return(a<<24|o<<16|c<<8|f)>>>0}e.toRgba=n;function s(a,o,c,f){return{css:e.toCss(a,o,c,f),rgba:e.toRgba(a,o,c,f)}}e.toColor=s})(kt||(kt={}));var nt;(e=>{function t(p,h){if(ft=(h.rgba&255)/255,ft===1)return{css:h.css,rgba:h.rgba};let g=h.rgba>>24&255,_=h.rgba>>16&255,b=h.rgba>>8&255,y=p.rgba>>24&255,x=p.rgba>>16&255,k=p.rgba>>8&255;jt=y+Math.round((g-y)*ft),Ht=x+Math.round((_-x)*ft),Pt=k+Math.round((b-k)*ft);let L=kt.toCss(jt,Ht,Pt),M=kt.toRgba(jt,Ht,Pt);return{css:L,rgba:M}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,h,g){let _=uu.ensureContrastRatio(p.rgba,h.rgba,g);if(_)return kt.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function a(p){let h=(p.rgba|255)>>>0;return[jt,Ht,Pt]=uu.toChannels(h),{css:kt.toCss(jt,Ht,Pt),rgba:h}}e.opaque=a;function o(p,h){return ft=Math.round(h*255),[jt,Ht,Pt]=uu.toChannels(p.rgba),{css:kt.toCss(jt,Ht,Pt,ft),rgba:kt.toRgba(jt,Ht,Pt,ft)}}e.opacity=o;function c(p,h){return ft=p.rgba&255,o(p,ft*h/255)}e.multiplyOpacity=c;function f(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=f})(nt||(nt={}));var ot;(e=>{let t,n;try{let a=document.createElement("canvas");a.width=1,a.height=1;let o=a.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return jt=parseInt(a.slice(1,2).repeat(2),16),Ht=parseInt(a.slice(2,3).repeat(2),16),Pt=parseInt(a.slice(3,4).repeat(2),16),kt.toColor(jt,Ht,Pt);case 5:return jt=parseInt(a.slice(1,2).repeat(2),16),Ht=parseInt(a.slice(2,3).repeat(2),16),Pt=parseInt(a.slice(3,4).repeat(2),16),ft=parseInt(a.slice(4,5).repeat(2),16),kt.toColor(jt,Ht,Pt,ft);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let o=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return jt=parseInt(o[1]),Ht=parseInt(o[2]),Pt=parseInt(o[3]),ft=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),kt.toColor(jt,Ht,Pt,ft);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[jt,Ht,Pt,ft]=t.getImageData(0,0,1,1).data,ft!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:kt.toRgba(jt,Ht,Pt,ft),css:a}}e.toColor=s})(ot||(ot={}));var li;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,a,o){let c=s/255,f=a/255,p=o/255,h=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),_=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return h*.2126+g*.7152+_*.0722}e.relativeLuminance2=n})(li||(li={}));var uu;(e=>{function t(c,f){if(ft=(f&255)/255,ft===1)return f;let p=f>>24&255,h=f>>16&255,g=f>>8&255,_=c>>24&255,b=c>>16&255,y=c>>8&255;return jt=_+Math.round((p-_)*ft),Ht=b+Math.round((h-b)*ft),Pt=y+Math.round((g-y)*ft),kt.toRgba(jt,Ht,Pt)}e.blend=t;function n(c,f,p){let h=li.relativeLuminance(c>>8),g=li.relativeLuminance(f>>8);if(jn(h,g)>8));if(x>8));return x>L?y:k}return y}let _=a(c,f,p),b=jn(h,li.relativeLuminance(_>>8));if(b>8));return b>x?_:y}return _}}e.ensureContrastRatio=n;function s(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=jn(li.relativeLuminance2(b,y,x),li.relativeLuminance2(h,g,_));for(;k0||y>0||x>0);)b-=Math.max(0,Math.ceil(b*.1)),y-=Math.max(0,Math.ceil(y*.1)),x-=Math.max(0,Math.ceil(x*.1)),k=jn(li.relativeLuminance2(b,y,x),li.relativeLuminance2(h,g,_));return(b<<24|y<<16|x<<8|255)>>>0}e.reduceLuminance=s;function a(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=jn(li.relativeLuminance2(b,y,x),li.relativeLuminance2(h,g,_));for(;k>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(uu||(uu={}));function Vr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function jn(e,t){return e1){let g=this._getJoinedRanges(s,c,o,t,a);for(let _=0;_1){let h=this._getJoinedRanges(s,c,o,t,a);for(let g=0;g=U,j=B,H=this._workCell;if(b.length>0&&B===b[0][0]&&T){let we=b.shift(),Et=this._isCellInSelection(we[0],t);for(Z=we[0]+1;Z=we[1]),T?(R=!0,H=new pC(this._workCell,e.translateToString(!0,we[0],we[1]),we[1]-we[0]),j=we[1]-1,A=H.getWidth()):U=we[1]}let oe=this._isCellInSelection(B,t),E=n&&B===o,D=V&&B>=h&&B<=g,K=!1;this._decorationService.forEachDecorationAtCell(B,t,void 0,we=>{K=!0});let C=H.getChars()||xr;if(C===" "&&(H.isUnderline()||H.isOverline())&&(C=" "),me=A*f-p.get(C,H.isBold(),H.isItalic()),!k)k=this._document.createElement("span");else if(L&&(oe&&ue||!oe&&!ue&&H.bg===I)&&(oe&&ue&&y.selectionForeground||H.fg===Q)&&H.extended.ext===W&&D===O&&me===ie&&!E&&!R&&!K&&T){H.isInvisible()?M+=xr:M+=C,L++;continue}else L&&(k.textContent=M),k=this._document.createElement("span"),L=0,M="";if(I=H.bg,Q=H.fg,W=H.extended.ext,O=D,ie=me,ue=oe,R&&o>=B&&o<=j&&(o=B),!this._coreService.isCursorHidden&&E&&this._coreService.isCursorInitialized){if(le.push("xterm-cursor"),this._coreBrowserService.isFocused)c&&le.push("xterm-cursor-blink"),le.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":le.push("xterm-cursor-outline");break;case"block":le.push("xterm-cursor-block");break;case"bar":le.push("xterm-cursor-bar");break;case"underline":le.push("xterm-cursor-underline");break}}if(H.isBold()&&le.push("xterm-bold"),H.isItalic()&&le.push("xterm-italic"),H.isDim()&&le.push("xterm-dim"),H.isInvisible()?M=xr:M=H.getChars()||xr,H.isUnderline()&&(le.push(`xterm-underline-${H.extended.underlineStyle}`),M===" "&&(M=" "),!H.isUnderlineColorDefault()))if(H.isUnderlineColorRGB())k.style.textDecorationColor=`rgb(${Ca.toColorRGB(H.getUnderlineColor()).join(",")})`;else{let we=H.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&H.isBold()&&we<8&&(we+=8),k.style.textDecorationColor=y.ansi[we].css}H.isOverline()&&(le.push("xterm-overline"),M===" "&&(M=" ")),H.isStrikethrough()&&le.push("xterm-strikethrough"),D&&(k.style.textDecoration="underline");let J=H.getFgColor(),fe=H.getFgColorMode(),de=H.getBgColor(),xe=H.getBgColorMode(),Ne=!!H.isInverse();if(Ne){let we=J;J=de,de=we;let Et=fe;fe=xe,xe=Et}let Ce,rt,et=!1;this._decorationService.forEachDecorationAtCell(B,t,void 0,we=>{we.options.layer!=="top"&&et||(we.backgroundColorRGB&&(xe=50331648,de=we.backgroundColorRGB.rgba>>8&16777215,Ce=we.backgroundColorRGB),we.foregroundColorRGB&&(fe=50331648,J=we.foregroundColorRGB.rgba>>8&16777215,rt=we.foregroundColorRGB),et=we.options.layer==="top")}),!et&&oe&&(Ce=this._coreBrowserService.isFocused?y.selectionBackgroundOpaque:y.selectionInactiveBackgroundOpaque,de=Ce.rgba>>8&16777215,xe=50331648,et=!0,y.selectionForeground&&(fe=50331648,J=y.selectionForeground.rgba>>8&16777215,rt=y.selectionForeground)),et&&le.push("xterm-decoration-top");let ut;switch(xe){case 16777216:case 33554432:ut=y.ansi[de],le.push(`xterm-bg-${de}`);break;case 50331648:ut=kt.toColor(de>>16,de>>8&255,de&255),this._addStyle(k,`background-color:#${Tv((de>>>0).toString(16),"0",6)}`);break;case 0:default:Ne?(ut=y.foreground,le.push("xterm-bg-257")):ut=y.background}switch(Ce||H.isDim()&&(Ce=nt.multiplyOpacity(ut,.5)),fe){case 16777216:case 33554432:H.isBold()&&J<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(J+=8),this._applyMinimumContrast(k,ut,y.ansi[J],H,Ce,void 0)||le.push(`xterm-fg-${J}`);break;case 50331648:let we=kt.toColor(J>>16&255,J>>8&255,J&255);this._applyMinimumContrast(k,ut,we,H,Ce,rt)||this._addStyle(k,`color:#${Tv(J.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(k,ut,y.foreground,H,Ce,rt)||Ne&&le.push("xterm-fg-257")}le.length&&(k.className=le.join(" "),le.length=0),!E&&!R&&!K&&T?L++:k.textContent=M,me!==this.defaultSpacing&&(k.style.letterSpacing=`${me}px`),_.push(k),B=j}return k&&L&&(k.textContent=M),_}_applyMinimumContrast(e,t,n,s,a,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||gC(s.getCode()))return!1;let c=this._getContrastCache(s),f;if(!a&&!o&&(f=c.getColor(t.rgba,n.rgba)),f===void 0){let p=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);f=nt.ensureContrastRatio(a||t,o||n,p),c.setColor((a||t).rgba,(o||n).rgba,f??null)}return f?(this._addStyle(e,`color:${f.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t=n[0]&&e=n[0]}};Zf=pt([pe(1,hb),pe(2,ci),pe(3,In),pe(4,ns),pe(5,ka),pe(6,Js)],Zf);function Tv(e,t,n){for(;e.length0&&(this._flat[s]=c),c}let a=e;t&&(a+="B"),n&&(a+="I");let o=this._holey.get(a);if(o===void 0){let c=0;t&&(c|=1),n&&(c|=2),o=this._measure(e,c),o>0&&this._holey.set(a,o)}return o}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},bC=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let a=e.buffers.active.ydisp,o=t[1]-a,c=n[1]-a,f=Math.max(o,0),p=Math.min(c,e.rows-1);if(f>=e.rows||p<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=o,this.viewportEndRow=c,this.viewportCappedStartRow=f,this.viewportCappedEndRow=p,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n=this.startCol&&t=this.startCol):!1}};function SC(){return new bC}var tf="xterm-dom-renderer-owner-",qi="xterm-rows",Qo="xterm-fg-",Av="xterm-bg-",Zl="xterm-focus",Jo="xterm-selection",xC=1,Qf=class extends Be{constructor(e,t,n,s,a,o,c,f,p,h,g,_,b,y){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=a,this._helperContainer=o,this._linkifier2=c,this._charSizeService=p,this._optionsService=h,this._bufferService=g,this._coreService=_,this._coreBrowserService=b,this._themeService=y,this._terminalClass=xC++,this._rowElements=[],this._selectionRenderModel=SC(),this.onRequestRedraw=this._register(new ce).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(qi),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Jo),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=vC(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(x=>this._injectCss(x))),this._injectCss(this._themeService.colors),this._rowFactory=f.createInstance(Zf,document),this._element.classList.add(tf+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(x=>this._handleLinkHover(x))),this._register(this._linkifier2.onHideLinkUnderline(x=>this._handleLinkLeave(x))),this._register(lt(()=>{this._element.classList.remove(tf+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new yC(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${qi} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${qi} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${qi} .xterm-dim { color: ${nt.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,a=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${a} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${qi}.${Zl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${qi}.${Zl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${qi}.${Zl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${qi} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${qi} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${qi} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${qi} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${qi} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Jo} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Jo} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Jo} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,c]of e.ansi.entries())t+=`${this._terminalSelector} .${Qo}${o} { color: ${c.css}; }${this._terminalSelector} .${Qo}${o}.xterm-dim { color: ${nt.multiplyOpacity(c,.5).css}; }${this._terminalSelector} .${Av}${o} { background-color: ${c.css}; }`;t+=`${this._terminalSelector} .${Qo}257 { color: ${nt.opaque(e.background).css}; }${this._terminalSelector} .${Qo}257.xterm-dim { color: ${nt.multiplyOpacity(nt.opaque(e.background),.5).css}; }${this._terminalSelector} .${Av}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Zl),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Zl),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,a=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,c=this._selectionRenderModel.viewportCappedEndRow,f=this._document.createDocumentFragment();if(n){let p=e[0]>t[0];f.appendChild(this._createSelectionElement(o,p?t[0]:e[0],p?e[0]:t[0],c-o+1))}else{let p=s===o?e[0]:0,h=o===a?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(o,p,h));let g=c-o-1;if(f.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,g)),o!==c){let _=a===c?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(c,0,_))}}this._selectionContainer.appendChild(f)}_createSelectionElement(e,t,n,s=1){let a=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,c=this.dimensions.css.cell.width*(n-t);return o+c>this.dimensions.css.canvas.width&&(c=this.dimensions.css.canvas.width-o),a.style.height=`${s*this.dimensions.css.cell.height}px`,a.style.top=`${e*this.dimensions.css.cell.height}px`,a.style.left=`${o}px`,a.style.width=`${c}px`,a}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,s=n.ybase+n.y,a=Math.min(n.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,c=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=e;p<=t;p++){let h=p+n.ydisp,g=this._rowElements[p],_=n.lines.get(h);if(!g||!_)break;g.replaceChildren(...this._rowFactory.createRow(_,h,h===s,c,f,a,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${tf}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,s,a,o){n<0&&(e=0),s<0&&(t=0);let c=this._bufferService.rows-1;n=Math.max(Math.min(n,c),0),s=Math.max(Math.min(s,c),0),a=Math.min(a,this._bufferService.cols);let f=this._bufferService.buffer,p=f.ybase+f.y,h=Math.min(f.x,a-1),g=this._optionsService.rawOptions.cursorBlink,_=this._optionsService.rawOptions.cursorStyle,b=this._optionsService.rawOptions.cursorInactiveStyle;for(let y=n;y<=s;++y){let x=y+f.ydisp,k=this._rowElements[y],L=f.lines.get(x);if(!k||!L)break;k.replaceChildren(...this._rowFactory.createRow(L,x,x===p,_,b,h,g,this.dimensions.css.cell.width,this._widthCache,o?y===n?e:0:-1,o?(y===s?t:a)-1:-1))}}};Qf=pt([pe(7,Cd),pe(8,Cu),pe(9,ci),pe(10,ui),pe(11,ns),pe(12,In),pe(13,Js)],Qf);var Jf=class extends Be{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new ce),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new CC(this._optionsService))}catch{this._measureStrategy=this._register(new wC(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Jf=pt([pe(2,ci)],Jf);var Rb=class extends Be{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},wC=class extends Rb{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},CC=class extends Rb{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},kC=class extends Be{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new EC(this._window)),this._onDprChange=this._register(new ce),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ce),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Jt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(ke(this._textarea,"focus",()=>this._isFocused=!0)),this._register(ke(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},EC=class extends Be{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Zs),this._onDprChange=this._register(new ce),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(lt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=ke(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},TC=class extends Be{constructor(){super(),this.linkProviders=[],this._register(lt(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Bd(e,t,n){let s=n.getBoundingClientRect(),a=e.getComputedStyle(n),o=parseInt(a.getPropertyValue("padding-left")),c=parseInt(a.getPropertyValue("padding-top"));return[t.clientX-s.left-o,t.clientY-s.top-c]}function AC(e,t,n,s,a,o,c,f,p){if(!o)return;let h=Bd(e,t,n);if(h)return h[0]=Math.ceil((h[0]+(p?c/2:0))/c),h[1]=Math.ceil(h[1]/f),h[0]=Math.min(Math.max(h[0],1),s+(p?1:0)),h[1]=Math.min(Math.max(h[1],1),a),h}var ed=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,a){return AC(window,e,t,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,a)}getMouseReportCoords(e,t){let n=Bd(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};ed=pt([pe(0,Fn),pe(1,Cu)],ed);var DC=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Mb={};Px(Mb,{getSafariVersion:()=>MC,isChromeOS:()=>zb,isFirefox:()=>Bb,isIpad:()=>BC,isIphone:()=>NC,isLegacyEdge:()=>RC,isLinux:()=>Nd,isMac:()=>_u,isNode:()=>ku,isSafari:()=>Nb,isWindows:()=>Lb});var ku=typeof process<"u"&&"title"in process,Ea=ku?"node":navigator.userAgent,Ta=ku?"node":navigator.platform,Bb=Ea.includes("Firefox"),RC=Ea.includes("Edge"),Nb=/^((?!chrome|android).)*safari/i.test(Ea);function MC(){if(!Nb)return 0;let e=Ea.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var _u=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Ta),BC=Ta==="iPad",NC=Ta==="iPhone",Lb=["Windows","Win16","Win32","WinCE"].includes(Ta),Nd=Ta.indexOf("Linux")>=0,zb=/\bCrOS\b/.test(Ea),Ob=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._ia){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=a}this.clear()}},LC=class extends Ob{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},zC=class extends Ob{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},gu=!ku&&"requestIdleCallback"in window?zC:LC,OC=class{constructor(){this._queue=new gu}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},td=class extends Be{constructor(e,t,n,s,a,o,c,f,p){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=a,this._coreBrowserService=f,this._renderer=this._register(new Zs),this._pausedResizeTask=new OC,this._observerDisposable=this._register(new Zs),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new ce),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new ce),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new ce),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new ce),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new DC((h,g)=>this._renderRows(h,g),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new jC(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(lt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(c.onResize(()=>this._fullRefresh())),this._register(c.buffers.onBufferActivate(()=>{var h;return(h=this._renderer.value)==null?void 0:h.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(c.cols,c.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(c.buffer.y,c.buffer.y,!0))),this._register(p.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(h=>this._registerIntersectionObserver(h,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=lt(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var n;return(n=this._renderer.value)==null?void 0:n.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,n){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};td=pt([pe(2,ci),pe(3,Cu),pe(4,ns),pe(5,ka),pe(6,ui),pe(7,In),pe(8,Js)],td);var jC=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function HC(e,t,n,s){let a=n.buffer.x,o=n.buffer.y;if(!n.buffer.hasScrollback)return IC(a,o,e,t,n,s)+Eu(o,t,n,s)+FC(a,o,e,t,n,s);let c;if(o===t)return c=a>e?"D":"C",ya(Math.abs(a-e),va(c,s));c=o>t?"D":"C";let f=Math.abs(o-t),p=UC(o>t?e:a,n)+(f-1)*n.cols+1+PC(o>t?a:e);return ya(p,va(c,s))}function PC(e,t){return e-1}function UC(e,t){return t.cols-e}function IC(e,t,n,s,a,o){return Eu(t,s,a,o).length===0?"":ya(Hb(e,t,e,t-ts(t,a),!1,a).length,va("D",o))}function Eu(e,t,n,s){let a=e-ts(e,n),o=t-ts(t,n),c=Math.abs(a-o)-qC(e,t,n);return ya(c,va(jb(e,t),s))}function FC(e,t,n,s,a,o){let c;Eu(t,s,a,o).length>0?c=s-ts(s,a):c=t;let f=s,p=WC(e,t,n,s,a,o);return ya(Hb(e,c,n,f,p==="C",a).length,va(p,o))}function qC(e,t,n){var c;let s=0,a=e-ts(e,n),o=t-ts(t,n);for(let f=0;f=0&&e0?c=s-ts(s,a):c=t,e=n&&ct?"A":"B"}function Hb(e,t,n,s,a,o){let c=e,f=t,p="";for(;(c!==n||f!==s)&&f>=0&&fo.cols-1?(p+=o.buffer.translateBufferLineToString(f,!1,e,c),c=0,e=0,f++):!a&&c<0&&(p+=o.buffer.translateBufferLineToString(f,!1,0,e+1),c=o.cols-1,e=c,f--);return p+o.buffer.translateBufferLineToString(f,!1,e,c)}function va(e,t){let n=t?"O":"[";return se.ESC+n+e}function ya(e,t){e=Math.floor(e);let n="";for(let s=0;sthis._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Dv(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var nf=50,VC=15,KC=50,XC=500,GC=" ",$C=new RegExp(GC,"g"),id=class extends Be{constructor(e,t,n,s,a,o,c,f,p){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=a,this._mouseService=o,this._optionsService=c,this._renderService=f,this._coreBrowserService=p,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Ki,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new ce),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new ce),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new ce),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new ce),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=h=>this._handleMouseMove(h),this._mouseUpListener=h=>this._handleMouseUp(h),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(h=>this._handleTrim(h)),this._register(this._bufferService.buffers.onBufferActivate(h=>this._handleBufferActivate(h))),this.enable(),this._model=new YC(this._bufferService),this._activeSelectionMode=0,this._register(lt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(h=>{h.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let a=e[0]a.replace($C," ")).join(Lb?`\r +`))}},fw=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},dw=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},pw=0,Zh=class{constructor(e){this.value=e,this.id=pw++}},mw=2,_w,he=class{constructor(t){var n,s,a,o;this._size=0,this._options=t,this._leakageMon=(n=this._options)!=null&&n.leakWarningThreshold?new cw((t==null?void 0:t.onListenerError)??su,((s=this._options)==null?void 0:s.leakWarningThreshold)??uw):void 0,this._perfMon=(a=this._options)!=null&&a._profName?new ow(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var t,n,s,a;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(s=(n=this._options)==null?void 0:n.onDidRemoveLastListener)==null||s.call(n),(a=this._leakageMon)==null||a.dispose())}get event(){return this._event??(this._event=(t,n,s)=>{var f,p,h,g,_;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let b=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(b);let y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],x=new dw(`${b}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((f=this._options)==null?void 0:f.onListenerError)||su)(x),Be.None}if(this._disposed)return Be.None;n&&(t=t.bind(n));let a=new Zh(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(a.stack=hw.create(),o=this._leakageMon.check(a.stack,this._size+1)),this._listeners?this._listeners instanceof Zh?(this._deliveryQueue??(this._deliveryQueue=new gw),this._listeners=[this._listeners,a]):this._listeners.push(a):((h=(p=this._options)==null?void 0:p.onWillAddFirstListener)==null||h.call(p,this),this._listeners=a,(_=(g=this._options)==null?void 0:g.onDidAddFirstListener)==null||_.call(g,this)),this._size++;let c=at(()=>{o==null||o(),this._removeListener(a)});return s instanceof wr?s.add(c):Array.isArray(s)&&s.push(c),c}),this._event}_removeListener(t){var o,c,f,p;if((c=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||c.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(p=(f=this._options)==null?void 0:f.onDidRemoveLastListener)==null||p.call(f,this),this._size=0;return}let n=this._listeners,s=n.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,n[s]=void 0;let a=this._deliveryQueue.current===this;if(this._size*mw<=n.length){let h=0;for(let g=0;g0}},gw=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Uf=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new he,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new he,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Uf.INSTANCE=new Uf;var Ed=Uf;function vw(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Ed.INSTANCE.onDidChangeZoomLevel;function yw(e){return Ed.INSTANCE.getZoomFactor(e)}Ed.INSTANCE.onDidChangeFullscreen;var il=typeof navigator=="object"?navigator.userAgent:"",If=il.indexOf("Firefox")>=0,bw=il.indexOf("AppleWebKit")>=0,Td=il.indexOf("Chrome")>=0,Sw=!Td&&il.indexOf("Safari")>=0;il.indexOf("Electron/")>=0;il.indexOf("Android")>=0;var Qh=!1;if(typeof Un.matchMedia=="function"){let e=Un.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Un.matchMedia("(display-mode: fullscreen)");Qh=e.matches,vw(Un,e,({matches:n})=>{Qh&&t.matches||(Qh=n)})}var Zs="en",Ff=!1,qf=!1,lu=!1,Sb=!1,$o,au=Zs,fv=Zs,xw,Qi,Jr=globalThis,Qt,Zy;typeof Jr.vscode<"u"&&typeof Jr.vscode.process<"u"?Qt=Jr.vscode.process:typeof process<"u"&&typeof((Zy=process==null?void 0:process.versions)==null?void 0:Zy.node)=="string"&&(Qt=process);var Qy,ww=typeof((Qy=Qt==null?void 0:Qt.versions)==null?void 0:Qy.electron)=="string",Cw=ww&&(Qt==null?void 0:Qt.type)==="renderer",Jy;if(typeof Qt=="object"){Ff=Qt.platform==="win32",qf=Qt.platform==="darwin",lu=Qt.platform==="linux",lu&&Qt.env.SNAP&&Qt.env.SNAP_REVISION,Qt.env.CI||Qt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,$o=Zs,au=Zs;let e=Qt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);$o=t.userLocale,fv=t.osLocale,au=t.resolvedLanguage||Zs,xw=(Jy=t.languagePack)==null?void 0:Jy.translationsConfigFile}catch{}Sb=!0}else typeof navigator=="object"&&!Cw?(Qi=navigator.userAgent,Ff=Qi.indexOf("Windows")>=0,qf=Qi.indexOf("Macintosh")>=0,(Qi.indexOf("Macintosh")>=0||Qi.indexOf("iPad")>=0||Qi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,lu=Qi.indexOf("Linux")>=0,(Qi==null?void 0:Qi.indexOf("Mobi"))>=0,au=globalThis._VSCODE_NLS_LANGUAGE||Zs,$o=navigator.language.toLowerCase(),fv=$o):console.error("Unable to resolve platform.");var xb=Ff,hn=qf,kw=lu,dv=Sb,fn=Qi,_r=au,Ew;(e=>{function t(){return _r}e.value=t;function n(){return _r.length===2?_r==="en":_r.length>=3?_r[0]==="e"&&_r[1]==="n"&&_r[2]==="-":!1}e.isDefaultVariant=n;function s(){return _r==="en"}e.isDefault=s})(Ew||(Ew={}));var Tw=typeof Jr.postMessage=="function"&&!Jr.importScripts;(()=>{if(Tw){let e=[];Jr.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,a=e.length;s{let s=++t;e.push({id:s,callback:n}),Jr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var Aw=!!(fn&&fn.indexOf("Chrome")>=0);fn&&fn.indexOf("Firefox")>=0;!Aw&&fn&&fn.indexOf("Safari")>=0;fn&&fn.indexOf("Edg/")>=0;fn&&fn.indexOf("Android")>=0;var Ws=typeof navigator=="object"?navigator:{};dv||document.queryCommandSupported&&document.queryCommandSupported("copy")||Ws&&Ws.clipboard&&Ws.clipboard.writeText,dv||Ws&&Ws.clipboard&&Ws.clipboard.readText;var Ad=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Jh=new Ad,pv=new Ad,mv=new Ad,Dw=new Array(230),wb;(e=>{function t(f){return Jh.keyCodeToStr(f)}e.toString=t;function n(f){return Jh.strToKeyCode(f)}e.fromString=n;function s(f){return pv.keyCodeToStr(f)}e.toUserSettingsUS=s;function a(f){return mv.keyCodeToStr(f)}e.toUserSettingsGeneral=a;function o(f){return pv.strToKeyCode(f)||mv.strToKeyCode(f)}e.fromUserSettings=o;function c(f){if(f>=98&&f<=113)return null;switch(f){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Jh.keyCodeToStr(f)}e.toElectronAccelerator=c})(wb||(wb={}));var Rw=class Cb{constructor(t,n,s,a,o){this.ctrlKey=t,this.shiftKey=n,this.altKey=s,this.metaKey=a,this.keyCode=o}equals(t){return t instanceof Cb&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",s=this.altKey?"1":"0",a=this.metaKey?"1":"0";return`K${t}${n}${s}${a}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Mw([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Mw=class{constructor(e){if(e.length===0)throw iw("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t{function t(n){return n===e.None||n===e.Cancelled||n instanceof Uw?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Jt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:kb})})(Pw||(Pw={}));var Uw=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?kb:(this._emitter||(this._emitter=new he),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Dd=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new zf("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new zf("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Iw=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new zf("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=at(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Fw;(e=>{async function t(s){let a,o=await Promise.all(s.map(c=>c.then(f=>f,f=>{a||(a=f)})));if(typeof a<"u")throw a;return o}e.settled=t;function n(s){return new Promise(async(a,o)=>{try{await s(a,o)}catch(c){o(c)}})}e.withAsyncBody=n})(Fw||(Fw={}));var yv=class Wi{static fromArray(t){return new Wi(n=>{n.emitMany(t)})}static fromPromise(t){return new Wi(async n=>{n.emitMany(await t)})}static fromPromises(t){return new Wi(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new Wi(async n=>{await Promise.all(t.map(async s=>{for await(let a of s)n.emitOne(a)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new he,queueMicrotask(async()=>{let s={emitOne:a=>this.emitOne(a),emitMany:a=>this.emitMany(a),reject:a=>this.reject(a)};try{await Promise.resolve(t(s)),this.resolve()}catch(a){this.reject(a)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(t,n){return new Wi(async s=>{for await(let a of t)s.emitOne(n(a))})}map(t){return Wi.map(this,t)}static filter(t,n){return new Wi(async s=>{for await(let a of t)n(a)&&s.emitOne(a)})}filter(t){return Wi.filter(this,t)}static coalesce(t){return Wi.filter(t,n=>!!n)}coalesce(){return Wi.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return Wi.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};yv.EMPTY=yv.fromArray([]);var{getWindow:cn,getWindowId:qw,onDidRegisterWindow:Ww}=(function(){let e=new Map,t={window:Un,disposables:new wr};e.set(Un.vscodeWindowId,t);let n=new he,s=new he,a=new he;function o(c,f){return(typeof c=="number"?e.get(c):void 0)??(f?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:a.event,onDidUnregisterWindow:s.event,registerWindow(c){if(e.has(c.vscodeWindowId))return Be.None;let f=new wr,p={window:c,disposables:f.add(new wr)};return e.set(c.vscodeWindowId,p),f.add(at(()=>{e.delete(c.vscodeWindowId),s.fire(c)})),f.add(Ee(c,Ot.BEFORE_UNLOAD,()=>{a.fire(c)})),n.fire(p),f},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return e.has(c)},getWindowById:o,getWindow(c){var h;let f=c;if((h=f==null?void 0:f.ownerDocument)!=null&&h.defaultView)return f.ownerDocument.defaultView.window;let p=c;return p!=null&&p.view?p.view.window:Un},getDocument(c){return cn(c).document}}})(),Yw=class{constructor(e,t,n,s){this._node=e,this._type=t,this._handler=n,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Ee(e,t,n,s){return new Yw(e,t,n,s)}var bv=function(e,t,n,s){return Ee(e,t,n,s)},Rd,Vw=class extends Iw{constructor(e){super(),this.defaultTarget=e&&cn(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Sv=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){su(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,s=new Map,a=o=>{n.set(o,!1);let c=e.get(o)??[];for(t.set(o,c),e.set(o,[]),s.set(o,!0);c.length>0;)c.sort(Sv.sort),c.shift().execute();s.set(o,!1)};Rd=(o,c,f=0)=>{let p=qw(o),h=new Sv(c,f),g=e.get(p);return g||(g=[],e.set(p,g)),g.push(h),n.get(p)||(n.set(p,!0),o.requestAnimationFrame(()=>a(p))),h}})();function Kw(e){let t=e.getBoundingClientRect(),n=cn(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Ot={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Xw=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=yi(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=yi(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=yi(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=yi(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=yi(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=yi(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=yi(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=yi(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=yi(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=yi(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=yi(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=yi(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=yi(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=yi(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function yi(e){return typeof e=="number"?`${e}px`:e}function pa(e){return new Xw(e)}var Eb=class{constructor(){this._hooks=new wr,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,s,a){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=a;let o=e;try{e.setPointerCapture(t),this._hooks.add(at(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=cn(e)}this._hooks.add(Ee(o,Ot.POINTER_MOVE,c=>{if(c.buttons!==n){this.stopMonitoring(!0);return}c.preventDefault(),this._pointerMoveCallback(c)})),this._hooks.add(Ee(o,Ot.POINTER_UP,c=>this.stopMonitoring(!0)))}};function $w(e,t,n){let s=null,a=null;if(typeof n.value=="function"?(s="value",a=n.value,a.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",a=n.get),!a)throw new Error("not supported");let o=`$memoize$${t}`;n[s]=function(...c){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:a.apply(this,c)}),this[o]}}var on;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(on||(on={}));var ua=class ti extends Be{constructor(){super(),this.dispatched=!1,this.targets=new hv,this.ignoreTargets=new hv,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Jt.runAndSubscribe(Ww,({window:t,disposables:n})=>{n.add(Ee(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(Ee(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(Ee(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Un,disposables:this._store}))}static addTarget(t){if(!ti.isTouchDevice())return Be.None;ti.INSTANCE||(ti.INSTANCE=new ti);let n=ti.INSTANCE.targets.push(t);return at(n)}static ignoreTarget(t){if(!ti.isTouchDevice())return Be.None;ti.INSTANCE||(ti.INSTANCE=new ti);let n=ti.INSTANCE.ignoreTargets.push(t);return at(n)}static isTouchDevice(){return"ontouchstart"in Un||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,a=t.targetTouches.length;s=ti.HOLD_DELAY&&Math.abs(p.initialPageX-Di(p.rollingPageX))<30&&Math.abs(p.initialPageY-Di(p.rollingPageY))<30){let g=this.newGestureEvent(on.Contextmenu,p.initialTarget);g.pageX=Di(p.rollingPageX),g.pageY=Di(p.rollingPageY),this.dispatchEvent(g)}else if(a===1){let g=Di(p.rollingPageX),_=Di(p.rollingPageY),b=Di(p.rollingTimestamps)-p.rollingTimestamps[0],y=g-p.rollingPageX[0],x=_-p.rollingPageY[0],k=[...this.targets].filter(L=>p.initialTarget instanceof Node&&L.contains(p.initialTarget));this.inertia(t,k,s,Math.abs(y)/b,y>0?1:-1,g,Math.abs(x)/b,x>0?1:-1,_)}this.dispatchEvent(this.newGestureEvent(on.End,p.initialTarget)),delete this.activeTouches[f.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(t){if(t.type===on.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>ti.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===on.Change||t.type===on.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let n=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let a=0,o=t.initialTarget;for(;o&&o!==s;)a++,o=o.parentElement;n.push([a,s])}n.sort((s,a)=>s[0]-a[0]);for(let[s,a]of n)a.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,s,a,o,c,f,p,h){this.handle=Rd(t,()=>{let g=Date.now(),_=g-s,b=0,y=0,x=!0;a+=ti.SCROLL_FRICTION*_,f+=ti.SCROLL_FRICTION*_,a>0&&(x=!1,b=o*a*_),f>0&&(x=!1,y=p*f*_);let k=this.newGestureEvent(on.Change);k.translationX=b,k.translationY=y,n.forEach(L=>L.dispatchEvent(k)),x||this.inertia(t,n,g,a,o,c+b,f,p,h+y)})}onTouchMove(t){let n=Date.now();for(let s=0,a=t.changedTouches.length;s3&&(c.rollingPageX.shift(),c.rollingPageY.shift(),c.rollingTimestamps.shift()),c.rollingPageX.push(o.pageX),c.rollingPageY.push(o.pageY),c.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};ua.SCROLL_FRICTION=-.005,ua.HOLD_DELAY=700,ua.CLEAR_TAP_COUNT_TIME=400,mt([$w],ua,"isTouchDevice",1);var Gw=ua,Md=class extends Be{onclick(e,t){this._register(Ee(e,Ot.CLICK,n=>t(new Go(cn(e),n))))}onmousedown(e,t){this._register(Ee(e,Ot.MOUSE_DOWN,n=>t(new Go(cn(e),n))))}onmouseover(e,t){this._register(Ee(e,Ot.MOUSE_OVER,n=>t(new Go(cn(e),n))))}onmouseleave(e,t){this._register(Ee(e,Ot.MOUSE_LEAVE,n=>t(new Go(cn(e),n))))}onkeydown(e,t){this._register(Ee(e,Ot.KEY_DOWN,n=>t(new _v(n))))}onkeyup(e,t){this._register(Ee(e,Ot.KEY_UP,n=>t(new _v(n))))}oninput(e,t){this._register(Ee(e,Ot.INPUT,t))}onblur(e,t){this._register(Ee(e,Ot.BLUR,t))}onfocus(e,t){this._register(Ee(e,Ot.FOCUS,t))}onchange(e,t){this._register(Ee(e,Ot.CHANGE,t))}ignoreGesture(e){return Gw.ignoreTarget(e)}},xv=11,Zw=class extends Md{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=xv+"px",this.domNode.style.height=xv+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new Eb),this._register(bv(this.bgDomNode,Ot.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(bv(this.domNode,Ot.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Vw),this._pointerdownScheduleRepeatTimer=this._register(new Dd)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,cn(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Qw=class Wf{constructor(t,n,s,a,o,c,f){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,a=a|0,o=o|0,c=c|0,f=f|0),this.rawScrollLeft=a,this.rawScrollTop=f,n<0&&(n=0),a+n>s&&(a=s-n),a<0&&(a=0),o<0&&(o=0),f+o>c&&(f=c-o),f<0&&(f=0),this.width=n,this.scrollWidth=s,this.scrollLeft=a,this.height=o,this.scrollHeight=c,this.scrollTop=f}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new Wf(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Wf(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let s=this.width!==t.width,a=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,c=this.height!==t.height,f=this.scrollHeight!==t.scrollHeight,p=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:a,scrollLeftChanged:o,heightChanged:c,scrollHeightChanged:f,scrollTopChanged:p}}},Jw=class extends Be{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new he),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Qw(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let s;t?s=new Cv(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=Cv.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},wv=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function ef(e,t){let n=t-e;return function(s){return e+n*iC(s)}}function eC(e,t,n){return function(s){return s2.5*s){let a,o;return t{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},rC=140,Tb=class extends Md{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new nC(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Eb),this._shouldRender=!0,this.domNode=pa(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Ee(this.domNode.domNode,Ot.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Zw(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=pa(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ee(this.slider.domNode,Ot.POINTER_DOWN,a=>{a.button===0&&(a.preventDefault(),this._sliderPointerDown(a))})),this.onclick(this.slider.domNode,a=>{a.leftButton&&a.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),a=this._sliderPointerPosition(e);n<=a&&a<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let a=Kw(this.domNode.domNode);t=e.pageX-a.left,n=e.pageY-a.top}let s=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,a=>{let o=this._sliderOrthogonalPointerPosition(a),c=Math.abs(o-n);if(xb&&c>rC){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let f=this._sliderPointerPosition(a)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(f))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Ab=class Vf{constructor(t,n,s,a,o,c){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=a,this._scrollSize=o,this._scrollPosition=c,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Vf(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,s,a,o){let c=Math.max(0,s-t),f=Math.max(0,c-2*n),p=a>0&&a>s;if(!p)return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(f),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(s*f/a))),g=(f-h)/(a-s),_=o*g;return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(h),computedSliderRatio:g,computedSliderPosition:Math.round(_)}}_refreshComputedValues(){let t=Vf._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,s=this._scrollPosition;return n0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),n){let a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),c=Math.abs(n.deltaX),f=Math.abs(n.deltaY),p=Math.max(Math.min(a,c),1),h=Math.max(Math.min(o,f),1),g=Math.max(a,c),_=Math.max(o,f);g%p===0&&_%h===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Kf.INSTANCE=new Kf;var uC=Kf,cC=class extends Md{constructor(e,t,n){super(),this._onScroll=this._register(new he),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new he),this.onWillScroll=this._onWillScroll.event,this._options=fC(t),this._scrollable=n,this._register(this._scrollable.onScroll(a=>{this._onWillScroll.fire(a),this._onDidScroll(a),this._onScroll.fire(a)}));let s={onMouseWheel:a=>this._onMouseWheel(a),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new lC(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new sC(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=pa(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=pa(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=pa(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,a=>this._onMouseOver(a)),this.onmouseleave(this._listenOnDomNode,a=>this._onMouseLeave(a)),this._hideTimeout=this._register(new Dd),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=es(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,hn&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new vv(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=es(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new vv(n))};this._mouseWheelToDispose.push(Ee(this._listenOnDomNode,Ot.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var a;if((a=e.browserEvent)!=null&&a.defaultPrevented)return;let t=uC.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+o===0?c=o=0:Math.abs(o)>=Math.abs(c)?c=0:o=0),this._options.flipAxes&&([o,c]=[c,o]);let f=!hn&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||f)&&!c&&(c=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),h={};if(o){let g=kv*o,_=p.scrollTop-(g<0?Math.floor(g):Math.ceil(g));this._verticalScrollbar.writeScrollPosition(h,_)}if(c){let g=kv*c,_=p.scrollLeft-(g<0?Math.floor(g):Math.ceil(g));this._horizontalScrollbar.writeScrollPosition(h,_)}h=this._scrollable.validateScrollPosition(h),(p.scrollLeft!==h.scrollLeft||p.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),n=!0)}let s=n;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,s=n?" left":"",a=t?" top":"",o=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${a}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${a}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),aC)}},hC=class extends cC{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function fC(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,hn&&(t.className+=" mac"),t}var Xf=class extends Be{constructor(e,t,n,s,a,o,c,f){super(),this._bufferService=n,this._optionsService=c,this._renderService=f,this._onRequestScrollLines=this._register(new he),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new Jw({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Rd(s.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new hC(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},p)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(a.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Jt.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(at(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(at(()=>this._styleElement.remove())),this._register(Jt.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(` +`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(h=>this._handleScroll(h)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};Xf=mt([pe(2,ui),pe(3,In),pe(4,ob),pe(5,tl),pe(6,ci),pe(7,Fn)],Xf);var $f=class extends Be{constructor(e,t,n,s,a){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=s,this._renderService=a,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(at(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};$f=mt([pe(1,ui),pe(2,In),pe(3,ka),pe(4,Fn)],$f);var dC=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},ln={full:0,left:0,center:0,right:0},gr={full:0,left:0,center:0,right:0},Ql={full:0,left:0,center:0,right:0},pu=class extends Be{constructor(e,t,n,s,a,o,c,f){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=a,this._optionsService=o,this._themeService=c,this._coreBrowserService=f,this._colorZoneStore=new dC,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(h=this._viewportElement.parentElement)==null||h.insertBefore(this._canvas,this._viewportElement),this._register(at(()=>{var g;return(g=this._canvas)==null?void 0:g.remove()}));let p=this._canvas.getContext("2d");if(p)this._ctx=p;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);gr.full=this._canvas.width,gr.left=e,gr.center=t,gr.right=e,this._refreshDrawHeightConstants(),Ql.full=1,Ql.left=1,Ql.center=1+gr.left,Ql.right=1+gr.left+gr.center}_refreshDrawHeightConstants(){ln.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);ln.left=t,ln.center=t,ln.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Ql[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ln[e.position||"full"]/2),gr[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ln[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};pu=mt([pe(2,ui),pe(3,ka),pe(4,Fn),pe(5,ci),pe(6,tl),pe(7,In)],pu);var se;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=` +`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(se||(se={}));var ou;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(ou||(ou={}));var Db;(e=>e.ST=`${se.ESC}\\`)(Db||(Db={}));var Gf=class{constructor(e,t,n,s,a,o){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=s,this._coreService=a,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.lengththis.updateCompositionElements(!0),0)}}};Gf=mt([pe(2,ui),pe(3,ci),pe(4,ns),pe(5,Fn)],Gf);var jt=0,Ht=0,Pt=0,dt=0,Ev={css:"#00000000",rgba:0},kt;(e=>{function t(a,o,c,f){return f!==void 0?`#${Vr(a)}${Vr(o)}${Vr(c)}${Vr(f)}`:`#${Vr(a)}${Vr(o)}${Vr(c)}`}e.toCss=t;function n(a,o,c,f=255){return(a<<24|o<<16|c<<8|f)>>>0}e.toRgba=n;function s(a,o,c,f){return{css:e.toCss(a,o,c,f),rgba:e.toRgba(a,o,c,f)}}e.toColor=s})(kt||(kt={}));var nt;(e=>{function t(p,h){if(dt=(h.rgba&255)/255,dt===1)return{css:h.css,rgba:h.rgba};let g=h.rgba>>24&255,_=h.rgba>>16&255,b=h.rgba>>8&255,y=p.rgba>>24&255,x=p.rgba>>16&255,k=p.rgba>>8&255;jt=y+Math.round((g-y)*dt),Ht=x+Math.round((_-x)*dt),Pt=k+Math.round((b-k)*dt);let L=kt.toCss(jt,Ht,Pt),M=kt.toRgba(jt,Ht,Pt);return{css:L,rgba:M}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,h,g){let _=uu.ensureContrastRatio(p.rgba,h.rgba,g);if(_)return kt.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function a(p){let h=(p.rgba|255)>>>0;return[jt,Ht,Pt]=uu.toChannels(h),{css:kt.toCss(jt,Ht,Pt),rgba:h}}e.opaque=a;function o(p,h){return dt=Math.round(h*255),[jt,Ht,Pt]=uu.toChannels(p.rgba),{css:kt.toCss(jt,Ht,Pt,dt),rgba:kt.toRgba(jt,Ht,Pt,dt)}}e.opacity=o;function c(p,h){return dt=p.rgba&255,o(p,dt*h/255)}e.multiplyOpacity=c;function f(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=f})(nt||(nt={}));var ut;(e=>{let t,n;try{let a=document.createElement("canvas");a.width=1,a.height=1;let o=a.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return jt=parseInt(a.slice(1,2).repeat(2),16),Ht=parseInt(a.slice(2,3).repeat(2),16),Pt=parseInt(a.slice(3,4).repeat(2),16),kt.toColor(jt,Ht,Pt);case 5:return jt=parseInt(a.slice(1,2).repeat(2),16),Ht=parseInt(a.slice(2,3).repeat(2),16),Pt=parseInt(a.slice(3,4).repeat(2),16),dt=parseInt(a.slice(4,5).repeat(2),16),kt.toColor(jt,Ht,Pt,dt);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let o=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return jt=parseInt(o[1]),Ht=parseInt(o[2]),Pt=parseInt(o[3]),dt=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),kt.toColor(jt,Ht,Pt,dt);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[jt,Ht,Pt,dt]=t.getImageData(0,0,1,1).data,dt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:kt.toRgba(jt,Ht,Pt,dt),css:a}}e.toColor=s})(ut||(ut={}));var li;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,a,o){let c=s/255,f=a/255,p=o/255,h=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),_=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return h*.2126+g*.7152+_*.0722}e.relativeLuminance2=n})(li||(li={}));var uu;(e=>{function t(c,f){if(dt=(f&255)/255,dt===1)return f;let p=f>>24&255,h=f>>16&255,g=f>>8&255,_=c>>24&255,b=c>>16&255,y=c>>8&255;return jt=_+Math.round((p-_)*dt),Ht=b+Math.round((h-b)*dt),Pt=y+Math.round((g-y)*dt),kt.toRgba(jt,Ht,Pt)}e.blend=t;function n(c,f,p){let h=li.relativeLuminance(c>>8),g=li.relativeLuminance(f>>8);if(jn(h,g)>8));if(x>8));return x>L?y:k}return y}let _=a(c,f,p),b=jn(h,li.relativeLuminance(_>>8));if(b>8));return b>x?_:y}return _}}e.ensureContrastRatio=n;function s(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=jn(li.relativeLuminance2(b,y,x),li.relativeLuminance2(h,g,_));for(;k0||y>0||x>0);)b-=Math.max(0,Math.ceil(b*.1)),y-=Math.max(0,Math.ceil(y*.1)),x-=Math.max(0,Math.ceil(x*.1)),k=jn(li.relativeLuminance2(b,y,x),li.relativeLuminance2(h,g,_));return(b<<24|y<<16|x<<8|255)>>>0}e.reduceLuminance=s;function a(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=jn(li.relativeLuminance2(b,y,x),li.relativeLuminance2(h,g,_));for(;k>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(uu||(uu={}));function Vr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function jn(e,t){return e1){let g=this._getJoinedRanges(s,c,o,t,a);for(let _=0;_1){let h=this._getJoinedRanges(s,c,o,t,a);for(let g=0;g=U,j=B,H=this._workCell;if(b.length>0&&B===b[0][0]&&T){let we=b.shift(),Et=this._isCellInSelection(we[0],t);for(Z=we[0]+1;Z=we[1]),T?(R=!0,H=new pC(this._workCell,e.translateToString(!0,we[0],we[1]),we[1]-we[0]),j=we[1]-1,A=H.getWidth()):U=we[1]}let ae=this._isCellInSelection(B,t),E=n&&B===o,D=V&&B>=h&&B<=g,K=!1;this._decorationService.forEachDecorationAtCell(B,t,void 0,we=>{K=!0});let C=H.getChars()||xr;if(C===" "&&(H.isUnderline()||H.isOverline())&&(C=" "),me=A*f-p.get(C,H.isBold(),H.isItalic()),!k)k=this._document.createElement("span");else if(L&&(ae&&ue||!ae&&!ue&&H.bg===I)&&(ae&&ue&&y.selectionForeground||H.fg===Q)&&H.extended.ext===W&&D===O&&me===ie&&!E&&!R&&!K&&T){H.isInvisible()?M+=xr:M+=C,L++;continue}else L&&(k.textContent=M),k=this._document.createElement("span"),L=0,M="";if(I=H.bg,Q=H.fg,W=H.extended.ext,O=D,ie=me,ue=ae,R&&o>=B&&o<=j&&(o=B),!this._coreService.isCursorHidden&&E&&this._coreService.isCursorInitialized){if(le.push("xterm-cursor"),this._coreBrowserService.isFocused)c&&le.push("xterm-cursor-blink"),le.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":le.push("xterm-cursor-outline");break;case"block":le.push("xterm-cursor-block");break;case"bar":le.push("xterm-cursor-bar");break;case"underline":le.push("xterm-cursor-underline");break}}if(H.isBold()&&le.push("xterm-bold"),H.isItalic()&&le.push("xterm-italic"),H.isDim()&&le.push("xterm-dim"),H.isInvisible()?M=xr:M=H.getChars()||xr,H.isUnderline()&&(le.push(`xterm-underline-${H.extended.underlineStyle}`),M===" "&&(M=" "),!H.isUnderlineColorDefault()))if(H.isUnderlineColorRGB())k.style.textDecorationColor=`rgb(${Ca.toColorRGB(H.getUnderlineColor()).join(",")})`;else{let we=H.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&H.isBold()&&we<8&&(we+=8),k.style.textDecorationColor=y.ansi[we].css}H.isOverline()&&(le.push("xterm-overline"),M===" "&&(M=" ")),H.isStrikethrough()&&le.push("xterm-strikethrough"),D&&(k.style.textDecoration="underline");let J=H.getFgColor(),fe=H.getFgColorMode(),de=H.getBgColor(),xe=H.getBgColorMode(),Ne=!!H.isInverse();if(Ne){let we=J;J=de,de=we;let Et=fe;fe=xe,xe=Et}let ke,rt,et=!1;this._decorationService.forEachDecorationAtCell(B,t,void 0,we=>{we.options.layer!=="top"&&et||(we.backgroundColorRGB&&(xe=50331648,de=we.backgroundColorRGB.rgba>>8&16777215,ke=we.backgroundColorRGB),we.foregroundColorRGB&&(fe=50331648,J=we.foregroundColorRGB.rgba>>8&16777215,rt=we.foregroundColorRGB),et=we.options.layer==="top")}),!et&&ae&&(ke=this._coreBrowserService.isFocused?y.selectionBackgroundOpaque:y.selectionInactiveBackgroundOpaque,de=ke.rgba>>8&16777215,xe=50331648,et=!0,y.selectionForeground&&(fe=50331648,J=y.selectionForeground.rgba>>8&16777215,rt=y.selectionForeground)),et&&le.push("xterm-decoration-top");let ct;switch(xe){case 16777216:case 33554432:ct=y.ansi[de],le.push(`xterm-bg-${de}`);break;case 50331648:ct=kt.toColor(de>>16,de>>8&255,de&255),this._addStyle(k,`background-color:#${Tv((de>>>0).toString(16),"0",6)}`);break;case 0:default:Ne?(ct=y.foreground,le.push("xterm-bg-257")):ct=y.background}switch(ke||H.isDim()&&(ke=nt.multiplyOpacity(ct,.5)),fe){case 16777216:case 33554432:H.isBold()&&J<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(J+=8),this._applyMinimumContrast(k,ct,y.ansi[J],H,ke,void 0)||le.push(`xterm-fg-${J}`);break;case 50331648:let we=kt.toColor(J>>16&255,J>>8&255,J&255);this._applyMinimumContrast(k,ct,we,H,ke,rt)||this._addStyle(k,`color:#${Tv(J.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(k,ct,y.foreground,H,ke,rt)||Ne&&le.push("xterm-fg-257")}le.length&&(k.className=le.join(" "),le.length=0),!E&&!R&&!K&&T?L++:k.textContent=M,me!==this.defaultSpacing&&(k.style.letterSpacing=`${me}px`),_.push(k),B=j}return k&&L&&(k.textContent=M),_}_applyMinimumContrast(e,t,n,s,a,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||gC(s.getCode()))return!1;let c=this._getContrastCache(s),f;if(!a&&!o&&(f=c.getColor(t.rgba,n.rgba)),f===void 0){let p=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);f=nt.ensureContrastRatio(a||t,o||n,p),c.setColor((a||t).rgba,(o||n).rgba,f??null)}return f?(this._addStyle(e,`color:${f.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t=n[0]&&e=n[0]}};Zf=mt([pe(1,hb),pe(2,ci),pe(3,In),pe(4,ns),pe(5,ka),pe(6,tl)],Zf);function Tv(e,t,n){for(;e.length0&&(this._flat[s]=c),c}let a=e;t&&(a+="B"),n&&(a+="I");let o=this._holey.get(a);if(o===void 0){let c=0;t&&(c|=1),n&&(c|=2),o=this._measure(e,c),o>0&&this._holey.set(a,o)}return o}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},bC=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let a=e.buffers.active.ydisp,o=t[1]-a,c=n[1]-a,f=Math.max(o,0),p=Math.min(c,e.rows-1);if(f>=e.rows||p<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=o,this.viewportEndRow=c,this.viewportCappedStartRow=f,this.viewportCappedEndRow=p,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n=this.startCol&&t=this.startCol):!1}};function SC(){return new bC}var tf="xterm-dom-renderer-owner-",qi="xterm-rows",Qo="xterm-fg-",Av="xterm-bg-",Jl="xterm-focus",Jo="xterm-selection",xC=1,Qf=class extends Be{constructor(e,t,n,s,a,o,c,f,p,h,g,_,b,y){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=a,this._helperContainer=o,this._linkifier2=c,this._charSizeService=p,this._optionsService=h,this._bufferService=g,this._coreService=_,this._coreBrowserService=b,this._themeService=y,this._terminalClass=xC++,this._rowElements=[],this._selectionRenderModel=SC(),this.onRequestRedraw=this._register(new he).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(qi),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Jo),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=vC(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(x=>this._injectCss(x))),this._injectCss(this._themeService.colors),this._rowFactory=f.createInstance(Zf,document),this._element.classList.add(tf+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(x=>this._handleLinkHover(x))),this._register(this._linkifier2.onHideLinkUnderline(x=>this._handleLinkLeave(x))),this._register(at(()=>{this._element.classList.remove(tf+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new yC(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${qi} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${qi} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${qi} .xterm-dim { color: ${nt.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,a=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${a} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${qi}.${Jl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${qi}.${Jl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${qi}.${Jl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${qi} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${qi} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${qi} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${qi} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${qi} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Jo} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Jo} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Jo} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,c]of e.ansi.entries())t+=`${this._terminalSelector} .${Qo}${o} { color: ${c.css}; }${this._terminalSelector} .${Qo}${o}.xterm-dim { color: ${nt.multiplyOpacity(c,.5).css}; }${this._terminalSelector} .${Av}${o} { background-color: ${c.css}; }`;t+=`${this._terminalSelector} .${Qo}257 { color: ${nt.opaque(e.background).css}; }${this._terminalSelector} .${Qo}257.xterm-dim { color: ${nt.multiplyOpacity(nt.opaque(e.background),.5).css}; }${this._terminalSelector} .${Av}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Jl),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Jl),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,a=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,c=this._selectionRenderModel.viewportCappedEndRow,f=this._document.createDocumentFragment();if(n){let p=e[0]>t[0];f.appendChild(this._createSelectionElement(o,p?t[0]:e[0],p?e[0]:t[0],c-o+1))}else{let p=s===o?e[0]:0,h=o===a?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(o,p,h));let g=c-o-1;if(f.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,g)),o!==c){let _=a===c?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(c,0,_))}}this._selectionContainer.appendChild(f)}_createSelectionElement(e,t,n,s=1){let a=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,c=this.dimensions.css.cell.width*(n-t);return o+c>this.dimensions.css.canvas.width&&(c=this.dimensions.css.canvas.width-o),a.style.height=`${s*this.dimensions.css.cell.height}px`,a.style.top=`${e*this.dimensions.css.cell.height}px`,a.style.left=`${o}px`,a.style.width=`${c}px`,a}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,s=n.ybase+n.y,a=Math.min(n.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,c=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=e;p<=t;p++){let h=p+n.ydisp,g=this._rowElements[p],_=n.lines.get(h);if(!g||!_)break;g.replaceChildren(...this._rowFactory.createRow(_,h,h===s,c,f,a,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${tf}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,s,a,o){n<0&&(e=0),s<0&&(t=0);let c=this._bufferService.rows-1;n=Math.max(Math.min(n,c),0),s=Math.max(Math.min(s,c),0),a=Math.min(a,this._bufferService.cols);let f=this._bufferService.buffer,p=f.ybase+f.y,h=Math.min(f.x,a-1),g=this._optionsService.rawOptions.cursorBlink,_=this._optionsService.rawOptions.cursorStyle,b=this._optionsService.rawOptions.cursorInactiveStyle;for(let y=n;y<=s;++y){let x=y+f.ydisp,k=this._rowElements[y],L=f.lines.get(x);if(!k||!L)break;k.replaceChildren(...this._rowFactory.createRow(L,x,x===p,_,b,h,g,this.dimensions.css.cell.width,this._widthCache,o?y===n?e:0:-1,o?(y===s?t:a)-1:-1))}}};Qf=mt([pe(7,Cd),pe(8,Cu),pe(9,ci),pe(10,ui),pe(11,ns),pe(12,In),pe(13,tl)],Qf);var Jf=class extends Be{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new he),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new CC(this._optionsService))}catch{this._measureStrategy=this._register(new wC(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Jf=mt([pe(2,ci)],Jf);var Rb=class extends Be{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},wC=class extends Rb{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},CC=class extends Rb{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},kC=class extends Be{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new EC(this._window)),this._onDprChange=this._register(new he),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new he),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Jt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ee(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ee(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},EC=class extends Be{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Js),this._onDprChange=this._register(new he),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(at(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ee(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},TC=class extends Be{constructor(){super(),this.linkProviders=[],this._register(at(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Bd(e,t,n){let s=n.getBoundingClientRect(),a=e.getComputedStyle(n),o=parseInt(a.getPropertyValue("padding-left")),c=parseInt(a.getPropertyValue("padding-top"));return[t.clientX-s.left-o,t.clientY-s.top-c]}function AC(e,t,n,s,a,o,c,f,p){if(!o)return;let h=Bd(e,t,n);if(h)return h[0]=Math.ceil((h[0]+(p?c/2:0))/c),h[1]=Math.ceil(h[1]/f),h[0]=Math.min(Math.max(h[0],1),s+(p?1:0)),h[1]=Math.min(Math.max(h[1],1),a),h}var ed=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,a){return AC(window,e,t,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,a)}getMouseReportCoords(e,t){let n=Bd(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};ed=mt([pe(0,Fn),pe(1,Cu)],ed);var DC=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Mb={};Px(Mb,{getSafariVersion:()=>MC,isChromeOS:()=>zb,isFirefox:()=>Bb,isIpad:()=>BC,isIphone:()=>NC,isLegacyEdge:()=>RC,isLinux:()=>Nd,isMac:()=>_u,isNode:()=>ku,isSafari:()=>Nb,isWindows:()=>Lb});var ku=typeof process<"u"&&"title"in process,Ea=ku?"node":navigator.userAgent,Ta=ku?"node":navigator.platform,Bb=Ea.includes("Firefox"),RC=Ea.includes("Edge"),Nb=/^((?!chrome|android).)*safari/i.test(Ea);function MC(){if(!Nb)return 0;let e=Ea.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var _u=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Ta),BC=Ta==="iPad",NC=Ta==="iPhone",Lb=["Windows","Win16","Win32","WinCE"].includes(Ta),Nd=Ta.indexOf("Linux")>=0,zb=/\bCrOS\b/.test(Ea),Ob=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._ia){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=a}this.clear()}},LC=class extends Ob{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},zC=class extends Ob{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},gu=!ku&&"requestIdleCallback"in window?zC:LC,OC=class{constructor(){this._queue=new gu}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},td=class extends Be{constructor(e,t,n,s,a,o,c,f,p){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=a,this._coreBrowserService=f,this._renderer=this._register(new Js),this._pausedResizeTask=new OC,this._observerDisposable=this._register(new Js),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new he),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new he),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new he),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new he),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new DC((h,g)=>this._renderRows(h,g),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new jC(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(at(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(c.onResize(()=>this._fullRefresh())),this._register(c.buffers.onBufferActivate(()=>{var h;return(h=this._renderer.value)==null?void 0:h.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(c.cols,c.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(c.buffer.y,c.buffer.y,!0))),this._register(p.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(h=>this._registerIntersectionObserver(h,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=at(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var n;return(n=this._renderer.value)==null?void 0:n.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,n){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};td=mt([pe(2,ci),pe(3,Cu),pe(4,ns),pe(5,ka),pe(6,ui),pe(7,In),pe(8,tl)],td);var jC=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function HC(e,t,n,s){let a=n.buffer.x,o=n.buffer.y;if(!n.buffer.hasScrollback)return IC(a,o,e,t,n,s)+Eu(o,t,n,s)+FC(a,o,e,t,n,s);let c;if(o===t)return c=a>e?"D":"C",ya(Math.abs(a-e),va(c,s));c=o>t?"D":"C";let f=Math.abs(o-t),p=UC(o>t?e:a,n)+(f-1)*n.cols+1+PC(o>t?a:e);return ya(p,va(c,s))}function PC(e,t){return e-1}function UC(e,t){return t.cols-e}function IC(e,t,n,s,a,o){return Eu(t,s,a,o).length===0?"":ya(Hb(e,t,e,t-ts(t,a),!1,a).length,va("D",o))}function Eu(e,t,n,s){let a=e-ts(e,n),o=t-ts(t,n),c=Math.abs(a-o)-qC(e,t,n);return ya(c,va(jb(e,t),s))}function FC(e,t,n,s,a,o){let c;Eu(t,s,a,o).length>0?c=s-ts(s,a):c=t;let f=s,p=WC(e,t,n,s,a,o);return ya(Hb(e,c,n,f,p==="C",a).length,va(p,o))}function qC(e,t,n){var c;let s=0,a=e-ts(e,n),o=t-ts(t,n);for(let f=0;f=0&&e0?c=s-ts(s,a):c=t,e=n&&ct?"A":"B"}function Hb(e,t,n,s,a,o){let c=e,f=t,p="";for(;(c!==n||f!==s)&&f>=0&&fo.cols-1?(p+=o.buffer.translateBufferLineToString(f,!1,e,c),c=0,e=0,f++):!a&&c<0&&(p+=o.buffer.translateBufferLineToString(f,!1,0,e+1),c=o.cols-1,e=c,f--);return p+o.buffer.translateBufferLineToString(f,!1,e,c)}function va(e,t){let n=t?"O":"[";return se.ESC+n+e}function ya(e,t){e=Math.floor(e);let n="";for(let s=0;sthis._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Dv(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var nf=50,VC=15,KC=50,XC=500,$C=" ",GC=new RegExp($C,"g"),id=class extends Be{constructor(e,t,n,s,a,o,c,f,p){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=a,this._mouseService=o,this._optionsService=c,this._renderService=f,this._coreBrowserService=p,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Ki,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new he),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new he),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new he),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new he),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=h=>this._handleMouseMove(h),this._mouseUpListener=h=>this._handleMouseUp(h),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(h=>this._handleTrim(h)),this._register(this._bufferService.buffers.onBufferActivate(h=>this._handleBufferActivate(h))),this.enable(),this._model=new YC(this._bufferService),this._activeSelectionMode=0,this._register(at(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(h=>{h.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let a=e[0]a.replace(GC," ")).join(Lb?`\r `:` -`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Nd&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s||!t?!1:this._areCoordsInSelection(t,n,s)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,t],n,s)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){var a,o;let n=(o=(a=this._linkifier.currentLink)==null?void 0:a.link)==null?void 0:o.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=Dv(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Bd(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-nf),nf),t/=nf,t/Math.abs(t)+Math.round(t*(VC-1)))}shouldForceSelection(e){return _u?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),KC)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(_u&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&tthis._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let s=0;t>=s;s++){let a=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:a>1&&t!==s&&(n+=a-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let a=this._bufferService.buffer,o=a.lines.get(e[1]);if(!o)return;let c=a.translateBufferLineToString(e[1],!1),f=this._convertViewportColToCharacterIndex(o,e[0]),p=f,h=e[0]-f,g=0,_=0,b=0,y=0;if(c.charAt(f)===" "){for(;f>0&&c.charAt(f-1)===" ";)f--;for(;p1&&(y+=Z-1,p+=Z-1);L>0&&f>0&&!this._isCharWordSeparator(o.loadCell(L-1,this._workCell));){o.loadCell(L-1,this._workCell);let I=this._workCell.getChars().length;this._workCell.getWidth()===0?(g++,L--):I>1&&(b+=I-1,f-=I-1),f--,L--}for(;M1&&(y+=I-1,p+=I-1),p++,M++}}p++;let x=f+h-g+b,k=Math.min(this._bufferService.cols,p-f+g+_-b-y);if(!(!t&&c.slice(f,p).trim()==="")){if(n&&x===0&&o.getCodePoint(0)!==32){let L=a.lines.get(e[1]-1);if(L&&o.isWrapped&&L.getCodePoint(this._bufferService.cols-1)!==32){let M=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(M){let Z=this._bufferService.cols-M.start;x-=Z,k+=Z}}}if(s&&x+k===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let L=a.lines.get(e[1]+1);if(L!=null&&L.isWrapped&&L.getCodePoint(0)!==32){let M=this._getWordAt([0,e[1]+1],!1,!1,!0);M&&(k+=M.length)}}return{start:x,length:k}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Dv(n,this._bufferService.cols)}};id=pt([pe(3,ui),pe(4,ns),pe(5,kd),pe(6,ci),pe(7,Fn),pe(8,In)],id);var Rv=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Mv=class{constructor(){this._color=new Rv,this._css=new Rv}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Rt=Object.freeze((()=>{let e=[ot.toColor("#2e3436"),ot.toColor("#cc0000"),ot.toColor("#4e9a06"),ot.toColor("#c4a000"),ot.toColor("#3465a4"),ot.toColor("#75507b"),ot.toColor("#06989a"),ot.toColor("#d3d7cf"),ot.toColor("#555753"),ot.toColor("#ef2929"),ot.toColor("#8ae234"),ot.toColor("#fce94f"),ot.toColor("#729fcf"),ot.toColor("#ad7fa8"),ot.toColor("#34e2e2"),ot.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],a=t[n/6%6|0],o=t[n%6];e.push({css:kt.toCss(s,a,o),rgba:kt.toRgba(s,a,o)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:kt.toCss(s,s,s),rgba:kt.toRgba(s,s,s)})}return e})()),$r=ot.toColor("#ffffff"),ca=ot.toColor("#000000"),Bv=ot.toColor("#ffffff"),Nv=ca,Ql={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},ZC=$r,nd=class extends Be{constructor(e){super(),this._optionsService=e,this._contrastCache=new Mv,this._halfContrastCache=new Mv,this._onChangeColors=this._register(new ce),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:$r,background:ca,cursor:Bv,cursorAccent:Nv,selectionForeground:void 0,selectionBackgroundTransparent:Ql,selectionBackgroundOpaque:nt.blend(ca,Ql),selectionInactiveBackgroundTransparent:Ql,selectionInactiveBackgroundOpaque:nt.blend(ca,Ql),scrollbarSliderBackground:nt.opacity($r,.2),scrollbarSliderHoverBackground:nt.opacity($r,.4),scrollbarSliderActiveBackground:nt.opacity($r,.5),overviewRulerBorder:$r,ansi:Rt.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=Ge(e.foreground,$r),t.background=Ge(e.background,ca),t.cursor=nt.blend(t.background,Ge(e.cursor,Bv)),t.cursorAccent=nt.blend(t.background,Ge(e.cursorAccent,Nv)),t.selectionBackgroundTransparent=Ge(e.selectionBackground,Ql),t.selectionBackgroundOpaque=nt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Ge(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=nt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Ge(e.selectionForeground,Ev):void 0,t.selectionForeground===Ev&&(t.selectionForeground=void 0),nt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=nt.opacity(t.selectionBackgroundTransparent,.3)),nt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=nt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Ge(e.scrollbarSliderBackground,nt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Ge(e.scrollbarSliderHoverBackground,nt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Ge(e.scrollbarSliderActiveBackground,nt.opacity(t.foreground,.5)),t.overviewRulerBorder=Ge(e.overviewRulerBorder,ZC),t.ansi=Rt.slice(),t.ansi[0]=Ge(e.black,Rt[0]),t.ansi[1]=Ge(e.red,Rt[1]),t.ansi[2]=Ge(e.green,Rt[2]),t.ansi[3]=Ge(e.yellow,Rt[3]),t.ansi[4]=Ge(e.blue,Rt[4]),t.ansi[5]=Ge(e.magenta,Rt[5]),t.ansi[6]=Ge(e.cyan,Rt[6]),t.ansi[7]=Ge(e.white,Rt[7]),t.ansi[8]=Ge(e.brightBlack,Rt[8]),t.ansi[9]=Ge(e.brightRed,Rt[9]),t.ansi[10]=Ge(e.brightGreen,Rt[10]),t.ansi[11]=Ge(e.brightYellow,Rt[11]),t.ansi[12]=Ge(e.brightBlue,Rt[12]),t.ansi[13]=Ge(e.brightMagenta,Rt[13]),t.ansi[14]=Ge(e.brightCyan,Rt[14]),t.ansi[15]=Ge(e.brightWhite,Rt[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;so.index-c.index),s=[];for(let o of n){let c=this._services.get(o.id);if(!c)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);s.push(c)}let a=n.length>0?n[0].index:t.length;if(t.length!==a)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${a+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},e2={trace:0,debug:1,info:2,warn:3,error:4,off:5},t2="xterm.js: ",rd=class extends Be{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=e2[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;s--)this._array[this._getCyclicIndex(s+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;sthis._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let a=t-1;a>=0;a--)this.set(e+a+n,this.get(e+a));let s=e+t+n-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*Me+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Me+0]=t|2097152|n[2]<<22):this._data[t*Me+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Me+0]>>22}hasWidth(t){return this._data[t*Me+0]&12582912}getFg(t){return this._data[t*Me+1]}getBg(t){return this._data[t*Me+2]}hasContent(t){return this._data[t*Me+0]&4194303}getCodePoint(t){let n=this._data[t*Me+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Me+0]&2097152}getString(t){let n=this._data[t*Me+0];return n&2097152?this._combined[t]:n&2097151?br(n&2097151):""}isProtected(t){return this._data[t*Me+2]&536870912}loadCell(t,n){return eu=t*Me,n.content=this._data[eu+0],n.fg=this._data[eu+1],n.bg=this._data[eu+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*Me+0]=n.content,this._data[t*Me+1]=n.fg,this._data[t*Me+2]=n.bg}setCellFromCodepoint(t,n,s,a){a.bg&268435456&&(this._extendedAttrs[t]=a.extended),this._data[t*Me+0]=n|s<<22,this._data[t*Me+1]=a.fg,this._data[t*Me+2]=a.bg}addCodepointToCell(t,n,s){let a=this._data[t*Me+0];a&2097152?this._combined[t]+=br(n):a&2097151?(this._combined[t]=br(a&2097151)+br(n),a&=-2097152,a|=2097152):a=n|1<<22,s&&(a&=-12582913,a|=s<<22),this._data[t*Me+0]=a}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n=0;--o)this.setCell(t+n+o,this.loadCell(t+o,a));for(let o=0;othis.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let a=new Uint32Array(s);a.set(this._data),this._data=a}for(let a=this.length;a=t&&delete this._combined[f]}let o=Object.keys(this._extendedAttrs);for(let c=0;c=t&&delete this._extendedAttrs[f]}}return this.length=t,s*4*rf=0;--t)if(this._data[t*Me+0]&4194303)return t+(this._data[t*Me+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Me+0]&4194303||this._data[t*Me+2]&50331648)return t+(this._data[t*Me+0]>>22);return 0}copyCellsFrom(t,n,s,a,o){let c=t._data;if(o)for(let p=a-1;p>=0;p--){for(let h=0;h=n&&(this._combined[h-n+s]=t._combined[h])}}translateToString(t,n,s,a){n=n??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),a&&(a.length=0);let o="";for(;n>22||1}return a&&a.push(n),o}};function i2(e,t,n,s,a,o){let c=[];for(let f=0;f=f&&s0&&(L>_||g[L].getTrimmedLength()===0);L--)k++;k>0&&(c.push(f+g.length-k),c.push(k)),f+=g.length-1}return c}function n2(e,t){let n=[],s=0,a=t[s],o=0;for(let c=0;cba(e,h,t)).reduce((p,h)=>p+h),o=0,c=0,f=0;for(;fp&&(o-=p,c++);let h=e[c].getWidth(o-1)===2;h&&o--;let g=h?n-1:n;s.push(g),f+=g}return s}function ba(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,a=e[t+1].getWidth(0)===2;return s&&a?n-1:n}var Ub=class Ib{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Ib._nextId++,this._onDispose=this.register(new ce),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),es(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Ub._nextId=1;var l2=Ub,Nt={},Zr=Nt.B;Nt[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Nt.A={"#":"£"};Nt.B=void 0;Nt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Nt.C=Nt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Nt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Nt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Nt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Nt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Nt.E=Nt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Nt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Nt.H=Nt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Nt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var zv=4294967295,Ov=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Ct.clone(),this.savedCharset=Zr,this.markers=[],this._nullCell=Ki.fromCharData([0,rb,1,0]),this._whitespaceCell=Ki.fromCharData([0,xr,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new gu,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Lv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new du),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new du),this._whitespaceCell}getBlankLine(e,t){return new ha(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&ezv?zv:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ct);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Lv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Ct),s=0,a=this._getCorrectBufferLength(t);if(a>this.lines.maxLength&&(this.lines.maxLength=a),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new ha(e,n)));else for(let c=this._rows;c>t;c--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(a0&&(this.lines.trimStart(c),this.ybase=Math.max(this.ybase-c,0),this.ydisp=Math.max(this.ydisp-c,0),this.savedY=Math.max(this.savedY-c,0)),this.lines.maxLength=a}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let o=0;o.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=i2(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ct),n);if(s.length>0){let a=n2(this.lines,s);r2(this.lines,a.layout),this._reflowLargerAdjustViewport(e,t,a.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(Ct),a=n;for(;a-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;c--){let f=this.lines.get(c);if(!f||!f.isWrapped&&f.getTrimmedLength()<=e)continue;let p=[f];for(;f.isWrapped&&c>0;)f=this.lines.get(--c),p.unshift(f);if(!n){let I=this.ybase+this.y;if(I>=c&&I0&&(a.push({start:c+p.length+o,newLines:y}),o+=y.length),p.push(...y);let x=g.length-1,k=g[x];k===0&&(x--,k=g[x]);let L=p.length-_-1,M=h;for(;L>=0;){let I=Math.min(M,k);if(p[x]===void 0)break;if(p[x].copyCellsFrom(p[L],M-I,k-I,I,!0),k-=I,k===0&&(x--,k=g[x]),M-=I,M===0){L--;let Q=Math.max(L,0);M=ba(p,Q,this._cols)}}for(let I=0;I0;)this.ybase===0?this.y0){let c=[],f=[];for(let k=0;k=0;k--)if(_&&_.start>h+b){for(let L=_.newLines.length-1;L>=0;L--)this.lines.set(k--,_.newLines[L]);k++,c.push({index:h+1,amount:_.newLines.length}),b+=_.newLines.length,_=a[++g]}else this.lines.set(k,f[h--]);let y=0;for(let k=c.length-1;k>=0;k--)c[k].index+=y,this.lines.onInsertEmitter.fire(c[k]),y+=c[k].amount;let x=Math.max(0,p+o-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(e,t,n=0,s){let a=this.lines.get(e);return a?a.translateToString(t,n,s):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+10;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.linen.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},a2=class extends Be{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new ce),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new Ov(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Ov(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},Fb=2,qb=1,sd=class extends Be{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new ce),this.onResize=this._onResize.event,this._onScroll=this._register(new ce),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Fb),this.rows=Math.max(e.rawOptions.rows||0,qb),this.buffers=this._register(new a2(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=n.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let a=n.ybase+n.scrollTop,o=n.ybase+n.scrollBottom;if(n.scrollTop===0){let c=n.lines.isFull;o===n.lines.length-1?c?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(o+1,0,s.clone()),c?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let c=o-a+1;n.lines.shiftElements(a+1,c-1,-1),n.lines.set(o,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),s!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};sd=pt([pe(0,ci)],sd);var Ys={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:_u,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},o2=["normal","bold","100","200","300","400","500","600","700","800","900"],u2=class extends Be{constructor(e){super(),this._onOptionChange=this._register(new ce),this.onOptionChange=this._onOptionChange.event;let t={...Ys};for(let n in e)if(n in t)try{let s=e[n];t[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(lt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in Ys))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in Ys))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Ys[e]),!c2(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Ys[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=o2.includes(t)?t:Ys[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function c2(e){return e==="block"||e==="underline"||e==="bar"}function fa(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let s in e)n[s]=t<=1?e[s]:e[s]&&fa(e[s],t-1);return n}var jv=Object.freeze({insertMode:!1}),Hv=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),ld=class extends Be{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new ce),this.onData=this._onData.event,this._onUserInput=this._register(new ce),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ce),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ce),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=fa(jv),this.decPrivateModes=fa(Hv)}reset(){this.modes=fa(jv),this.decPrivateModes=fa(Hv)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};ld=pt([pe(0,ui),pe(1,ub),pe(2,ci)],ld);var Pv={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function sf(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var lf=String.fromCharCode,Uv={DEFAULT:e=>{let t=[sf(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${lf(t[0])}${lf(t[1])}${lf(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${sf(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${sf(e,!0)};${e.x};${e.y}${t}`}},ad=class extends Be{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new ce),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Pv))this.addProtocol(s,Pv[s]);for(let s of Object.keys(Uv))this.addEncoding(s,Uv[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let s=t/n,a=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(a/=s+0,Math.abs(e.deltaY)<50&&(a*=.3),this._wheelPartialScroll+=a,a=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(a*=this._bufferService.rows),a}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};ad=pt([pe(0,ui),pe(1,ns),pe(2,ci)],ad);var af=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],h2=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Mt;function f2(e,t){let n=0,s=t.length-1,a;if(et[s][1])return!1;for(;s>=n;)if(a=n+s>>1,e>t[a][1])n=a+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let a=Qr.extractWidth(t);a===0?s=!1:a>n&&(n=a)}return Qr.createPropertyValue(0,n,s)}},Qr=class cu{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ce,this.onChange=this._onChange.event;let t=new d2;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,s=!1){return(t&16777215)<<3|(n&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,s=0,a=t.length;for(let o=0;o=a)return n+this.wcwidth(c);let h=t.charCodeAt(o);56320<=h&&h<=57343?c=(c-55296)*1024+h-56320+65536:n+=this.wcwidth(h)}let f=this.charProperties(c,s),p=cu.extractWidth(f);cu.extractShouldJoin(f)&&(p-=cu.extractWidth(s)),n+=p,s=f}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},p2=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Iv(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var Jl=2147483647,m2=256,Wb=class od{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>m2)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new od;if(!t.length)return n;for(let s=Array.isArray(t[0])?1:0;s>8,a=this._subParamsIdx[n]&255;a-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,a))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Jl?Jl:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Jl?Jl:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let t={};for(let n=0;n>8,a=this._subParamsIdx[n]&255;a-s>0&&(t[n]=this._subParams.slice(s,a))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,a=s[n-1];s[n-1]=~a?Math.min(a*10+t,Jl):t}},ea=[],_2=class{constructor(){this._state=0,this._active=ea,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ea}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=ea,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ea,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",wu(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=ea,this._id=-1,this._state=0}}},Ri=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=wu(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},ta=[],g2=class{constructor(){this._handlers=Object.create(null),this._active=ta,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ta}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=ta,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||ta,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",wu(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=ta,this._ident=0}},da=new Wb;da.addParam(0);var Fv=class{constructor(e){this._handler=e,this._data="",this._params=da,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():da,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=wu(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=da,this._data="",this._hitLimit=!1,n));return this._params=da,this._data="",this._hitLimit=!1,t}},v2=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let a=0;ap),n=(f,p)=>t.slice(f,p),s=n(32,127),a=n(0,24);a.push(25),a.push.apply(a,n(28,32));let o=n(0,14),c;e.setDefault(1,0),e.addMany(s,0,2,0);for(c in o)e.addMany([24,26,153,154],c,3,0),e.addMany(n(128,144),c,3,0),e.addMany(n(144,152),c,3,0),e.add(156,c,0,0),e.add(27,c,11,1),e.add(157,c,4,8),e.addMany([152,158,159],c,0,7),e.add(155,c,11,3),e.add(144,c,11,9);return e.addMany(a,0,3,0),e.addMany(a,1,3,1),e.add(127,1,0,1),e.addMany(a,8,0,8),e.addMany(a,3,3,3),e.add(127,3,0,3),e.addMany(a,4,3,4),e.add(127,4,0,4),e.addMany(a,6,3,6),e.addMany(a,5,3,5),e.add(127,5,0,5),e.addMany(a,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(a,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(a,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(a,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(a,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(a,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(a,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Yi,0,2,0),e.add(Yi,8,5,8),e.add(Yi,6,0,6),e.add(Yi,11,0,11),e.add(Yi,13,13,13),e})(),b2=class extends Be{constructor(e=y2){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Wb,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(lt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new _2),this._dcsParser=this._register(new g2),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let a=0;ao||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=s,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];return s.push(t),{dispose:()=>{let a=s.indexOf(t);a!==-1&&s.splice(a,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];return s.push(t),{dispose:()=>{let a=s.indexOf(t);a!==-1&&s.splice(a,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,s,a){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=a}parse(e,t,n){let s=0,a=0,o=0,c;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let f=this._parseStack.handlers,p=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&p>-1){for(;p>=0&&(c=f[p](this._params),c!==!0);p--)if(c instanceof Promise)return this._parseStack.handlerPos=p,c}this._parseStack.handlers=[];break;case 4:if(n===!1&&p>-1){for(;p>=0&&(c=f[p](),c!==!0);p--)if(c instanceof Promise)return this._parseStack.handlerPos=p,c}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],c=this._dcsParser.unhook(s!==24&&s!==26,n),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],c=this._oscParser.end(s!==24&&s!==26,n),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let f=o;f>4){case 2:for(let b=f+1;;++b){if(b>=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=0&&(c=p[h](this._params),c!==!0);h--)if(c instanceof Promise)return this._preserveStack(3,p,h,a,f),c;h<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++f47&&s<60);f--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let g=this._escHandlers[this._collect<<8|s],_=g?g.length-1:-1;for(;_>=0&&(c=g[_](),c!==!0);_--)if(c instanceof Promise)return this._preserveStack(4,g,_,a,f),c;_<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let b=f+1;;++b)if(b>=t||(s=e[b])===24||s===26||s===27||s>127&&s=t||(s=e[b])<32||s>127&&s>4:o>>8}return s}}function of(e,t){let n=e.toString(16),s=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function w2(e,t=16){let[n,s,a]=e;return`rgb:${of(n,t)}/${of(s,t)}/${of(a,t)}`}var C2={"(":0,")":1,"*":2,"+":3,"-":1,".":2},vr=131072,Wv=10;function Yv(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Vv=5e3,Kv=0,k2=class extends Be{constructor(e,t,n,s,a,o,c,f,p=new b2){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=a,this._oscLinkService=o,this._coreMouseService=c,this._unicodeService=f,this._parser=p,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Wx,this._utf8Decoder=new Yx,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ct.clone(),this._eraseAttrDataInternal=Ct.clone(),this._onRequestBell=this._register(new ce),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ce),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ce),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ce),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ce),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ce),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ce),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ce),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ce),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ce),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ce),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ce),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ce),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new ud(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,g)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:g.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,g,_)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:g,data:_})}),this._parser.setDcsHandlerFallback((h,g,_)=>{g==="HOOK"&&(_=_.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:g,payload:_})}),this._parser.setPrintHandler((h,g,_)=>this.print(h,g,_)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler(se.BEL,()=>this.bell()),this._parser.setExecuteHandler(se.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(se.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(se.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(se.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(se.BS,()=>this.backspace()),this._parser.setExecuteHandler(se.HT,()=>this.tab()),this._parser.setExecuteHandler(se.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(se.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ou.IND,()=>this.index()),this._parser.setExecuteHandler(ou.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ou.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ri(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new Ri(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new Ri(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new Ri(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new Ri(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new Ri(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new Ri(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new Ri(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new Ri(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new Ri(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new Ri(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new Ri(h=>this.restoreCursorColor(h))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let h in Nt)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Fv((h,g)=>this.requestStatusString(h,g)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),Vv))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Vv} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,a=this._activeBuffer.y,o=0,c=this._parseStack.paused;if(c){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,a=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>vr&&(o=this._parseStack.position+vr)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(h=>h.charCodeAt(0)):e),this._parseBuffer.lengthvr)for(let h=o;h0&&_.getWidth(this._activeBuffer.x-1)===2&&_.setCellFromCodepoint(this._activeBuffer.x-1,0,1,g);let b=this._parser.precedingJoinState;for(let y=t;yf){if(p){let M=_,Z=this._activeBuffer.x-L;for(this._activeBuffer.x=L,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),_=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),L>0&&_ instanceof ha&&_.copyCellsFrom(M,Z,0,L,!1);Z=0;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,g);continue}if(h&&(_.insertCells(this._activeBuffer.x,a-L,this._activeBuffer.getNullCell(g)),_.getWidth(f-1)===2&&_.setCellFromCodepoint(f-1,0,1,g)),_.setCellFromCodepoint(this._activeBuffer.x++,s,a,g),a>0)for(;--a;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,g)}this._parser.precedingJoinState=b,this._activeBuffer.x0&&_.getWidth(this._activeBuffer.x)===0&&!_.hasContent(this._activeBuffer.x)&&_.setCellFromCodepoint(this._activeBuffer.x,0,1,g),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>Yv(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Fv(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ri(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,s=!1,a=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),a),s&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&s.getTrimmedLength()););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let a=this._activeBuffer.lines.length-this._bufferService.rows;a>0&&(this._activeBuffer.lines.trimStart(a),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-a,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-a,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y65535?2:1}let p=f;for(let h=1;h0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(se.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(se.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(se.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(se.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(se.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t(k[k.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",k[k.SET=1]="SET",k[k.RESET=2]="RESET",k[k.PERMANENTLY_SET=3]="PERMANENTLY_SET",k[k.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:a,activeEncoding:o}=this._coreMouseService,c=this._coreService,{buffers:f,cols:p}=this._bufferService,{active:h,alt:g}=f,_=this._optionsService.rawOptions,b=(k,L)=>(c.triggerDataEvent(`${se.ESC}[${t?"":"?"}${k};${L}$y`),!0),y=k=>k?1:2,x=e.params[0];return t?x===2?b(x,4):x===4?b(x,y(c.modes.insertMode)):x===12?b(x,3):x===20?b(x,y(_.convertEol)):b(x,0):x===1?b(x,y(s.applicationCursorKeys)):x===3?b(x,_.windowOptions.setWinLines?p===80?2:p===132?1:0:0):x===6?b(x,y(s.origin)):x===7?b(x,y(s.wraparound)):x===8?b(x,3):x===9?b(x,y(a==="X10")):x===12?b(x,y(_.cursorBlink)):x===25?b(x,y(!c.isCursorHidden)):x===45?b(x,y(s.reverseWraparound)):x===66?b(x,y(s.applicationKeypad)):x===67?b(x,4):x===1e3?b(x,y(a==="VT200")):x===1002?b(x,y(a==="DRAG")):x===1003?b(x,y(a==="ANY")):x===1004?b(x,y(s.sendFocus)):x===1005?b(x,4):x===1006?b(x,y(o==="SGR")):x===1015?b(x,4):x===1016?b(x,y(o==="SGR_PIXELS")):x===1048?b(x,1):x===47||x===1047||x===1049?b(x,y(h===g)):x===2004?b(x,y(s.bracketedPasteMode)):x===2026?b(x,y(s.synchronizedOutput)):b(x,0)}_updateAttrColor(e,t,n,s,a){return t===2?(e|=50331648,e&=-16777216,e|=Ca.fromColorRGB([n,s,a])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let s=[0,0,-1,0,0,0],a=0,o=0;do{if(s[o+a]=e.params[t+o],e.hasSubParams(t+o)){let c=e.getSubParams(t+o),f=0;do s[1]===5&&(a=1),s[o+f+1+a]=c[f];while(++f=2||s[1]===2&&o+a>=5)break;s[1]&&(a=1)}while(++o+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Ct.fg,e.bg=Ct.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,s=this._curAttrData;for(let a=0;a=30&&n<=37?(s.fg&=-50331904,s.fg|=16777216|n-30):n>=40&&n<=47?(s.bg&=-50331904,s.bg|=16777216|n-40):n>=90&&n<=97?(s.fg&=-50331904,s.fg|=16777216|n-90|8):n>=100&&n<=107?(s.bg&=-50331904,s.bg|=16777216|n-100|8):n===0?this._processSGR0(s):n===1?s.fg|=134217728:n===3?s.bg|=67108864:n===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(a)?e.getSubParams(a)[0]:1,s)):n===5?s.fg|=536870912:n===7?s.fg|=67108864:n===8?s.fg|=1073741824:n===9?s.fg|=2147483648:n===2?s.bg|=134217728:n===21?this._processUnderline(2,s):n===22?(s.fg&=-134217729,s.bg&=-134217729):n===23?s.bg&=-67108865:n===24?(s.fg&=-268435457,this._processUnderline(0,s)):n===25?s.fg&=-536870913:n===27?s.fg&=-67108865:n===28?s.fg&=-1073741825:n===29?s.fg&=2147483647:n===39?(s.fg&=-67108864,s.fg|=Ct.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=Ct.bg&16777215):n===38||n===48||n===58?a+=this._extractColor(e,a,s):n===53?s.bg|=1073741824:n===55?s.bg&=-1073741825:n===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):n===100?(s.fg&=-67108864,s.fg|=Ct.fg&16777215,s.bg&=-67108864,s.bg|=Ct.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${se.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${se.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${se.ESC}[?${t};${n}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Ct.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Yv(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${se.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Wv&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Wv&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let s=n.shift(),a=n.shift();if(/^\d+$/.exec(s)){let o=parseInt(s);if(Xv(o))if(a==="?")t.push({type:0,index:o});else{let c=qv(a);c&&t.push({type:1,index:o,color:c})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),s,a=n.findIndex(o=>o.startsWith("id="));return a!==-1&&(s=n[a].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let s=0;s=this._specialColors.length);++s,++t)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let a=qv(n[s]);a&&this._onColor.fire([{type:1,index:this._specialColors[t],color:a}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let s=0;s=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Ct.clone(),this._eraseAttrDataInternal=Ct.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Ki;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t(this._coreService.triggerDataEvent(`${se.ESC}${c}${se.ESC}\\`),!0),s=this._bufferService.buffer,a=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[a.cursorStyle]-(a.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},ud=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){ethis.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Kv=e,e=t,t=Kv),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};ud=pt([pe(0,ui)],ud);function Xv(e){return 0<=e&&e<256}var E2=5e7,Gv=12,T2=50,A2=class extends Be{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new ce),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>E2)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],a=this._action(s,t);if(a){let c=f=>performance.now()-n>=Gv?setTimeout(()=>this._innerWrite(0,f)):this._innerWrite(n,f);a.catch(f=>(queueMicrotask(()=>{throw f}),Promise.resolve(!1))).then(c);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=Gv)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>T2&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},cd=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let f=t.addMarker(t.ybase+t.y),p={data:e,id:this._nextId++,lines:[f]};return f.onDispose(()=>this._removeMarkerFromLink(p,f)),this._dataByLinkId.set(p.id,p),p.id}let n=e,s=this._getEntryIdKey(n),a=this._entriesWithId.get(s);if(a)return this.addLineToLink(a.id,t.ybase+t.y),a.id;let o=t.addMarker(t.ybase+t.y),c={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(c,o)),this._entriesWithId.set(c.key,c),this._dataByLinkId.set(c.id,c),c.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};cd=pt([pe(0,ui)],cd);var $v=!1,D2=class extends Be{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Zs),this._onBinary=this._register(new ce),this.onBinary=this._onBinary.event,this._onData=this._register(new ce),this.onData=this._onData.event,this._onLineFeed=this._register(new ce),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ce),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ce),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ce),this._instantiationService=new JC,this.optionsService=this._register(new u2(e)),this._instantiationService.setService(ci,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(sd)),this._instantiationService.setService(ui,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(rd)),this._instantiationService.setService(ub,this._logService),this.coreService=this._register(this._instantiationService.createInstance(ld)),this._instantiationService.setService(ns,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(ad)),this._instantiationService.setService(ob,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Qr)),this._instantiationService.setService(Gx,this.unicodeService),this._charsetService=this._instantiationService.createInstance(p2),this._instantiationService.setService(Xx,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(cd),this._instantiationService.setService(cb,this._oscLinkService),this._inputHandler=this._register(new k2(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Jt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Jt.forward(this._bufferService.onResize,this._onResize)),this._register(Jt.forward(this.coreService.onData,this._onData)),this._register(Jt.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new A2((t,n)=>this._inputHandler.parse(t,n))),this._register(Jt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ce),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!$v&&(this._logService.warn("writeSync is unreliable and will be removed soon."),$v=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,Fb),t=Math.max(t,qb),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Iv.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Iv(this._bufferService),!1))),this._windowsWrappingHeuristics.value=lt(()=>{for(let t of e)t.dispose()})}}},R2={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function M2(e,t,n,s){var c;let a={type:0,cancel:!1,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?a.key=se.ESC+"OA":a.key=se.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?a.key=se.ESC+"OD":a.key=se.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?a.key=se.ESC+"OC":a.key=se.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?a.key=se.ESC+"OB":a.key=se.ESC+"[B");break;case 8:a.key=e.ctrlKey?"\b":se.DEL,e.altKey&&(a.key=se.ESC+a.key);break;case 9:if(e.shiftKey){a.key=se.ESC+"[Z";break}a.key=se.HT,a.cancel=!0;break;case 13:a.key=e.altKey?se.ESC+se.CR:se.CR,a.cancel=!0;break;case 27:a.key=se.ESC,e.altKey&&(a.key=se.ESC+se.ESC),a.cancel=!0;break;case 37:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"D":t?a.key=se.ESC+"OD":a.key=se.ESC+"[D";break;case 39:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"C":t?a.key=se.ESC+"OC":a.key=se.ESC+"[C";break;case 38:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"A":t?a.key=se.ESC+"OA":a.key=se.ESC+"[A";break;case 40:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"B":t?a.key=se.ESC+"OB":a.key=se.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(a.key=se.ESC+"[2~");break;case 46:o?a.key=se.ESC+"[3;"+(o+1)+"~":a.key=se.ESC+"[3~";break;case 36:o?a.key=se.ESC+"[1;"+(o+1)+"H":t?a.key=se.ESC+"OH":a.key=se.ESC+"[H";break;case 35:o?a.key=se.ESC+"[1;"+(o+1)+"F":t?a.key=se.ESC+"OF":a.key=se.ESC+"[F";break;case 33:e.shiftKey?a.type=2:e.ctrlKey?a.key=se.ESC+"[5;"+(o+1)+"~":a.key=se.ESC+"[5~";break;case 34:e.shiftKey?a.type=3:e.ctrlKey?a.key=se.ESC+"[6;"+(o+1)+"~":a.key=se.ESC+"[6~";break;case 112:o?a.key=se.ESC+"[1;"+(o+1)+"P":a.key=se.ESC+"OP";break;case 113:o?a.key=se.ESC+"[1;"+(o+1)+"Q":a.key=se.ESC+"OQ";break;case 114:o?a.key=se.ESC+"[1;"+(o+1)+"R":a.key=se.ESC+"OR";break;case 115:o?a.key=se.ESC+"[1;"+(o+1)+"S":a.key=se.ESC+"OS";break;case 116:o?a.key=se.ESC+"[15;"+(o+1)+"~":a.key=se.ESC+"[15~";break;case 117:o?a.key=se.ESC+"[17;"+(o+1)+"~":a.key=se.ESC+"[17~";break;case 118:o?a.key=se.ESC+"[18;"+(o+1)+"~":a.key=se.ESC+"[18~";break;case 119:o?a.key=se.ESC+"[19;"+(o+1)+"~":a.key=se.ESC+"[19~";break;case 120:o?a.key=se.ESC+"[20;"+(o+1)+"~":a.key=se.ESC+"[20~";break;case 121:o?a.key=se.ESC+"[21;"+(o+1)+"~":a.key=se.ESC+"[21~";break;case 122:o?a.key=se.ESC+"[23;"+(o+1)+"~":a.key=se.ESC+"[23~";break;case 123:o?a.key=se.ESC+"[24;"+(o+1)+"~":a.key=se.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?a.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?a.key=se.NUL:e.keyCode>=51&&e.keyCode<=55?a.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?a.key=se.DEL:e.keyCode===219?a.key=se.ESC:e.keyCode===220?a.key=se.FS:e.keyCode===221&&(a.key=se.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let f=(c=R2[e.keyCode])==null?void 0:c[e.shiftKey?1:0];if(f)a.key=se.ESC+f;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,h=String.fromCharCode(p);e.shiftKey&&(h=h.toUpperCase()),a.key=se.ESC+h}else if(e.keyCode===32)a.key=se.ESC+(e.ctrlKey?se.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),a.key=se.ESC+p,a.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(a.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?a.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(a.key=se.US),e.key==="@"&&(a.key=se.NUL));break}return a}var gt=0,B2=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new gu,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new gu,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((a,o)=>this._getKey(a)-this._getKey(o)),t=0,n=0,s=new Array(this._array.length+this._insertedValues.length);for(let a=0;a=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(s[a]=e[t],t++):s[a]=this._array[n++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(gt=this._search(t),gt===-1)||this._getKey(this._array[gt])!==t)return!1;do if(this._array[gt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(gt),!0;while(++gta-o),t=0,n=new Array(this._array.length-e.length),s=0;for(let a=0;a0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(gt=this._search(e),!(gt<0||gt>=this._array.length)&&this._getKey(this._array[gt])===e))do yield this._array[gt];while(++gt=this._array.length)&&this._getKey(this._array[gt])===e))do t(this._array[gt]);while(++gt=t;){let s=t+n>>1,a=this._getKey(this._array[s]);if(a>e)n=s-1;else if(a0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},uf=0,Zv=0,N2=class extends Be{constructor(){super(),this._decorations=new B2(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new ce),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ce),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(lt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new L2(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let s=0,a=0;for(let o of this._decorations.getKeyIterator(t))s=o.options.x??0,a=s+(o.options.width??1),e>=s&&e{uf=a.options.x??0,Zv=uf+(a.options.width??1),e>=uf&&e=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let a=s-this._lastRefreshMs,o=this._debounceThresholdMS-a;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Qv=20,vu=class extends Be{constructor(e,t,n,s){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let a=this._coreBrowserService.mainDocument;this._accessibilityContainer=a.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=a.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;othis._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=a.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new O2(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(` -`))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(ke(a,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(lt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===` -`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Qv+1&&(this._liveRegion.textContent+=Rf.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,s=n.lines.length.toString();for(let a=e;a<=t;a++){let o=n.lines.get(n.ydisp+a),c=[],f=(o==null?void 0:o.translateToString(!0,void 0,void 0,c))||"",p=(n.ydisp+a+1).toString(),h=this._rowElements[a];h&&(f.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=f,this._rowColumns.set(h,c)),h.setAttribute("aria-posinset",p),h.setAttribute("aria-setsize",s),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],a=n.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(a===o||e.relatedTarget!==s)return;let c,f;if(t===0?(c=n,f=this._rowElements.pop(),this._rowContainer.removeChild(f)):(c=this._rowElements.shift(),f=n,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),f.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let p=this._createAccessibilityTreeNode();this._rowElements.unshift(p),this._rowContainer.insertAdjacentElement("afterbegin",p)}else{let p=this._createAccessibilityTreeNode();this._rowElements.push(p),this._rowContainer.appendChild(p)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var f;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:s,offset:((f=s.textContent)==null?void 0:f.length)??0}),!this._rowContainer.contains(n.node))return;let a=({node:p,offset:h})=>{let g=p instanceof Text?p.parentNode:p,_=parseInt(g==null?void 0:g.getAttribute("aria-posinset"),10)-1;if(isNaN(_))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(g);if(!b)return console.warn("columns is null. Race condition?"),null;let y=h=this._terminal.cols&&(++_,y=0),{row:_,column:y}},o=a(t),c=a(n);if(!(!o||!c)){if(o.row>c.row||o.row===c.row&&o.column>=c.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(c.row-o.row)*this._terminal.cols-o.column+c.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;te;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e{var o;es(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(o=this._activeProviderReplies)==null||o.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(ke(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(ke(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(ke(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(ke(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let s=0;s{o==null||o.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[o,c]of this._linkProviderService.linkProviders.entries())t?(a=this._activeProviderReplies)!=null&&a.get(o)&&(n=this._checkLinkProviderResult(o,e,n)):c.provideLinks(e.y,f=>{var h,g;if(this._isMouseOut)return;let p=f==null?void 0:f.map(_=>({link:_}));(h=this._activeProviderReplies)==null||h.set(o,p),n=this._checkLinkProviderResult(o,e,n),((g=this._activeProviderReplies)==null?void 0:g.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;se?this._bufferService.cols:c.link.range.end.x;for(let h=f;h<=p;h++){if(n.has(h)){a.splice(o--,1);break}n.add(h)}}}}_checkLinkProviderResult(e,t,n){var o;if(!this._activeProviderReplies)return n;let s=this._activeProviderReplies.get(e),a=!1;for(let c=0;cthis._linkAtPosition(f.link,t));c&&(n=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let c=0;cthis._linkAtPosition(p.link,t));if(f){n=!0,this._handleNewLink(f);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&j2(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,es(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.pointerCursor},set:n=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.underline},set:n=>{var s,a,o;(s=this._currentLink)!=null&&s.state&&((o=(a=this._currentLink)==null?void 0:a.state)==null?void 0:o.decorations.underline)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let s=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,a=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=a&&(this._clearCurrentLink(s,a),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,s=this._bufferService.buffer.ydisp,a=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(a)}_linkLeave(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,a=t.y*this._bufferService.cols+t.x;return n<=a&&a<=s}_positionFromMouseEvent(e,t,n){let s=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,s,a){return{x1:e,y1:t,x2:n,y2:s,cols:this._bufferService.cols,fg:a}}};hd=pt([pe(1,kd),pe(2,Fn),pe(3,ui),pe(4,fb)],hd);function j2(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var H2=class extends D2{constructor(e={}){super(e),this._linkifier=this._register(new Zs),this.browser=Mb,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Zs),this._onCursorMove=this._register(new ce),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ce),this.onKey=this._onKey.event,this._onRender=this._register(new ce),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ce),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ce),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ce),this.onBell=this._onBell.event,this._onFocus=this._register(new ce),this._onBlur=this._register(new ce),this._onA11yCharEmitter=this._register(new ce),this._onA11yTabEmitter=this._register(new ce),this._onWillOpen=this._register(new ce),this._setup(),this._decorationService=this._instantiationService.createInstance(N2),this._instantiationService.setService(ka,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(TC),this._instantiationService.setService(fb,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Bf)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Jt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Jt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Jt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Jt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(lt(()=>{var t,n;this._customKeyEventHandler=void 0,(n=(t=this.element)==null?void 0:t.parentNode)==null||n.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,s="";switch(t.index){case 256:n="foreground",s="10";break;case 257:n="background",s="11";break;case 258:n="cursor",s="12";break;default:n="ansi",s="4;"+t.index}switch(t.type){case 0:let a=nt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${se.ESC}]${s};${w2(a)}${Db.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=kt.toColor(...t.color));else{let o=n;this._themeService.modifyColors(c=>c[o]=kt.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(vu,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(se.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(se.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,a=t.getWidth(n),o=this._renderService.dimensions.css.cell.width*a,c=this.buffer.y*this._renderService.dimensions.css.cell.height,f=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=f+"px",this.textarea.style.top=c+"px",this.textarea.style.width=o+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(ke(this.element,"copy",t=>{this.hasSelection()&&Fx(t,this._selectionService)}));let e=t=>qx(t,this.textarea,this.coreService,this.optionsService);this._register(ke(this.textarea,"paste",e)),this._register(ke(this.element,"paste",e)),Bb?this._register(ke(this.element,"mousedown",t=>{t.button===2&&ov(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(ke(this.element,"contextmenu",t=>{ov(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Nd&&this._register(ke(this.element,"auxclick",t=>{t.button===1&&nb(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(ke(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(ke(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(ke(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(ke(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(ke(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(ke(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(ke(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var a;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((a=this.element)==null?void 0:a.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(ke(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Df.get()),zb||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(kC,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(In,this._coreBrowserService),this._register(ke(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(ke(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Jf,this._document,this._helperContainer),this._instantiationService.setService(Cu,this._charSizeService),this._themeService=this._instantiationService.createInstance(nd),this._instantiationService.setService(Js,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(mu),this._instantiationService.setService(hb,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(td,this.rows,this.screenElement)),this._instantiationService.setService(Fn,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance($f,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(ed),this._instantiationService.setService(kd,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(hd,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Xf,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(id,this.element,this.screenElement,s)),this._instantiationService.setService(Zx,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register(Jt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(Gf,this.screenElement)),this._register(ke(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(vu,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(pu,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(pu,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Qf,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(o){var h,g,_,b,y;let c=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!c)return!1;let f,p;switch(o.overrideType||o.type){case"mousemove":p=32,o.buttons===void 0?(f=3,o.button!==void 0&&(f=o.button<3?o.button:3)):f=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":p=0,f=o.button<3?o.button:3;break;case"mousedown":p=1,f=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let x=o.deltaY;if(x===0||e.coreMouseService.consumeWheelEvent(o,(b=(_=(g=(h=e._renderService)==null?void 0:h.dimensions)==null?void 0:g.device)==null?void 0:_.cell)==null?void 0:b.height,(y=e._coreBrowserService)==null?void 0:y.dpr)===0)return!1;p=x<0?0:1,f=4;break;default:return!1}return p===void 0||f===void 0||f>4?!1:e.coreMouseService.triggerMouseEvent({col:c.col,row:c.row,x:c.x,y:c.y,button:f,action:p,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:o=>(n(o),o.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(o)),wheel:o=>(n(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&n(o)},mousemove:o=>{o.buttons||n(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?s.mousemove||(t.addEventListener("mousemove",a.mousemove),s.mousemove=a.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),o&16?s.wheel||(t.addEventListener("wheel",a.wheel,{passive:!1}),s.wheel=a.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),o&2?s.mouseup||(s.mouseup=a.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),o&4?s.mousedrag||(s.mousedrag=a.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(ke(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return n(o),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(o)})),this._register(ke(t,"wheel",o=>{var c,f,p,h,g;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,(h=(p=(f=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:f.device)==null?void 0:p.cell)==null?void 0:h.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return this.cancel(o,!0);let _=se.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(_,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var n;(n=this._renderService)==null||n.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){ib(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var n;(n=this._selectionService)==null||n.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=M2(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let s=this.rows-1;return this.scrollLines(n.type===2?-s:s),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===se.ETX||n.key===se.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(P2(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var n;(n=this._charSizeService)==null||n.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Ki)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Jv=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new I2(t)}getNullCell(){return new Ki}},F2=class extends Be{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ce),this.onBufferChange=this._onBufferChange.event,this._normal=new Jv(this._core.buffers.normal,"normal"),this._alternate=new Jv(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},q2=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,s)=>t(n,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},W2=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},Y2=["cols","rows"],an=0,V2=class extends Be{constructor(e){super(),this._core=this._register(new H2(e)),this._addonManager=this._register(new U2),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],n=(s,a)=>{this._checkReadonlyOptions(s),this._core.options[s]=a};for(let s in this._core.options){let a={get:t.bind(this,s),set:n.bind(this,s)};Object.defineProperty(this._publicOptions,s,a)}}_checkReadonlyOptions(e){if(Y2.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new q2(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new W2(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new F2(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r +`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Nd&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s||!t?!1:this._areCoordsInSelection(t,n,s)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,t],n,s)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){var a,o;let n=(o=(a=this._linkifier.currentLink)==null?void 0:a.link)==null?void 0:o.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=Dv(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Bd(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-nf),nf),t/=nf,t/Math.abs(t)+Math.round(t*(VC-1)))}shouldForceSelection(e){return _u?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),KC)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(_u&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&tthis._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let s=0;t>=s;s++){let a=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:a>1&&t!==s&&(n+=a-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let a=this._bufferService.buffer,o=a.lines.get(e[1]);if(!o)return;let c=a.translateBufferLineToString(e[1],!1),f=this._convertViewportColToCharacterIndex(o,e[0]),p=f,h=e[0]-f,g=0,_=0,b=0,y=0;if(c.charAt(f)===" "){for(;f>0&&c.charAt(f-1)===" ";)f--;for(;p1&&(y+=Z-1,p+=Z-1);L>0&&f>0&&!this._isCharWordSeparator(o.loadCell(L-1,this._workCell));){o.loadCell(L-1,this._workCell);let I=this._workCell.getChars().length;this._workCell.getWidth()===0?(g++,L--):I>1&&(b+=I-1,f-=I-1),f--,L--}for(;M1&&(y+=I-1,p+=I-1),p++,M++}}p++;let x=f+h-g+b,k=Math.min(this._bufferService.cols,p-f+g+_-b-y);if(!(!t&&c.slice(f,p).trim()==="")){if(n&&x===0&&o.getCodePoint(0)!==32){let L=a.lines.get(e[1]-1);if(L&&o.isWrapped&&L.getCodePoint(this._bufferService.cols-1)!==32){let M=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(M){let Z=this._bufferService.cols-M.start;x-=Z,k+=Z}}}if(s&&x+k===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let L=a.lines.get(e[1]+1);if(L!=null&&L.isWrapped&&L.getCodePoint(0)!==32){let M=this._getWordAt([0,e[1]+1],!1,!1,!0);M&&(k+=M.length)}}return{start:x,length:k}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Dv(n,this._bufferService.cols)}};id=mt([pe(3,ui),pe(4,ns),pe(5,kd),pe(6,ci),pe(7,Fn),pe(8,In)],id);var Rv=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Mv=class{constructor(){this._color=new Rv,this._css=new Rv}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Rt=Object.freeze((()=>{let e=[ut.toColor("#2e3436"),ut.toColor("#cc0000"),ut.toColor("#4e9a06"),ut.toColor("#c4a000"),ut.toColor("#3465a4"),ut.toColor("#75507b"),ut.toColor("#06989a"),ut.toColor("#d3d7cf"),ut.toColor("#555753"),ut.toColor("#ef2929"),ut.toColor("#8ae234"),ut.toColor("#fce94f"),ut.toColor("#729fcf"),ut.toColor("#ad7fa8"),ut.toColor("#34e2e2"),ut.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],a=t[n/6%6|0],o=t[n%6];e.push({css:kt.toCss(s,a,o),rgba:kt.toRgba(s,a,o)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:kt.toCss(s,s,s),rgba:kt.toRgba(s,s,s)})}return e})()),Gr=ut.toColor("#ffffff"),ca=ut.toColor("#000000"),Bv=ut.toColor("#ffffff"),Nv=ca,ea={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},ZC=Gr,nd=class extends Be{constructor(e){super(),this._optionsService=e,this._contrastCache=new Mv,this._halfContrastCache=new Mv,this._onChangeColors=this._register(new he),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Gr,background:ca,cursor:Bv,cursorAccent:Nv,selectionForeground:void 0,selectionBackgroundTransparent:ea,selectionBackgroundOpaque:nt.blend(ca,ea),selectionInactiveBackgroundTransparent:ea,selectionInactiveBackgroundOpaque:nt.blend(ca,ea),scrollbarSliderBackground:nt.opacity(Gr,.2),scrollbarSliderHoverBackground:nt.opacity(Gr,.4),scrollbarSliderActiveBackground:nt.opacity(Gr,.5),overviewRulerBorder:Gr,ansi:Rt.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=$e(e.foreground,Gr),t.background=$e(e.background,ca),t.cursor=nt.blend(t.background,$e(e.cursor,Bv)),t.cursorAccent=nt.blend(t.background,$e(e.cursorAccent,Nv)),t.selectionBackgroundTransparent=$e(e.selectionBackground,ea),t.selectionBackgroundOpaque=nt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=$e(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=nt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?$e(e.selectionForeground,Ev):void 0,t.selectionForeground===Ev&&(t.selectionForeground=void 0),nt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=nt.opacity(t.selectionBackgroundTransparent,.3)),nt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=nt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=$e(e.scrollbarSliderBackground,nt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=$e(e.scrollbarSliderHoverBackground,nt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=$e(e.scrollbarSliderActiveBackground,nt.opacity(t.foreground,.5)),t.overviewRulerBorder=$e(e.overviewRulerBorder,ZC),t.ansi=Rt.slice(),t.ansi[0]=$e(e.black,Rt[0]),t.ansi[1]=$e(e.red,Rt[1]),t.ansi[2]=$e(e.green,Rt[2]),t.ansi[3]=$e(e.yellow,Rt[3]),t.ansi[4]=$e(e.blue,Rt[4]),t.ansi[5]=$e(e.magenta,Rt[5]),t.ansi[6]=$e(e.cyan,Rt[6]),t.ansi[7]=$e(e.white,Rt[7]),t.ansi[8]=$e(e.brightBlack,Rt[8]),t.ansi[9]=$e(e.brightRed,Rt[9]),t.ansi[10]=$e(e.brightGreen,Rt[10]),t.ansi[11]=$e(e.brightYellow,Rt[11]),t.ansi[12]=$e(e.brightBlue,Rt[12]),t.ansi[13]=$e(e.brightMagenta,Rt[13]),t.ansi[14]=$e(e.brightCyan,Rt[14]),t.ansi[15]=$e(e.brightWhite,Rt[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;so.index-c.index),s=[];for(let o of n){let c=this._services.get(o.id);if(!c)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);s.push(c)}let a=n.length>0?n[0].index:t.length;if(t.length!==a)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${a+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},e2={trace:0,debug:1,info:2,warn:3,error:4,off:5},t2="xterm.js: ",rd=class extends Be{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=e2[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;s--)this._array[this._getCyclicIndex(s+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;sthis._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let a=t-1;a>=0;a--)this.set(e+a+n,this.get(e+a));let s=e+t+n-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*Me+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Me+0]=t|2097152|n[2]<<22):this._data[t*Me+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Me+0]>>22}hasWidth(t){return this._data[t*Me+0]&12582912}getFg(t){return this._data[t*Me+1]}getBg(t){return this._data[t*Me+2]}hasContent(t){return this._data[t*Me+0]&4194303}getCodePoint(t){let n=this._data[t*Me+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Me+0]&2097152}getString(t){let n=this._data[t*Me+0];return n&2097152?this._combined[t]:n&2097151?br(n&2097151):""}isProtected(t){return this._data[t*Me+2]&536870912}loadCell(t,n){return eu=t*Me,n.content=this._data[eu+0],n.fg=this._data[eu+1],n.bg=this._data[eu+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*Me+0]=n.content,this._data[t*Me+1]=n.fg,this._data[t*Me+2]=n.bg}setCellFromCodepoint(t,n,s,a){a.bg&268435456&&(this._extendedAttrs[t]=a.extended),this._data[t*Me+0]=n|s<<22,this._data[t*Me+1]=a.fg,this._data[t*Me+2]=a.bg}addCodepointToCell(t,n,s){let a=this._data[t*Me+0];a&2097152?this._combined[t]+=br(n):a&2097151?(this._combined[t]=br(a&2097151)+br(n),a&=-2097152,a|=2097152):a=n|1<<22,s&&(a&=-12582913,a|=s<<22),this._data[t*Me+0]=a}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n=0;--o)this.setCell(t+n+o,this.loadCell(t+o,a));for(let o=0;othis.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let a=new Uint32Array(s);a.set(this._data),this._data=a}for(let a=this.length;a=t&&delete this._combined[f]}let o=Object.keys(this._extendedAttrs);for(let c=0;c=t&&delete this._extendedAttrs[f]}}return this.length=t,s*4*rf=0;--t)if(this._data[t*Me+0]&4194303)return t+(this._data[t*Me+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Me+0]&4194303||this._data[t*Me+2]&50331648)return t+(this._data[t*Me+0]>>22);return 0}copyCellsFrom(t,n,s,a,o){let c=t._data;if(o)for(let p=a-1;p>=0;p--){for(let h=0;h=n&&(this._combined[h-n+s]=t._combined[h])}}translateToString(t,n,s,a){n=n??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),a&&(a.length=0);let o="";for(;n>22||1}return a&&a.push(n),o}};function i2(e,t,n,s,a,o){let c=[];for(let f=0;f=f&&s0&&(L>_||g[L].getTrimmedLength()===0);L--)k++;k>0&&(c.push(f+g.length-k),c.push(k)),f+=g.length-1}return c}function n2(e,t){let n=[],s=0,a=t[s],o=0;for(let c=0;cba(e,h,t)).reduce((p,h)=>p+h),o=0,c=0,f=0;for(;fp&&(o-=p,c++);let h=e[c].getWidth(o-1)===2;h&&o--;let g=h?n-1:n;s.push(g),f+=g}return s}function ba(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,a=e[t+1].getWidth(0)===2;return s&&a?n-1:n}var Ub=class Ib{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Ib._nextId++,this._onDispose=this.register(new he),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),es(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Ub._nextId=1;var l2=Ub,Nt={},Zr=Nt.B;Nt[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Nt.A={"#":"£"};Nt.B=void 0;Nt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Nt.C=Nt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Nt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Nt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Nt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Nt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Nt.E=Nt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Nt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Nt.H=Nt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Nt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var zv=4294967295,Ov=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Ct.clone(),this.savedCharset=Zr,this.markers=[],this._nullCell=Ki.fromCharData([0,rb,1,0]),this._whitespaceCell=Ki.fromCharData([0,xr,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new gu,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Lv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new du),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new du),this._whitespaceCell}getBlankLine(e,t){return new ha(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&ezv?zv:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ct);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Lv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Ct),s=0,a=this._getCorrectBufferLength(t);if(a>this.lines.maxLength&&(this.lines.maxLength=a),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new ha(e,n)));else for(let c=this._rows;c>t;c--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(a0&&(this.lines.trimStart(c),this.ybase=Math.max(this.ybase-c,0),this.ydisp=Math.max(this.ydisp-c,0),this.savedY=Math.max(this.savedY-c,0)),this.lines.maxLength=a}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let o=0;o.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=i2(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ct),n);if(s.length>0){let a=n2(this.lines,s);r2(this.lines,a.layout),this._reflowLargerAdjustViewport(e,t,a.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(Ct),a=n;for(;a-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;c--){let f=this.lines.get(c);if(!f||!f.isWrapped&&f.getTrimmedLength()<=e)continue;let p=[f];for(;f.isWrapped&&c>0;)f=this.lines.get(--c),p.unshift(f);if(!n){let I=this.ybase+this.y;if(I>=c&&I0&&(a.push({start:c+p.length+o,newLines:y}),o+=y.length),p.push(...y);let x=g.length-1,k=g[x];k===0&&(x--,k=g[x]);let L=p.length-_-1,M=h;for(;L>=0;){let I=Math.min(M,k);if(p[x]===void 0)break;if(p[x].copyCellsFrom(p[L],M-I,k-I,I,!0),k-=I,k===0&&(x--,k=g[x]),M-=I,M===0){L--;let Q=Math.max(L,0);M=ba(p,Q,this._cols)}}for(let I=0;I0;)this.ybase===0?this.y0){let c=[],f=[];for(let k=0;k=0;k--)if(_&&_.start>h+b){for(let L=_.newLines.length-1;L>=0;L--)this.lines.set(k--,_.newLines[L]);k++,c.push({index:h+1,amount:_.newLines.length}),b+=_.newLines.length,_=a[++g]}else this.lines.set(k,f[h--]);let y=0;for(let k=c.length-1;k>=0;k--)c[k].index+=y,this.lines.onInsertEmitter.fire(c[k]),y+=c[k].amount;let x=Math.max(0,p+o-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(e,t,n=0,s){let a=this.lines.get(e);return a?a.translateToString(t,n,s):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+10;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.linen.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},a2=class extends Be{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new he),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new Ov(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Ov(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},Fb=2,qb=1,sd=class extends Be{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new he),this.onResize=this._onResize.event,this._onScroll=this._register(new he),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Fb),this.rows=Math.max(e.rawOptions.rows||0,qb),this.buffers=this._register(new a2(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=n.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let a=n.ybase+n.scrollTop,o=n.ybase+n.scrollBottom;if(n.scrollTop===0){let c=n.lines.isFull;o===n.lines.length-1?c?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(o+1,0,s.clone()),c?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let c=o-a+1;n.lines.shiftElements(a+1,c-1,-1),n.lines.set(o,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),s!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};sd=mt([pe(0,ci)],sd);var Ys={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:_u,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},o2=["normal","bold","100","200","300","400","500","600","700","800","900"],u2=class extends Be{constructor(e){super(),this._onOptionChange=this._register(new he),this.onOptionChange=this._onOptionChange.event;let t={...Ys};for(let n in e)if(n in t)try{let s=e[n];t[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(at(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in Ys))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in Ys))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Ys[e]),!c2(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Ys[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=o2.includes(t)?t:Ys[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function c2(e){return e==="block"||e==="underline"||e==="bar"}function fa(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let s in e)n[s]=t<=1?e[s]:e[s]&&fa(e[s],t-1);return n}var jv=Object.freeze({insertMode:!1}),Hv=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),ld=class extends Be{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new he),this.onData=this._onData.event,this._onUserInput=this._register(new he),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new he),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new he),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=fa(jv),this.decPrivateModes=fa(Hv)}reset(){this.modes=fa(jv),this.decPrivateModes=fa(Hv)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};ld=mt([pe(0,ui),pe(1,ub),pe(2,ci)],ld);var Pv={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function sf(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var lf=String.fromCharCode,Uv={DEFAULT:e=>{let t=[sf(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${lf(t[0])}${lf(t[1])}${lf(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${sf(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${sf(e,!0)};${e.x};${e.y}${t}`}},ad=class extends Be{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new he),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Pv))this.addProtocol(s,Pv[s]);for(let s of Object.keys(Uv))this.addEncoding(s,Uv[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let s=t/n,a=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(a/=s+0,Math.abs(e.deltaY)<50&&(a*=.3),this._wheelPartialScroll+=a,a=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(a*=this._bufferService.rows),a}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};ad=mt([pe(0,ui),pe(1,ns),pe(2,ci)],ad);var af=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],h2=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Mt;function f2(e,t){let n=0,s=t.length-1,a;if(et[s][1])return!1;for(;s>=n;)if(a=n+s>>1,e>t[a][1])n=a+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let a=Qr.extractWidth(t);a===0?s=!1:a>n&&(n=a)}return Qr.createPropertyValue(0,n,s)}},Qr=class cu{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new he,this.onChange=this._onChange.event;let t=new d2;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,s=!1){return(t&16777215)<<3|(n&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,s=0,a=t.length;for(let o=0;o=a)return n+this.wcwidth(c);let h=t.charCodeAt(o);56320<=h&&h<=57343?c=(c-55296)*1024+h-56320+65536:n+=this.wcwidth(h)}let f=this.charProperties(c,s),p=cu.extractWidth(f);cu.extractShouldJoin(f)&&(p-=cu.extractWidth(s)),n+=p,s=f}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},p2=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Iv(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var ta=2147483647,m2=256,Wb=class od{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>m2)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new od;if(!t.length)return n;for(let s=Array.isArray(t[0])?1:0;s>8,a=this._subParamsIdx[n]&255;a-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,a))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>ta?ta:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>ta?ta:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let t={};for(let n=0;n>8,a=this._subParamsIdx[n]&255;a-s>0&&(t[n]=this._subParams.slice(s,a))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,a=s[n-1];s[n-1]=~a?Math.min(a*10+t,ta):t}},ia=[],_2=class{constructor(){this._state=0,this._active=ia,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ia}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=ia,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ia,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",wu(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=ia,this._id=-1,this._state=0}}},Ri=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=wu(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},na=[],g2=class{constructor(){this._handlers=Object.create(null),this._active=na,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=na}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=na,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||na,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",wu(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=na,this._ident=0}},da=new Wb;da.addParam(0);var Fv=class{constructor(e){this._handler=e,this._data="",this._params=da,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():da,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=wu(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=da,this._data="",this._hitLimit=!1,n));return this._params=da,this._data="",this._hitLimit=!1,t}},v2=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let a=0;ap),n=(f,p)=>t.slice(f,p),s=n(32,127),a=n(0,24);a.push(25),a.push.apply(a,n(28,32));let o=n(0,14),c;e.setDefault(1,0),e.addMany(s,0,2,0);for(c in o)e.addMany([24,26,153,154],c,3,0),e.addMany(n(128,144),c,3,0),e.addMany(n(144,152),c,3,0),e.add(156,c,0,0),e.add(27,c,11,1),e.add(157,c,4,8),e.addMany([152,158,159],c,0,7),e.add(155,c,11,3),e.add(144,c,11,9);return e.addMany(a,0,3,0),e.addMany(a,1,3,1),e.add(127,1,0,1),e.addMany(a,8,0,8),e.addMany(a,3,3,3),e.add(127,3,0,3),e.addMany(a,4,3,4),e.add(127,4,0,4),e.addMany(a,6,3,6),e.addMany(a,5,3,5),e.add(127,5,0,5),e.addMany(a,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(a,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(a,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(a,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(a,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(a,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(a,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Yi,0,2,0),e.add(Yi,8,5,8),e.add(Yi,6,0,6),e.add(Yi,11,0,11),e.add(Yi,13,13,13),e})(),b2=class extends Be{constructor(e=y2){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Wb,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(at(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new _2),this._dcsParser=this._register(new g2),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let a=0;ao||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=s,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];return s.push(t),{dispose:()=>{let a=s.indexOf(t);a!==-1&&s.splice(a,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];return s.push(t),{dispose:()=>{let a=s.indexOf(t);a!==-1&&s.splice(a,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,s,a){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=a}parse(e,t,n){let s=0,a=0,o=0,c;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let f=this._parseStack.handlers,p=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&p>-1){for(;p>=0&&(c=f[p](this._params),c!==!0);p--)if(c instanceof Promise)return this._parseStack.handlerPos=p,c}this._parseStack.handlers=[];break;case 4:if(n===!1&&p>-1){for(;p>=0&&(c=f[p](),c!==!0);p--)if(c instanceof Promise)return this._parseStack.handlerPos=p,c}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],c=this._dcsParser.unhook(s!==24&&s!==26,n),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],c=this._oscParser.end(s!==24&&s!==26,n),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let f=o;f>4){case 2:for(let b=f+1;;++b){if(b>=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=0&&(c=p[h](this._params),c!==!0);h--)if(c instanceof Promise)return this._preserveStack(3,p,h,a,f),c;h<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++f47&&s<60);f--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let g=this._escHandlers[this._collect<<8|s],_=g?g.length-1:-1;for(;_>=0&&(c=g[_](),c!==!0);_--)if(c instanceof Promise)return this._preserveStack(4,g,_,a,f),c;_<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let b=f+1;;++b)if(b>=t||(s=e[b])===24||s===26||s===27||s>127&&s=t||(s=e[b])<32||s>127&&s>4:o>>8}return s}}function of(e,t){let n=e.toString(16),s=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function w2(e,t=16){let[n,s,a]=e;return`rgb:${of(n,t)}/${of(s,t)}/${of(a,t)}`}var C2={"(":0,")":1,"*":2,"+":3,"-":1,".":2},vr=131072,Wv=10;function Yv(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Vv=5e3,Kv=0,k2=class extends Be{constructor(e,t,n,s,a,o,c,f,p=new b2){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=a,this._oscLinkService=o,this._coreMouseService=c,this._unicodeService=f,this._parser=p,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Wx,this._utf8Decoder=new Yx,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ct.clone(),this._eraseAttrDataInternal=Ct.clone(),this._onRequestBell=this._register(new he),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new he),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new he),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new he),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new he),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new he),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new he),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new he),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new he),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new he),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new he),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new he),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new he),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new ud(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,g)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:g.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,g,_)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:g,data:_})}),this._parser.setDcsHandlerFallback((h,g,_)=>{g==="HOOK"&&(_=_.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:g,payload:_})}),this._parser.setPrintHandler((h,g,_)=>this.print(h,g,_)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler(se.BEL,()=>this.bell()),this._parser.setExecuteHandler(se.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(se.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(se.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(se.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(se.BS,()=>this.backspace()),this._parser.setExecuteHandler(se.HT,()=>this.tab()),this._parser.setExecuteHandler(se.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(se.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ou.IND,()=>this.index()),this._parser.setExecuteHandler(ou.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ou.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ri(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new Ri(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new Ri(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new Ri(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new Ri(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new Ri(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new Ri(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new Ri(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new Ri(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new Ri(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new Ri(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new Ri(h=>this.restoreCursorColor(h))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let h in Nt)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Fv((h,g)=>this.requestStatusString(h,g)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),Vv))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Vv} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,a=this._activeBuffer.y,o=0,c=this._parseStack.paused;if(c){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,a=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>vr&&(o=this._parseStack.position+vr)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(h=>h.charCodeAt(0)):e),this._parseBuffer.lengthvr)for(let h=o;h0&&_.getWidth(this._activeBuffer.x-1)===2&&_.setCellFromCodepoint(this._activeBuffer.x-1,0,1,g);let b=this._parser.precedingJoinState;for(let y=t;yf){if(p){let M=_,Z=this._activeBuffer.x-L;for(this._activeBuffer.x=L,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),_=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),L>0&&_ instanceof ha&&_.copyCellsFrom(M,Z,0,L,!1);Z=0;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,g);continue}if(h&&(_.insertCells(this._activeBuffer.x,a-L,this._activeBuffer.getNullCell(g)),_.getWidth(f-1)===2&&_.setCellFromCodepoint(f-1,0,1,g)),_.setCellFromCodepoint(this._activeBuffer.x++,s,a,g),a>0)for(;--a;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,g)}this._parser.precedingJoinState=b,this._activeBuffer.x0&&_.getWidth(this._activeBuffer.x)===0&&!_.hasContent(this._activeBuffer.x)&&_.setCellFromCodepoint(this._activeBuffer.x,0,1,g),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>Yv(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Fv(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ri(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,s=!1,a=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),a),s&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&s.getTrimmedLength()););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let a=this._activeBuffer.lines.length-this._bufferService.rows;a>0&&(this._activeBuffer.lines.trimStart(a),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-a,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-a,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y65535?2:1}let p=f;for(let h=1;h0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(se.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(se.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(se.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(se.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(se.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t(k[k.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",k[k.SET=1]="SET",k[k.RESET=2]="RESET",k[k.PERMANENTLY_SET=3]="PERMANENTLY_SET",k[k.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:a,activeEncoding:o}=this._coreMouseService,c=this._coreService,{buffers:f,cols:p}=this._bufferService,{active:h,alt:g}=f,_=this._optionsService.rawOptions,b=(k,L)=>(c.triggerDataEvent(`${se.ESC}[${t?"":"?"}${k};${L}$y`),!0),y=k=>k?1:2,x=e.params[0];return t?x===2?b(x,4):x===4?b(x,y(c.modes.insertMode)):x===12?b(x,3):x===20?b(x,y(_.convertEol)):b(x,0):x===1?b(x,y(s.applicationCursorKeys)):x===3?b(x,_.windowOptions.setWinLines?p===80?2:p===132?1:0:0):x===6?b(x,y(s.origin)):x===7?b(x,y(s.wraparound)):x===8?b(x,3):x===9?b(x,y(a==="X10")):x===12?b(x,y(_.cursorBlink)):x===25?b(x,y(!c.isCursorHidden)):x===45?b(x,y(s.reverseWraparound)):x===66?b(x,y(s.applicationKeypad)):x===67?b(x,4):x===1e3?b(x,y(a==="VT200")):x===1002?b(x,y(a==="DRAG")):x===1003?b(x,y(a==="ANY")):x===1004?b(x,y(s.sendFocus)):x===1005?b(x,4):x===1006?b(x,y(o==="SGR")):x===1015?b(x,4):x===1016?b(x,y(o==="SGR_PIXELS")):x===1048?b(x,1):x===47||x===1047||x===1049?b(x,y(h===g)):x===2004?b(x,y(s.bracketedPasteMode)):x===2026?b(x,y(s.synchronizedOutput)):b(x,0)}_updateAttrColor(e,t,n,s,a){return t===2?(e|=50331648,e&=-16777216,e|=Ca.fromColorRGB([n,s,a])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let s=[0,0,-1,0,0,0],a=0,o=0;do{if(s[o+a]=e.params[t+o],e.hasSubParams(t+o)){let c=e.getSubParams(t+o),f=0;do s[1]===5&&(a=1),s[o+f+1+a]=c[f];while(++f=2||s[1]===2&&o+a>=5)break;s[1]&&(a=1)}while(++o+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Ct.fg,e.bg=Ct.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,s=this._curAttrData;for(let a=0;a=30&&n<=37?(s.fg&=-50331904,s.fg|=16777216|n-30):n>=40&&n<=47?(s.bg&=-50331904,s.bg|=16777216|n-40):n>=90&&n<=97?(s.fg&=-50331904,s.fg|=16777216|n-90|8):n>=100&&n<=107?(s.bg&=-50331904,s.bg|=16777216|n-100|8):n===0?this._processSGR0(s):n===1?s.fg|=134217728:n===3?s.bg|=67108864:n===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(a)?e.getSubParams(a)[0]:1,s)):n===5?s.fg|=536870912:n===7?s.fg|=67108864:n===8?s.fg|=1073741824:n===9?s.fg|=2147483648:n===2?s.bg|=134217728:n===21?this._processUnderline(2,s):n===22?(s.fg&=-134217729,s.bg&=-134217729):n===23?s.bg&=-67108865:n===24?(s.fg&=-268435457,this._processUnderline(0,s)):n===25?s.fg&=-536870913:n===27?s.fg&=-67108865:n===28?s.fg&=-1073741825:n===29?s.fg&=2147483647:n===39?(s.fg&=-67108864,s.fg|=Ct.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=Ct.bg&16777215):n===38||n===48||n===58?a+=this._extractColor(e,a,s):n===53?s.bg|=1073741824:n===55?s.bg&=-1073741825:n===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):n===100?(s.fg&=-67108864,s.fg|=Ct.fg&16777215,s.bg&=-67108864,s.bg|=Ct.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${se.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${se.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${se.ESC}[?${t};${n}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Ct.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Yv(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${se.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Wv&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Wv&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let s=n.shift(),a=n.shift();if(/^\d+$/.exec(s)){let o=parseInt(s);if(Xv(o))if(a==="?")t.push({type:0,index:o});else{let c=qv(a);c&&t.push({type:1,index:o,color:c})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),s,a=n.findIndex(o=>o.startsWith("id="));return a!==-1&&(s=n[a].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let s=0;s=this._specialColors.length);++s,++t)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let a=qv(n[s]);a&&this._onColor.fire([{type:1,index:this._specialColors[t],color:a}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let s=0;s=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Ct.clone(),this._eraseAttrDataInternal=Ct.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Ki;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t(this._coreService.triggerDataEvent(`${se.ESC}${c}${se.ESC}\\`),!0),s=this._bufferService.buffer,a=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[a.cursorStyle]-(a.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},ud=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){ethis.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Kv=e,e=t,t=Kv),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};ud=mt([pe(0,ui)],ud);function Xv(e){return 0<=e&&e<256}var E2=5e7,$v=12,T2=50,A2=class extends Be{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new he),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>E2)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],a=this._action(s,t);if(a){let c=f=>performance.now()-n>=$v?setTimeout(()=>this._innerWrite(0,f)):this._innerWrite(n,f);a.catch(f=>(queueMicrotask(()=>{throw f}),Promise.resolve(!1))).then(c);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=$v)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>T2&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},cd=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let f=t.addMarker(t.ybase+t.y),p={data:e,id:this._nextId++,lines:[f]};return f.onDispose(()=>this._removeMarkerFromLink(p,f)),this._dataByLinkId.set(p.id,p),p.id}let n=e,s=this._getEntryIdKey(n),a=this._entriesWithId.get(s);if(a)return this.addLineToLink(a.id,t.ybase+t.y),a.id;let o=t.addMarker(t.ybase+t.y),c={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(c,o)),this._entriesWithId.set(c.key,c),this._dataByLinkId.set(c.id,c),c.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};cd=mt([pe(0,ui)],cd);var Gv=!1,D2=class extends Be{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Js),this._onBinary=this._register(new he),this.onBinary=this._onBinary.event,this._onData=this._register(new he),this.onData=this._onData.event,this._onLineFeed=this._register(new he),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new he),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new he),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new he),this._instantiationService=new JC,this.optionsService=this._register(new u2(e)),this._instantiationService.setService(ci,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(sd)),this._instantiationService.setService(ui,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(rd)),this._instantiationService.setService(ub,this._logService),this.coreService=this._register(this._instantiationService.createInstance(ld)),this._instantiationService.setService(ns,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(ad)),this._instantiationService.setService(ob,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Qr)),this._instantiationService.setService($x,this.unicodeService),this._charsetService=this._instantiationService.createInstance(p2),this._instantiationService.setService(Xx,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(cd),this._instantiationService.setService(cb,this._oscLinkService),this._inputHandler=this._register(new k2(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Jt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Jt.forward(this._bufferService.onResize,this._onResize)),this._register(Jt.forward(this.coreService.onData,this._onData)),this._register(Jt.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new A2((t,n)=>this._inputHandler.parse(t,n))),this._register(Jt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new he),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Gv&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Gv=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,Fb),t=Math.max(t,qb),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Iv.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Iv(this._bufferService),!1))),this._windowsWrappingHeuristics.value=at(()=>{for(let t of e)t.dispose()})}}},R2={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function M2(e,t,n,s){var c;let a={type:0,cancel:!1,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?a.key=se.ESC+"OA":a.key=se.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?a.key=se.ESC+"OD":a.key=se.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?a.key=se.ESC+"OC":a.key=se.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?a.key=se.ESC+"OB":a.key=se.ESC+"[B");break;case 8:a.key=e.ctrlKey?"\b":se.DEL,e.altKey&&(a.key=se.ESC+a.key);break;case 9:if(e.shiftKey){a.key=se.ESC+"[Z";break}a.key=se.HT,a.cancel=!0;break;case 13:a.key=e.altKey?se.ESC+se.CR:se.CR,a.cancel=!0;break;case 27:a.key=se.ESC,e.altKey&&(a.key=se.ESC+se.ESC),a.cancel=!0;break;case 37:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"D":t?a.key=se.ESC+"OD":a.key=se.ESC+"[D";break;case 39:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"C":t?a.key=se.ESC+"OC":a.key=se.ESC+"[C";break;case 38:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"A":t?a.key=se.ESC+"OA":a.key=se.ESC+"[A";break;case 40:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"B":t?a.key=se.ESC+"OB":a.key=se.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(a.key=se.ESC+"[2~");break;case 46:o?a.key=se.ESC+"[3;"+(o+1)+"~":a.key=se.ESC+"[3~";break;case 36:o?a.key=se.ESC+"[1;"+(o+1)+"H":t?a.key=se.ESC+"OH":a.key=se.ESC+"[H";break;case 35:o?a.key=se.ESC+"[1;"+(o+1)+"F":t?a.key=se.ESC+"OF":a.key=se.ESC+"[F";break;case 33:e.shiftKey?a.type=2:e.ctrlKey?a.key=se.ESC+"[5;"+(o+1)+"~":a.key=se.ESC+"[5~";break;case 34:e.shiftKey?a.type=3:e.ctrlKey?a.key=se.ESC+"[6;"+(o+1)+"~":a.key=se.ESC+"[6~";break;case 112:o?a.key=se.ESC+"[1;"+(o+1)+"P":a.key=se.ESC+"OP";break;case 113:o?a.key=se.ESC+"[1;"+(o+1)+"Q":a.key=se.ESC+"OQ";break;case 114:o?a.key=se.ESC+"[1;"+(o+1)+"R":a.key=se.ESC+"OR";break;case 115:o?a.key=se.ESC+"[1;"+(o+1)+"S":a.key=se.ESC+"OS";break;case 116:o?a.key=se.ESC+"[15;"+(o+1)+"~":a.key=se.ESC+"[15~";break;case 117:o?a.key=se.ESC+"[17;"+(o+1)+"~":a.key=se.ESC+"[17~";break;case 118:o?a.key=se.ESC+"[18;"+(o+1)+"~":a.key=se.ESC+"[18~";break;case 119:o?a.key=se.ESC+"[19;"+(o+1)+"~":a.key=se.ESC+"[19~";break;case 120:o?a.key=se.ESC+"[20;"+(o+1)+"~":a.key=se.ESC+"[20~";break;case 121:o?a.key=se.ESC+"[21;"+(o+1)+"~":a.key=se.ESC+"[21~";break;case 122:o?a.key=se.ESC+"[23;"+(o+1)+"~":a.key=se.ESC+"[23~";break;case 123:o?a.key=se.ESC+"[24;"+(o+1)+"~":a.key=se.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?a.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?a.key=se.NUL:e.keyCode>=51&&e.keyCode<=55?a.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?a.key=se.DEL:e.keyCode===219?a.key=se.ESC:e.keyCode===220?a.key=se.FS:e.keyCode===221&&(a.key=se.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let f=(c=R2[e.keyCode])==null?void 0:c[e.shiftKey?1:0];if(f)a.key=se.ESC+f;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,h=String.fromCharCode(p);e.shiftKey&&(h=h.toUpperCase()),a.key=se.ESC+h}else if(e.keyCode===32)a.key=se.ESC+(e.ctrlKey?se.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),a.key=se.ESC+p,a.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(a.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?a.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(a.key=se.US),e.key==="@"&&(a.key=se.NUL));break}return a}var vt=0,B2=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new gu,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new gu,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((a,o)=>this._getKey(a)-this._getKey(o)),t=0,n=0,s=new Array(this._array.length+this._insertedValues.length);for(let a=0;a=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(s[a]=e[t],t++):s[a]=this._array[n++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(vt=this._search(t),vt===-1)||this._getKey(this._array[vt])!==t)return!1;do if(this._array[vt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(vt),!0;while(++vta-o),t=0,n=new Array(this._array.length-e.length),s=0;for(let a=0;a0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(vt=this._search(e),!(vt<0||vt>=this._array.length)&&this._getKey(this._array[vt])===e))do yield this._array[vt];while(++vt=this._array.length)&&this._getKey(this._array[vt])===e))do t(this._array[vt]);while(++vt=t;){let s=t+n>>1,a=this._getKey(this._array[s]);if(a>e)n=s-1;else if(a0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},uf=0,Zv=0,N2=class extends Be{constructor(){super(),this._decorations=new B2(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new he),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new he),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(at(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new L2(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let s=0,a=0;for(let o of this._decorations.getKeyIterator(t))s=o.options.x??0,a=s+(o.options.width??1),e>=s&&e{uf=a.options.x??0,Zv=uf+(a.options.width??1),e>=uf&&e=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let a=s-this._lastRefreshMs,o=this._debounceThresholdMS-a;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Qv=20,vu=class extends Be{constructor(e,t,n,s){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let a=this._coreBrowserService.mainDocument;this._accessibilityContainer=a.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=a.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;othis._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=a.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new O2(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(` +`))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ee(a,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(at(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===` +`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Qv+1&&(this._liveRegion.textContent+=Rf.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,s=n.lines.length.toString();for(let a=e;a<=t;a++){let o=n.lines.get(n.ydisp+a),c=[],f=(o==null?void 0:o.translateToString(!0,void 0,void 0,c))||"",p=(n.ydisp+a+1).toString(),h=this._rowElements[a];h&&(f.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=f,this._rowColumns.set(h,c)),h.setAttribute("aria-posinset",p),h.setAttribute("aria-setsize",s),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],a=n.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(a===o||e.relatedTarget!==s)return;let c,f;if(t===0?(c=n,f=this._rowElements.pop(),this._rowContainer.removeChild(f)):(c=this._rowElements.shift(),f=n,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),f.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let p=this._createAccessibilityTreeNode();this._rowElements.unshift(p),this._rowContainer.insertAdjacentElement("afterbegin",p)}else{let p=this._createAccessibilityTreeNode();this._rowElements.push(p),this._rowContainer.appendChild(p)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var f;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:s,offset:((f=s.textContent)==null?void 0:f.length)??0}),!this._rowContainer.contains(n.node))return;let a=({node:p,offset:h})=>{let g=p instanceof Text?p.parentNode:p,_=parseInt(g==null?void 0:g.getAttribute("aria-posinset"),10)-1;if(isNaN(_))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(g);if(!b)return console.warn("columns is null. Race condition?"),null;let y=h=this._terminal.cols&&(++_,y=0),{row:_,column:y}},o=a(t),c=a(n);if(!(!o||!c)){if(o.row>c.row||o.row===c.row&&o.column>=c.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(c.row-o.row)*this._terminal.cols-o.column+c.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;te;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e{var o;es(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(o=this._activeProviderReplies)==null||o.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Ee(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ee(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ee(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ee(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let s=0;s{o==null||o.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[o,c]of this._linkProviderService.linkProviders.entries())t?(a=this._activeProviderReplies)!=null&&a.get(o)&&(n=this._checkLinkProviderResult(o,e,n)):c.provideLinks(e.y,f=>{var h,g;if(this._isMouseOut)return;let p=f==null?void 0:f.map(_=>({link:_}));(h=this._activeProviderReplies)==null||h.set(o,p),n=this._checkLinkProviderResult(o,e,n),((g=this._activeProviderReplies)==null?void 0:g.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;se?this._bufferService.cols:c.link.range.end.x;for(let h=f;h<=p;h++){if(n.has(h)){a.splice(o--,1);break}n.add(h)}}}}_checkLinkProviderResult(e,t,n){var o;if(!this._activeProviderReplies)return n;let s=this._activeProviderReplies.get(e),a=!1;for(let c=0;cthis._linkAtPosition(f.link,t));c&&(n=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let c=0;cthis._linkAtPosition(p.link,t));if(f){n=!0,this._handleNewLink(f);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&j2(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,es(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.pointerCursor},set:n=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.underline},set:n=>{var s,a,o;(s=this._currentLink)!=null&&s.state&&((o=(a=this._currentLink)==null?void 0:a.state)==null?void 0:o.decorations.underline)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let s=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,a=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=a&&(this._clearCurrentLink(s,a),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,s=this._bufferService.buffer.ydisp,a=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(a)}_linkLeave(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,a=t.y*this._bufferService.cols+t.x;return n<=a&&a<=s}_positionFromMouseEvent(e,t,n){let s=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,s,a){return{x1:e,y1:t,x2:n,y2:s,cols:this._bufferService.cols,fg:a}}};hd=mt([pe(1,kd),pe(2,Fn),pe(3,ui),pe(4,fb)],hd);function j2(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var H2=class extends D2{constructor(e={}){super(e),this._linkifier=this._register(new Js),this.browser=Mb,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Js),this._onCursorMove=this._register(new he),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new he),this.onKey=this._onKey.event,this._onRender=this._register(new he),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new he),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new he),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new he),this.onBell=this._onBell.event,this._onFocus=this._register(new he),this._onBlur=this._register(new he),this._onA11yCharEmitter=this._register(new he),this._onA11yTabEmitter=this._register(new he),this._onWillOpen=this._register(new he),this._setup(),this._decorationService=this._instantiationService.createInstance(N2),this._instantiationService.setService(ka,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(TC),this._instantiationService.setService(fb,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Bf)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Jt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Jt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Jt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Jt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(at(()=>{var t,n;this._customKeyEventHandler=void 0,(n=(t=this.element)==null?void 0:t.parentNode)==null||n.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,s="";switch(t.index){case 256:n="foreground",s="10";break;case 257:n="background",s="11";break;case 258:n="cursor",s="12";break;default:n="ansi",s="4;"+t.index}switch(t.type){case 0:let a=nt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${se.ESC}]${s};${w2(a)}${Db.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=kt.toColor(...t.color));else{let o=n;this._themeService.modifyColors(c=>c[o]=kt.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(vu,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(se.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(se.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,a=t.getWidth(n),o=this._renderService.dimensions.css.cell.width*a,c=this.buffer.y*this._renderService.dimensions.css.cell.height,f=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=f+"px",this.textarea.style.top=c+"px",this.textarea.style.width=o+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ee(this.element,"copy",t=>{this.hasSelection()&&Fx(t,this._selectionService)}));let e=t=>qx(t,this.textarea,this.coreService,this.optionsService);this._register(Ee(this.textarea,"paste",e)),this._register(Ee(this.element,"paste",e)),Bb?this._register(Ee(this.element,"mousedown",t=>{t.button===2&&ov(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ee(this.element,"contextmenu",t=>{ov(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Nd&&this._register(Ee(this.element,"auxclick",t=>{t.button===1&&nb(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ee(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ee(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ee(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ee(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ee(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ee(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ee(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var a;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((a=this.element)==null?void 0:a.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Ee(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Df.get()),zb||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(kC,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(In,this._coreBrowserService),this._register(Ee(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Ee(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Jf,this._document,this._helperContainer),this._instantiationService.setService(Cu,this._charSizeService),this._themeService=this._instantiationService.createInstance(nd),this._instantiationService.setService(tl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(mu),this._instantiationService.setService(hb,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(td,this.rows,this.screenElement)),this._instantiationService.setService(Fn,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Gf,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(ed),this._instantiationService.setService(kd,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(hd,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Xf,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(id,this.element,this.screenElement,s)),this._instantiationService.setService(Zx,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register(Jt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance($f,this.screenElement)),this._register(Ee(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(vu,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(pu,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(pu,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Qf,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(o){var h,g,_,b,y;let c=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!c)return!1;let f,p;switch(o.overrideType||o.type){case"mousemove":p=32,o.buttons===void 0?(f=3,o.button!==void 0&&(f=o.button<3?o.button:3)):f=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":p=0,f=o.button<3?o.button:3;break;case"mousedown":p=1,f=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let x=o.deltaY;if(x===0||e.coreMouseService.consumeWheelEvent(o,(b=(_=(g=(h=e._renderService)==null?void 0:h.dimensions)==null?void 0:g.device)==null?void 0:_.cell)==null?void 0:b.height,(y=e._coreBrowserService)==null?void 0:y.dpr)===0)return!1;p=x<0?0:1,f=4;break;default:return!1}return p===void 0||f===void 0||f>4?!1:e.coreMouseService.triggerMouseEvent({col:c.col,row:c.row,x:c.x,y:c.y,button:f,action:p,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:o=>(n(o),o.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(o)),wheel:o=>(n(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&n(o)},mousemove:o=>{o.buttons||n(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?s.mousemove||(t.addEventListener("mousemove",a.mousemove),s.mousemove=a.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),o&16?s.wheel||(t.addEventListener("wheel",a.wheel,{passive:!1}),s.wheel=a.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),o&2?s.mouseup||(s.mouseup=a.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),o&4?s.mousedrag||(s.mousedrag=a.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ee(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return n(o),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(o)})),this._register(Ee(t,"wheel",o=>{var c,f,p,h,g;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,(h=(p=(f=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:f.device)==null?void 0:p.cell)==null?void 0:h.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return this.cancel(o,!0);let _=se.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(_,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var n;(n=this._renderService)==null||n.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){ib(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var n;(n=this._selectionService)==null||n.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=M2(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let s=this.rows-1;return this.scrollLines(n.type===2?-s:s),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===se.ETX||n.key===se.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(P2(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var n;(n=this._charSizeService)==null||n.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Ki)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Jv=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new I2(t)}getNullCell(){return new Ki}},F2=class extends Be{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new he),this.onBufferChange=this._onBufferChange.event,this._normal=new Jv(this._core.buffers.normal,"normal"),this._alternate=new Jv(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},q2=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,s)=>t(n,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},W2=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},Y2=["cols","rows"],an=0,V2=class extends Be{constructor(e){super(),this._core=this._register(new H2(e)),this._addonManager=this._register(new U2),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],n=(s,a)=>{this._checkReadonlyOptions(s),this._core.options[s]=a};for(let s in this._core.options){let a={get:t.bind(this,s),set:n.bind(this,s)};Object.defineProperty(this._publicOptions,s,a)}}_checkReadonlyOptions(e){if(Y2.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new q2(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new W2(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new F2(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Df.get()},set promptLabel(e){Df.set(e)},get tooMuchOutput(){return Rf.get()},set tooMuchOutput(e){Rf.set(e)}}}_verifyIntegers(...e){for(an of e)if(an===1/0||isNaN(an)||an%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(an of e)if(an&&(an===1/0||isNaN(an)||an%1!==0||an<0))throw new Error("This API only accepts positive integers")}};/** * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. * @license MIT @@ -83,7 +83,7 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t * Fabrice Bellard's javascript vt100 for jslinux: * http://bellard.org/jslinux/ * Copyright (c) 2011 Fabrice Bellard - */var K2=2,X2=1,G2=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var _;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((_=this._terminal.options.overviewRuler)==null?void 0:_.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),a=Math.max(0,parseInt(n.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),c={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},f=c.top+c.bottom,p=c.right+c.left,h=s-f,g=a-p-t;return{cols:Math.max(K2,Math.floor(g/e.css.cell.width)),rows:Math.max(X2,Math.floor(h/e.css.cell.height))}}};/** + */var K2=2,X2=1,$2=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var _;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((_=this._terminal.options.overviewRuler)==null?void 0:_.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),a=Math.max(0,parseInt(n.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),c={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},f=c.top+c.bottom,p=c.right+c.left,h=s-f,g=a-p-t;return{cols:Math.max(K2,Math.floor(g/e.css.cell.width)),rows:Math.max(X2,Math.floor(h/e.css.cell.height))}}};/** * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. * @license MIT * @@ -94,37 +94,37 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t * Fabrice Bellard's javascript vt100 for jslinux: * http://bellard.org/jslinux/ * Copyright (c) 2011 Fabrice Bellard - */var Ut=0,It=0,Ft=0,dt=0,ii;(e=>{function t(a,o,c,f){return f!==void 0?`#${Kr(a)}${Kr(o)}${Kr(c)}${Kr(f)}`:`#${Kr(a)}${Kr(o)}${Kr(c)}`}e.toCss=t;function n(a,o,c,f=255){return(a<<24|o<<16|c<<8|f)>>>0}e.toRgba=n;function s(a,o,c,f){return{css:e.toCss(a,o,c,f),rgba:e.toRgba(a,o,c,f)}}e.toColor=s})(ii||(ii={}));var $2;(e=>{function t(p,h){if(dt=(h.rgba&255)/255,dt===1)return{css:h.css,rgba:h.rgba};let g=h.rgba>>24&255,_=h.rgba>>16&255,b=h.rgba>>8&255,y=p.rgba>>24&255,x=p.rgba>>16&255,k=p.rgba>>8&255;Ut=y+Math.round((g-y)*dt),It=x+Math.round((_-x)*dt),Ft=k+Math.round((b-k)*dt);let L=ii.toCss(Ut,It,Ft),M=ii.toRgba(Ut,It,Ft);return{css:L,rgba:M}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,h,g){let _=hu.ensureContrastRatio(p.rgba,h.rgba,g);if(_)return ii.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function a(p){let h=(p.rgba|255)>>>0;return[Ut,It,Ft]=hu.toChannels(h),{css:ii.toCss(Ut,It,Ft),rgba:h}}e.opaque=a;function o(p,h){return dt=Math.round(h*255),[Ut,It,Ft]=hu.toChannels(p.rgba),{css:ii.toCss(Ut,It,Ft,dt),rgba:ii.toRgba(Ut,It,Ft,dt)}}e.opacity=o;function c(p,h){return dt=p.rgba&255,o(p,dt*h/255)}e.multiplyOpacity=c;function f(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=f})($2||($2={}));var Zt;(e=>{let t,n;try{let a=document.createElement("canvas");a.width=1,a.height=1;let o=a.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return Ut=parseInt(a.slice(1,2).repeat(2),16),It=parseInt(a.slice(2,3).repeat(2),16),Ft=parseInt(a.slice(3,4).repeat(2),16),ii.toColor(Ut,It,Ft);case 5:return Ut=parseInt(a.slice(1,2).repeat(2),16),It=parseInt(a.slice(2,3).repeat(2),16),Ft=parseInt(a.slice(3,4).repeat(2),16),dt=parseInt(a.slice(4,5).repeat(2),16),ii.toColor(Ut,It,Ft,dt);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let o=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Ut=parseInt(o[1]),It=parseInt(o[2]),Ft=parseInt(o[3]),dt=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),ii.toColor(Ut,It,Ft,dt);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ut,It,Ft,dt]=t.getImageData(0,0,1,1).data,dt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ii.toRgba(Ut,It,Ft,dt),css:a}}e.toColor=s})(Zt||(Zt={}));var ai;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,a,o){let c=s/255,f=a/255,p=o/255,h=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),_=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return h*.2126+g*.7152+_*.0722}e.relativeLuminance2=n})(ai||(ai={}));var hu;(e=>{function t(c,f){if(dt=(f&255)/255,dt===1)return f;let p=f>>24&255,h=f>>16&255,g=f>>8&255,_=c>>24&255,b=c>>16&255,y=c>>8&255;return Ut=_+Math.round((p-_)*dt),It=b+Math.round((h-b)*dt),Ft=y+Math.round((g-y)*dt),ii.toRgba(Ut,It,Ft)}e.blend=t;function n(c,f,p){let h=ai.relativeLuminance(c>>8),g=ai.relativeLuminance(f>>8);if(Hn(h,g)>8));if(x>8));return x>L?y:k}return y}let _=a(c,f,p),b=Hn(h,ai.relativeLuminance(_>>8));if(b>8));return b>x?_:y}return _}}e.ensureContrastRatio=n;function s(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=Hn(ai.relativeLuminance2(b,y,x),ai.relativeLuminance2(h,g,_));for(;k0||y>0||x>0);)b-=Math.max(0,Math.ceil(b*.1)),y-=Math.max(0,Math.ceil(y*.1)),x-=Math.max(0,Math.ceil(x*.1)),k=Hn(ai.relativeLuminance2(b,y,x),ai.relativeLuminance2(h,g,_));return(b<<24|y<<16|x<<8|255)>>>0}e.reduceLuminance=s;function a(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=Hn(ai.relativeLuminance2(b,y,x),ai.relativeLuminance2(h,g,_));for(;k>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(hu||(hu={}));function Kr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Hn(e,t){return e{let e=[Zt.toColor("#2e3436"),Zt.toColor("#cc0000"),Zt.toColor("#4e9a06"),Zt.toColor("#c4a000"),Zt.toColor("#3465a4"),Zt.toColor("#75507b"),Zt.toColor("#06989a"),Zt.toColor("#d3d7cf"),Zt.toColor("#555753"),Zt.toColor("#ef2929"),Zt.toColor("#8ae234"),Zt.toColor("#fce94f"),Zt.toColor("#729fcf"),Zt.toColor("#ad7fa8"),Zt.toColor("#34e2e2"),Zt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],a=t[n/6%6|0],o=t[n%6];e.push({css:ii.toCss(s,a,o),rgba:ii.toRgba(s,a,o)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:ii.toCss(s,s,s),rgba:ii.toRgba(s,s,s)})}return e})());function ey(e,t,n){return Math.max(t,Math.min(e,n))}function Q2(e){switch(e){case"&":return"&";case"<":return"<"}return e}var Yb=class{constructor(e){this._buffer=e}serialize(e,t){let n=this._buffer.getNullCell(),s=this._buffer.getNullCell(),a=n,o=e.start.y,c=e.end.y,f=e.start.x,p=e.end.x;this._beforeSerialize(c-o,o,c);for(let h=o;h<=c;h++){let g=this._buffer.getLine(h);if(g){let _=h===e.start.y?f:0,b=h===e.end.y?p:g.length;for(let y=_;y0&&!Pn(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let n="";if(!t){e-this._firstRow>=this._terminal.rows&&((s=this._buffer.getLine(this._cursorStyleRow))==null||s.getCell(this._cursorStyleCol,this._backgroundCell));let a=this._buffer.getLine(e),o=this._buffer.getLine(e+1);if(!o.isWrapped)n=`\r -`,this._lastCursorRow=e+1,this._lastCursorCol=0;else{n="";let c=a.getCell(a.length-1,this._thisRowLastChar),f=a.getCell(a.length-2,this._thisRowLastSecondChar),p=o.getCell(0,this._nextRowFirstChar),h=p.getWidth()>1,g=!1;(p.getChars()&&h?this._nullCellCount<=1:this._nullCellCount<=0)&&((c.getChars()||c.getWidth()===0)&&Pn(c,p)&&(g=!0),h&&(f.getChars()||f.getWidth()===0)&&Pn(c,p)&&Pn(f,p)&&(g=!0)),g||(n="-".repeat(this._nullCellCount+1),n+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(n+="\x1B[A",n+=`\x1B[${a.length-this._nullCellCount}C`,n+=`\x1B[${this._nullCellCount}X`,n+=`\x1B[${a.length-this._nullCellCount}D`,n+="\x1B[B"),this._lastContentCursorRow=e+1,this._lastContentCursorCol=0,this._lastCursorRow=e+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=n,this._currentRow="",this._nullCellCount=0}_diffStyle(e,t){let n=[],s=!Vb(e,t),a=!Pn(e,t),o=!Kb(e,t);if(s||a||o)if(e.isAttributeDefault())t.isAttributeDefault()||n.push(0);else{if(s){let c=e.getFgColor();e.isFgRGB()?n.push(38,2,c>>>16&255,c>>>8&255,c&255):e.isFgPalette()?c>=16?n.push(38,5,c):n.push(c&8?90+(c&7):30+(c&7)):n.push(39)}if(a){let c=e.getBgColor();e.isBgRGB()?n.push(48,2,c>>>16&255,c>>>8&255,c&255):e.isBgPalette()?c>=16?n.push(48,5,c):n.push(c&8?100+(c&7):40+(c&7)):n.push(49)}o&&(e.isInverse()!==t.isInverse()&&n.push(e.isInverse()?7:27),e.isBold()!==t.isBold()&&n.push(e.isBold()?1:22),e.isUnderline()!==t.isUnderline()&&n.push(e.isUnderline()?4:24),e.isOverline()!==t.isOverline()&&n.push(e.isOverline()?53:55),e.isBlink()!==t.isBlink()&&n.push(e.isBlink()?5:25),e.isInvisible()!==t.isInvisible()&&n.push(e.isInvisible()?8:28),e.isItalic()!==t.isItalic()&&n.push(e.isItalic()?3:23),e.isDim()!==t.isDim()&&n.push(e.isDim()?2:22),e.isStrikethrough()!==t.isStrikethrough()&&n.push(e.isStrikethrough()?9:29))}return n}_nextCell(e,t,n,s){if(e.getWidth()===0)return;let a=e.getChars()==="",o=this._diffStyle(e,this._cursorStyle);if(a?!Pn(this._cursorStyle,e):o.length>0){this._nullCellCount>0&&(Pn(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=s,this._currentRow+=`\x1B[${o.join(";")}m`;let c=this._buffer.getLine(n);c!==void 0&&(c.getCell(s,this._cursorStyle),this._cursorStyleRow=n,this._cursorStyleCol=s)}a?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(Pn(this._cursorStyle,this._backgroundCell)?this._currentRow+=`\x1B[${this._nullCellCount}C`:(this._currentRow+=`\x1B[${this._nullCellCount}X`,this._currentRow+=`\x1B[${this._nullCellCount}C`),this._nullCellCount=0),this._currentRow+=e.getChars(),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=s+e.getWidth())}_serializeString(e){let t=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(t=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let n="";for(let o=0;o{h>0?n+=`\x1B[${h}C`:h<0&&(n+=`\x1B[${-h}D`)};f&&((h=>{h>0?n+=`\x1B[${h}B`:h<0&&(n+=`\x1B[${-h}A`)})(o-this._lastCursorRow),p(c-this._lastCursorCol))}let s=this._terminal._core._inputHandler._curAttrData,a=this._diffStyle(s,this._cursorStyle);return a.length>0&&(n+=`\x1B[${a.join(";")}m`),n}},ek=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,n){let s=t.length,a=n===void 0?s:ey(n+e.rows,0,s);return this._serializeBufferByRange(e,t,{start:s-a,end:s-1},!1)}_serializeBufferByRange(e,t,n,s){return new J2(t,e).serialize({start:{x:0,y:typeof n.start=="number"?n.start:n.start.line},end:{x:e.cols,y:typeof n.end=="number"?n.end:n.end.line}},s)}_serializeBufferAsHTML(e,t){var f;let n=e.buffer.active,s=new tk(n,e,t),a=t.onlySelection??!1,o=t.range;if(o)return s.serialize({start:{x:o.startCol,y:(o.startLine,o.startLine)},end:{x:e.cols,y:(o.endLine,o.endLine)}});if(!a){let p=n.length,h=t.scrollback,g=h===void 0?p:ey(h+e.rows,0,p);return s.serialize({start:{x:0,y:p-g},end:{x:e.cols,y:p-1}})}let c=(f=this._terminal)==null?void 0:f.getSelectionPosition();return c!==void 0?s.serialize({start:{x:c.start.x,y:c.start.y},end:{x:c.end.x,y:c.end.y}}):""}_serializeModes(e){let t="",n=e.modes;if(n.applicationCursorKeysMode&&(t+="\x1B[?1h"),n.applicationKeypadMode&&(t+="\x1B[?66h"),n.bracketedPasteMode&&(t+="\x1B[?2004h"),n.insertMode&&(t+="\x1B[4h"),n.originMode&&(t+="\x1B[?6h"),n.reverseWraparoundMode&&(t+="\x1B[?45h"),n.sendFocusMode&&(t+="\x1B[?1004h"),n.wraparoundMode===!1&&(t+="\x1B[?7l"),n.mouseTrackingMode!=="none")switch(n.mouseTrackingMode){case"x10":t+="\x1B[?9h";break;case"vt200":t+="\x1B[?1000h";break;case"drag":t+="\x1B[?1002h";break;case"any":t+="\x1B[?1003h";break}return t}serialize(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let t=e!=null&&e.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,e.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,e==null?void 0:e.scrollback);if(!(e!=null&&e.excludeAltBuffer)&&this._terminal.buffer.active.type==="alternate"){let n=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);t+=`\x1B[?1049h\x1B[H${n}`}return e!=null&&e.excludeModes||(t+=this._serializeModes(this._terminal)),t}serializeAsHTML(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,e||{})}dispose(){}},tk=class extends Yb{constructor(e,t,n){super(e),this._terminal=t,this._options=n,this._currentRow="",this._htmlContent="",t._core._themeService?this._ansiColors=t._core._themeService.colors.ansi:this._ansiColors=Z2}_padStart(e,t,n){return t=t>>0,n=n??" ",e.length>t?e:(t-=e.length,t>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}_beforeSerialize(e,t,n){var c,f;this._htmlContent+="
";let s="#000000",a="#ffffff";(this._options.includeGlobalBackground??!1)&&(s=((c=this._terminal.options.theme)==null?void 0:c.foreground)??"#ffffff",a=((f=this._terminal.options.theme)==null?void 0:f.background)??"#000000");let o=[];o.push("color: "+s+";"),o.push("background-color: "+a+";"),o.push("font-family: "+this._terminal.options.fontFamily+";"),o.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="
"}_afterSerialize(){this._htmlContent+="
",this._htmlContent+="
"}_rowEnd(e,t){this._htmlContent+="
"+this._currentRow+"
",this._currentRow=""}_getHexColor(e,t){let n=t?e.getFgColor():e.getBgColor();if(t?e.isFgRGB():e.isBgRGB())return"#"+[n>>16&255,n>>8&255,n&255].map(s=>this._padStart(s.toString(16),2,"0")).join("");if(t?e.isFgPalette():e.isBgPalette())return this._ansiColors[n].css}_diffStyle(e,t){let n=[],s=!Vb(e,t),a=!Pn(e,t),o=!Kb(e,t);if(s||a||o){let c=this._getHexColor(e,!0);c&&n.push("color: "+c+";");let f=this._getHexColor(e,!1);return f&&n.push("background-color: "+f+";"),e.isInverse()&&n.push("color: #000000; background-color: #BFBFBF;"),e.isBold()&&n.push("font-weight: bold;"),e.isUnderline()&&e.isOverline()?n.push("text-decoration: overline underline;"):e.isUnderline()?n.push("text-decoration: underline;"):e.isOverline()&&n.push("text-decoration: overline;"),e.isBlink()&&n.push("text-decoration: blink;"),e.isInvisible()&&n.push("visibility: hidden;"),e.isItalic()&&n.push("font-style: italic;"),e.isDim()&&n.push("opacity: 0.5;"),e.isStrikethrough()&&n.push("text-decoration: line-through;"),n}}_nextCell(e,t,n,s){if(e.getWidth()===0)return;let a=e.getChars()==="",o=this._diffStyle(e,t);o&&(this._currentRow+=o.length===0?"
":""),a?this._currentRow+=" ":this._currentRow+=Q2(e.getChars())}_serializeString(){return this._htmlContent}};const ik={background:"#F0EBE1",foreground:"#2C1810",cursor:"#8B4513",cursorAccent:"#F0EBE1",selectionBackground:"#D4C5B0",selectionForeground:"#2C1810",black:"#2C1810",red:"#A63D40",green:"#4A7A4A",yellow:"#8B6914",blue:"#4A6FA5",magenta:"#7B4B8A",cyan:"#3D7A7A",white:"#E6DDD0",brightBlack:"#8B7355",brightRed:"#B85C5C",brightGreen:"#5A8A5A",brightYellow:"#A07D1C",brightBlue:"#5A82BA",brightMagenta:"#8E5D9F",brightCyan:"#5A8F8F",brightWhite:"#4A3728"},nk="plotlink-terminal",rk=1,Cr="scrollback",ty=10*1024*1024;function Ld(){return new Promise((e,t)=>{const n=indexedDB.open(nk,rk);n.onupgradeneeded=()=>{const s=n.result;s.objectStoreNames.contains(Cr)||s.createObjectStore(Cr)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function ia(e,t){const n=t.length>ty?t.slice(-ty):t,s=await Ld();return new Promise((a,o)=>{const c=s.transaction(Cr,"readwrite");c.objectStore(Cr).put(n,e),c.oncomplete=()=>{s.close(),a()},c.onerror=()=>{s.close(),o(c.error)}})}async function sk(e){const t=await Ld();return new Promise((n,s)=>{const o=t.transaction(Cr,"readonly").objectStore(Cr).get(e);o.onsuccess=()=>{t.close(),n(o.result??null)},o.onerror=()=>{t.close(),s(o.error)}})}async function iy(e){const t=await Ld();return new Promise((n,s)=>{const a=t.transaction(Cr,"readwrite");a.objectStore(Cr).delete(e),a.oncomplete=()=>{t.close(),n()},a.onerror=()=>{t.close(),s(a.error)}})}const Bt=new Map;function lk({token:e,storyName:t,authFetch:n,onSelectStory:s,onDestroySession:a,onArchiveStory:o,confirmedStories:c,renameRef:f}){const p=$.useRef(null),h=$.useRef(n),[g,_]=$.useState([]),[b,y]=$.useState(new Set),[x,k]=$.useState(null),[L,M]=$.useState(null),Z=$.useRef(()=>{});$.useEffect(()=>{h.current=n},[n]);const I=$.useCallback(B=>{var R;const{width:A}=B.container.getBoundingClientRect();if(!(A<50))try{B.fit.fit(),((R=B.ws)==null?void 0:R.readyState)===WebSocket.OPEN&&B.ws.send(JSON.stringify({type:"resize",cols:B.term.cols,rows:B.term.rows}))}catch{}},[]),Q=$.useCallback(B=>{for(const[A,R]of Bt)R.container.style.display=A===B?"block":"none";if(B){const A=Bt.get(B);A&&setTimeout(()=>I(A),50)}},[I]),W=$.useCallback((B,A,R)=>{const T=window.location.protocol==="https:"?"wss:":"ws:",j=new WebSocket(`${T}//${window.location.host}/ws/terminal?story=${encodeURIComponent(B)}&token=${e}&resume=${R}`);j.onopen=()=>{A.connected=!0,A._retried=!1,y(H=>{const oe=new Set(H);return oe.delete(B),oe}),j.send(JSON.stringify({type:"resize",cols:A.term.cols,rows:A.term.rows}))},j.onmessage=H=>{A.term.write(H.data)},j.onclose=H=>{if(A.connected=!1,A.ws===j){A.ws=null;try{const oe=A.serialize.serialize();ia(B,oe).catch(()=>{})}catch{}if(H.code===4e3&&!A._retried){A._retried=!0,A.term.write(`\r + */var Ut=0,It=0,Ft=0,pt=0,ii;(e=>{function t(a,o,c,f){return f!==void 0?`#${Kr(a)}${Kr(o)}${Kr(c)}${Kr(f)}`:`#${Kr(a)}${Kr(o)}${Kr(c)}`}e.toCss=t;function n(a,o,c,f=255){return(a<<24|o<<16|c<<8|f)>>>0}e.toRgba=n;function s(a,o,c,f){return{css:e.toCss(a,o,c,f),rgba:e.toRgba(a,o,c,f)}}e.toColor=s})(ii||(ii={}));var G2;(e=>{function t(p,h){if(pt=(h.rgba&255)/255,pt===1)return{css:h.css,rgba:h.rgba};let g=h.rgba>>24&255,_=h.rgba>>16&255,b=h.rgba>>8&255,y=p.rgba>>24&255,x=p.rgba>>16&255,k=p.rgba>>8&255;Ut=y+Math.round((g-y)*pt),It=x+Math.round((_-x)*pt),Ft=k+Math.round((b-k)*pt);let L=ii.toCss(Ut,It,Ft),M=ii.toRgba(Ut,It,Ft);return{css:L,rgba:M}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,h,g){let _=hu.ensureContrastRatio(p.rgba,h.rgba,g);if(_)return ii.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function a(p){let h=(p.rgba|255)>>>0;return[Ut,It,Ft]=hu.toChannels(h),{css:ii.toCss(Ut,It,Ft),rgba:h}}e.opaque=a;function o(p,h){return pt=Math.round(h*255),[Ut,It,Ft]=hu.toChannels(p.rgba),{css:ii.toCss(Ut,It,Ft,pt),rgba:ii.toRgba(Ut,It,Ft,pt)}}e.opacity=o;function c(p,h){return pt=p.rgba&255,o(p,pt*h/255)}e.multiplyOpacity=c;function f(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=f})(G2||(G2={}));var Zt;(e=>{let t,n;try{let a=document.createElement("canvas");a.width=1,a.height=1;let o=a.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return Ut=parseInt(a.slice(1,2).repeat(2),16),It=parseInt(a.slice(2,3).repeat(2),16),Ft=parseInt(a.slice(3,4).repeat(2),16),ii.toColor(Ut,It,Ft);case 5:return Ut=parseInt(a.slice(1,2).repeat(2),16),It=parseInt(a.slice(2,3).repeat(2),16),Ft=parseInt(a.slice(3,4).repeat(2),16),pt=parseInt(a.slice(4,5).repeat(2),16),ii.toColor(Ut,It,Ft,pt);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let o=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Ut=parseInt(o[1]),It=parseInt(o[2]),Ft=parseInt(o[3]),pt=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),ii.toColor(Ut,It,Ft,pt);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ut,It,Ft,pt]=t.getImageData(0,0,1,1).data,pt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ii.toRgba(Ut,It,Ft,pt),css:a}}e.toColor=s})(Zt||(Zt={}));var ai;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,a,o){let c=s/255,f=a/255,p=o/255,h=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),_=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return h*.2126+g*.7152+_*.0722}e.relativeLuminance2=n})(ai||(ai={}));var hu;(e=>{function t(c,f){if(pt=(f&255)/255,pt===1)return f;let p=f>>24&255,h=f>>16&255,g=f>>8&255,_=c>>24&255,b=c>>16&255,y=c>>8&255;return Ut=_+Math.round((p-_)*pt),It=b+Math.round((h-b)*pt),Ft=y+Math.round((g-y)*pt),ii.toRgba(Ut,It,Ft)}e.blend=t;function n(c,f,p){let h=ai.relativeLuminance(c>>8),g=ai.relativeLuminance(f>>8);if(Hn(h,g)>8));if(x>8));return x>L?y:k}return y}let _=a(c,f,p),b=Hn(h,ai.relativeLuminance(_>>8));if(b>8));return b>x?_:y}return _}}e.ensureContrastRatio=n;function s(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=Hn(ai.relativeLuminance2(b,y,x),ai.relativeLuminance2(h,g,_));for(;k0||y>0||x>0);)b-=Math.max(0,Math.ceil(b*.1)),y-=Math.max(0,Math.ceil(y*.1)),x-=Math.max(0,Math.ceil(x*.1)),k=Hn(ai.relativeLuminance2(b,y,x),ai.relativeLuminance2(h,g,_));return(b<<24|y<<16|x<<8|255)>>>0}e.reduceLuminance=s;function a(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=Hn(ai.relativeLuminance2(b,y,x),ai.relativeLuminance2(h,g,_));for(;k>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(hu||(hu={}));function Kr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Hn(e,t){return e{let e=[Zt.toColor("#2e3436"),Zt.toColor("#cc0000"),Zt.toColor("#4e9a06"),Zt.toColor("#c4a000"),Zt.toColor("#3465a4"),Zt.toColor("#75507b"),Zt.toColor("#06989a"),Zt.toColor("#d3d7cf"),Zt.toColor("#555753"),Zt.toColor("#ef2929"),Zt.toColor("#8ae234"),Zt.toColor("#fce94f"),Zt.toColor("#729fcf"),Zt.toColor("#ad7fa8"),Zt.toColor("#34e2e2"),Zt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],a=t[n/6%6|0],o=t[n%6];e.push({css:ii.toCss(s,a,o),rgba:ii.toRgba(s,a,o)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:ii.toCss(s,s,s),rgba:ii.toRgba(s,s,s)})}return e})());function ey(e,t,n){return Math.max(t,Math.min(e,n))}function Q2(e){switch(e){case"&":return"&";case"<":return"<"}return e}var Yb=class{constructor(e){this._buffer=e}serialize(e,t){let n=this._buffer.getNullCell(),s=this._buffer.getNullCell(),a=n,o=e.start.y,c=e.end.y,f=e.start.x,p=e.end.x;this._beforeSerialize(c-o,o,c);for(let h=o;h<=c;h++){let g=this._buffer.getLine(h);if(g){let _=h===e.start.y?f:0,b=h===e.end.y?p:g.length;for(let y=_;y0&&!Pn(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let n="";if(!t){e-this._firstRow>=this._terminal.rows&&((s=this._buffer.getLine(this._cursorStyleRow))==null||s.getCell(this._cursorStyleCol,this._backgroundCell));let a=this._buffer.getLine(e),o=this._buffer.getLine(e+1);if(!o.isWrapped)n=`\r +`,this._lastCursorRow=e+1,this._lastCursorCol=0;else{n="";let c=a.getCell(a.length-1,this._thisRowLastChar),f=a.getCell(a.length-2,this._thisRowLastSecondChar),p=o.getCell(0,this._nextRowFirstChar),h=p.getWidth()>1,g=!1;(p.getChars()&&h?this._nullCellCount<=1:this._nullCellCount<=0)&&((c.getChars()||c.getWidth()===0)&&Pn(c,p)&&(g=!0),h&&(f.getChars()||f.getWidth()===0)&&Pn(c,p)&&Pn(f,p)&&(g=!0)),g||(n="-".repeat(this._nullCellCount+1),n+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(n+="\x1B[A",n+=`\x1B[${a.length-this._nullCellCount}C`,n+=`\x1B[${this._nullCellCount}X`,n+=`\x1B[${a.length-this._nullCellCount}D`,n+="\x1B[B"),this._lastContentCursorRow=e+1,this._lastContentCursorCol=0,this._lastCursorRow=e+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=n,this._currentRow="",this._nullCellCount=0}_diffStyle(e,t){let n=[],s=!Vb(e,t),a=!Pn(e,t),o=!Kb(e,t);if(s||a||o)if(e.isAttributeDefault())t.isAttributeDefault()||n.push(0);else{if(s){let c=e.getFgColor();e.isFgRGB()?n.push(38,2,c>>>16&255,c>>>8&255,c&255):e.isFgPalette()?c>=16?n.push(38,5,c):n.push(c&8?90+(c&7):30+(c&7)):n.push(39)}if(a){let c=e.getBgColor();e.isBgRGB()?n.push(48,2,c>>>16&255,c>>>8&255,c&255):e.isBgPalette()?c>=16?n.push(48,5,c):n.push(c&8?100+(c&7):40+(c&7)):n.push(49)}o&&(e.isInverse()!==t.isInverse()&&n.push(e.isInverse()?7:27),e.isBold()!==t.isBold()&&n.push(e.isBold()?1:22),e.isUnderline()!==t.isUnderline()&&n.push(e.isUnderline()?4:24),e.isOverline()!==t.isOverline()&&n.push(e.isOverline()?53:55),e.isBlink()!==t.isBlink()&&n.push(e.isBlink()?5:25),e.isInvisible()!==t.isInvisible()&&n.push(e.isInvisible()?8:28),e.isItalic()!==t.isItalic()&&n.push(e.isItalic()?3:23),e.isDim()!==t.isDim()&&n.push(e.isDim()?2:22),e.isStrikethrough()!==t.isStrikethrough()&&n.push(e.isStrikethrough()?9:29))}return n}_nextCell(e,t,n,s){if(e.getWidth()===0)return;let a=e.getChars()==="",o=this._diffStyle(e,this._cursorStyle);if(a?!Pn(this._cursorStyle,e):o.length>0){this._nullCellCount>0&&(Pn(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=s,this._currentRow+=`\x1B[${o.join(";")}m`;let c=this._buffer.getLine(n);c!==void 0&&(c.getCell(s,this._cursorStyle),this._cursorStyleRow=n,this._cursorStyleCol=s)}a?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(Pn(this._cursorStyle,this._backgroundCell)?this._currentRow+=`\x1B[${this._nullCellCount}C`:(this._currentRow+=`\x1B[${this._nullCellCount}X`,this._currentRow+=`\x1B[${this._nullCellCount}C`),this._nullCellCount=0),this._currentRow+=e.getChars(),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=s+e.getWidth())}_serializeString(e){let t=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(t=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let n="";for(let o=0;o{h>0?n+=`\x1B[${h}C`:h<0&&(n+=`\x1B[${-h}D`)};f&&((h=>{h>0?n+=`\x1B[${h}B`:h<0&&(n+=`\x1B[${-h}A`)})(o-this._lastCursorRow),p(c-this._lastCursorCol))}let s=this._terminal._core._inputHandler._curAttrData,a=this._diffStyle(s,this._cursorStyle);return a.length>0&&(n+=`\x1B[${a.join(";")}m`),n}},ek=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,n){let s=t.length,a=n===void 0?s:ey(n+e.rows,0,s);return this._serializeBufferByRange(e,t,{start:s-a,end:s-1},!1)}_serializeBufferByRange(e,t,n,s){return new J2(t,e).serialize({start:{x:0,y:typeof n.start=="number"?n.start:n.start.line},end:{x:e.cols,y:typeof n.end=="number"?n.end:n.end.line}},s)}_serializeBufferAsHTML(e,t){var f;let n=e.buffer.active,s=new tk(n,e,t),a=t.onlySelection??!1,o=t.range;if(o)return s.serialize({start:{x:o.startCol,y:(o.startLine,o.startLine)},end:{x:e.cols,y:(o.endLine,o.endLine)}});if(!a){let p=n.length,h=t.scrollback,g=h===void 0?p:ey(h+e.rows,0,p);return s.serialize({start:{x:0,y:p-g},end:{x:e.cols,y:p-1}})}let c=(f=this._terminal)==null?void 0:f.getSelectionPosition();return c!==void 0?s.serialize({start:{x:c.start.x,y:c.start.y},end:{x:c.end.x,y:c.end.y}}):""}_serializeModes(e){let t="",n=e.modes;if(n.applicationCursorKeysMode&&(t+="\x1B[?1h"),n.applicationKeypadMode&&(t+="\x1B[?66h"),n.bracketedPasteMode&&(t+="\x1B[?2004h"),n.insertMode&&(t+="\x1B[4h"),n.originMode&&(t+="\x1B[?6h"),n.reverseWraparoundMode&&(t+="\x1B[?45h"),n.sendFocusMode&&(t+="\x1B[?1004h"),n.wraparoundMode===!1&&(t+="\x1B[?7l"),n.mouseTrackingMode!=="none")switch(n.mouseTrackingMode){case"x10":t+="\x1B[?9h";break;case"vt200":t+="\x1B[?1000h";break;case"drag":t+="\x1B[?1002h";break;case"any":t+="\x1B[?1003h";break}return t}serialize(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let t=e!=null&&e.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,e.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,e==null?void 0:e.scrollback);if(!(e!=null&&e.excludeAltBuffer)&&this._terminal.buffer.active.type==="alternate"){let n=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);t+=`\x1B[?1049h\x1B[H${n}`}return e!=null&&e.excludeModes||(t+=this._serializeModes(this._terminal)),t}serializeAsHTML(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,e||{})}dispose(){}},tk=class extends Yb{constructor(e,t,n){super(e),this._terminal=t,this._options=n,this._currentRow="",this._htmlContent="",t._core._themeService?this._ansiColors=t._core._themeService.colors.ansi:this._ansiColors=Z2}_padStart(e,t,n){return t=t>>0,n=n??" ",e.length>t?e:(t-=e.length,t>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}_beforeSerialize(e,t,n){var c,f;this._htmlContent+="
";let s="#000000",a="#ffffff";(this._options.includeGlobalBackground??!1)&&(s=((c=this._terminal.options.theme)==null?void 0:c.foreground)??"#ffffff",a=((f=this._terminal.options.theme)==null?void 0:f.background)??"#000000");let o=[];o.push("color: "+s+";"),o.push("background-color: "+a+";"),o.push("font-family: "+this._terminal.options.fontFamily+";"),o.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="
"}_afterSerialize(){this._htmlContent+="
",this._htmlContent+="
"}_rowEnd(e,t){this._htmlContent+="
"+this._currentRow+"
",this._currentRow=""}_getHexColor(e,t){let n=t?e.getFgColor():e.getBgColor();if(t?e.isFgRGB():e.isBgRGB())return"#"+[n>>16&255,n>>8&255,n&255].map(s=>this._padStart(s.toString(16),2,"0")).join("");if(t?e.isFgPalette():e.isBgPalette())return this._ansiColors[n].css}_diffStyle(e,t){let n=[],s=!Vb(e,t),a=!Pn(e,t),o=!Kb(e,t);if(s||a||o){let c=this._getHexColor(e,!0);c&&n.push("color: "+c+";");let f=this._getHexColor(e,!1);return f&&n.push("background-color: "+f+";"),e.isInverse()&&n.push("color: #000000; background-color: #BFBFBF;"),e.isBold()&&n.push("font-weight: bold;"),e.isUnderline()&&e.isOverline()?n.push("text-decoration: overline underline;"):e.isUnderline()?n.push("text-decoration: underline;"):e.isOverline()&&n.push("text-decoration: overline;"),e.isBlink()&&n.push("text-decoration: blink;"),e.isInvisible()&&n.push("visibility: hidden;"),e.isItalic()&&n.push("font-style: italic;"),e.isDim()&&n.push("opacity: 0.5;"),e.isStrikethrough()&&n.push("text-decoration: line-through;"),n}}_nextCell(e,t,n,s){if(e.getWidth()===0)return;let a=e.getChars()==="",o=this._diffStyle(e,t);o&&(this._currentRow+=o.length===0?"
":""),a?this._currentRow+=" ":this._currentRow+=Q2(e.getChars())}_serializeString(){return this._htmlContent}};const ik={background:"#F0EBE1",foreground:"#2C1810",cursor:"#8B4513",cursorAccent:"#F0EBE1",selectionBackground:"#D4C5B0",selectionForeground:"#2C1810",black:"#2C1810",red:"#A63D40",green:"#4A7A4A",yellow:"#8B6914",blue:"#4A6FA5",magenta:"#7B4B8A",cyan:"#3D7A7A",white:"#E6DDD0",brightBlack:"#8B7355",brightRed:"#B85C5C",brightGreen:"#5A8A5A",brightYellow:"#A07D1C",brightBlue:"#5A82BA",brightMagenta:"#8E5D9F",brightCyan:"#5A8F8F",brightWhite:"#4A3728"},nk="plotlink-terminal",rk=1,Cr="scrollback",ty=10*1024*1024;function Ld(){return new Promise((e,t)=>{const n=indexedDB.open(nk,rk);n.onupgradeneeded=()=>{const s=n.result;s.objectStoreNames.contains(Cr)||s.createObjectStore(Cr)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function ra(e,t){const n=t.length>ty?t.slice(-ty):t,s=await Ld();return new Promise((a,o)=>{const c=s.transaction(Cr,"readwrite");c.objectStore(Cr).put(n,e),c.oncomplete=()=>{s.close(),a()},c.onerror=()=>{s.close(),o(c.error)}})}async function sk(e){const t=await Ld();return new Promise((n,s)=>{const o=t.transaction(Cr,"readonly").objectStore(Cr).get(e);o.onsuccess=()=>{t.close(),n(o.result??null)},o.onerror=()=>{t.close(),s(o.error)}})}async function iy(e){const t=await Ld();return new Promise((n,s)=>{const a=t.transaction(Cr,"readwrite");a.objectStore(Cr).delete(e),a.oncomplete=()=>{t.close(),n()},a.onerror=()=>{t.close(),s(a.error)}})}const Bt=new Map;function lk({token:e,storyName:t,authFetch:n,onSelectStory:s,onDestroySession:a,onArchiveStory:o,confirmedStories:c,renameRef:f}){const p=G.useRef(null),h=G.useRef(n),[g,_]=G.useState([]),[b,y]=G.useState(new Set),[x,k]=G.useState(null),[L,M]=G.useState(null),Z=G.useRef(()=>{});G.useEffect(()=>{h.current=n},[n]);const I=G.useCallback(B=>{var R;const{width:A}=B.container.getBoundingClientRect();if(!(A<50))try{B.fit.fit(),((R=B.ws)==null?void 0:R.readyState)===WebSocket.OPEN&&B.ws.send(JSON.stringify({type:"resize",cols:B.term.cols,rows:B.term.rows}))}catch{}},[]),Q=G.useCallback(B=>{for(const[A,R]of Bt)R.container.style.display=A===B?"block":"none";if(B){const A=Bt.get(B);A&&setTimeout(()=>I(A),50)}},[I]),W=G.useCallback((B,A,R)=>{const T=window.location.protocol==="https:"?"wss:":"ws:",j=new WebSocket(`${T}//${window.location.host}/ws/terminal?story=${encodeURIComponent(B)}&token=${e}&resume=${R}`);j.onopen=()=>{A.connected=!0,A._retried=!1,y(H=>{const ae=new Set(H);return ae.delete(B),ae}),j.send(JSON.stringify({type:"resize",cols:A.term.cols,rows:A.term.rows}))},j.onmessage=H=>{A.term.write(H.data)},j.onclose=H=>{if(A.connected=!1,A.ws===j){A.ws=null;try{const ae=A.serialize.serialize();ra(B,ae).catch(()=>{})}catch{}if(H.code===4e3&&!A._retried){A._retried=!0,A.term.write(`\r \x1B[33m[Resume failed — starting fresh session...]\x1B[0m\r -`),Z.current(B,A,!1);return}y(oe=>new Set(oe).add(B))}},A.term.onData(H=>{j.readyState===WebSocket.OPEN&&j.send(H)}),A.ws=j},[e]);$.useEffect(()=>{Z.current=W},[W]);const O=$.useCallback(async(B,A)=>{if(!p.current||Bt.has(B))return;const{resume:R=!1,autoConnect:T=!0}=A??{},j=document.createElement("div");j.style.width="100%",j.style.height="100%",j.style.display="none",j.style.paddingLeft="10px",j.style.boxSizing="border-box",p.current.appendChild(j);const H=new V2({cols:80,scrollback:5e3,fontSize:13,fontFamily:'"Geist Mono", ui-monospace, monospace',lineHeight:1.05,letterSpacing:0,cursorBlink:!0,cursorStyle:"block",theme:ik,allowTransparency:!1,drawBoldTextInBrightColors:!1,minimumContrastRatio:7}),oe=new G2,E=new ek;H.loadAddon(oe),H.loadAddon(E),H.open(j);const D={term:H,fit:oe,serialize:E,ws:null,container:j,observer:null,connected:!1},K=new ResizeObserver(()=>{var J;const{width:C}=j.getBoundingClientRect();if(!(C<50))try{oe.fit(),((J=D.ws)==null?void 0:J.readyState)===WebSocket.OPEN&&D.ws.send(JSON.stringify({type:"resize",cols:H.cols,rows:H.rows}))}catch{}});K.observe(j),D.observer=K,Bt.set(B,D),_(C=>[...C,B]);try{const C=await sk(B);C&&H.write(C)}catch{}T?W(B,D,R):y(C=>new Set(C).add(B)),setTimeout(()=>I(D),50)},[W,I]),ie=$.useCallback(async(B,A)=>{const R=Bt.get(B);R&&(R.ws&&(R.ws.close(),R.ws=null),A||(await h.current(`/api/terminal/${encodeURIComponent(B)}`,{method:"DELETE"}).catch(()=>{}),R.term.clear()),W(B,R,A))},[W]),ue=$.useCallback(B=>{const A=Bt.get(B);if(A){try{const R=A.serialize.serialize();ia(B,R).catch(()=>{})}catch{}A.observer.disconnect(),A.ws&&A.ws.close(),A.term.dispose(),A.container.remove(),Bt.delete(B),_(R=>R.filter(T=>T!==B)),y(R=>{const T=new Set(R);return T.delete(B),T}),n(`/api/terminal/${encodeURIComponent(B)}`,{method:"DELETE"}).catch(()=>{}),a==null||a(B)}},[n,a]),me=$.useCallback(B=>{var R;const A=Bt.get(B);A&&(((R=A.ws)==null?void 0:R.readyState)===WebSocket.OPEN&&A.ws.send(`exit -`),iy(B).catch(()=>{}),A.observer.disconnect(),A.ws&&A.ws.close(),A.term.dispose(),A.container.remove(),Bt.delete(B),_(T=>T.filter(j=>j!==B)),y(T=>{const j=new Set(T);return j.delete(B),j}),n(`/api/terminal/${encodeURIComponent(B)}/discard`,{method:"DELETE"}).catch(()=>{}),a==null||a(B))},[n,a]),U=$.useCallback(async(B,A)=>{const R=Bt.get(B);if(!R||Bt.has(A)||!(await h.current("/api/terminal/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldName:B,newName:A})})).ok)return!1;Bt.delete(B),Bt.set(A,R);try{const j=R.serialize.serialize();await iy(B),await ia(A,j)}catch{}return _(j=>j.map(H=>H===B?A:H)),y(j=>{if(!j.has(B))return j;const H=new Set(j);return H.delete(B),H.add(A),H}),!0},[]);$.useEffect(()=>(f&&(f.current=U),()=>{f&&(f.current=null)}),[f,U]),$.useEffect(()=>{t&&(Bt.has(t)?Q(t):h.current(`/api/terminal/session/${encodeURIComponent(t)}`).then(B=>B.ok?B.json():null).then(B=>{if(!Bt.has(t)){const A=(B==null?void 0:B.sessionId)&&!(B!=null&&B.running);O(t,{autoConnect:!A}),Q(t)}}).catch(()=>{Bt.has(t)||(O(t),Q(t))}))},[t,O,Q]),$.useEffect(()=>{const B=setInterval(()=>{for(const[A,R]of Bt)if(R.connected)try{const T=R.serialize.serialize();ia(A,T).catch(()=>{})}catch{}},3e4);return()=>clearInterval(B)},[]),$.useEffect(()=>()=>{for(const[B,A]of Bt){try{const R=A.serialize.serialize();ia(B,R).catch(()=>{})}catch{}A.observer.disconnect(),A.ws&&A.ws.close(),A.term.dispose(),A.container.remove(),h.current(`/api/terminal/${encodeURIComponent(B)}`,{method:"DELETE"}).catch(()=>{})}Bt.clear()},[]);const le=t?b.has(t):!1,V=g.length===0;return S.jsxs("div",{className:"h-full flex flex-col",children:[!V&&S.jsxs("div",{className:"px-2 py-1 border-b border-border flex items-center gap-1 overflow-x-auto",children:[g.map(B=>S.jsxs("div",{onClick:()=>s==null?void 0:s(B),className:`flex items-center gap-1 px-2 py-0.5 rounded text-xs font-mono cursor-pointer ${B===t?"bg-accent/10 text-accent":"text-muted hover:text-foreground"}`,children:[S.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${b.has(B)?"bg-amber-500":B===t?"bg-green-600":"bg-muted/50"}`}),S.jsx("span",{className:`truncate max-w-[120px] ${B.startsWith("_new_")?"italic":""}`,children:B.startsWith("_new_")?"Untitled":B}),S.jsx("button",{onClick:A=>{A.stopPropagation(),B.startsWith("_new_")?k(B):ue(B)},className:"ml-0.5 text-muted hover:text-error text-[10px] leading-none",title:"Close terminal",children:"×"})]},B)),t!=null&&t.startsWith("_new_")?S.jsx("button",{onClick:()=>k(t),className:"ml-auto px-2 py-0.5 text-xs text-error hover:bg-surface rounded flex items-center gap-1 flex-shrink-0",children:"Cancel ×"}):t&&o&&(c!=null&&c.has(t))?S.jsx("button",{onClick:()=>M(t),className:"ml-auto px-2 py-0.5 text-xs text-muted hover:text-foreground hover:bg-surface rounded flex items-center gap-1 flex-shrink-0",children:"Archive"}):null]}),S.jsxs("div",{className:"relative flex-1 min-h-0",children:[S.jsx("div",{ref:p,className:"h-full"}),V&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-muted",children:S.jsxs("div",{className:"text-center",children:[S.jsx("p",{className:"text-lg font-serif",children:"Select a story on the left menu"}),S.jsx("p",{className:"text-sm mt-1",children:"to start an AI Writer session"})]})}),x&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[S.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Discard this session?"}),S.jsx("p",{className:"text-xs text-muted",children:"This session will be lost — your AI hasn't created a story structure yet."}),S.jsxs("div",{className:"flex items-center justify-center gap-2",children:[S.jsx("button",{onClick:()=>k(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),S.jsx("button",{onClick:()=>{const B=x;k(null),me(B)},className:"px-4 py-1.5 bg-error text-white text-sm rounded hover:opacity-80",children:"Discard"})]})]})}),L&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[S.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Archive this story?"}),S.jsx("p",{className:"text-xs text-muted",children:"You can restore it later from the Archives view."}),S.jsxs("div",{className:"flex items-center justify-center gap-2",children:[S.jsx("button",{onClick:()=>M(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),S.jsx("button",{onClick:async()=>{const B=L;M(null);try{(await h.current("/api/stories/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B})})).ok&&(ue(B),o==null||o(B))}catch{}},className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Archive"})]})]})}),le&&t&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3",children:[S.jsx("p",{className:"text-sm font-serif text-foreground",children:"Terminal disconnected"}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("button",{onClick:()=>ie(t,!0),className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Resume Session"}),S.jsx("button",{onClick:()=>ie(t,!1),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Start Fresh"})]}),S.jsx("p",{className:"text-xs text-muted",children:"Resume continues your previous Claude conversation"})]})})]})]})}function ak(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const ok=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,uk=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ck={};function ny(e,t){return(ck.jsx?uk:ok).test(e)}const hk=/[ \t\n\f\r]/g;function fk(e){return typeof e=="object"?e.type==="text"?ry(e.value):!1:ry(e)}function ry(e){return e.replace(hk,"")===""}class Aa{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}}Aa.prototype.normal={};Aa.prototype.property={};Aa.prototype.space=void 0;function Xb(e,t){const n={},s={};for(const a of e)Object.assign(n,a.property),Object.assign(s,a.normal);return new Aa(n,s,t)}function fd(e){return e.toLowerCase()}class Si{constructor(t,n){this.attribute=n,this.property=t}}Si.prototype.attribute="";Si.prototype.booleanish=!1;Si.prototype.boolean=!1;Si.prototype.commaOrSpaceSeparated=!1;Si.prototype.commaSeparated=!1;Si.prototype.defined=!1;Si.prototype.mustUseProperty=!1;Si.prototype.number=!1;Si.prototype.overloadedBoolean=!1;Si.prototype.property="";Si.prototype.spaceSeparated=!1;Si.prototype.space=void 0;let dk=0;const Re=rs(),wt=rs(),dd=rs(),ae=rs(),Je=rs(),$s=rs(),Mi=rs();function rs(){return 2**++dk}const pd=Object.freeze(Object.defineProperty({__proto__:null,boolean:Re,booleanish:wt,commaOrSpaceSeparated:Mi,commaSeparated:$s,number:ae,overloadedBoolean:dd,spaceSeparated:Je},Symbol.toStringTag,{value:"Module"})),cf=Object.keys(pd);class zd extends Si{constructor(t,n,s,a){let o=-1;if(super(t,n),sy(this,"space",a),typeof s=="number")for(;++o4&&n.slice(0,4)==="data"&&vk.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(ly,Sk);s="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!ly.test(o)){let c=o.replace(gk,bk);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=zd}return new a(s,t)}function bk(e){return"-"+e.toLowerCase()}function Sk(e){return e.charAt(1).toUpperCase()}const xk=Xb([Gb,pk,Qb,Jb,eS],"html"),Od=Xb([Gb,mk,Qb,Jb,eS],"svg");function wk(e){return e.join(" ").trim()}var Vs={},hf,ay;function Ck(){if(ay)return hf;ay=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,f=/^\s+|\s+$/g,p=` -`,h="/",g="*",_="",b="comment",y="declaration";function x(L,M){if(typeof L!="string")throw new TypeError("First argument must be a string");if(!L)return[];M=M||{};var Z=1,I=1;function Q(A){var R=A.match(t);R&&(Z+=R.length);var T=A.lastIndexOf(p);I=~T?A.length-T:I+A.length}function W(){var A={line:Z,column:I};return function(R){return R.position=new O(A),me(),R}}function O(A){this.start=A,this.end={line:Z,column:I},this.source=M.source}O.prototype.content=L;function ie(A){var R=new Error(M.source+":"+Z+":"+I+": "+A);if(R.reason=A,R.filename=M.source,R.line=Z,R.column=I,R.source=L,!M.silent)throw R}function ue(A){var R=A.exec(L);if(R){var T=R[0];return Q(T),L=L.slice(T.length),R}}function me(){ue(n)}function U(A){var R;for(A=A||[];R=le();)R!==!1&&A.push(R);return A}function le(){var A=W();if(!(h!=L.charAt(0)||g!=L.charAt(1))){for(var R=2;_!=L.charAt(R)&&(g!=L.charAt(R)||h!=L.charAt(R+1));)++R;if(R+=2,_===L.charAt(R-1))return ie("End of comment missing");var T=L.slice(2,R-2);return I+=2,Q(T),L=L.slice(R),I+=2,A({type:b,comment:T})}}function V(){var A=W(),R=ue(s);if(R){if(le(),!ue(a))return ie("property missing ':'");var T=ue(o),j=A({type:y,property:k(R[0].replace(e,_)),value:T?k(T[0].replace(e,_)):_});return ue(c),j}}function B(){var A=[];U(A);for(var R;R=V();)R!==!1&&(A.push(R),U(A));return A}return me(),B()}function k(L){return L?L.replace(f,_):_}return hf=x,hf}var oy;function kk(){if(oy)return Vs;oy=1;var e=Vs&&Vs.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Vs,"__esModule",{value:!0}),Vs.default=n;const t=e(Ck());function n(s,a){let o=null;if(!s||typeof s!="string")return o;const c=(0,t.default)(s),f=typeof a=="function";return c.forEach(p=>{if(p.type!=="declaration")return;const{property:h,value:g}=p;f?a(h,g,p):g&&(o=o||{},o[h]=g)}),o}return Vs}var na={},uy;function Ek(){if(uy)return na;uy=1,Object.defineProperty(na,"__esModule",{value:!0}),na.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(h){return!h||n.test(h)||e.test(h)},c=function(h,g){return g.toUpperCase()},f=function(h,g){return"".concat(g,"-")},p=function(h,g){return g===void 0&&(g={}),o(h)?h:(h=h.toLowerCase(),g.reactCompat?h=h.replace(a,f):h=h.replace(s,f),h.replace(t,c))};return na.camelCase=p,na}var ra,cy;function Tk(){if(cy)return ra;cy=1;var e=ra&&ra.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(kk()),n=Ek();function s(a,o){var c={};return!a||typeof a!="string"||(0,t.default)(a,function(f,p){f&&p&&(c[(0,n.camelCase)(f,o)]=p)}),c}return s.default=s,ra=s,ra}var Ak=Tk();const Dk=xu(Ak),tS=iS("end"),jd=iS("start");function iS(e){return t;function t(n){const s=n&&n.position&&n.position[e]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function nS(e){const t=jd(e),n=tS(e);if(t&&n)return{start:t,end:n}}function ma(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?hy(e.position):"start"in e||"end"in e?hy(e):"line"in e||"column"in e?md(e):""}function md(e){return fy(e&&e.line)+":"+fy(e&&e.column)}function hy(e){return md(e&&e.start)+"-"+md(e&&e.end)}function fy(e){return e&&typeof e=="number"?e:1}class ri extends Error{constructor(t,n,s){super(),typeof n=="string"&&(s=n,n=void 0);let a="",o={},c=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?a=t:!o.cause&&t&&(c=!0,a=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof s=="string"){const p=s.indexOf(":");p===-1?o.ruleId=s:(o.source=s.slice(0,p),o.ruleId=s.slice(p+1))}if(!o.place&&o.ancestors&&o.ancestors){const p=o.ancestors[o.ancestors.length-1];p&&(o.place=p.position)}const f=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=f?f.line:void 0,this.name=ma(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=c&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ri.prototype.file="";ri.prototype.name="";ri.prototype.reason="";ri.prototype.message="";ri.prototype.stack="";ri.prototype.column=void 0;ri.prototype.line=void 0;ri.prototype.ancestors=void 0;ri.prototype.cause=void 0;ri.prototype.fatal=void 0;ri.prototype.place=void 0;ri.prototype.ruleId=void 0;ri.prototype.source=void 0;const Hd={}.hasOwnProperty,Rk=new Map,Mk=/[A-Z]/g,Bk=new Set(["table","tbody","thead","tfoot","tr"]),Nk=new Set(["td","th"]),rS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Lk(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let s;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=Fk(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");s=Ik(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Od:xk,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=sS(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function sS(e,t,n){if(t.type==="element")return zk(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Ok(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Hk(e,t,n);if(t.type==="mdxjsEsm")return jk(e,t);if(t.type==="root")return Pk(e,t,n);if(t.type==="text")return Uk(e,t)}function zk(e,t,n){const s=e.schema;let a=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(a=Od,e.schema=a),e.ancestors.push(t);const o=aS(e,t.tagName,!1),c=qk(e,t);let f=Ud(e,t);return Bk.has(t.tagName)&&(f=f.filter(function(p){return typeof p=="string"?!fk(p):!0})),lS(e,c,o,t),Pd(c,f),e.ancestors.pop(),e.schema=s,e.create(t,o,c,n)}function Ok(e,t){if(t.data&&t.data.estree&&e.evaluater){const s=t.data.estree.body[0];return s.type,e.evaluater.evaluateExpression(s.expression)}Sa(e,t.position)}function jk(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Sa(e,t.position)}function Hk(e,t,n){const s=e.schema;let a=s;t.name==="svg"&&s.space==="html"&&(a=Od,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:aS(e,t.name,!0),c=Wk(e,t),f=Ud(e,t);return lS(e,c,o,t),Pd(c,f),e.ancestors.pop(),e.schema=s,e.create(t,o,c,n)}function Pk(e,t,n){const s={};return Pd(s,Ud(e,t)),e.create(t,e.Fragment,s,n)}function Uk(e,t){return t.value}function lS(e,t,n,s){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=s)}function Pd(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Ik(e,t,n){return s;function s(a,o,c,f){const h=Array.isArray(c.children)?n:t;return f?h(o,c,f):h(o,c)}}function Fk(e,t){return n;function n(s,a,o,c){const f=Array.isArray(o.children),p=jd(s);return t(a,o,c,f,{columnNumber:p?p.column-1:void 0,fileName:e,lineNumber:p?p.line:void 0},void 0)}}function qk(e,t){const n={};let s,a;for(a in t.properties)if(a!=="children"&&Hd.call(t.properties,a)){const o=Yk(e,a,t.properties[a]);if(o){const[c,f]=o;e.tableCellAlignToStyle&&c==="align"&&typeof f=="string"&&Nk.has(t.tagName)?s=f:n[c]=f}}if(s){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return n}function Wk(e,t){const n={};for(const s of t.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&e.evaluater){const o=s.data.estree.body[0];o.type;const c=o.expression;c.type;const f=c.properties[0];f.type,Object.assign(n,e.evaluater.evaluateExpression(f.argument))}else Sa(e,t.position);else{const a=s.name;let o;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&e.evaluater){const f=s.value.data.estree.body[0];f.type,o=e.evaluater.evaluateExpression(f.expression)}else Sa(e,t.position);else o=s.value===null?!0:s.value;n[a]=o}return n}function Ud(e,t){const n=[];let s=-1;const a=e.passKeys?new Map:Rk;for(;++sa?0:a+t:t=t>a?a:t,n=n>0?n:0,s.length<1e4)c=Array.from(s),c.unshift(t,n),e.splice(...c);else for(n&&e.splice(t,n);o0?(Bi(e,e.length,0,t),e):t}const my={}.hasOwnProperty;function uS(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ji(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const oi=kr(/[A-Za-z]/),ni=kr(/[\dA-Za-z]/),eE=kr(/[#-'*+\--9=?A-Z^-~]/);function yu(e){return e!==null&&(e<32||e===127)}const _d=kr(/\d/),tE=kr(/[\dA-Fa-f]/),iE=kr(/[!-/:-@[-`{-~]/);function be(e){return e!==null&&e<-2}function Qe(e){return e!==null&&(e<0||e===32)}function Oe(e){return e===-2||e===-1||e===32}const Tu=kr(new RegExp("\\p{P}|\\p{S}","u")),is=kr(/\s/);function kr(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function il(e){const t=[];let n=-1,s=0,a=0;for(;++n55295&&o<57344){const f=e.charCodeAt(n+1);o<56320&&f>56319&&f<57344?(c=String.fromCharCode(o,f),a=1):c="�"}else c=String.fromCharCode(o);c&&(t.push(e.slice(s,n),encodeURIComponent(c)),s=n+a+1,c=""),a&&(n+=a,a=0)}return t.join("")+e.slice(s)}function Ue(e,t,n,s){const a=s?s-1:Number.POSITIVE_INFINITY;let o=0;return c;function c(p){return Oe(p)?(e.enter(n),f(p)):t(p)}function f(p){return Oe(p)&&o++c))return;const ie=t.events.length;let ue=ie,me,U;for(;ue--;)if(t.events[ue][0]==="exit"&&t.events[ue][1].type==="chunkFlow"){if(me){U=t.events[ue][1].end;break}me=!0}for(M(s),O=ie;OI;){const W=n[Q];t.containerState=W[1],W[0].exit.call(t,e)}n.length=I}function Z(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function aE(e,t,n){return Ue(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Qs(e){if(e===null||Qe(e)||is(e))return 1;if(Tu(e))return 2}function Au(e,t,n){const s=[];let a=-1;for(;++a1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const _={...e[s][1].end},b={...e[n][1].start};gy(_,-p),gy(b,p),c={type:p>1?"strongSequence":"emphasisSequence",start:_,end:{...e[s][1].end}},f={type:p>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:b},o={type:p>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[n][1].start}},a={type:p>1?"strong":"emphasis",start:{...c.start},end:{...f.end}},e[s][1].end={...c.start},e[n][1].start={...f.end},h=[],e[s][1].end.offset-e[s][1].start.offset&&(h=Vi(h,[["enter",e[s][1],t],["exit",e[s][1],t]])),h=Vi(h,[["enter",a,t],["enter",c,t],["exit",c,t],["enter",o,t]]),h=Vi(h,Au(t.parser.constructs.insideSpan.null,e.slice(s+1,n),t)),h=Vi(h,[["exit",o,t],["enter",f,t],["exit",f,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(g=2,h=Vi(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):g=0,Bi(e,s-1,n-s+3,h),n=s+h.length-g-2;break}}for(n=-1;++n0&&Oe(O)?Ue(e,Z,"linePrefix",o+1)(O):Z(O)}function Z(O){return O===null||be(O)?e.check(vy,k,Q)(O):(e.enter("codeFlowValue"),I(O))}function I(O){return O===null||be(O)?(e.exit("codeFlowValue"),Z(O)):(e.consume(O),I)}function Q(O){return e.exit("codeFenced"),t(O)}function W(O,ie,ue){let me=0;return U;function U(R){return O.enter("lineEnding"),O.consume(R),O.exit("lineEnding"),le}function le(R){return O.enter("codeFencedFence"),Oe(R)?Ue(O,V,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):V(R)}function V(R){return R===f?(O.enter("codeFencedFenceSequence"),B(R)):ue(R)}function B(R){return R===f?(me++,O.consume(R),B):me>=c?(O.exit("codeFencedFenceSequence"),Oe(R)?Ue(O,A,"whitespace")(R):A(R)):ue(R)}function A(R){return R===null||be(R)?(O.exit("codeFencedFence"),ie(R)):ue(R)}}}function yE(e,t,n){const s=this;return a;function a(c){return c===null?n(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o)}function o(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}const df={name:"codeIndented",tokenize:SE},bE={partial:!0,tokenize:xE};function SE(e,t,n){const s=this;return a;function a(h){return e.enter("codeIndented"),Ue(e,o,"linePrefix",5)(h)}function o(h){const g=s.events[s.events.length-1];return g&&g[1].type==="linePrefix"&&g[2].sliceSerialize(g[1],!0).length>=4?c(h):n(h)}function c(h){return h===null?p(h):be(h)?e.attempt(bE,c,p)(h):(e.enter("codeFlowValue"),f(h))}function f(h){return h===null||be(h)?(e.exit("codeFlowValue"),c(h)):(e.consume(h),f)}function p(h){return e.exit("codeIndented"),t(h)}}function xE(e,t,n){const s=this;return a;function a(c){return s.parser.lazy[s.now().line]?n(c):be(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):Ue(e,o,"linePrefix",5)(c)}function o(c){const f=s.events[s.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?t(c):be(c)?a(c):n(c)}}const wE={name:"codeText",previous:kE,resolve:CE,tokenize:EE};function CE(e){let t=e.length-4,n=3,s,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(s=n;++s=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(t,n,s){const a=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return s&&sa(this.left,s),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),sa(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),sa(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(c):e.interrupt(s.parser.constructs.flow,n,t)(c)}}function mS(e,t,n,s,a,o,c,f,p){const h=p||Number.POSITIVE_INFINITY;let g=0;return _;function _(M){return M===60?(e.enter(s),e.enter(a),e.enter(o),e.consume(M),e.exit(o),b):M===null||M===32||M===41||yu(M)?n(M):(e.enter(s),e.enter(c),e.enter(f),e.enter("chunkString",{contentType:"string"}),k(M))}function b(M){return M===62?(e.enter(o),e.consume(M),e.exit(o),e.exit(a),e.exit(s),t):(e.enter(f),e.enter("chunkString",{contentType:"string"}),y(M))}function y(M){return M===62?(e.exit("chunkString"),e.exit(f),b(M)):M===null||M===60||be(M)?n(M):(e.consume(M),M===92?x:y)}function x(M){return M===60||M===62||M===92?(e.consume(M),y):y(M)}function k(M){return!g&&(M===null||M===41||Qe(M))?(e.exit("chunkString"),e.exit(f),e.exit(c),e.exit(s),t(M)):g999||y===null||y===91||y===93&&!p||y===94&&!f&&"_hiddenFootnoteSupport"in c.parser.constructs?n(y):y===93?(e.exit(o),e.enter(a),e.consume(y),e.exit(a),e.exit(s),t):be(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),g):(e.enter("chunkString",{contentType:"string"}),_(y))}function _(y){return y===null||y===91||y===93||be(y)||f++>999?(e.exit("chunkString"),g(y)):(e.consume(y),p||(p=!Oe(y)),y===92?b:_)}function b(y){return y===91||y===92||y===93?(e.consume(y),f++,_):_(y)}}function gS(e,t,n,s,a,o){let c;return f;function f(b){return b===34||b===39||b===40?(e.enter(s),e.enter(a),e.consume(b),e.exit(a),c=b===40?41:b,p):n(b)}function p(b){return b===c?(e.enter(a),e.consume(b),e.exit(a),e.exit(s),t):(e.enter(o),h(b))}function h(b){return b===c?(e.exit(o),p(c)):b===null?n(b):be(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),Ue(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),g(b))}function g(b){return b===c||b===null||be(b)?(e.exit("chunkString"),h(b)):(e.consume(b),b===92?_:g)}function _(b){return b===c||b===92?(e.consume(b),g):g(b)}}function _a(e,t){let n;return s;function s(a){return be(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,s):Oe(a)?Ue(e,s,n?"linePrefix":"lineSuffix")(a):t(a)}}const LE={name:"definition",tokenize:OE},zE={partial:!0,tokenize:jE};function OE(e,t,n){const s=this;let a;return o;function o(y){return e.enter("definition"),c(y)}function c(y){return _S.call(s,e,f,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function f(y){return a=Ji(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),p):n(y)}function p(y){return Qe(y)?_a(e,h)(y):h(y)}function h(y){return mS(e,g,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function g(y){return e.attempt(zE,_,_)(y)}function _(y){return Oe(y)?Ue(e,b,"whitespace")(y):b(y)}function b(y){return y===null||be(y)?(e.exit("definition"),s.parser.defined.push(a),t(y)):n(y)}}function jE(e,t,n){return s;function s(f){return Qe(f)?_a(e,a)(f):n(f)}function a(f){return gS(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function o(f){return Oe(f)?Ue(e,c,"whitespace")(f):c(f)}function c(f){return f===null||be(f)?t(f):n(f)}}const HE={name:"hardBreakEscape",tokenize:PE};function PE(e,t,n){return s;function s(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return be(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const UE={name:"headingAtx",resolve:IE,tokenize:FE};function IE(e,t){let n=e.length-2,s=3,a,o;return e[s][1].type==="whitespace"&&(s+=2),n-2>s&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(s===n-1||n-4>s&&e[n-2][1].type==="whitespace")&&(n-=s+1===n?2:4),n>s&&(a={type:"atxHeadingText",start:e[s][1].start,end:e[n][1].end},o={type:"chunkText",start:e[s][1].start,end:e[n][1].end,contentType:"text"},Bi(e,s,n-s+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function FE(e,t,n){let s=0;return a;function a(g){return e.enter("atxHeading"),o(g)}function o(g){return e.enter("atxHeadingSequence"),c(g)}function c(g){return g===35&&s++<6?(e.consume(g),c):g===null||Qe(g)?(e.exit("atxHeadingSequence"),f(g)):n(g)}function f(g){return g===35?(e.enter("atxHeadingSequence"),p(g)):g===null||be(g)?(e.exit("atxHeading"),t(g)):Oe(g)?Ue(e,f,"whitespace")(g):(e.enter("atxHeadingText"),h(g))}function p(g){return g===35?(e.consume(g),p):(e.exit("atxHeadingSequence"),f(g))}function h(g){return g===null||g===35||Qe(g)?(e.exit("atxHeadingText"),f(g)):(e.consume(g),h)}}const qE=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],by=["pre","script","style","textarea"],WE={concrete:!0,name:"htmlFlow",resolveTo:KE,tokenize:XE},YE={partial:!0,tokenize:$E},VE={partial:!0,tokenize:GE};function KE(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function XE(e,t,n){const s=this;let a,o,c,f,p;return h;function h(C){return g(C)}function g(C){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(C),_}function _(C){return C===33?(e.consume(C),b):C===47?(e.consume(C),o=!0,k):C===63?(e.consume(C),a=3,s.interrupt?t:E):oi(C)?(e.consume(C),c=String.fromCharCode(C),L):n(C)}function b(C){return C===45?(e.consume(C),a=2,y):C===91?(e.consume(C),a=5,f=0,x):oi(C)?(e.consume(C),a=4,s.interrupt?t:E):n(C)}function y(C){return C===45?(e.consume(C),s.interrupt?t:E):n(C)}function x(C){const J="CDATA[";return C===J.charCodeAt(f++)?(e.consume(C),f===J.length?s.interrupt?t:V:x):n(C)}function k(C){return oi(C)?(e.consume(C),c=String.fromCharCode(C),L):n(C)}function L(C){if(C===null||C===47||C===62||Qe(C)){const J=C===47,fe=c.toLowerCase();return!J&&!o&&by.includes(fe)?(a=1,s.interrupt?t(C):V(C)):qE.includes(c.toLowerCase())?(a=6,J?(e.consume(C),M):s.interrupt?t(C):V(C)):(a=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(C):o?Z(C):I(C))}return C===45||ni(C)?(e.consume(C),c+=String.fromCharCode(C),L):n(C)}function M(C){return C===62?(e.consume(C),s.interrupt?t:V):n(C)}function Z(C){return Oe(C)?(e.consume(C),Z):U(C)}function I(C){return C===47?(e.consume(C),U):C===58||C===95||oi(C)?(e.consume(C),Q):Oe(C)?(e.consume(C),I):U(C)}function Q(C){return C===45||C===46||C===58||C===95||ni(C)?(e.consume(C),Q):W(C)}function W(C){return C===61?(e.consume(C),O):Oe(C)?(e.consume(C),W):I(C)}function O(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(e.consume(C),p=C,ie):Oe(C)?(e.consume(C),O):ue(C)}function ie(C){return C===p?(e.consume(C),p=null,me):C===null||be(C)?n(C):(e.consume(C),ie)}function ue(C){return C===null||C===34||C===39||C===47||C===60||C===61||C===62||C===96||Qe(C)?W(C):(e.consume(C),ue)}function me(C){return C===47||C===62||Oe(C)?I(C):n(C)}function U(C){return C===62?(e.consume(C),le):n(C)}function le(C){return C===null||be(C)?V(C):Oe(C)?(e.consume(C),le):n(C)}function V(C){return C===45&&a===2?(e.consume(C),T):C===60&&a===1?(e.consume(C),j):C===62&&a===4?(e.consume(C),D):C===63&&a===3?(e.consume(C),E):C===93&&a===5?(e.consume(C),oe):be(C)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(YE,K,B)(C)):C===null||be(C)?(e.exit("htmlFlowData"),B(C)):(e.consume(C),V)}function B(C){return e.check(VE,A,K)(C)}function A(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),R}function R(C){return C===null||be(C)?B(C):(e.enter("htmlFlowData"),V(C))}function T(C){return C===45?(e.consume(C),E):V(C)}function j(C){return C===47?(e.consume(C),c="",H):V(C)}function H(C){if(C===62){const J=c.toLowerCase();return by.includes(J)?(e.consume(C),D):V(C)}return oi(C)&&c.length<8?(e.consume(C),c+=String.fromCharCode(C),H):V(C)}function oe(C){return C===93?(e.consume(C),E):V(C)}function E(C){return C===62?(e.consume(C),D):C===45&&a===2?(e.consume(C),E):V(C)}function D(C){return C===null||be(C)?(e.exit("htmlFlowData"),K(C)):(e.consume(C),D)}function K(C){return e.exit("htmlFlow"),t(C)}}function GE(e,t,n){const s=this;return a;function a(c){return be(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):n(c)}function o(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}function $E(e,t,n){return s;function s(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Da,t,n)}}const ZE={name:"htmlText",tokenize:QE};function QE(e,t,n){const s=this;let a,o,c;return f;function f(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),p}function p(E){return E===33?(e.consume(E),h):E===47?(e.consume(E),W):E===63?(e.consume(E),I):oi(E)?(e.consume(E),ue):n(E)}function h(E){return E===45?(e.consume(E),g):E===91?(e.consume(E),o=0,x):oi(E)?(e.consume(E),Z):n(E)}function g(E){return E===45?(e.consume(E),y):n(E)}function _(E){return E===null?n(E):E===45?(e.consume(E),b):be(E)?(c=_,j(E)):(e.consume(E),_)}function b(E){return E===45?(e.consume(E),y):_(E)}function y(E){return E===62?T(E):E===45?b(E):_(E)}function x(E){const D="CDATA[";return E===D.charCodeAt(o++)?(e.consume(E),o===D.length?k:x):n(E)}function k(E){return E===null?n(E):E===93?(e.consume(E),L):be(E)?(c=k,j(E)):(e.consume(E),k)}function L(E){return E===93?(e.consume(E),M):k(E)}function M(E){return E===62?T(E):E===93?(e.consume(E),M):k(E)}function Z(E){return E===null||E===62?T(E):be(E)?(c=Z,j(E)):(e.consume(E),Z)}function I(E){return E===null?n(E):E===63?(e.consume(E),Q):be(E)?(c=I,j(E)):(e.consume(E),I)}function Q(E){return E===62?T(E):I(E)}function W(E){return oi(E)?(e.consume(E),O):n(E)}function O(E){return E===45||ni(E)?(e.consume(E),O):ie(E)}function ie(E){return be(E)?(c=ie,j(E)):Oe(E)?(e.consume(E),ie):T(E)}function ue(E){return E===45||ni(E)?(e.consume(E),ue):E===47||E===62||Qe(E)?me(E):n(E)}function me(E){return E===47?(e.consume(E),T):E===58||E===95||oi(E)?(e.consume(E),U):be(E)?(c=me,j(E)):Oe(E)?(e.consume(E),me):T(E)}function U(E){return E===45||E===46||E===58||E===95||ni(E)?(e.consume(E),U):le(E)}function le(E){return E===61?(e.consume(E),V):be(E)?(c=le,j(E)):Oe(E)?(e.consume(E),le):me(E)}function V(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),a=E,B):be(E)?(c=V,j(E)):Oe(E)?(e.consume(E),V):(e.consume(E),A)}function B(E){return E===a?(e.consume(E),a=void 0,R):E===null?n(E):be(E)?(c=B,j(E)):(e.consume(E),B)}function A(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||Qe(E)?me(E):(e.consume(E),A)}function R(E){return E===47||E===62||Qe(E)?me(E):n(E)}function T(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function j(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),H}function H(E){return Oe(E)?Ue(e,oe,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):oe(E)}function oe(E){return e.enter("htmlTextData"),c(E)}}const qd={name:"labelEnd",resolveAll:i5,resolveTo:n5,tokenize:r5},JE={tokenize:s5},e5={tokenize:l5},t5={tokenize:a5};function i5(e){let t=-1;const n=[];for(;++t=3&&(h===null||be(h))?(e.exit("thematicBreak"),t(h)):n(h)}function p(h){return h===a?(e.consume(h),s++,p):(e.exit("thematicBreakSequence"),Oe(h)?Ue(e,f,"whitespace")(h):f(h))}}const bi={continuation:{tokenize:g5},exit:y5,name:"list",tokenize:_5},p5={partial:!0,tokenize:b5},m5={partial:!0,tokenize:v5};function _5(e,t,n){const s=this,a=s.events[s.events.length-1];let o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,c=0;return f;function f(y){const x=s.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(x==="listUnordered"?!s.containerState.marker||y===s.containerState.marker:_d(y)){if(s.containerState.type||(s.containerState.type=x,e.enter(x,{_container:!0})),x==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(fu,n,h)(y):h(y);if(!s.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),p(y)}return n(y)}function p(y){return _d(y)&&++c<10?(e.consume(y),p):(!s.interrupt||c<2)&&(s.containerState.marker?y===s.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),h(y)):n(y)}function h(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||y,e.check(Da,s.interrupt?n:g,e.attempt(p5,b,_))}function g(y){return s.containerState.initialBlankLine=!0,o++,b(y)}function _(y){return Oe(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),b):n(y)}function b(y){return s.containerState.size=o+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function g5(e,t,n){const s=this;return s.containerState._closeFlow=void 0,e.check(Da,a,o);function a(f){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,Ue(e,t,"listItemIndent",s.containerState.size+1)(f)}function o(f){return s.containerState.furtherBlankLines||!Oe(f)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,c(f)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(m5,t,c)(f))}function c(f){return s.containerState._closeFlow=!0,s.interrupt=void 0,Ue(e,e.attempt(bi,t,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function v5(e,t,n){const s=this;return Ue(e,a,"listItemIndent",s.containerState.size+1);function a(o){const c=s.events[s.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===s.containerState.size?t(o):n(o)}}function y5(e){e.exit(this.containerState.type)}function b5(e,t,n){const s=this;return Ue(e,a,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(o){const c=s.events[s.events.length-1];return!Oe(o)&&c&&c[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const Sy={name:"setextUnderline",resolveTo:S5,tokenize:x5};function S5(e,t){let n=e.length,s,a,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){s=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const c={type:"setextHeading",start:{...e[s][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",o?(e.splice(a,0,["enter",c,t]),e.splice(o+1,0,["exit",e[s][1],t]),e[s][1].end={...e[o][1].end}):e[s][1]=c,e.push(["exit",c,t]),e}function x5(e,t,n){const s=this;let a;return o;function o(h){let g=s.events.length,_;for(;g--;)if(s.events[g][1].type!=="lineEnding"&&s.events[g][1].type!=="linePrefix"&&s.events[g][1].type!=="content"){_=s.events[g][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||_)?(e.enter("setextHeadingLine"),a=h,c(h)):n(h)}function c(h){return e.enter("setextHeadingLineSequence"),f(h)}function f(h){return h===a?(e.consume(h),f):(e.exit("setextHeadingLineSequence"),Oe(h)?Ue(e,p,"lineSuffix")(h):p(h))}function p(h){return h===null||be(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const w5={tokenize:C5};function C5(e){const t=this,n=e.attempt(Da,s,e.attempt(this.parser.constructs.flowInitial,a,Ue(e,e.attempt(this.parser.constructs.flow,a,e.attempt(DE,a)),"linePrefix")));return n;function s(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const k5={resolveAll:yS()},E5=vS("string"),T5=vS("text");function vS(e){return{resolveAll:yS(e==="text"?A5:void 0),tokenize:t};function t(n){const s=this,a=this.parser.constructs[e],o=n.attempt(a,c,f);return c;function c(g){return h(g)?o(g):f(g)}function f(g){if(g===null){n.consume(g);return}return n.enter("data"),n.consume(g),p}function p(g){return h(g)?(n.exit("data"),o(g)):(n.consume(g),p)}function h(g){if(g===null)return!0;const _=a[g];let b=-1;if(_)for(;++b<_.length;){const y=_[b];if(!y.previous||y.previous.call(s,s.previous))return!0}return!1}}}function yS(e){return t;function t(n,s){let a=-1,o;for(;++a<=n.length;)o===void 0?n[a]&&n[a][1].type==="data"&&(o=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==o+2&&(n[o][1].end=n[a-1][1].end,n.splice(o+2,a-o-2),a=o+2),o=void 0);return e?e(n,s):n}}function A5(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const s=e[n-1][1],a=t.sliceStream(s);let o=a.length,c=-1,f=0,p;for(;o--;){const h=a[o];if(typeof h=="string"){for(c=h.length;h.charCodeAt(c-1)===32;)f++,c--;if(c)break;c=-1}else if(h===-2)p=!0,f++;else if(h!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(f=0),f){const h={type:n===e.length||p||f<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?c:s.start._bufferIndex+c,_index:s.start._index+o,line:s.end.line,column:s.end.column-f,offset:s.end.offset-f},end:{...s.end}};s.end={...h.start},s.start.offset===s.end.offset?Object.assign(s,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const D5={42:bi,43:bi,45:bi,48:bi,49:bi,50:bi,51:bi,52:bi,53:bi,54:bi,55:bi,56:bi,57:bi,62:hS},R5={91:LE},M5={[-2]:df,[-1]:df,32:df},B5={35:UE,42:fu,45:[Sy,fu],60:WE,61:Sy,95:fu,96:yy,126:yy},N5={38:dS,92:fS},L5={[-5]:pf,[-4]:pf,[-3]:pf,33:o5,38:dS,42:gd,60:[cE,ZE],91:c5,92:[HE,fS],93:qd,95:gd,96:wE},z5={null:[gd,k5]},O5={null:[42,95]},j5={null:[]},H5=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:O5,contentInitial:R5,disable:j5,document:D5,flow:B5,flowInitial:M5,insideSpan:z5,string:N5,text:L5},Symbol.toStringTag,{value:"Module"}));function P5(e,t,n){let s={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},o=[];let c=[],f=[];const p={attempt:ie(W),check:ie(O),consume:Z,enter:I,exit:Q,interrupt:ie(O,{interrupt:!0})},h={code:null,containerState:{},defineSkip:k,events:[],now:x,parser:e,previous:null,sliceSerialize:b,sliceStream:y,write:_};let g=t.tokenize.call(h,p);return t.resolveAll&&o.push(t),h;function _(le){return c=Vi(c,le),L(),c[c.length-1]!==null?[]:(ue(t,0),h.events=Au(o,h.events,h),h.events)}function b(le,V){return I5(y(le),V)}function y(le){return U5(c,le)}function x(){const{_bufferIndex:le,_index:V,line:B,column:A,offset:R}=s;return{_bufferIndex:le,_index:V,line:B,column:A,offset:R}}function k(le){a[le.line]=le.column,U()}function L(){let le;for(;s._index-1){const f=c[0];typeof f=="string"?c[0]=f.slice(s):c.shift()}o>0&&c.push(e[a].slice(0,o))}return c}function I5(e,t){let n=-1;const s=[];let a;for(;++nnew Set(ae).add(B))}},A.term.onData(H=>{j.readyState===WebSocket.OPEN&&j.send(H)}),A.ws=j},[e]);G.useEffect(()=>{Z.current=W},[W]);const O=G.useCallback(async(B,A)=>{if(!p.current||Bt.has(B))return;const{resume:R=!1,autoConnect:T=!0}=A??{},j=document.createElement("div");j.style.width="100%",j.style.height="100%",j.style.display="none",j.style.paddingLeft="10px",j.style.boxSizing="border-box",p.current.appendChild(j);const H=new V2({cols:80,scrollback:5e3,fontSize:13,fontFamily:'"Geist Mono", ui-monospace, monospace',lineHeight:1.05,letterSpacing:0,cursorBlink:!0,cursorStyle:"block",theme:ik,allowTransparency:!1,drawBoldTextInBrightColors:!1,minimumContrastRatio:7}),ae=new $2,E=new ek;H.loadAddon(ae),H.loadAddon(E),H.open(j);const D={term:H,fit:ae,serialize:E,ws:null,container:j,observer:null,connected:!1},K=new ResizeObserver(()=>{var J;const{width:C}=j.getBoundingClientRect();if(!(C<50))try{ae.fit(),((J=D.ws)==null?void 0:J.readyState)===WebSocket.OPEN&&D.ws.send(JSON.stringify({type:"resize",cols:H.cols,rows:H.rows}))}catch{}});K.observe(j),D.observer=K,Bt.set(B,D),_(C=>[...C,B]);try{const C=await sk(B);C&&H.write(C)}catch{}T?W(B,D,R):y(C=>new Set(C).add(B)),setTimeout(()=>I(D),50)},[W,I]),ie=G.useCallback(async(B,A)=>{const R=Bt.get(B);R&&(R.ws&&(R.ws.close(),R.ws=null),A||(await h.current(`/api/terminal/${encodeURIComponent(B)}`,{method:"DELETE"}).catch(()=>{}),R.term.clear()),W(B,R,A))},[W]),ue=G.useCallback(B=>{const A=Bt.get(B);if(A){try{const R=A.serialize.serialize();ra(B,R).catch(()=>{})}catch{}A.observer.disconnect(),A.ws&&A.ws.close(),A.term.dispose(),A.container.remove(),Bt.delete(B),_(R=>R.filter(T=>T!==B)),y(R=>{const T=new Set(R);return T.delete(B),T}),n(`/api/terminal/${encodeURIComponent(B)}`,{method:"DELETE"}).catch(()=>{}),a==null||a(B)}},[n,a]),me=G.useCallback(B=>{var R;const A=Bt.get(B);A&&(((R=A.ws)==null?void 0:R.readyState)===WebSocket.OPEN&&A.ws.send(`exit +`),iy(B).catch(()=>{}),A.observer.disconnect(),A.ws&&A.ws.close(),A.term.dispose(),A.container.remove(),Bt.delete(B),_(T=>T.filter(j=>j!==B)),y(T=>{const j=new Set(T);return j.delete(B),j}),n(`/api/terminal/${encodeURIComponent(B)}/discard`,{method:"DELETE"}).catch(()=>{}),a==null||a(B))},[n,a]),U=G.useCallback(async(B,A)=>{const R=Bt.get(B);if(!R||Bt.has(A)||!(await h.current("/api/terminal/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldName:B,newName:A})})).ok)return!1;Bt.delete(B),Bt.set(A,R);try{const j=R.serialize.serialize();await iy(B),await ra(A,j)}catch{}return _(j=>j.map(H=>H===B?A:H)),y(j=>{if(!j.has(B))return j;const H=new Set(j);return H.delete(B),H.add(A),H}),!0},[]);G.useEffect(()=>(f&&(f.current=U),()=>{f&&(f.current=null)}),[f,U]),G.useEffect(()=>{t&&(Bt.has(t)?Q(t):h.current(`/api/terminal/session/${encodeURIComponent(t)}`).then(B=>B.ok?B.json():null).then(B=>{if(!Bt.has(t)){const A=(B==null?void 0:B.sessionId)&&!(B!=null&&B.running);O(t,{autoConnect:!A}),Q(t)}}).catch(()=>{Bt.has(t)||(O(t),Q(t))}))},[t,O,Q]),G.useEffect(()=>{const B=setInterval(()=>{for(const[A,R]of Bt)if(R.connected)try{const T=R.serialize.serialize();ra(A,T).catch(()=>{})}catch{}},3e4);return()=>clearInterval(B)},[]),G.useEffect(()=>()=>{for(const[B,A]of Bt){try{const R=A.serialize.serialize();ra(B,R).catch(()=>{})}catch{}A.observer.disconnect(),A.ws&&A.ws.close(),A.term.dispose(),A.container.remove(),h.current(`/api/terminal/${encodeURIComponent(B)}`,{method:"DELETE"}).catch(()=>{})}Bt.clear()},[]);const le=t?b.has(t):!1,V=g.length===0;return S.jsxs("div",{className:"h-full flex flex-col",children:[!V&&S.jsxs("div",{className:"px-2 py-1 border-b border-border flex items-center gap-1 overflow-x-auto",children:[g.map(B=>S.jsxs("div",{onClick:()=>s==null?void 0:s(B),className:`flex items-center gap-1 px-2 py-0.5 rounded text-xs font-mono cursor-pointer ${B===t?"bg-accent/10 text-accent":"text-muted hover:text-foreground"}`,children:[S.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${b.has(B)?"bg-amber-500":B===t?"bg-green-600":"bg-muted/50"}`}),S.jsx("span",{className:`truncate max-w-[120px] ${B.startsWith("_new_")?"italic":""}`,children:B.startsWith("_new_")?"Untitled":B}),S.jsx("button",{onClick:A=>{A.stopPropagation(),B.startsWith("_new_")?k(B):ue(B)},className:"ml-0.5 text-muted hover:text-error text-[10px] leading-none",title:"Close terminal",children:"×"})]},B)),t!=null&&t.startsWith("_new_")?S.jsx("button",{onClick:()=>k(t),className:"ml-auto px-2 py-0.5 text-xs text-error hover:bg-surface rounded flex items-center gap-1 flex-shrink-0",children:"Cancel ×"}):t&&o&&(c!=null&&c.has(t))?S.jsx("button",{onClick:()=>M(t),className:"ml-auto px-2 py-0.5 text-xs text-muted hover:text-foreground hover:bg-surface rounded flex items-center gap-1 flex-shrink-0",children:"Archive"}):null]}),S.jsxs("div",{className:"relative flex-1 min-h-0",children:[S.jsx("div",{ref:p,className:"h-full"}),V&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-muted",children:S.jsxs("div",{className:"text-center",children:[S.jsx("p",{className:"text-lg font-serif",children:"Select a story on the left menu"}),S.jsx("p",{className:"text-sm mt-1",children:"to start an AI Writer session"})]})}),x&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[S.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Discard this session?"}),S.jsx("p",{className:"text-xs text-muted",children:"This session will be lost — your AI hasn't created a story structure yet."}),S.jsxs("div",{className:"flex items-center justify-center gap-2",children:[S.jsx("button",{onClick:()=>k(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),S.jsx("button",{onClick:()=>{const B=x;k(null),me(B)},className:"px-4 py-1.5 bg-error text-white text-sm rounded hover:opacity-80",children:"Discard"})]})]})}),L&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[S.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Archive this story?"}),S.jsx("p",{className:"text-xs text-muted",children:"You can restore it later from the Archives view."}),S.jsxs("div",{className:"flex items-center justify-center gap-2",children:[S.jsx("button",{onClick:()=>M(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),S.jsx("button",{onClick:async()=>{const B=L;M(null);try{(await h.current("/api/stories/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B})})).ok&&(ue(B),o==null||o(B))}catch{}},className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Archive"})]})]})}),le&&t&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3",children:[S.jsx("p",{className:"text-sm font-serif text-foreground",children:"Terminal disconnected"}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("button",{onClick:()=>ie(t,!0),className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Resume Session"}),S.jsx("button",{onClick:()=>ie(t,!1),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Start Fresh"})]}),S.jsx("p",{className:"text-xs text-muted",children:"Resume continues your previous Claude conversation"})]})})]})]})}function ak(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const ok=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,uk=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ck={};function ny(e,t){return(ck.jsx?uk:ok).test(e)}const hk=/[ \t\n\f\r]/g;function fk(e){return typeof e=="object"?e.type==="text"?ry(e.value):!1:ry(e)}function ry(e){return e.replace(hk,"")===""}class Aa{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}}Aa.prototype.normal={};Aa.prototype.property={};Aa.prototype.space=void 0;function Xb(e,t){const n={},s={};for(const a of e)Object.assign(n,a.property),Object.assign(s,a.normal);return new Aa(n,s,t)}function fd(e){return e.toLowerCase()}class Si{constructor(t,n){this.attribute=n,this.property=t}}Si.prototype.attribute="";Si.prototype.booleanish=!1;Si.prototype.boolean=!1;Si.prototype.commaOrSpaceSeparated=!1;Si.prototype.commaSeparated=!1;Si.prototype.defined=!1;Si.prototype.mustUseProperty=!1;Si.prototype.number=!1;Si.prototype.overloadedBoolean=!1;Si.prototype.property="";Si.prototype.spaceSeparated=!1;Si.prototype.space=void 0;let dk=0;const Re=rs(),wt=rs(),dd=rs(),oe=rs(),Je=rs(),Qs=rs(),Mi=rs();function rs(){return 2**++dk}const pd=Object.freeze(Object.defineProperty({__proto__:null,boolean:Re,booleanish:wt,commaOrSpaceSeparated:Mi,commaSeparated:Qs,number:oe,overloadedBoolean:dd,spaceSeparated:Je},Symbol.toStringTag,{value:"Module"})),cf=Object.keys(pd);class zd extends Si{constructor(t,n,s,a){let o=-1;if(super(t,n),sy(this,"space",a),typeof s=="number")for(;++o4&&n.slice(0,4)==="data"&&vk.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(ly,Sk);s="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!ly.test(o)){let c=o.replace(gk,bk);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=zd}return new a(s,t)}function bk(e){return"-"+e.toLowerCase()}function Sk(e){return e.charAt(1).toUpperCase()}const xk=Xb([$b,pk,Qb,Jb,eS],"html"),Od=Xb([$b,mk,Qb,Jb,eS],"svg");function wk(e){return e.join(" ").trim()}var Vs={},hf,ay;function Ck(){if(ay)return hf;ay=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,f=/^\s+|\s+$/g,p=` +`,h="/",g="*",_="",b="comment",y="declaration";function x(L,M){if(typeof L!="string")throw new TypeError("First argument must be a string");if(!L)return[];M=M||{};var Z=1,I=1;function Q(A){var R=A.match(t);R&&(Z+=R.length);var T=A.lastIndexOf(p);I=~T?A.length-T:I+A.length}function W(){var A={line:Z,column:I};return function(R){return R.position=new O(A),me(),R}}function O(A){this.start=A,this.end={line:Z,column:I},this.source=M.source}O.prototype.content=L;function ie(A){var R=new Error(M.source+":"+Z+":"+I+": "+A);if(R.reason=A,R.filename=M.source,R.line=Z,R.column=I,R.source=L,!M.silent)throw R}function ue(A){var R=A.exec(L);if(R){var T=R[0];return Q(T),L=L.slice(T.length),R}}function me(){ue(n)}function U(A){var R;for(A=A||[];R=le();)R!==!1&&A.push(R);return A}function le(){var A=W();if(!(h!=L.charAt(0)||g!=L.charAt(1))){for(var R=2;_!=L.charAt(R)&&(g!=L.charAt(R)||h!=L.charAt(R+1));)++R;if(R+=2,_===L.charAt(R-1))return ie("End of comment missing");var T=L.slice(2,R-2);return I+=2,Q(T),L=L.slice(R),I+=2,A({type:b,comment:T})}}function V(){var A=W(),R=ue(s);if(R){if(le(),!ue(a))return ie("property missing ':'");var T=ue(o),j=A({type:y,property:k(R[0].replace(e,_)),value:T?k(T[0].replace(e,_)):_});return ue(c),j}}function B(){var A=[];U(A);for(var R;R=V();)R!==!1&&(A.push(R),U(A));return A}return me(),B()}function k(L){return L?L.replace(f,_):_}return hf=x,hf}var oy;function kk(){if(oy)return Vs;oy=1;var e=Vs&&Vs.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Vs,"__esModule",{value:!0}),Vs.default=n;const t=e(Ck());function n(s,a){let o=null;if(!s||typeof s!="string")return o;const c=(0,t.default)(s),f=typeof a=="function";return c.forEach(p=>{if(p.type!=="declaration")return;const{property:h,value:g}=p;f?a(h,g,p):g&&(o=o||{},o[h]=g)}),o}return Vs}var sa={},uy;function Ek(){if(uy)return sa;uy=1,Object.defineProperty(sa,"__esModule",{value:!0}),sa.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(h){return!h||n.test(h)||e.test(h)},c=function(h,g){return g.toUpperCase()},f=function(h,g){return"".concat(g,"-")},p=function(h,g){return g===void 0&&(g={}),o(h)?h:(h=h.toLowerCase(),g.reactCompat?h=h.replace(a,f):h=h.replace(s,f),h.replace(t,c))};return sa.camelCase=p,sa}var la,cy;function Tk(){if(cy)return la;cy=1;var e=la&&la.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(kk()),n=Ek();function s(a,o){var c={};return!a||typeof a!="string"||(0,t.default)(a,function(f,p){f&&p&&(c[(0,n.camelCase)(f,o)]=p)}),c}return s.default=s,la=s,la}var Ak=Tk();const Dk=xu(Ak),tS=iS("end"),jd=iS("start");function iS(e){return t;function t(n){const s=n&&n.position&&n.position[e]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function nS(e){const t=jd(e),n=tS(e);if(t&&n)return{start:t,end:n}}function ma(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?hy(e.position):"start"in e||"end"in e?hy(e):"line"in e||"column"in e?md(e):""}function md(e){return fy(e&&e.line)+":"+fy(e&&e.column)}function hy(e){return md(e&&e.start)+"-"+md(e&&e.end)}function fy(e){return e&&typeof e=="number"?e:1}class ri extends Error{constructor(t,n,s){super(),typeof n=="string"&&(s=n,n=void 0);let a="",o={},c=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?a=t:!o.cause&&t&&(c=!0,a=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof s=="string"){const p=s.indexOf(":");p===-1?o.ruleId=s:(o.source=s.slice(0,p),o.ruleId=s.slice(p+1))}if(!o.place&&o.ancestors&&o.ancestors){const p=o.ancestors[o.ancestors.length-1];p&&(o.place=p.position)}const f=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=f?f.line:void 0,this.name=ma(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=c&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ri.prototype.file="";ri.prototype.name="";ri.prototype.reason="";ri.prototype.message="";ri.prototype.stack="";ri.prototype.column=void 0;ri.prototype.line=void 0;ri.prototype.ancestors=void 0;ri.prototype.cause=void 0;ri.prototype.fatal=void 0;ri.prototype.place=void 0;ri.prototype.ruleId=void 0;ri.prototype.source=void 0;const Hd={}.hasOwnProperty,Rk=new Map,Mk=/[A-Z]/g,Bk=new Set(["table","tbody","thead","tfoot","tr"]),Nk=new Set(["td","th"]),rS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Lk(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let s;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=Fk(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");s=Ik(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Od:xk,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=sS(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function sS(e,t,n){if(t.type==="element")return zk(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Ok(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Hk(e,t,n);if(t.type==="mdxjsEsm")return jk(e,t);if(t.type==="root")return Pk(e,t,n);if(t.type==="text")return Uk(e,t)}function zk(e,t,n){const s=e.schema;let a=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(a=Od,e.schema=a),e.ancestors.push(t);const o=aS(e,t.tagName,!1),c=qk(e,t);let f=Ud(e,t);return Bk.has(t.tagName)&&(f=f.filter(function(p){return typeof p=="string"?!fk(p):!0})),lS(e,c,o,t),Pd(c,f),e.ancestors.pop(),e.schema=s,e.create(t,o,c,n)}function Ok(e,t){if(t.data&&t.data.estree&&e.evaluater){const s=t.data.estree.body[0];return s.type,e.evaluater.evaluateExpression(s.expression)}Sa(e,t.position)}function jk(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Sa(e,t.position)}function Hk(e,t,n){const s=e.schema;let a=s;t.name==="svg"&&s.space==="html"&&(a=Od,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:aS(e,t.name,!0),c=Wk(e,t),f=Ud(e,t);return lS(e,c,o,t),Pd(c,f),e.ancestors.pop(),e.schema=s,e.create(t,o,c,n)}function Pk(e,t,n){const s={};return Pd(s,Ud(e,t)),e.create(t,e.Fragment,s,n)}function Uk(e,t){return t.value}function lS(e,t,n,s){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=s)}function Pd(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Ik(e,t,n){return s;function s(a,o,c,f){const h=Array.isArray(c.children)?n:t;return f?h(o,c,f):h(o,c)}}function Fk(e,t){return n;function n(s,a,o,c){const f=Array.isArray(o.children),p=jd(s);return t(a,o,c,f,{columnNumber:p?p.column-1:void 0,fileName:e,lineNumber:p?p.line:void 0},void 0)}}function qk(e,t){const n={};let s,a;for(a in t.properties)if(a!=="children"&&Hd.call(t.properties,a)){const o=Yk(e,a,t.properties[a]);if(o){const[c,f]=o;e.tableCellAlignToStyle&&c==="align"&&typeof f=="string"&&Nk.has(t.tagName)?s=f:n[c]=f}}if(s){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return n}function Wk(e,t){const n={};for(const s of t.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&e.evaluater){const o=s.data.estree.body[0];o.type;const c=o.expression;c.type;const f=c.properties[0];f.type,Object.assign(n,e.evaluater.evaluateExpression(f.argument))}else Sa(e,t.position);else{const a=s.name;let o;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&e.evaluater){const f=s.value.data.estree.body[0];f.type,o=e.evaluater.evaluateExpression(f.expression)}else Sa(e,t.position);else o=s.value===null?!0:s.value;n[a]=o}return n}function Ud(e,t){const n=[];let s=-1;const a=e.passKeys?new Map:Rk;for(;++sa?0:a+t:t=t>a?a:t,n=n>0?n:0,s.length<1e4)c=Array.from(s),c.unshift(t,n),e.splice(...c);else for(n&&e.splice(t,n);o0?(Bi(e,e.length,0,t),e):t}const my={}.hasOwnProperty;function uS(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ji(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const oi=kr(/[A-Za-z]/),ni=kr(/[\dA-Za-z]/),eE=kr(/[#-'*+\--9=?A-Z^-~]/);function yu(e){return e!==null&&(e<32||e===127)}const _d=kr(/\d/),tE=kr(/[\dA-Fa-f]/),iE=kr(/[!-/:-@[-`{-~]/);function be(e){return e!==null&&e<-2}function Qe(e){return e!==null&&(e<0||e===32)}function Oe(e){return e===-2||e===-1||e===32}const Tu=kr(new RegExp("\\p{P}|\\p{S}","u")),is=kr(/\s/);function kr(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function rl(e){const t=[];let n=-1,s=0,a=0;for(;++n55295&&o<57344){const f=e.charCodeAt(n+1);o<56320&&f>56319&&f<57344?(c=String.fromCharCode(o,f),a=1):c="�"}else c=String.fromCharCode(o);c&&(t.push(e.slice(s,n),encodeURIComponent(c)),s=n+a+1,c=""),a&&(n+=a,a=0)}return t.join("")+e.slice(s)}function Ue(e,t,n,s){const a=s?s-1:Number.POSITIVE_INFINITY;let o=0;return c;function c(p){return Oe(p)?(e.enter(n),f(p)):t(p)}function f(p){return Oe(p)&&o++c))return;const ie=t.events.length;let ue=ie,me,U;for(;ue--;)if(t.events[ue][0]==="exit"&&t.events[ue][1].type==="chunkFlow"){if(me){U=t.events[ue][1].end;break}me=!0}for(M(s),O=ie;OI;){const W=n[Q];t.containerState=W[1],W[0].exit.call(t,e)}n.length=I}function Z(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function aE(e,t,n){return Ue(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function el(e){if(e===null||Qe(e)||is(e))return 1;if(Tu(e))return 2}function Au(e,t,n){const s=[];let a=-1;for(;++a1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const _={...e[s][1].end},b={...e[n][1].start};gy(_,-p),gy(b,p),c={type:p>1?"strongSequence":"emphasisSequence",start:_,end:{...e[s][1].end}},f={type:p>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:b},o={type:p>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[n][1].start}},a={type:p>1?"strong":"emphasis",start:{...c.start},end:{...f.end}},e[s][1].end={...c.start},e[n][1].start={...f.end},h=[],e[s][1].end.offset-e[s][1].start.offset&&(h=Vi(h,[["enter",e[s][1],t],["exit",e[s][1],t]])),h=Vi(h,[["enter",a,t],["enter",c,t],["exit",c,t],["enter",o,t]]),h=Vi(h,Au(t.parser.constructs.insideSpan.null,e.slice(s+1,n),t)),h=Vi(h,[["exit",o,t],["enter",f,t],["exit",f,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(g=2,h=Vi(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):g=0,Bi(e,s-1,n-s+3,h),n=s+h.length-g-2;break}}for(n=-1;++n0&&Oe(O)?Ue(e,Z,"linePrefix",o+1)(O):Z(O)}function Z(O){return O===null||be(O)?e.check(vy,k,Q)(O):(e.enter("codeFlowValue"),I(O))}function I(O){return O===null||be(O)?(e.exit("codeFlowValue"),Z(O)):(e.consume(O),I)}function Q(O){return e.exit("codeFenced"),t(O)}function W(O,ie,ue){let me=0;return U;function U(R){return O.enter("lineEnding"),O.consume(R),O.exit("lineEnding"),le}function le(R){return O.enter("codeFencedFence"),Oe(R)?Ue(O,V,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):V(R)}function V(R){return R===f?(O.enter("codeFencedFenceSequence"),B(R)):ue(R)}function B(R){return R===f?(me++,O.consume(R),B):me>=c?(O.exit("codeFencedFenceSequence"),Oe(R)?Ue(O,A,"whitespace")(R):A(R)):ue(R)}function A(R){return R===null||be(R)?(O.exit("codeFencedFence"),ie(R)):ue(R)}}}function yE(e,t,n){const s=this;return a;function a(c){return c===null?n(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o)}function o(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}const df={name:"codeIndented",tokenize:SE},bE={partial:!0,tokenize:xE};function SE(e,t,n){const s=this;return a;function a(h){return e.enter("codeIndented"),Ue(e,o,"linePrefix",5)(h)}function o(h){const g=s.events[s.events.length-1];return g&&g[1].type==="linePrefix"&&g[2].sliceSerialize(g[1],!0).length>=4?c(h):n(h)}function c(h){return h===null?p(h):be(h)?e.attempt(bE,c,p)(h):(e.enter("codeFlowValue"),f(h))}function f(h){return h===null||be(h)?(e.exit("codeFlowValue"),c(h)):(e.consume(h),f)}function p(h){return e.exit("codeIndented"),t(h)}}function xE(e,t,n){const s=this;return a;function a(c){return s.parser.lazy[s.now().line]?n(c):be(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):Ue(e,o,"linePrefix",5)(c)}function o(c){const f=s.events[s.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?t(c):be(c)?a(c):n(c)}}const wE={name:"codeText",previous:kE,resolve:CE,tokenize:EE};function CE(e){let t=e.length-4,n=3,s,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(s=n;++s=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(t,n,s){const a=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return s&&aa(this.left,s),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),aa(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),aa(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(c):e.interrupt(s.parser.constructs.flow,n,t)(c)}}function mS(e,t,n,s,a,o,c,f,p){const h=p||Number.POSITIVE_INFINITY;let g=0;return _;function _(M){return M===60?(e.enter(s),e.enter(a),e.enter(o),e.consume(M),e.exit(o),b):M===null||M===32||M===41||yu(M)?n(M):(e.enter(s),e.enter(c),e.enter(f),e.enter("chunkString",{contentType:"string"}),k(M))}function b(M){return M===62?(e.enter(o),e.consume(M),e.exit(o),e.exit(a),e.exit(s),t):(e.enter(f),e.enter("chunkString",{contentType:"string"}),y(M))}function y(M){return M===62?(e.exit("chunkString"),e.exit(f),b(M)):M===null||M===60||be(M)?n(M):(e.consume(M),M===92?x:y)}function x(M){return M===60||M===62||M===92?(e.consume(M),y):y(M)}function k(M){return!g&&(M===null||M===41||Qe(M))?(e.exit("chunkString"),e.exit(f),e.exit(c),e.exit(s),t(M)):g999||y===null||y===91||y===93&&!p||y===94&&!f&&"_hiddenFootnoteSupport"in c.parser.constructs?n(y):y===93?(e.exit(o),e.enter(a),e.consume(y),e.exit(a),e.exit(s),t):be(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),g):(e.enter("chunkString",{contentType:"string"}),_(y))}function _(y){return y===null||y===91||y===93||be(y)||f++>999?(e.exit("chunkString"),g(y)):(e.consume(y),p||(p=!Oe(y)),y===92?b:_)}function b(y){return y===91||y===92||y===93?(e.consume(y),f++,_):_(y)}}function gS(e,t,n,s,a,o){let c;return f;function f(b){return b===34||b===39||b===40?(e.enter(s),e.enter(a),e.consume(b),e.exit(a),c=b===40?41:b,p):n(b)}function p(b){return b===c?(e.enter(a),e.consume(b),e.exit(a),e.exit(s),t):(e.enter(o),h(b))}function h(b){return b===c?(e.exit(o),p(c)):b===null?n(b):be(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),Ue(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),g(b))}function g(b){return b===c||b===null||be(b)?(e.exit("chunkString"),h(b)):(e.consume(b),b===92?_:g)}function _(b){return b===c||b===92?(e.consume(b),g):g(b)}}function _a(e,t){let n;return s;function s(a){return be(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,s):Oe(a)?Ue(e,s,n?"linePrefix":"lineSuffix")(a):t(a)}}const LE={name:"definition",tokenize:OE},zE={partial:!0,tokenize:jE};function OE(e,t,n){const s=this;let a;return o;function o(y){return e.enter("definition"),c(y)}function c(y){return _S.call(s,e,f,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function f(y){return a=Ji(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),p):n(y)}function p(y){return Qe(y)?_a(e,h)(y):h(y)}function h(y){return mS(e,g,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function g(y){return e.attempt(zE,_,_)(y)}function _(y){return Oe(y)?Ue(e,b,"whitespace")(y):b(y)}function b(y){return y===null||be(y)?(e.exit("definition"),s.parser.defined.push(a),t(y)):n(y)}}function jE(e,t,n){return s;function s(f){return Qe(f)?_a(e,a)(f):n(f)}function a(f){return gS(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function o(f){return Oe(f)?Ue(e,c,"whitespace")(f):c(f)}function c(f){return f===null||be(f)?t(f):n(f)}}const HE={name:"hardBreakEscape",tokenize:PE};function PE(e,t,n){return s;function s(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return be(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const UE={name:"headingAtx",resolve:IE,tokenize:FE};function IE(e,t){let n=e.length-2,s=3,a,o;return e[s][1].type==="whitespace"&&(s+=2),n-2>s&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(s===n-1||n-4>s&&e[n-2][1].type==="whitespace")&&(n-=s+1===n?2:4),n>s&&(a={type:"atxHeadingText",start:e[s][1].start,end:e[n][1].end},o={type:"chunkText",start:e[s][1].start,end:e[n][1].end,contentType:"text"},Bi(e,s,n-s+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function FE(e,t,n){let s=0;return a;function a(g){return e.enter("atxHeading"),o(g)}function o(g){return e.enter("atxHeadingSequence"),c(g)}function c(g){return g===35&&s++<6?(e.consume(g),c):g===null||Qe(g)?(e.exit("atxHeadingSequence"),f(g)):n(g)}function f(g){return g===35?(e.enter("atxHeadingSequence"),p(g)):g===null||be(g)?(e.exit("atxHeading"),t(g)):Oe(g)?Ue(e,f,"whitespace")(g):(e.enter("atxHeadingText"),h(g))}function p(g){return g===35?(e.consume(g),p):(e.exit("atxHeadingSequence"),f(g))}function h(g){return g===null||g===35||Qe(g)?(e.exit("atxHeadingText"),f(g)):(e.consume(g),h)}}const qE=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],by=["pre","script","style","textarea"],WE={concrete:!0,name:"htmlFlow",resolveTo:KE,tokenize:XE},YE={partial:!0,tokenize:GE},VE={partial:!0,tokenize:$E};function KE(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function XE(e,t,n){const s=this;let a,o,c,f,p;return h;function h(C){return g(C)}function g(C){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(C),_}function _(C){return C===33?(e.consume(C),b):C===47?(e.consume(C),o=!0,k):C===63?(e.consume(C),a=3,s.interrupt?t:E):oi(C)?(e.consume(C),c=String.fromCharCode(C),L):n(C)}function b(C){return C===45?(e.consume(C),a=2,y):C===91?(e.consume(C),a=5,f=0,x):oi(C)?(e.consume(C),a=4,s.interrupt?t:E):n(C)}function y(C){return C===45?(e.consume(C),s.interrupt?t:E):n(C)}function x(C){const J="CDATA[";return C===J.charCodeAt(f++)?(e.consume(C),f===J.length?s.interrupt?t:V:x):n(C)}function k(C){return oi(C)?(e.consume(C),c=String.fromCharCode(C),L):n(C)}function L(C){if(C===null||C===47||C===62||Qe(C)){const J=C===47,fe=c.toLowerCase();return!J&&!o&&by.includes(fe)?(a=1,s.interrupt?t(C):V(C)):qE.includes(c.toLowerCase())?(a=6,J?(e.consume(C),M):s.interrupt?t(C):V(C)):(a=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(C):o?Z(C):I(C))}return C===45||ni(C)?(e.consume(C),c+=String.fromCharCode(C),L):n(C)}function M(C){return C===62?(e.consume(C),s.interrupt?t:V):n(C)}function Z(C){return Oe(C)?(e.consume(C),Z):U(C)}function I(C){return C===47?(e.consume(C),U):C===58||C===95||oi(C)?(e.consume(C),Q):Oe(C)?(e.consume(C),I):U(C)}function Q(C){return C===45||C===46||C===58||C===95||ni(C)?(e.consume(C),Q):W(C)}function W(C){return C===61?(e.consume(C),O):Oe(C)?(e.consume(C),W):I(C)}function O(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(e.consume(C),p=C,ie):Oe(C)?(e.consume(C),O):ue(C)}function ie(C){return C===p?(e.consume(C),p=null,me):C===null||be(C)?n(C):(e.consume(C),ie)}function ue(C){return C===null||C===34||C===39||C===47||C===60||C===61||C===62||C===96||Qe(C)?W(C):(e.consume(C),ue)}function me(C){return C===47||C===62||Oe(C)?I(C):n(C)}function U(C){return C===62?(e.consume(C),le):n(C)}function le(C){return C===null||be(C)?V(C):Oe(C)?(e.consume(C),le):n(C)}function V(C){return C===45&&a===2?(e.consume(C),T):C===60&&a===1?(e.consume(C),j):C===62&&a===4?(e.consume(C),D):C===63&&a===3?(e.consume(C),E):C===93&&a===5?(e.consume(C),ae):be(C)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(YE,K,B)(C)):C===null||be(C)?(e.exit("htmlFlowData"),B(C)):(e.consume(C),V)}function B(C){return e.check(VE,A,K)(C)}function A(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),R}function R(C){return C===null||be(C)?B(C):(e.enter("htmlFlowData"),V(C))}function T(C){return C===45?(e.consume(C),E):V(C)}function j(C){return C===47?(e.consume(C),c="",H):V(C)}function H(C){if(C===62){const J=c.toLowerCase();return by.includes(J)?(e.consume(C),D):V(C)}return oi(C)&&c.length<8?(e.consume(C),c+=String.fromCharCode(C),H):V(C)}function ae(C){return C===93?(e.consume(C),E):V(C)}function E(C){return C===62?(e.consume(C),D):C===45&&a===2?(e.consume(C),E):V(C)}function D(C){return C===null||be(C)?(e.exit("htmlFlowData"),K(C)):(e.consume(C),D)}function K(C){return e.exit("htmlFlow"),t(C)}}function $E(e,t,n){const s=this;return a;function a(c){return be(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):n(c)}function o(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}function GE(e,t,n){return s;function s(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Da,t,n)}}const ZE={name:"htmlText",tokenize:QE};function QE(e,t,n){const s=this;let a,o,c;return f;function f(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),p}function p(E){return E===33?(e.consume(E),h):E===47?(e.consume(E),W):E===63?(e.consume(E),I):oi(E)?(e.consume(E),ue):n(E)}function h(E){return E===45?(e.consume(E),g):E===91?(e.consume(E),o=0,x):oi(E)?(e.consume(E),Z):n(E)}function g(E){return E===45?(e.consume(E),y):n(E)}function _(E){return E===null?n(E):E===45?(e.consume(E),b):be(E)?(c=_,j(E)):(e.consume(E),_)}function b(E){return E===45?(e.consume(E),y):_(E)}function y(E){return E===62?T(E):E===45?b(E):_(E)}function x(E){const D="CDATA[";return E===D.charCodeAt(o++)?(e.consume(E),o===D.length?k:x):n(E)}function k(E){return E===null?n(E):E===93?(e.consume(E),L):be(E)?(c=k,j(E)):(e.consume(E),k)}function L(E){return E===93?(e.consume(E),M):k(E)}function M(E){return E===62?T(E):E===93?(e.consume(E),M):k(E)}function Z(E){return E===null||E===62?T(E):be(E)?(c=Z,j(E)):(e.consume(E),Z)}function I(E){return E===null?n(E):E===63?(e.consume(E),Q):be(E)?(c=I,j(E)):(e.consume(E),I)}function Q(E){return E===62?T(E):I(E)}function W(E){return oi(E)?(e.consume(E),O):n(E)}function O(E){return E===45||ni(E)?(e.consume(E),O):ie(E)}function ie(E){return be(E)?(c=ie,j(E)):Oe(E)?(e.consume(E),ie):T(E)}function ue(E){return E===45||ni(E)?(e.consume(E),ue):E===47||E===62||Qe(E)?me(E):n(E)}function me(E){return E===47?(e.consume(E),T):E===58||E===95||oi(E)?(e.consume(E),U):be(E)?(c=me,j(E)):Oe(E)?(e.consume(E),me):T(E)}function U(E){return E===45||E===46||E===58||E===95||ni(E)?(e.consume(E),U):le(E)}function le(E){return E===61?(e.consume(E),V):be(E)?(c=le,j(E)):Oe(E)?(e.consume(E),le):me(E)}function V(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),a=E,B):be(E)?(c=V,j(E)):Oe(E)?(e.consume(E),V):(e.consume(E),A)}function B(E){return E===a?(e.consume(E),a=void 0,R):E===null?n(E):be(E)?(c=B,j(E)):(e.consume(E),B)}function A(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||Qe(E)?me(E):(e.consume(E),A)}function R(E){return E===47||E===62||Qe(E)?me(E):n(E)}function T(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function j(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),H}function H(E){return Oe(E)?Ue(e,ae,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):ae(E)}function ae(E){return e.enter("htmlTextData"),c(E)}}const qd={name:"labelEnd",resolveAll:i5,resolveTo:n5,tokenize:r5},JE={tokenize:s5},e5={tokenize:l5},t5={tokenize:a5};function i5(e){let t=-1;const n=[];for(;++t=3&&(h===null||be(h))?(e.exit("thematicBreak"),t(h)):n(h)}function p(h){return h===a?(e.consume(h),s++,p):(e.exit("thematicBreakSequence"),Oe(h)?Ue(e,f,"whitespace")(h):f(h))}}const bi={continuation:{tokenize:g5},exit:y5,name:"list",tokenize:_5},p5={partial:!0,tokenize:b5},m5={partial:!0,tokenize:v5};function _5(e,t,n){const s=this,a=s.events[s.events.length-1];let o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,c=0;return f;function f(y){const x=s.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(x==="listUnordered"?!s.containerState.marker||y===s.containerState.marker:_d(y)){if(s.containerState.type||(s.containerState.type=x,e.enter(x,{_container:!0})),x==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(fu,n,h)(y):h(y);if(!s.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),p(y)}return n(y)}function p(y){return _d(y)&&++c<10?(e.consume(y),p):(!s.interrupt||c<2)&&(s.containerState.marker?y===s.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),h(y)):n(y)}function h(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||y,e.check(Da,s.interrupt?n:g,e.attempt(p5,b,_))}function g(y){return s.containerState.initialBlankLine=!0,o++,b(y)}function _(y){return Oe(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),b):n(y)}function b(y){return s.containerState.size=o+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function g5(e,t,n){const s=this;return s.containerState._closeFlow=void 0,e.check(Da,a,o);function a(f){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,Ue(e,t,"listItemIndent",s.containerState.size+1)(f)}function o(f){return s.containerState.furtherBlankLines||!Oe(f)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,c(f)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(m5,t,c)(f))}function c(f){return s.containerState._closeFlow=!0,s.interrupt=void 0,Ue(e,e.attempt(bi,t,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function v5(e,t,n){const s=this;return Ue(e,a,"listItemIndent",s.containerState.size+1);function a(o){const c=s.events[s.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===s.containerState.size?t(o):n(o)}}function y5(e){e.exit(this.containerState.type)}function b5(e,t,n){const s=this;return Ue(e,a,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(o){const c=s.events[s.events.length-1];return!Oe(o)&&c&&c[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const Sy={name:"setextUnderline",resolveTo:S5,tokenize:x5};function S5(e,t){let n=e.length,s,a,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){s=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const c={type:"setextHeading",start:{...e[s][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",o?(e.splice(a,0,["enter",c,t]),e.splice(o+1,0,["exit",e[s][1],t]),e[s][1].end={...e[o][1].end}):e[s][1]=c,e.push(["exit",c,t]),e}function x5(e,t,n){const s=this;let a;return o;function o(h){let g=s.events.length,_;for(;g--;)if(s.events[g][1].type!=="lineEnding"&&s.events[g][1].type!=="linePrefix"&&s.events[g][1].type!=="content"){_=s.events[g][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||_)?(e.enter("setextHeadingLine"),a=h,c(h)):n(h)}function c(h){return e.enter("setextHeadingLineSequence"),f(h)}function f(h){return h===a?(e.consume(h),f):(e.exit("setextHeadingLineSequence"),Oe(h)?Ue(e,p,"lineSuffix")(h):p(h))}function p(h){return h===null||be(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const w5={tokenize:C5};function C5(e){const t=this,n=e.attempt(Da,s,e.attempt(this.parser.constructs.flowInitial,a,Ue(e,e.attempt(this.parser.constructs.flow,a,e.attempt(DE,a)),"linePrefix")));return n;function s(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const k5={resolveAll:yS()},E5=vS("string"),T5=vS("text");function vS(e){return{resolveAll:yS(e==="text"?A5:void 0),tokenize:t};function t(n){const s=this,a=this.parser.constructs[e],o=n.attempt(a,c,f);return c;function c(g){return h(g)?o(g):f(g)}function f(g){if(g===null){n.consume(g);return}return n.enter("data"),n.consume(g),p}function p(g){return h(g)?(n.exit("data"),o(g)):(n.consume(g),p)}function h(g){if(g===null)return!0;const _=a[g];let b=-1;if(_)for(;++b<_.length;){const y=_[b];if(!y.previous||y.previous.call(s,s.previous))return!0}return!1}}}function yS(e){return t;function t(n,s){let a=-1,o;for(;++a<=n.length;)o===void 0?n[a]&&n[a][1].type==="data"&&(o=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==o+2&&(n[o][1].end=n[a-1][1].end,n.splice(o+2,a-o-2),a=o+2),o=void 0);return e?e(n,s):n}}function A5(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const s=e[n-1][1],a=t.sliceStream(s);let o=a.length,c=-1,f=0,p;for(;o--;){const h=a[o];if(typeof h=="string"){for(c=h.length;h.charCodeAt(c-1)===32;)f++,c--;if(c)break;c=-1}else if(h===-2)p=!0,f++;else if(h!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(f=0),f){const h={type:n===e.length||p||f<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?c:s.start._bufferIndex+c,_index:s.start._index+o,line:s.end.line,column:s.end.column-f,offset:s.end.offset-f},end:{...s.end}};s.end={...h.start},s.start.offset===s.end.offset?Object.assign(s,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const D5={42:bi,43:bi,45:bi,48:bi,49:bi,50:bi,51:bi,52:bi,53:bi,54:bi,55:bi,56:bi,57:bi,62:hS},R5={91:LE},M5={[-2]:df,[-1]:df,32:df},B5={35:UE,42:fu,45:[Sy,fu],60:WE,61:Sy,95:fu,96:yy,126:yy},N5={38:dS,92:fS},L5={[-5]:pf,[-4]:pf,[-3]:pf,33:o5,38:dS,42:gd,60:[cE,ZE],91:c5,92:[HE,fS],93:qd,95:gd,96:wE},z5={null:[gd,k5]},O5={null:[42,95]},j5={null:[]},H5=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:O5,contentInitial:R5,disable:j5,document:D5,flow:B5,flowInitial:M5,insideSpan:z5,string:N5,text:L5},Symbol.toStringTag,{value:"Module"}));function P5(e,t,n){let s={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},o=[];let c=[],f=[];const p={attempt:ie(W),check:ie(O),consume:Z,enter:I,exit:Q,interrupt:ie(O,{interrupt:!0})},h={code:null,containerState:{},defineSkip:k,events:[],now:x,parser:e,previous:null,sliceSerialize:b,sliceStream:y,write:_};let g=t.tokenize.call(h,p);return t.resolveAll&&o.push(t),h;function _(le){return c=Vi(c,le),L(),c[c.length-1]!==null?[]:(ue(t,0),h.events=Au(o,h.events,h),h.events)}function b(le,V){return I5(y(le),V)}function y(le){return U5(c,le)}function x(){const{_bufferIndex:le,_index:V,line:B,column:A,offset:R}=s;return{_bufferIndex:le,_index:V,line:B,column:A,offset:R}}function k(le){a[le.line]=le.column,U()}function L(){let le;for(;s._index-1){const f=c[0];typeof f=="string"?c[0]=f.slice(s):c.shift()}o>0&&c.push(e[a].slice(0,o))}return c}function I5(e,t){let n=-1;const s=[];let a;for(;++n0){const vt=he.tokenStack[he.tokenStack.length-1];(vt[1]||wy).call(he,void 0,vt[0])}for(X.position={start:yr(te.length>0?te[0][1].start:{line:1,column:1,offset:0}),end:yr(te.length>0?te[te.length-2][1].end:{line:1,column:1,offset:0})},Te=-1;++Te0){const st=ce.tokenStack[ce.tokenStack.length-1];(st[1]||wy).call(ce,void 0,st[0])}for(X.position={start:yr(te.length>0?te[0][1].start:{line:1,column:1,offset:0}),end:yr(te.length>0?te[te.length-2][1].end:{line:1,column:1,offset:0})},Ce=-1;++Ce0&&(s.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:s,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function tT(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function iT(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nT(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),a=il(s.toLowerCase()),o=e.footnoteOrder.indexOf(s);let c,f=e.footnoteCounts.get(s);f===void 0?(f=0,e.footnoteOrder.push(s),c=e.footnoteOrder.length):c=o+1,f+=1,e.footnoteCounts.set(s,f);const p={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(f>1?"-"+f:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};e.patch(t,p);const h={type:"element",tagName:"sup",properties:{},children:[p]};return e.patch(t,h),e.applyData(t,h)}function rT(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function sT(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function xS(e,t){const n=t.referenceType;let s="]";if(n==="collapsed"?s+="[]":n==="full"&&(s+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+s}];const a=e.all(t),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const c=a[a.length-1];return c&&c.type==="text"?c.value+=s:a.push({type:"text",value:s}),a}function lT(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return xS(e,t);const a={src:il(s.url||""),alt:t.alt};s.title!==null&&s.title!==void 0&&(a.title=s.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)}function aT(e,t){const n={src:il(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,s),e.applyData(t,s)}function oT(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const s={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,s),e.applyData(t,s)}function uT(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return xS(e,t);const a={href:il(s.url||"")};s.title!==null&&s.title!==void 0&&(a.title=s.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function cT(e,t){const n={href:il(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function hT(e,t,n){const s=e.all(t),a=n?fT(n):wS(t),o={},c=[];if(typeof t.checked=="boolean"){const g=s[0];let _;g&&g.type==="element"&&g.tagName==="p"?_=g:(_={type:"element",tagName:"p",properties:{},children:[]},s.unshift(_)),_.children.length>0&&_.children.unshift({type:"text",value:" "}),_.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let f=-1;for(;++f0&&(s.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:s,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function tT(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function iT(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nT(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),a=rl(s.toLowerCase()),o=e.footnoteOrder.indexOf(s);let c,f=e.footnoteCounts.get(s);f===void 0?(f=0,e.footnoteOrder.push(s),c=e.footnoteOrder.length):c=o+1,f+=1,e.footnoteCounts.set(s,f);const p={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(f>1?"-"+f:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};e.patch(t,p);const h={type:"element",tagName:"sup",properties:{},children:[p]};return e.patch(t,h),e.applyData(t,h)}function rT(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function sT(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function xS(e,t){const n=t.referenceType;let s="]";if(n==="collapsed"?s+="[]":n==="full"&&(s+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+s}];const a=e.all(t),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const c=a[a.length-1];return c&&c.type==="text"?c.value+=s:a.push({type:"text",value:s}),a}function lT(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return xS(e,t);const a={src:rl(s.url||""),alt:t.alt};s.title!==null&&s.title!==void 0&&(a.title=s.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)}function aT(e,t){const n={src:rl(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,s),e.applyData(t,s)}function oT(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const s={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,s),e.applyData(t,s)}function uT(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return xS(e,t);const a={href:rl(s.url||"")};s.title!==null&&s.title!==void 0&&(a.title=s.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function cT(e,t){const n={href:rl(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function hT(e,t,n){const s=e.all(t),a=n?fT(n):wS(t),o={},c=[];if(typeof t.checked=="boolean"){const g=s[0];let _;g&&g.type==="element"&&g.tagName==="p"?_=g:(_={type:"element",tagName:"p",properties:{},children:[]},s.unshift(_)),_.children.length>0&&_.children.unshift({type:"text",value:" "}),_.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let f=-1;for(;++f1}function dT(e,t){const n={},s=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++a0){const c={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},f=jd(t.children[1]),p=tS(t.children[t.children.length-1]);f&&p&&(c.position={start:f,end:p}),a.push(c)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,o),e.applyData(t,o)}function vT(e,t,n){const s=n?n.children:void 0,o=(s?s.indexOf(t):1)===0?"th":"td",c=n&&n.type==="table"?n.align:void 0,f=c?c.length:t.children.length;let p=-1;const h=[];for(;++p0,!0),s[0]),a=s.index+s[0].length,s=n.exec(t);return o.push(Ey(t.slice(a),a>0,!1)),o.join("")}function Ey(e,t,n){let s=0,a=e.length;if(t){let o=e.codePointAt(s);for(;o===Cy||o===ky;)s++,o=e.codePointAt(s)}if(n){let o=e.codePointAt(a-1);for(;o===Cy||o===ky;)a--,o=e.codePointAt(a-1)}return a>s?e.slice(s,a):""}function ST(e,t){const n={type:"text",value:bT(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function xT(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const wT={blockquote:Q5,break:J5,code:eT,delete:tT,emphasis:iT,footnoteReference:nT,heading:rT,html:sT,imageReference:lT,image:aT,inlineCode:oT,linkReference:uT,link:cT,listItem:hT,list:dT,paragraph:pT,root:mT,strong:_T,table:gT,tableCell:yT,tableRow:vT,text:ST,thematicBreak:xT,toml:tu,yaml:tu,definition:tu,footnoteDefinition:tu};function tu(){}const CS=-1,Du=0,ga=1,bu=2,Wd=3,Yd=4,Vd=5,Kd=6,kS=7,ES=8,Ty=typeof self=="object"?self:globalThis,CT=(e,t)=>{const n=(a,o)=>(e.set(o,a),a),s=a=>{if(e.has(a))return e.get(a);const[o,c]=t[a];switch(o){case Du:case CS:return n(c,a);case ga:{const f=n([],a);for(const p of c)f.push(s(p));return f}case bu:{const f=n({},a);for(const[p,h]of c)f[s(p)]=s(h);return f}case Wd:return n(new Date(c),a);case Yd:{const{source:f,flags:p}=c;return n(new RegExp(f,p),a)}case Vd:{const f=n(new Map,a);for(const[p,h]of c)f.set(s(p),s(h));return f}case Kd:{const f=n(new Set,a);for(const p of c)f.add(s(p));return f}case kS:{const{name:f,message:p}=c;return n(new Ty[f](p),a)}case ES:return n(BigInt(c),a);case"BigInt":return n(Object(BigInt(c)),a);case"ArrayBuffer":return n(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:f}=new Uint8Array(c);return n(new DataView(f),c)}}return n(new Ty[o](c),a)};return s},Ay=e=>CT(new Map,e)(0),Ks="",{toString:kT}={},{keys:ET}=Object,la=e=>{const t=typeof e;if(t!=="object"||!e)return[Du,t];const n=kT.call(e).slice(8,-1);switch(n){case"Array":return[ga,Ks];case"Object":return[bu,Ks];case"Date":return[Wd,Ks];case"RegExp":return[Yd,Ks];case"Map":return[Vd,Ks];case"Set":return[Kd,Ks];case"DataView":return[ga,n]}return n.includes("Array")?[ga,n]:n.includes("Error")?[kS,n]:[bu,n]},iu=([e,t])=>e===Du&&(t==="function"||t==="symbol"),TT=(e,t,n,s)=>{const a=(c,f)=>{const p=s.push(c)-1;return n.set(f,p),p},o=c=>{if(n.has(c))return n.get(c);let[f,p]=la(c);switch(f){case Du:{let g=c;switch(p){case"bigint":f=ES,g=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+p);g=null;break;case"undefined":return a([CS],c)}return a([f,g],c)}case ga:{if(p){let b=c;return p==="DataView"?b=new Uint8Array(c.buffer):p==="ArrayBuffer"&&(b=new Uint8Array(c)),a([p,[...b]],c)}const g=[],_=a([f,g],c);for(const b of c)g.push(o(b));return _}case bu:{if(p)switch(p){case"BigInt":return a([p,c.toString()],c);case"Boolean":case"Number":case"String":return a([p,c.valueOf()],c)}if(t&&"toJSON"in c)return o(c.toJSON());const g=[],_=a([f,g],c);for(const b of ET(c))(e||!iu(la(c[b])))&&g.push([o(b),o(c[b])]);return _}case Wd:return a([f,c.toISOString()],c);case Yd:{const{source:g,flags:_}=c;return a([f,{source:g,flags:_}],c)}case Vd:{const g=[],_=a([f,g],c);for(const[b,y]of c)(e||!(iu(la(b))||iu(la(y))))&&g.push([o(b),o(y)]);return _}case Kd:{const g=[],_=a([f,g],c);for(const b of c)(e||!iu(la(b)))&&g.push(o(b));return _}}const{message:h}=c;return a([f,{name:p,message:h}],c)};return o},Dy=(e,{json:t,lossy:n}={})=>{const s=[];return TT(!(t||n),!!t,new Map,s)(e),s},xa=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Ay(Dy(e,t)):structuredClone(e):(e,t)=>Ay(Dy(e,t));function AT(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function DT(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function RT(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||AT,s=e.options.footnoteBackLabel||DT,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",c=e.options.footnoteLabelProperties||{className:["sr-only"]},f=[];let p=-1;for(;++p0&&x.push({type:"text",value:" "});let Z=typeof n=="string"?n:n(p,y);typeof Z=="string"&&(Z={type:"text",value:Z}),x.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+b+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof s=="string"?s:s(p,y),className:["data-footnote-backref"]},children:Array.isArray(Z)?Z:[Z]})}const L=g[g.length-1];if(L&&L.type==="element"&&L.tagName==="p"){const Z=L.children[L.children.length-1];Z&&Z.type==="text"?Z.value+=" ":L.children.push({type:"text",value:" "}),L.children.push(...x)}else g.push(...x);const M={type:"element",tagName:"li",properties:{id:t+"fn-"+b},children:e.wrap(g,!0)};e.patch(h,M),f.push(M)}if(f.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...xa(c),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:` +`});const h={type:"element",tagName:"li",properties:o,children:c};return e.patch(t,h),e.applyData(t,h)}function fT(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let s=-1;for(;!t&&++s1}function dT(e,t){const n={},s=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++a0){const c={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},f=jd(t.children[1]),p=tS(t.children[t.children.length-1]);f&&p&&(c.position={start:f,end:p}),a.push(c)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,o),e.applyData(t,o)}function vT(e,t,n){const s=n?n.children:void 0,o=(s?s.indexOf(t):1)===0?"th":"td",c=n&&n.type==="table"?n.align:void 0,f=c?c.length:t.children.length;let p=-1;const h=[];for(;++p0,!0),s[0]),a=s.index+s[0].length,s=n.exec(t);return o.push(Ey(t.slice(a),a>0,!1)),o.join("")}function Ey(e,t,n){let s=0,a=e.length;if(t){let o=e.codePointAt(s);for(;o===Cy||o===ky;)s++,o=e.codePointAt(s)}if(n){let o=e.codePointAt(a-1);for(;o===Cy||o===ky;)a--,o=e.codePointAt(a-1)}return a>s?e.slice(s,a):""}function ST(e,t){const n={type:"text",value:bT(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function xT(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const wT={blockquote:Q5,break:J5,code:eT,delete:tT,emphasis:iT,footnoteReference:nT,heading:rT,html:sT,imageReference:lT,image:aT,inlineCode:oT,linkReference:uT,link:cT,listItem:hT,list:dT,paragraph:pT,root:mT,strong:_T,table:gT,tableCell:yT,tableRow:vT,text:ST,thematicBreak:xT,toml:tu,yaml:tu,definition:tu,footnoteDefinition:tu};function tu(){}const CS=-1,Du=0,ga=1,bu=2,Wd=3,Yd=4,Vd=5,Kd=6,kS=7,ES=8,Ty=typeof self=="object"?self:globalThis,CT=(e,t)=>{const n=(a,o)=>(e.set(o,a),a),s=a=>{if(e.has(a))return e.get(a);const[o,c]=t[a];switch(o){case Du:case CS:return n(c,a);case ga:{const f=n([],a);for(const p of c)f.push(s(p));return f}case bu:{const f=n({},a);for(const[p,h]of c)f[s(p)]=s(h);return f}case Wd:return n(new Date(c),a);case Yd:{const{source:f,flags:p}=c;return n(new RegExp(f,p),a)}case Vd:{const f=n(new Map,a);for(const[p,h]of c)f.set(s(p),s(h));return f}case Kd:{const f=n(new Set,a);for(const p of c)f.add(s(p));return f}case kS:{const{name:f,message:p}=c;return n(new Ty[f](p),a)}case ES:return n(BigInt(c),a);case"BigInt":return n(Object(BigInt(c)),a);case"ArrayBuffer":return n(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:f}=new Uint8Array(c);return n(new DataView(f),c)}}return n(new Ty[o](c),a)};return s},Ay=e=>CT(new Map,e)(0),Ks="",{toString:kT}={},{keys:ET}=Object,oa=e=>{const t=typeof e;if(t!=="object"||!e)return[Du,t];const n=kT.call(e).slice(8,-1);switch(n){case"Array":return[ga,Ks];case"Object":return[bu,Ks];case"Date":return[Wd,Ks];case"RegExp":return[Yd,Ks];case"Map":return[Vd,Ks];case"Set":return[Kd,Ks];case"DataView":return[ga,n]}return n.includes("Array")?[ga,n]:n.includes("Error")?[kS,n]:[bu,n]},iu=([e,t])=>e===Du&&(t==="function"||t==="symbol"),TT=(e,t,n,s)=>{const a=(c,f)=>{const p=s.push(c)-1;return n.set(f,p),p},o=c=>{if(n.has(c))return n.get(c);let[f,p]=oa(c);switch(f){case Du:{let g=c;switch(p){case"bigint":f=ES,g=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+p);g=null;break;case"undefined":return a([CS],c)}return a([f,g],c)}case ga:{if(p){let b=c;return p==="DataView"?b=new Uint8Array(c.buffer):p==="ArrayBuffer"&&(b=new Uint8Array(c)),a([p,[...b]],c)}const g=[],_=a([f,g],c);for(const b of c)g.push(o(b));return _}case bu:{if(p)switch(p){case"BigInt":return a([p,c.toString()],c);case"Boolean":case"Number":case"String":return a([p,c.valueOf()],c)}if(t&&"toJSON"in c)return o(c.toJSON());const g=[],_=a([f,g],c);for(const b of ET(c))(e||!iu(oa(c[b])))&&g.push([o(b),o(c[b])]);return _}case Wd:return a([f,c.toISOString()],c);case Yd:{const{source:g,flags:_}=c;return a([f,{source:g,flags:_}],c)}case Vd:{const g=[],_=a([f,g],c);for(const[b,y]of c)(e||!(iu(oa(b))||iu(oa(y))))&&g.push([o(b),o(y)]);return _}case Kd:{const g=[],_=a([f,g],c);for(const b of c)(e||!iu(oa(b)))&&g.push(o(b));return _}}const{message:h}=c;return a([f,{name:p,message:h}],c)};return o},Dy=(e,{json:t,lossy:n}={})=>{const s=[];return TT(!(t||n),!!t,new Map,s)(e),s},xa=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Ay(Dy(e,t)):structuredClone(e):(e,t)=>Ay(Dy(e,t));function AT(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function DT(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function RT(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||AT,s=e.options.footnoteBackLabel||DT,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",c=e.options.footnoteLabelProperties||{className:["sr-only"]},f=[];let p=-1;for(;++p0&&x.push({type:"text",value:" "});let Z=typeof n=="string"?n:n(p,y);typeof Z=="string"&&(Z={type:"text",value:Z}),x.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+b+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof s=="string"?s:s(p,y),className:["data-footnote-backref"]},children:Array.isArray(Z)?Z:[Z]})}const L=g[g.length-1];if(L&&L.type==="element"&&L.tagName==="p"){const Z=L.children[L.children.length-1];Z&&Z.type==="text"?Z.value+=" ":L.children.push({type:"text",value:" "}),L.children.push(...x)}else g.push(...x);const M={type:"element",tagName:"li",properties:{id:t+"fn-"+b},children:e.wrap(g,!0)};e.patch(h,M),f.push(M)}if(f.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...xa(c),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:` `},{type:"element",tagName:"ol",properties:{},children:e.wrap(f,!0)},{type:"text",value:` `}]}}const Ru=(function(e){if(e==null)return LT;if(typeof e=="function")return Mu(e);if(typeof e=="object")return Array.isArray(e)?MT(e):BT(e);if(typeof e=="string")return NT(e);throw new Error("Expected function, string, or object as test")});function MT(e){const t=[];let n=-1;for(;++n":""))+")"})}return b;function b(){let y=TS,x,k,L;if((!t||o(p,h,g[g.length-1]||void 0))&&(y=HT(n(p,g)),y[0]===vd))return y;if("children"in p&&p.children){const M=p;if(M.children&&y[0]!==jT)for(k=(s?M.children.length:-1)+c,L=g.concat(M);k>-1&&k0&&n.push({type:"text",value:` `}),n}function Ry(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function My(e,t){const n=UT(e,t),s=n.one(e,void 0),a=RT(n),o=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return a&&o.children.push({type:"text",value:` -`},a),o}function YT(e,t){return e&&"run"in e?async function(n,s){const a=My(n,{file:s,...t});await e.run(a,s)}:function(n,s){return My(n,{file:s,...e||t})}}function By(e){if(e)throw e}var mf,Ny;function VT(){if(Ny)return mf;Ny=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},o=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var g=e.call(h,"constructor"),_=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!g&&!_)return!1;var b;for(b in h);return typeof b>"u"||e.call(h,b)},c=function(h,g){n&&g.name==="__proto__"?n(h,g.name,{enumerable:!0,configurable:!0,value:g.newValue,writable:!0}):h[g.name]=g.newValue},f=function(h,g){if(g==="__proto__")if(e.call(h,g)){if(s)return s(h,g).value}else return;return h[g]};return mf=function p(){var h,g,_,b,y,x,k=arguments[0],L=1,M=arguments.length,Z=!1;for(typeof k=="boolean"&&(Z=k,k=arguments[1]||{},L=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});Lc.length;let p;f&&c.push(a);try{p=e.apply(this,c)}catch(h){const g=h;if(f&&n)throw g;return a(g)}f||(p&&p.then&&typeof p.then=="function"?p.then(o,a):p instanceof Error?a(p):o(p))}function a(c,...f){n||(n=!0,t(c,...f))}function o(c){a(null,c)}}const un={basename:$T,dirname:ZT,extname:QT,join:JT,sep:"/"};function $T(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Ra(e);let n=0,s=-1,a=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else s<0&&(o=!0,s=a+1);return s<0?"":e.slice(n,s)}if(t===e)return"";let c=-1,f=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else c<0&&(o=!0,c=a+1),f>-1&&(e.codePointAt(a)===t.codePointAt(f--)?f<0&&(s=a):(f=-1,s=c));return n===s?s=c:s<0&&(s=e.length),e.slice(n,s)}function ZT(e){if(Ra(e),e.length===0)return".";let t=-1,n=e.length,s;for(;--n;)if(e.codePointAt(n)===47){if(s){t=n;break}}else s||(s=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function QT(e){Ra(e);let t=e.length,n=-1,s=0,a=-1,o=0,c;for(;t--;){const f=e.codePointAt(t);if(f===47){if(c){s=t+1;break}continue}n<0&&(c=!0,n=t+1),f===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||n<0||o===0||o===1&&a===n-1&&a===s+1?"":e.slice(a,n)}function JT(...e){let t=-1,n;for(;++t0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function t3(e,t){let n="",s=0,a=-1,o=0,c=-1,f,p;for(;++c<=e.length;){if(c2){if(p=n.lastIndexOf("/"),p!==n.length-1){p<0?(n="",s=0):(n=n.slice(0,p),s=n.length-1-n.lastIndexOf("/")),a=c,o=0;continue}}else if(n.length>0){n="",s=0,a=c,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",s=2)}else n.length>0?n+="/"+e.slice(a+1,c):n=e.slice(a+1,c),s=c-a-1;a=c,o=0}else f===46&&o>-1?o++:o=-1}return n}function Ra(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const i3={cwd:n3};function n3(){return"/"}function Sd(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function r3(e){if(typeof e=="string")e=new URL(e);else if(!Sd(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return s3(e)}function s3(e){if(e.hostname!==""){const s=new TypeError('File URL host must be "localhost" or empty on darwin');throw s.code="ERR_INVALID_FILE_URL_HOST",s}const t=e.pathname;let n=-1;for(;++n0){let[y,...x]=g;const k=s[b][1];bd(k)&&bd(y)&&(y=_f(!0,k,y)),s[b]=[h,y,...x]}}}}const u3=new Gd().freeze();function bf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Sf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function xf(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function zy(e){if(!bd(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Oy(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function nu(e){return c3(e)?e:new DS(e)}function c3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function h3(e){return typeof e=="string"||f3(e)}function f3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const d3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",jy=[],Hy={allowDangerousHtml:!0},p3=/^(https?|ircs?|mailto|xmpp)$/i,m3=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function _3(e){const t=g3(e),n=v3(e);return y3(t.runSync(t.parse(n),n),e)}function g3(e){const t=e.rehypePlugins||jy,n=e.remarkPlugins||jy,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Hy}:Hy;return u3().use(Z5).use(n).use(YT,s).use(t)}function v3(e){const t=e.children||"",n=new DS;return typeof t=="string"&&(n.value=t),n}function y3(e,t){const n=t.allowedElements,s=t.allowElement,a=t.components,o=t.disallowedElements,c=t.skipHtml,f=t.unwrapDisallowed,p=t.urlTransform||b3;for(const g of m3)Object.hasOwn(t,g.from)&&(""+g.from+(g.to?"use `"+g.to+"` instead":"remove it")+d3+g.id,void 0);return Xd(e,h),Lk(e,{Fragment:S.Fragment,components:a,ignoreInvalidStyle:!0,jsx:S.jsx,jsxs:S.jsxs,passKeys:!0,passNode:!0});function h(g,_,b){if(g.type==="raw"&&b&&typeof _=="number")return c?b.children.splice(_,1):b.children[_]={type:"text",value:g.value},_;if(g.type==="element"){let y;for(y in ff)if(Object.hasOwn(ff,y)&&Object.hasOwn(g.properties,y)){const x=g.properties[y],k=ff[y];(k===null||k.includes(g.tagName))&&(g.properties[y]=p(String(x||""),y,g))}}if(g.type==="element"){let y=n?!n.includes(g.tagName):o?o.includes(g.tagName):!1;if(!y&&s&&typeof _=="number"&&(y=!s(g,_,b)),y&&b&&typeof _=="number")return f&&g.children?b.children.splice(_,1,...g.children):b.children.splice(_,1),_}}}function b3(e){const t=e.indexOf(":"),n=e.indexOf("?"),s=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||s!==-1&&t>s||p3.test(e.slice(0,t))?e:""}function S3(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function RS(e,t,n){const a=Ru((n||{}).ignore||[]),o=x3(t);let c=-1;for(;++c0?{type:"text",value:O}:void 0),O===!1?b.lastIndex=Q+1:(x!==Q&&Z.push({type:"text",value:h.value.slice(x,Q)}),Array.isArray(O)?Z.push(...O):O&&Z.push(O),x=Q+I[0].length,M=!0),!b.global)break;I=b.exec(h.value)}return M?(x?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],s=n.indexOf(")");const a=Py(e,"(");let o=Py(e,")");for(;s!==-1&&a>o;)e+=n.slice(0,s+1),n=n.slice(s+1),s=n.indexOf(")"),o++;return[e,n]}function MS(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||is(n)||Tu(n))&&(!t||n!==47)}BS.peek=X3;function U3(){this.buffer()}function I3(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function F3(){this.buffer()}function q3(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function W3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ji(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Y3(e){this.exit(e)}function V3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ji(this.sliceSerialize(e)).toLowerCase(),n.label=t}function K3(e){this.exit(e)}function X3(){return"["}function BS(e,t,n,s){const a=n.createTracker(s);let o=a.move("[^");const c=n.enter("footnoteReference"),f=n.enter("reference");return o+=a.move(n.safe(n.associationId(e),{after:"]",before:o})),f(),c(),o+=a.move("]"),o}function G3(){return{enter:{gfmFootnoteCallString:U3,gfmFootnoteCall:I3,gfmFootnoteDefinitionLabelString:F3,gfmFootnoteDefinition:q3},exit:{gfmFootnoteCallString:W3,gfmFootnoteCall:Y3,gfmFootnoteDefinitionLabelString:V3,gfmFootnoteDefinition:K3}}}function $3(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:BS},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(s,a,o,c){const f=o.createTracker(c);let p=f.move("[^");const h=o.enter("footnoteDefinition"),g=o.enter("label");return p+=f.move(o.safe(o.associationId(s),{before:p,after:"]"})),g(),p+=f.move("]:"),s.children&&s.children.length>0&&(f.shift(4),p+=f.move((t?` +`},a),o}function YT(e,t){return e&&"run"in e?async function(n,s){const a=My(n,{file:s,...t});await e.run(a,s)}:function(n,s){return My(n,{file:s,...e||t})}}function By(e){if(e)throw e}var mf,Ny;function VT(){if(Ny)return mf;Ny=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},o=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var g=e.call(h,"constructor"),_=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!g&&!_)return!1;var b;for(b in h);return typeof b>"u"||e.call(h,b)},c=function(h,g){n&&g.name==="__proto__"?n(h,g.name,{enumerable:!0,configurable:!0,value:g.newValue,writable:!0}):h[g.name]=g.newValue},f=function(h,g){if(g==="__proto__")if(e.call(h,g)){if(s)return s(h,g).value}else return;return h[g]};return mf=function p(){var h,g,_,b,y,x,k=arguments[0],L=1,M=arguments.length,Z=!1;for(typeof k=="boolean"&&(Z=k,k=arguments[1]||{},L=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});Lc.length;let p;f&&c.push(a);try{p=e.apply(this,c)}catch(h){const g=h;if(f&&n)throw g;return a(g)}f||(p&&p.then&&typeof p.then=="function"?p.then(o,a):p instanceof Error?a(p):o(p))}function a(c,...f){n||(n=!0,t(c,...f))}function o(c){a(null,c)}}const un={basename:GT,dirname:ZT,extname:QT,join:JT,sep:"/"};function GT(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Ra(e);let n=0,s=-1,a=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else s<0&&(o=!0,s=a+1);return s<0?"":e.slice(n,s)}if(t===e)return"";let c=-1,f=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else c<0&&(o=!0,c=a+1),f>-1&&(e.codePointAt(a)===t.codePointAt(f--)?f<0&&(s=a):(f=-1,s=c));return n===s?s=c:s<0&&(s=e.length),e.slice(n,s)}function ZT(e){if(Ra(e),e.length===0)return".";let t=-1,n=e.length,s;for(;--n;)if(e.codePointAt(n)===47){if(s){t=n;break}}else s||(s=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function QT(e){Ra(e);let t=e.length,n=-1,s=0,a=-1,o=0,c;for(;t--;){const f=e.codePointAt(t);if(f===47){if(c){s=t+1;break}continue}n<0&&(c=!0,n=t+1),f===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||n<0||o===0||o===1&&a===n-1&&a===s+1?"":e.slice(a,n)}function JT(...e){let t=-1,n;for(;++t0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function t3(e,t){let n="",s=0,a=-1,o=0,c=-1,f,p;for(;++c<=e.length;){if(c2){if(p=n.lastIndexOf("/"),p!==n.length-1){p<0?(n="",s=0):(n=n.slice(0,p),s=n.length-1-n.lastIndexOf("/")),a=c,o=0;continue}}else if(n.length>0){n="",s=0,a=c,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",s=2)}else n.length>0?n+="/"+e.slice(a+1,c):n=e.slice(a+1,c),s=c-a-1;a=c,o=0}else f===46&&o>-1?o++:o=-1}return n}function Ra(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const i3={cwd:n3};function n3(){return"/"}function Sd(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function r3(e){if(typeof e=="string")e=new URL(e);else if(!Sd(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return s3(e)}function s3(e){if(e.hostname!==""){const s=new TypeError('File URL host must be "localhost" or empty on darwin');throw s.code="ERR_INVALID_FILE_URL_HOST",s}const t=e.pathname;let n=-1;for(;++n0){let[y,...x]=g;const k=s[b][1];bd(k)&&bd(y)&&(y=_f(!0,k,y)),s[b]=[h,y,...x]}}}}const u3=new $d().freeze();function bf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Sf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function xf(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function zy(e){if(!bd(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Oy(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function nu(e){return c3(e)?e:new DS(e)}function c3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function h3(e){return typeof e=="string"||f3(e)}function f3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const d3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",jy=[],Hy={allowDangerousHtml:!0},p3=/^(https?|ircs?|mailto|xmpp)$/i,m3=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function _3(e){const t=g3(e),n=v3(e);return y3(t.runSync(t.parse(n),n),e)}function g3(e){const t=e.rehypePlugins||jy,n=e.remarkPlugins||jy,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Hy}:Hy;return u3().use(Z5).use(n).use(YT,s).use(t)}function v3(e){const t=e.children||"",n=new DS;return typeof t=="string"&&(n.value=t),n}function y3(e,t){const n=t.allowedElements,s=t.allowElement,a=t.components,o=t.disallowedElements,c=t.skipHtml,f=t.unwrapDisallowed,p=t.urlTransform||b3;for(const g of m3)Object.hasOwn(t,g.from)&&(""+g.from+(g.to?"use `"+g.to+"` instead":"remove it")+d3+g.id,void 0);return Xd(e,h),Lk(e,{Fragment:S.Fragment,components:a,ignoreInvalidStyle:!0,jsx:S.jsx,jsxs:S.jsxs,passKeys:!0,passNode:!0});function h(g,_,b){if(g.type==="raw"&&b&&typeof _=="number")return c?b.children.splice(_,1):b.children[_]={type:"text",value:g.value},_;if(g.type==="element"){let y;for(y in ff)if(Object.hasOwn(ff,y)&&Object.hasOwn(g.properties,y)){const x=g.properties[y],k=ff[y];(k===null||k.includes(g.tagName))&&(g.properties[y]=p(String(x||""),y,g))}}if(g.type==="element"){let y=n?!n.includes(g.tagName):o?o.includes(g.tagName):!1;if(!y&&s&&typeof _=="number"&&(y=!s(g,_,b)),y&&b&&typeof _=="number")return f&&g.children?b.children.splice(_,1,...g.children):b.children.splice(_,1),_}}}function b3(e){const t=e.indexOf(":"),n=e.indexOf("?"),s=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||s!==-1&&t>s||p3.test(e.slice(0,t))?e:""}function S3(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function RS(e,t,n){const a=Ru((n||{}).ignore||[]),o=x3(t);let c=-1;for(;++c0?{type:"text",value:O}:void 0),O===!1?b.lastIndex=Q+1:(x!==Q&&Z.push({type:"text",value:h.value.slice(x,Q)}),Array.isArray(O)?Z.push(...O):O&&Z.push(O),x=Q+I[0].length,M=!0),!b.global)break;I=b.exec(h.value)}return M?(x?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],s=n.indexOf(")");const a=Py(e,"(");let o=Py(e,")");for(;s!==-1&&a>o;)e+=n.slice(0,s+1),n=n.slice(s+1),s=n.indexOf(")"),o++;return[e,n]}function MS(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||is(n)||Tu(n))&&(!t||n!==47)}BS.peek=X3;function U3(){this.buffer()}function I3(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function F3(){this.buffer()}function q3(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function W3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ji(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Y3(e){this.exit(e)}function V3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ji(this.sliceSerialize(e)).toLowerCase(),n.label=t}function K3(e){this.exit(e)}function X3(){return"["}function BS(e,t,n,s){const a=n.createTracker(s);let o=a.move("[^");const c=n.enter("footnoteReference"),f=n.enter("reference");return o+=a.move(n.safe(n.associationId(e),{after:"]",before:o})),f(),c(),o+=a.move("]"),o}function $3(){return{enter:{gfmFootnoteCallString:U3,gfmFootnoteCall:I3,gfmFootnoteDefinitionLabelString:F3,gfmFootnoteDefinition:q3},exit:{gfmFootnoteCallString:W3,gfmFootnoteCall:Y3,gfmFootnoteDefinitionLabelString:V3,gfmFootnoteDefinition:K3}}}function G3(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:BS},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(s,a,o,c){const f=o.createTracker(c);let p=f.move("[^");const h=o.enter("footnoteDefinition"),g=o.enter("label");return p+=f.move(o.safe(o.associationId(s),{before:p,after:"]"})),g(),p+=f.move("]:"),s.children&&s.children.length>0&&(f.shift(4),p+=f.move((t?` `:" ")+o.indentLines(o.containerFlow(s,f.current()),t?NS:Z3))),h(),p}}function Z3(e,t,n){return t===0?e:NS(e,t,n)}function NS(e,t,n){return(n?"":" ")+e}const Q3=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];LS.peek=nA;function J3(){return{canContainEols:["delete"],enter:{strikethrough:tA},exit:{strikethrough:iA}}}function eA(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Q3}],handlers:{delete:LS}}}function tA(e){this.enter({type:"delete",children:[]},e)}function iA(e){this.exit(e)}function LS(e,t,n,s){const a=n.createTracker(s),o=n.enter("strikethrough");let c=a.move("~~");return c+=n.containerPhrasing(e,{...a.current(),before:c,after:"~"}),c+=a.move("~~"),o(),c}function nA(){return"~"}function rA(e){return e.length}function sA(e,t){const n=t||{},s=(n.align||[]).concat(),a=n.stringLength||rA,o=[],c=[],f=[],p=[];let h=0,g=-1;for(;++gh&&(h=e[g].length);++Mp[M])&&(p[M]=I)}k.push(Z)}c[g]=k,f[g]=L}let _=-1;if(typeof s=="object"&&"length"in s)for(;++_p[_]&&(p[_]=Z),y[_]=Z),b[_]=I}c.splice(1,0,b),f.splice(1,0,y),g=-1;const x=[];for(;++g "),o.shift(2);const c=n.indentLines(n.containerFlow(e,o.current()),oA);return a(),c}function oA(e,t,n){return">"+(n?"":" ")+e}function uA(e,t){return Iy(e,t.inConstruct,!0)&&!Iy(e,t.notInConstruct,!1)}function Iy(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let s=-1;for(;++sc&&(c=o):o=1,a=s+t.length,s=n.indexOf(t,a);return c}function hA(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function fA(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function dA(e,t,n,s){const a=fA(n),o=e.value||"",c=a==="`"?"GraveAccent":"Tilde";if(hA(e,n)){const _=n.enter("codeIndented"),b=n.indentLines(o,pA);return _(),b}const f=n.createTracker(s),p=a.repeat(Math.max(cA(o,a)+1,3)),h=n.enter("codeFenced");let g=f.move(p);if(e.lang){const _=n.enter(`codeFencedLang${c}`);g+=f.move(n.safe(e.lang,{before:g,after:" ",encode:["`"],...f.current()})),_()}if(e.lang&&e.meta){const _=n.enter(`codeFencedMeta${c}`);g+=f.move(" "),g+=f.move(n.safe(e.meta,{before:g,after:` `,encode:["`"],...f.current()})),_()}return g+=f.move(` `),o&&(g+=f.move(o+` -`)),g+=f.move(p),h(),g}function pA(e,t,n){return(n?"":" ")+e}function $d(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function mA(e,t,n,s){const a=$d(n),o=a==='"'?"Quote":"Apostrophe",c=n.enter("definition");let f=n.enter("label");const p=n.createTracker(s);let h=p.move("[");return h+=p.move(n.safe(n.associationId(e),{before:h,after:"]",...p.current()})),h+=p.move("]: "),f(),!e.url||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(n.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(f=n.enter("destinationRaw"),h+=p.move(n.safe(e.url,{before:h,after:e.title?" ":` -`,...p.current()}))),f(),e.title&&(f=n.enter(`title${o}`),h+=p.move(" "+a),h+=p.move(n.safe(e.title,{before:h,after:a,...p.current()})),h+=p.move(a),f()),c(),h}function _A(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function wa(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Su(e,t,n){const s=Qs(e),a=Qs(t);return s===void 0?a===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:s===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}zS.peek=gA;function zS(e,t,n,s){const a=_A(n),o=n.enter("emphasis"),c=n.createTracker(s),f=c.move(a);let p=c.move(n.containerPhrasing(e,{after:a,before:f,...c.current()}));const h=p.charCodeAt(0),g=Su(s.before.charCodeAt(s.before.length-1),h,a);g.inside&&(p=wa(h)+p.slice(1));const _=p.charCodeAt(p.length-1),b=Su(s.after.charCodeAt(0),_,a);b.inside&&(p=p.slice(0,-1)+wa(_));const y=c.move(a);return o(),n.attentionEncodeSurroundingInfo={after:b.outside,before:g.outside},f+p+y}function gA(e,t,n){return n.options.emphasis||"*"}function vA(e,t){let n=!1;return Xd(e,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return n=!0,vd}),!!((!e.depth||e.depth<3)&&Id(e)&&(t.options.setext||n))}function yA(e,t,n,s){const a=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(s);if(vA(e,n)){const g=n.enter("headingSetext"),_=n.enter("phrasing"),b=n.containerPhrasing(e,{...o.current(),before:` +`)),g+=f.move(p),h(),g}function pA(e,t,n){return(n?"":" ")+e}function Gd(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function mA(e,t,n,s){const a=Gd(n),o=a==='"'?"Quote":"Apostrophe",c=n.enter("definition");let f=n.enter("label");const p=n.createTracker(s);let h=p.move("[");return h+=p.move(n.safe(n.associationId(e),{before:h,after:"]",...p.current()})),h+=p.move("]: "),f(),!e.url||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(n.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(f=n.enter("destinationRaw"),h+=p.move(n.safe(e.url,{before:h,after:e.title?" ":` +`,...p.current()}))),f(),e.title&&(f=n.enter(`title${o}`),h+=p.move(" "+a),h+=p.move(n.safe(e.title,{before:h,after:a,...p.current()})),h+=p.move(a),f()),c(),h}function _A(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function wa(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Su(e,t,n){const s=el(e),a=el(t);return s===void 0?a===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:s===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}zS.peek=gA;function zS(e,t,n,s){const a=_A(n),o=n.enter("emphasis"),c=n.createTracker(s),f=c.move(a);let p=c.move(n.containerPhrasing(e,{after:a,before:f,...c.current()}));const h=p.charCodeAt(0),g=Su(s.before.charCodeAt(s.before.length-1),h,a);g.inside&&(p=wa(h)+p.slice(1));const _=p.charCodeAt(p.length-1),b=Su(s.after.charCodeAt(0),_,a);b.inside&&(p=p.slice(0,-1)+wa(_));const y=c.move(a);return o(),n.attentionEncodeSurroundingInfo={after:b.outside,before:g.outside},f+p+y}function gA(e,t,n){return n.options.emphasis||"*"}function vA(e,t){let n=!1;return Xd(e,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return n=!0,vd}),!!((!e.depth||e.depth<3)&&Id(e)&&(t.options.setext||n))}function yA(e,t,n,s){const a=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(s);if(vA(e,n)){const g=n.enter("headingSetext"),_=n.enter("phrasing"),b=n.containerPhrasing(e,{...o.current(),before:` `,after:` `});return _(),g(),b+` `+(a===1?"=":"-").repeat(b.length-(Math.max(b.lastIndexOf("\r"),b.lastIndexOf(` `))+1))}const c="#".repeat(a),f=n.enter("headingAtx"),p=n.enter("phrasing");o.move(c+" ");let h=n.containerPhrasing(e,{before:"# ",after:` -`,...o.current()});return/^[\t ]/.test(h)&&(h=wa(h.charCodeAt(0))+h.slice(1)),h=h?c+" "+h:c,n.options.closeAtx&&(h+=" "+c),p(),f(),h}OS.peek=bA;function OS(e){return e.value||""}function bA(){return"<"}jS.peek=SA;function jS(e,t,n,s){const a=$d(n),o=a==='"'?"Quote":"Apostrophe",c=n.enter("image");let f=n.enter("label");const p=n.createTracker(s);let h=p.move("![");return h+=p.move(n.safe(e.alt,{before:h,after:"]",...p.current()})),h+=p.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(n.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(f=n.enter("destinationRaw"),h+=p.move(n.safe(e.url,{before:h,after:e.title?" ":")",...p.current()}))),f(),e.title&&(f=n.enter(`title${o}`),h+=p.move(" "+a),h+=p.move(n.safe(e.title,{before:h,after:a,...p.current()})),h+=p.move(a),f()),h+=p.move(")"),c(),h}function SA(){return"!"}HS.peek=xA;function HS(e,t,n,s){const a=e.referenceType,o=n.enter("imageReference");let c=n.enter("label");const f=n.createTracker(s);let p=f.move("![");const h=n.safe(e.alt,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),c();const g=n.stack;n.stack=[],c=n.enter("reference");const _=n.safe(n.associationId(e),{before:p,after:"]",...f.current()});return c(),n.stack=g,o(),a==="full"||!h||h!==_?p+=f.move(_+"]"):a==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function xA(){return"!"}PS.peek=wA;function PS(e,t,n){let s=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(s);)a+="`";for(/[^ \r\n]/.test(s)&&(/^[ \r\n]/.test(s)&&/[ \r\n]$/.test(s)||/^`|`$/.test(s))&&(s=" "+s+" ");++o\u007F]/.test(e.url))}IS.peek=CA;function IS(e,t,n,s){const a=$d(n),o=a==='"'?"Quote":"Apostrophe",c=n.createTracker(s);let f,p;if(US(e,n)){const g=n.stack;n.stack=[],f=n.enter("autolink");let _=c.move("<");return _+=c.move(n.containerPhrasing(e,{before:_,after:">",...c.current()})),_+=c.move(">"),f(),n.stack=g,_}f=n.enter("link"),p=n.enter("label");let h=c.move("[");return h+=c.move(n.containerPhrasing(e,{before:h,after:"](",...c.current()})),h+=c.move("]("),p(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(p=n.enter("destinationLiteral"),h+=c.move("<"),h+=c.move(n.safe(e.url,{before:h,after:">",...c.current()})),h+=c.move(">")):(p=n.enter("destinationRaw"),h+=c.move(n.safe(e.url,{before:h,after:e.title?" ":")",...c.current()}))),p(),e.title&&(p=n.enter(`title${o}`),h+=c.move(" "+a),h+=c.move(n.safe(e.title,{before:h,after:a,...c.current()})),h+=c.move(a),p()),h+=c.move(")"),f(),h}function CA(e,t,n){return US(e,n)?"<":"["}FS.peek=kA;function FS(e,t,n,s){const a=e.referenceType,o=n.enter("linkReference");let c=n.enter("label");const f=n.createTracker(s);let p=f.move("[");const h=n.containerPhrasing(e,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),c();const g=n.stack;n.stack=[],c=n.enter("reference");const _=n.safe(n.associationId(e),{before:p,after:"]",...f.current()});return c(),n.stack=g,o(),a==="full"||!h||h!==_?p+=f.move(_+"]"):a==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function kA(){return"["}function Zd(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function EA(e){const t=Zd(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function TA(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function qS(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function AA(e,t,n,s){const a=n.enter("list"),o=n.bulletCurrent;let c=e.ordered?TA(n):Zd(n);const f=e.ordered?c==="."?")":".":EA(n);let p=t&&n.bulletLastUsed?c===n.bulletLastUsed:!1;if(!e.ordered){const g=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&g&&(!g.children||!g.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(p=!0),qS(n)===c&&g){let _=-1;for(;++_-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let c=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(c=Math.ceil(c/4)*4);const f=n.createTracker(s);f.move(o+" ".repeat(c-o.length)),f.shift(c);const p=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,f.current()),g);return p(),h;function g(_,b,y){return b?(y?"":" ".repeat(c))+_:(y?o:o+" ".repeat(c-o.length))+_}}function MA(e,t,n,s){const a=n.enter("paragraph"),o=n.enter("phrasing"),c=n.containerPhrasing(e,s);return o(),a(),c}const BA=Ru(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function NA(e,t,n,s){return(e.children.some(function(c){return BA(c)})?n.containerPhrasing:n.containerFlow).call(n,e,s)}function LA(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}WS.peek=zA;function WS(e,t,n,s){const a=LA(n),o=n.enter("strong"),c=n.createTracker(s),f=c.move(a+a);let p=c.move(n.containerPhrasing(e,{after:a,before:f,...c.current()}));const h=p.charCodeAt(0),g=Su(s.before.charCodeAt(s.before.length-1),h,a);g.inside&&(p=wa(h)+p.slice(1));const _=p.charCodeAt(p.length-1),b=Su(s.after.charCodeAt(0),_,a);b.inside&&(p=p.slice(0,-1)+wa(_));const y=c.move(a+a);return o(),n.attentionEncodeSurroundingInfo={after:b.outside,before:g.outside},f+p+y}function zA(e,t,n){return n.options.strong||"*"}function OA(e,t,n,s){return n.safe(e.value,s)}function jA(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function HA(e,t,n){const s=(qS(n)+(n.options.ruleSpaces?" ":"")).repeat(jA(n));return n.options.ruleSpaces?s.slice(0,-1):s}const YS={blockquote:aA,break:Fy,code:dA,definition:mA,emphasis:zS,hardBreak:Fy,heading:yA,html:OS,image:jS,imageReference:HS,inlineCode:PS,link:IS,linkReference:FS,list:AA,listItem:RA,paragraph:MA,root:NA,strong:WS,text:OA,thematicBreak:HA};function PA(){return{enter:{table:UA,tableData:qy,tableHeader:qy,tableRow:FA},exit:{codeText:qA,table:IA,tableData:Ef,tableHeader:Ef,tableRow:Ef}}}function UA(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function IA(e){this.exit(e),this.data.inTable=void 0}function FA(e){this.enter({type:"tableRow",children:[]},e)}function Ef(e){this.exit(e)}function qy(e){this.enter({type:"tableCell",children:[]},e)}function qA(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,WA));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function WA(e,t){return t==="|"?t:e}function YA(e){const t=e||{},n=t.tableCellPadding,s=t.tablePipeAlign,a=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` +`,...o.current()});return/^[\t ]/.test(h)&&(h=wa(h.charCodeAt(0))+h.slice(1)),h=h?c+" "+h:c,n.options.closeAtx&&(h+=" "+c),p(),f(),h}OS.peek=bA;function OS(e){return e.value||""}function bA(){return"<"}jS.peek=SA;function jS(e,t,n,s){const a=Gd(n),o=a==='"'?"Quote":"Apostrophe",c=n.enter("image");let f=n.enter("label");const p=n.createTracker(s);let h=p.move("![");return h+=p.move(n.safe(e.alt,{before:h,after:"]",...p.current()})),h+=p.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(n.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(f=n.enter("destinationRaw"),h+=p.move(n.safe(e.url,{before:h,after:e.title?" ":")",...p.current()}))),f(),e.title&&(f=n.enter(`title${o}`),h+=p.move(" "+a),h+=p.move(n.safe(e.title,{before:h,after:a,...p.current()})),h+=p.move(a),f()),h+=p.move(")"),c(),h}function SA(){return"!"}HS.peek=xA;function HS(e,t,n,s){const a=e.referenceType,o=n.enter("imageReference");let c=n.enter("label");const f=n.createTracker(s);let p=f.move("![");const h=n.safe(e.alt,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),c();const g=n.stack;n.stack=[],c=n.enter("reference");const _=n.safe(n.associationId(e),{before:p,after:"]",...f.current()});return c(),n.stack=g,o(),a==="full"||!h||h!==_?p+=f.move(_+"]"):a==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function xA(){return"!"}PS.peek=wA;function PS(e,t,n){let s=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(s);)a+="`";for(/[^ \r\n]/.test(s)&&(/^[ \r\n]/.test(s)&&/[ \r\n]$/.test(s)||/^`|`$/.test(s))&&(s=" "+s+" ");++o\u007F]/.test(e.url))}IS.peek=CA;function IS(e,t,n,s){const a=Gd(n),o=a==='"'?"Quote":"Apostrophe",c=n.createTracker(s);let f,p;if(US(e,n)){const g=n.stack;n.stack=[],f=n.enter("autolink");let _=c.move("<");return _+=c.move(n.containerPhrasing(e,{before:_,after:">",...c.current()})),_+=c.move(">"),f(),n.stack=g,_}f=n.enter("link"),p=n.enter("label");let h=c.move("[");return h+=c.move(n.containerPhrasing(e,{before:h,after:"](",...c.current()})),h+=c.move("]("),p(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(p=n.enter("destinationLiteral"),h+=c.move("<"),h+=c.move(n.safe(e.url,{before:h,after:">",...c.current()})),h+=c.move(">")):(p=n.enter("destinationRaw"),h+=c.move(n.safe(e.url,{before:h,after:e.title?" ":")",...c.current()}))),p(),e.title&&(p=n.enter(`title${o}`),h+=c.move(" "+a),h+=c.move(n.safe(e.title,{before:h,after:a,...c.current()})),h+=c.move(a),p()),h+=c.move(")"),f(),h}function CA(e,t,n){return US(e,n)?"<":"["}FS.peek=kA;function FS(e,t,n,s){const a=e.referenceType,o=n.enter("linkReference");let c=n.enter("label");const f=n.createTracker(s);let p=f.move("[");const h=n.containerPhrasing(e,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),c();const g=n.stack;n.stack=[],c=n.enter("reference");const _=n.safe(n.associationId(e),{before:p,after:"]",...f.current()});return c(),n.stack=g,o(),a==="full"||!h||h!==_?p+=f.move(_+"]"):a==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function kA(){return"["}function Zd(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function EA(e){const t=Zd(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function TA(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function qS(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function AA(e,t,n,s){const a=n.enter("list"),o=n.bulletCurrent;let c=e.ordered?TA(n):Zd(n);const f=e.ordered?c==="."?")":".":EA(n);let p=t&&n.bulletLastUsed?c===n.bulletLastUsed:!1;if(!e.ordered){const g=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&g&&(!g.children||!g.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(p=!0),qS(n)===c&&g){let _=-1;for(;++_-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let c=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(c=Math.ceil(c/4)*4);const f=n.createTracker(s);f.move(o+" ".repeat(c-o.length)),f.shift(c);const p=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,f.current()),g);return p(),h;function g(_,b,y){return b?(y?"":" ".repeat(c))+_:(y?o:o+" ".repeat(c-o.length))+_}}function MA(e,t,n,s){const a=n.enter("paragraph"),o=n.enter("phrasing"),c=n.containerPhrasing(e,s);return o(),a(),c}const BA=Ru(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function NA(e,t,n,s){return(e.children.some(function(c){return BA(c)})?n.containerPhrasing:n.containerFlow).call(n,e,s)}function LA(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}WS.peek=zA;function WS(e,t,n,s){const a=LA(n),o=n.enter("strong"),c=n.createTracker(s),f=c.move(a+a);let p=c.move(n.containerPhrasing(e,{after:a,before:f,...c.current()}));const h=p.charCodeAt(0),g=Su(s.before.charCodeAt(s.before.length-1),h,a);g.inside&&(p=wa(h)+p.slice(1));const _=p.charCodeAt(p.length-1),b=Su(s.after.charCodeAt(0),_,a);b.inside&&(p=p.slice(0,-1)+wa(_));const y=c.move(a+a);return o(),n.attentionEncodeSurroundingInfo={after:b.outside,before:g.outside},f+p+y}function zA(e,t,n){return n.options.strong||"*"}function OA(e,t,n,s){return n.safe(e.value,s)}function jA(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function HA(e,t,n){const s=(qS(n)+(n.options.ruleSpaces?" ":"")).repeat(jA(n));return n.options.ruleSpaces?s.slice(0,-1):s}const YS={blockquote:aA,break:Fy,code:dA,definition:mA,emphasis:zS,hardBreak:Fy,heading:yA,html:OS,image:jS,imageReference:HS,inlineCode:PS,link:IS,linkReference:FS,list:AA,listItem:RA,paragraph:MA,root:NA,strong:WS,text:OA,thematicBreak:HA};function PA(){return{enter:{table:UA,tableData:qy,tableHeader:qy,tableRow:FA},exit:{codeText:qA,table:IA,tableData:Ef,tableHeader:Ef,tableRow:Ef}}}function UA(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function IA(e){this.exit(e),this.data.inTable=void 0}function FA(e){this.enter({type:"tableRow",children:[]},e)}function Ef(e){this.exit(e)}function qy(e){this.enter({type:"tableCell",children:[]},e)}function qA(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,WA));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function WA(e,t){return t==="|"?t:e}function YA(e){const t=e||{},n=t.tableCellPadding,s=t.tablePipeAlign,a=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:b,table:c,tableCell:p,tableRow:f}};function c(y,x,k,L){return h(g(y,k,L),y.align)}function f(y,x,k,L){const M=_(y,k,L),Z=h([M]);return Z.slice(0,Z.indexOf(` -`))}function p(y,x,k,L){const M=k.enter("tableCell"),Z=k.enter("phrasing"),I=k.containerPhrasing(y,{...L,before:o,after:o});return Z(),M(),I}function h(y,x){return sA(y,{align:x,alignDelimiters:s,padding:n,stringLength:a})}function g(y,x,k){const L=y.children;let M=-1;const Z=[],I=x.enter("table");for(;++M0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const uD={tokenize:gD,partial:!0};function cD(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:pD,continuation:{tokenize:mD},exit:_D}},text:{91:{name:"gfmFootnoteCall",tokenize:dD},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:hD,resolveTo:fD}}}}function hD(e,t,n){const s=this;let a=s.events.length;const o=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let c;for(;a--;){const p=s.events[a][1];if(p.type==="labelImage"){c=p;break}if(p.type==="gfmFootnoteCall"||p.type==="labelLink"||p.type==="label"||p.type==="image"||p.type==="link")break}return f;function f(p){if(!c||!c._balanced)return n(p);const h=Ji(s.sliceSerialize({start:c.end,end:s.now()}));return h.codePointAt(0)!==94||!o.includes(h.slice(1))?n(p):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),t(p))}}function fD(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const s={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},f=[e[n+1],e[n+2],["enter",s,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",c,t],["exit",c,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",s,t]];return e.splice(n,e.length-n+1,...f),e}function dD(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o=0,c;return f;function f(_){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(_),e.exit("gfmFootnoteCallLabelMarker"),p}function p(_){return _!==94?n(_):(e.enter("gfmFootnoteCallMarker"),e.consume(_),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(_){if(o>999||_===93&&!c||_===null||_===91||Qe(_))return n(_);if(_===93){e.exit("chunkString");const b=e.exit("gfmFootnoteCallString");return a.includes(Ji(s.sliceSerialize(b)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(_),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(_)}return Qe(_)||(c=!0),o++,e.consume(_),_===92?g:h}function g(_){return _===91||_===92||_===93?(e.consume(_),o++,h):h(_)}}function pD(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o,c=0,f;return p;function p(x){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(x){return x===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",g):n(x)}function g(x){if(c>999||x===93&&!f||x===null||x===91||Qe(x))return n(x);if(x===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return o=Ji(s.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),b}return Qe(x)||(f=!0),c++,e.consume(x),x===92?_:g}function _(x){return x===91||x===92||x===93?(e.consume(x),c++,g):g(x)}function b(x){return x===58?(e.enter("definitionMarker"),e.consume(x),e.exit("definitionMarker"),a.includes(o)||a.push(o),Ue(e,y,"gfmFootnoteDefinitionWhitespace")):n(x)}function y(x){return t(x)}}function mD(e,t,n){return e.check(Da,t,e.attempt(uD,t,n))}function _D(e){e.exit("gfmFootnoteDefinition")}function gD(e,t,n){const s=this;return Ue(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const c=s.events[s.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?t(o):n(o)}}function vD(e){let n=(e||{}).singleTilde;const s={name:"strikethrough",tokenize:o,resolveAll:a};return n==null&&(n=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function a(c,f){let p=-1;for(;++p1?p(x):(c.consume(x),_++,y);if(_<2&&!n)return p(x);const L=c.exit("strikethroughSequenceTemporary"),M=Qs(x);return L._open=!M||M===2&&!!k,L._close=!k||k===2&&!!M,f(x)}}}class yD{constructor(){this.map=[]}add(t,n,s){bD(this,t,n,s)}consume(t){if(this.map.sort(function(o,c){return o[0]-c[0]}),this.map.length===0)return;let n=this.map.length;const s=[];for(;n>0;)n-=1,s.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];s.push(t.slice()),t.length=0;let a=s.pop();for(;a;){for(const o of a)t.push(o);a=s.pop()}this.map.length=0}}function bD(e,t,n,s){let a=0;if(!(n===0&&s.length===0)){for(;a-1;){const A=s.events[le][1].type;if(A==="lineEnding"||A==="linePrefix")le--;else break}const V=le>-1?s.events[le][1].type:null,B=V==="tableHead"||V==="tableRow"?O:p;return B===O&&s.parser.lazy[s.now().line]?n(U):B(U)}function p(U){return e.enter("tableHead"),e.enter("tableRow"),h(U)}function h(U){return U===124||(c=!0,o+=1),g(U)}function g(U){return U===null?n(U):be(U)?o>1?(o=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(U),e.exit("lineEnding"),y):n(U):Oe(U)?Ue(e,g,"whitespace")(U):(o+=1,c&&(c=!1,a+=1),U===124?(e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),c=!0,g):(e.enter("data"),_(U)))}function _(U){return U===null||U===124||Qe(U)?(e.exit("data"),g(U)):(e.consume(U),U===92?b:_)}function b(U){return U===92||U===124?(e.consume(U),_):_(U)}function y(U){return s.interrupt=!1,s.parser.lazy[s.now().line]?n(U):(e.enter("tableDelimiterRow"),c=!1,Oe(U)?Ue(e,x,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(U):x(U))}function x(U){return U===45||U===58?L(U):U===124?(c=!0,e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),k):W(U)}function k(U){return Oe(U)?Ue(e,L,"whitespace")(U):L(U)}function L(U){return U===58?(o+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(U),e.exit("tableDelimiterMarker"),M):U===45?(o+=1,M(U)):U===null||be(U)?Q(U):W(U)}function M(U){return U===45?(e.enter("tableDelimiterFiller"),Z(U)):W(U)}function Z(U){return U===45?(e.consume(U),Z):U===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(U),e.exit("tableDelimiterMarker"),I):(e.exit("tableDelimiterFiller"),I(U))}function I(U){return Oe(U)?Ue(e,Q,"whitespace")(U):Q(U)}function Q(U){return U===124?x(U):U===null||be(U)?!c||a!==o?W(U):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(U)):W(U)}function W(U){return n(U)}function O(U){return e.enter("tableRow"),ie(U)}function ie(U){return U===124?(e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),ie):U===null||be(U)?(e.exit("tableRow"),t(U)):Oe(U)?Ue(e,ie,"whitespace")(U):(e.enter("data"),ue(U))}function ue(U){return U===null||U===124||Qe(U)?(e.exit("data"),ie(U)):(e.consume(U),U===92?me:ue)}function me(U){return U===92||U===124?(e.consume(U),ue):ue(U)}}function CD(e,t){let n=-1,s=!0,a=0,o=[0,0,0,0],c=[0,0,0,0],f=!1,p=0,h,g,_;const b=new yD;for(;++nn[2]+1){const x=n[2]+1,k=n[3]-n[2]-1;e.add(x,k,[])}}e.add(n[3]+1,0,[["exit",_,t]])}return a!==void 0&&(o.end=Object.assign({},Xs(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function Yy(e,t,n,s,a){const o=[],c=Xs(t.events,n);a&&(a.end=Object.assign({},c),o.push(["exit",a,t])),s.end=Object.assign({},c),o.push(["exit",s,t]),e.add(n+1,0,o)}function Xs(e,t){const n=e[t],s=n[0]==="enter"?"start":"end";return n[1][s]}const kD={name:"tasklistCheck",tokenize:TD};function ED(){return{text:{91:kD}}}function TD(e,t,n){const s=this;return a;function a(p){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?n(p):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),o)}function o(p){return Qe(p)?(e.enter("taskListCheckValueUnchecked"),e.consume(p),e.exit("taskListCheckValueUnchecked"),c):p===88||p===120?(e.enter("taskListCheckValueChecked"),e.consume(p),e.exit("taskListCheckValueChecked"),c):n(p)}function c(p){return p===93?(e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):n(p)}function f(p){return be(p)?t(p):Oe(p)?e.check({tokenize:AD},t,n)(p):n(p)}}function AD(e,t,n){return Ue(e,s,"whitespace");function s(a){return a===null?n(a):t(a)}}function DD(e){return uS([eD(),cD(),vD(e),xD(),ED()])}const RD={};function MD(e){const t=this,n=e||RD,s=t.data(),a=s.micromarkExtensions||(s.micromarkExtensions=[]),o=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),c=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);a.push(DD(n)),o.push($A()),c.push(ZA(n))}const Gr=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],Vy={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...Gr,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...Gr],h2:[["className","sr-only"]],img:[...Gr,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...Gr,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...Gr],table:[...Gr],ul:[...Gr,["className","contains-task-list"]],"*":["abbr","accept","acceptCharset","accessKey","action","align","alt","axis","border","cellPadding","cellSpacing","char","charOff","charSet","checked","clear","colSpan","color","cols","compact","coords","dateTime","dir","encType","frame","hSpace","headers","height","hrefLang","htmlFor","id","isMap","itemProp","label","lang","maxLength","media","method","multiple","name","noHref","noShade","noWrap","open","prompt","readOnly","rev","rowSpan","rows","rules","scope","selected","shape","size","span","start","summary","tabIndex","title","useMap","vAlign","value","width"]},clobber:["ariaDescribedBy","ariaLabelledBy","id","name"],clobberPrefix:"user-content-",protocols:{cite:["http","https"],href:["http","https","irc","ircs","mailto","xmpp"],longDesc:["http","https"],src:["http","https"]},required:{input:{disabled:!0,type:"checkbox"}},strip:["script"],tagNames:["a","b","blockquote","br","code","dd","del","details","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","i","img","input","ins","kbd","li","ol","p","picture","pre","q","rp","rt","ruby","s","samp","section","source","span","strike","strong","sub","summary","sup","table","tbody","td","tfoot","th","thead","tr","tt","ul","var"]},Sr={}.hasOwnProperty;function BD(e,t){let n={type:"root",children:[]};const s={schema:t?{...Vy,...t}:Vy,stack:[]},a=e0(s,e);return a&&(Array.isArray(a)?a.length===1?n=a[0]:n.children=a:n=a),n}function e0(e,t){if(t&&typeof t=="object"){const n=t;switch(typeof n.type=="string"?n.type:""){case"comment":return ND(e,n);case"doctype":return LD(e,n);case"element":return zD(e,n);case"root":return OD(e,n);case"text":return jD(e,n)}}}function ND(e,t){if(e.schema.allowComments){const n=typeof t.value=="string"?t.value:"",s=n.indexOf("-->"),o={type:"comment",value:s<0?n:n.slice(0,s)};return Ma(o,t),o}}function LD(e,t){if(e.schema.allowDoctypes){const n={type:"doctype"};return Ma(n,t),n}}function zD(e,t){const n=typeof t.tagName=="string"?t.tagName:"";e.stack.push(n);const s=t0(e,t.children),a=HD(e,t.properties);e.stack.pop();let o=!1;if(n&&n!=="*"&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(o=!0,e.schema.ancestors&&Sr.call(e.schema.ancestors,n))){const f=e.schema.ancestors[n];let p=-1;for(o=!1;++p1){let a=!1,o=0;for(;++o-1&&o>p||c>-1&&o>c||f>-1&&o>f)return!0;let h=-1;for(;++h4&&t.slice(0,4).toLowerCase()==="data")return n}function ID(e){return function(t){return BD(t,e)}}const aa=["Romance","Fantasy","Science Fiction","Mystery","Thriller","Horror","Adventure","Historical Fiction","Contemporary Lit","Humor","Poetry","Non-Fiction","Fanfiction","Short Story","Paranormal","Werewolf","LGBTQ+","New Adult","Teen Fiction","Diverse Lit","Others"],oa=["English","Chinese","Korean","Japanese","Spanish","French","Hindi","Arabic","Portuguese","Russian","Others"];function FD({storyName:e,fileName:t,authFetch:n,onPublish:s,publishingFile:a,walletAddress:o}){const[c,f]=$.useState(null),[p,h]=$.useState(!1),[g,_]=$.useState("preview"),[b,y]=$.useState(""),[x,k]=$.useState(!1),[L,M]=$.useState(!1),[Z,I]=$.useState(!1),[Q,W]=$.useState(null),[O,ie]=$.useState(aa[0]),[ue,me]=$.useState(oa[0]),[U,le]=$.useState(!1),V=$.useRef(null),B=$.useRef(!1),[A,R]=$.useState(!1),[T,j]=$.useState(aa[0]),[H,oe]=$.useState(oa[0]),[E,D]=$.useState(!1),[K,C]=$.useState(null),[J,fe]=$.useState(null),[de,xe]=$.useState(!1),[Ne,Ce]=$.useState(null),[rt,et]=$.useState(!1),ut=$.useRef(null),we=$.useRef(null),Et=$.useCallback(async()=>{if(!e||!t){f(null);return}const X=`${e}/${t}`,he=we.current!==X;he&&(we.current=X);try{const ve=await n(`/api/stories/${e}/${t}`);if(ve.ok){const Te=await ve.json();f(Te),(he||!B.current)&&(y(Te.content??""),he&&(M(!1),B.current=!1))}}catch{}},[e,t,n]);$.useEffect(()=>{h(!0),Et().finally(()=>h(!1))},[Et]),$.useEffect(()=>{if(!e||!t||g==="edit"&&L)return;const X=setInterval(Et,3e3);return()=>clearInterval(X)},[e,t,Et,g,L]),$.useEffect(()=>{if(!e)return;let X=!1;return n(`/api/stories/${e}/structure.md`).then(he=>he.ok?he.json():null).then(he=>{if(X||!(he!=null&&he.content))return;const ve=he.content.match(/\*{0,2}genre\*{0,2}[:\s]+(.+)/i);if(ve){const vt=ve[1].replace(/\*+/g,"").trim(),Yt=aa.find(Tt=>Tt.toLowerCase()===vt.toLowerCase());Yt&&ie(Yt)}const Te=he.content.match(/\*{0,2}language\*{0,2}[:\s]+(.+)/i);if(Te){const vt=Te[1].replace(/\*+/g,"").trim(),Yt=oa.find(Tt=>Tt.toLowerCase()===vt.toLowerCase());Yt&&me(Yt)}}).catch(()=>{}),()=>{X=!0}},[e,n]);const en=$.useCallback(async()=>{if(!(!e||!t)){k(!0);try{(await n(`/api/stories/${e}/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:b})})).ok&&(M(!1),B.current=!1,f(he=>he&&{...he,content:b}))}catch{}k(!1)}},[e,t,n,b]),Wn=$.useCallback(X=>{var ve;const he=(ve=X.target.files)==null?void 0:ve[0];if(he){if(he.size>500*1024){Ce("Image exceeds 500KB limit");return}if(!he.type.startsWith("image/")){Ce("File must be an image");return}C(he),fe(URL.createObjectURL(he)),Ce(null)}},[]),ss=$.useCallback(async()=>{if(c!=null&&c.storylineId){xe(!0),Ce(null),et(!1);try{let X;if(K){const ve=new FormData;ve.append("file",K);const Te=await n("/api/publish/upload-cover",{method:"POST",body:ve});if(!Te.ok){const Yt=await Te.json();throw new Error(Yt.error||"Cover upload failed")}X=(await Te.json()).cid}const he=await n("/api/publish/update-storyline",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storylineId:c.storylineId,...X!==void 0&&{coverCid:X},genre:T,language:H,isNsfw:E})});if(!he.ok){const ve=await he.json();throw new Error(ve.error||"Update failed")}et(!0),C(null),setTimeout(()=>et(!1),3e3)}catch(X){Ce(X instanceof Error?X.message:"Update failed")}finally{xe(!1)}}},[c==null?void 0:c.storylineId,K,T,H,E,n]);$.useEffect(()=>{R(!1),C(null),fe(null),Ce(null),et(!1)},[e,t]),$.useEffect(()=>{if(g!=="edit")return;const X=he=>{(he.metaKey||he.ctrlKey)&&he.key==="s"&&(he.preventDefault(),en())};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[g,en]),$.useEffect(()=>{if((c==null?void 0:c.status)!=="published-not-indexed"||!c.publishedAt)return;const X=new Date(c.publishedAt).getTime(),he=300*1e3,ve=()=>{const vt=Math.max(0,he-(Date.now()-X));W(vt)};ve();const Te=setInterval(ve,1e3);return()=>clearInterval(Te)},[c==null?void 0:c.status,c==null?void 0:c.publishedAt]);const Er=Q!==null&&Q<=0,pn=Q!==null&&Q>0?`${Math.floor(Q/6e4)}:${String(Math.floor(Q%6e4/1e3)).padStart(2,"0")}`:null;if(!e||!t)return S.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:S.jsxs("div",{className:"text-center",children:[S.jsx("p",{className:"text-lg font-serif",children:"Select a file to preview"}),S.jsx("p",{className:"text-sm mt-1",children:"Click a story file in the sidebar"})]})});if(p&&!c)return S.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:"Loading..."});const mn=(g==="edit"?b:(c==null?void 0:c.content)??"").length,_n=t==="genesis.md",gn=t?/^plot-\d+\.md$/.test(t):!1,Wt=(c==null?void 0:c.status)==="published"||(c==null?void 0:c.status)==="published-not-indexed",vn=_n||gn?1e4:null,te=!Wt&&vn!==null&&mn>vn;return S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"border-b border-border",children:[S.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[S.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono text-muted",children:[S.jsxs("span",{children:[e,"/",t]}),(c==null?void 0:c.status)==="published"&&S.jsx("span",{className:"text-green-700 font-medium",children:"Published"}),(c==null?void 0:c.status)==="published-not-indexed"&&S.jsx("span",{className:"text-amber-700 font-medium",title:c.indexError,children:"Published (not indexed)"}),(c==null?void 0:c.status)==="pending"&&S.jsx("span",{className:"text-amber-700 font-medium",children:"Pending"})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsxs("span",{className:`text-xs font-mono ${te?"text-error font-medium":"text-muted"}`,children:[mn.toLocaleString(),vn!==null?`/${vn.toLocaleString()}`:" chars"]}),te&&S.jsxs("span",{className:"text-error text-xs font-medium",children:[(mn-vn).toLocaleString()," over limit"]})]})]}),S.jsxs("div",{className:"flex px-3 gap-1",children:[S.jsx("button",{onClick:()=>_("preview"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${g==="preview"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:"Preview"}),S.jsxs("button",{onClick:()=>_("edit"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${g==="edit"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:["Edit",L&&S.jsx("span",{className:"ml-1 text-amber-600",children:"*"})]})]})]}),g==="preview"?S.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-6 py-4",style:{background:"var(--paper-bg)"},children:c!=null&&c.content?S.jsx("div",{className:"prose max-w-none",children:S.jsx(_3,{remarkPlugins:[T3,MD],rehypePlugins:[ID],children:c.content})}):S.jsx("p",{className:"text-muted italic",children:"No content"})}):S.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",style:{background:"var(--paper-bg)"},children:[S.jsx("textarea",{ref:V,value:b,onChange:X=>{y(X.target.value),M(!0),B.current=!0},className:"flex-1 min-h-0 w-full resize-none px-4 py-3 text-sm leading-relaxed focus:outline-none",style:{fontFamily:'"Geist Mono", ui-monospace, monospace',background:"var(--paper-bg)",color:"var(--text)"},spellCheck:!1}),S.jsxs("div",{className:"px-3 py-1.5 border-t border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs text-muted",children:L?"Unsaved changes":"No changes"}),S.jsx("button",{onClick:en,disabled:!L||x,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:x?"Saving...":"Save"})]})]}),S.jsx("div",{className:"px-3 py-2 border-t border-border flex items-center justify-between",children:t==="structure.md"?S.jsx("p",{className:"text-muted text-xs italic",children:"This is your story outline — not publishable. Ask AI to write the genesis next."}):(c==null?void 0:c.status)==="published-not-indexed"?S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[S.jsx("span",{className:"text-amber-700",children:"Published on-chain but not indexed on PlotLink"}),!Er&&S.jsx("button",{onClick:async()=>{if(!(!e||!t||!c.txHash)){I(!0);try{(await(await n("/api/publish/retry-index",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:e,fileName:t,txHash:c.txHash,content:c.content,storylineId:c.storylineId})})).json()).ok&&(await n(`/api/stories/${e}/${t}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:c.txHash,storylineId:c.storylineId,contentCid:"",gasCost:""})}),Et())}catch{}I(!1)}},disabled:Z,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:Z?"Retrying...":`Retry Index${pn?` (${pn})`:""}`}),gn&&S.jsx("button",{onClick:()=>e&&t&&(s==null?void 0:s(e,t,O,ue,U)),disabled:!!a,className:"px-3 py-1 border border-border text-xs rounded hover:bg-surface disabled:opacity-50",children:a===t?"Publishing...":"Retry Publish"}),c.txHash&&S.jsx("a",{href:`https://basescan.org/tx/${c.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"})]}),S.jsx("p",{className:"text-muted text-xs",children:Er?gn?"Index window expired. Use Retry Publish to create a new on-chain tx.":"Index window expired. Contact support or re-publish manually.":gn?"Try Retry Index first (available for 5 min after publish). If that fails, Retry Publish creates a new on-chain tx.":"Retry Index is available for 5 min after publish."}),c.indexError&&S.jsx("p",{className:"text-error text-xs",children:c.indexError})]}):(c==null?void 0:c.status)==="published"?S.jsxs("div",{className:"flex flex-col gap-2",children:[S.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[S.jsx("span",{className:"text-green-700",children:"Published"}),c.storylineId&&S.jsx("a",{href:(()=>{var ve;const X=`https://plotlink.xyz/story/${c.storylineId}`;if(!gn)return X;const he=c.plotIndex!=null&&c.plotIndex>0?c.plotIndex:parseInt(((ve=t==null?void 0:t.match(/^plot-(\d+)\.md$/))==null?void 0:ve[1])??"1");return`${X}/${he}`})(),target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"}),c.txHash&&S.jsx("a",{href:`https://basescan.org/tx/${c.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"}),_n&&o&&c.storylineId&&S.jsx("button",{onClick:()=>R(X=>!X),className:"px-2 py-0.5 border border-border text-xs rounded hover:bg-surface",children:A?"Close Edit":"Edit Story"})]}),A&&_n&&c.storylineId&&S.jsxs("div",{className:"border border-border rounded p-3 flex flex-col gap-3 bg-surface",children:[S.jsxs("div",{className:"flex flex-col gap-1.5",children:[S.jsx("span",{className:"text-xs font-medium text-foreground",children:"Cover Image"}),S.jsxs("div",{className:"flex items-start gap-3",children:[J&&S.jsxs("div",{className:"relative",children:[S.jsx("img",{src:J,alt:"Cover preview",className:"w-16 h-24 object-cover rounded border border-border"}),S.jsx("button",{onClick:()=>{C(null),fe(null),ut.current&&(ut.current.value="")},className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-error text-white rounded-full text-xs flex items-center justify-center",children:"x"})]}),S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsx("input",{ref:ut,type:"file",accept:"image/webp,image/jpeg,image/png",onChange:Wn,className:"text-xs"}),S.jsx("span",{className:"text-xs text-muted",children:"WebP/JPEG, max 500KB, 600x900px recommended"})]})]})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("select",{value:T,onChange:X=>j(X.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:aa.map(X=>S.jsx("option",{value:X,children:X},X))}),S.jsx("select",{value:H,onChange:X=>oe(X.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:oa.map(X=>S.jsx("option",{value:X,children:X},X))})]}),S.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[S.jsx("input",{type:"checkbox",checked:E,onChange:X=>D(X.target.checked),className:"rounded border-border"}),"This story contains adult content (18+)"]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("button",{onClick:ss,disabled:de,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:de?"Saving...":"Save Changes"}),rt&&S.jsx("span",{className:"text-green-700 text-xs",children:"Updated!"}),Ne&&S.jsx("span",{className:"text-error text-xs",children:Ne})]})]})]}):S.jsxs("div",{className:"flex flex-col gap-2",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[_n&&S.jsxs(S.Fragment,{children:[S.jsx("select",{value:O,onChange:X=>ie(X.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:aa.map(X=>S.jsx("option",{value:X,children:X},X))}),S.jsx("select",{value:ue,onChange:X=>me(X.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:oa.map(X=>S.jsx("option",{value:X,children:X},X))})]}),S.jsx("button",{onClick:()=>e&&t&&(s==null?void 0:s(e,t,O,ue,U)),disabled:!!a||te,className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:a===t?"Publishing...":"Publish to PlotLink"}),te&&S.jsx("span",{className:"text-error text-xs",children:"Reduce content to publish"})]}),_n&&S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[S.jsx("input",{type:"checkbox",checked:U,onChange:X=>le(X.target.checked),className:"rounded border-border"}),"This story contains adult content (18+)"]}),U&&S.jsx("span",{className:"text-xs text-amber-600",children:"Adult content will be hidden from the default browse view."})]})]})})]})}const n0="plotlink-panel-ratio",qD=.6,Gy=300,Tf=224,Af=6;function WD(){try{const e=localStorage.getItem(n0);if(e){const t=parseFloat(e);if(t>0&&t<1)return t}}catch{}return qD}function $y(e,t){if(t<=0)return e;const n=Gy/t,s=1-Gy/t;return n>=s?.5:Math.min(s,Math.max(n,e))}function YD({token:e,authFetch:t}){const[n,s]=$.useState(null),[a,o]=$.useState(null),[c,f]=$.useState(null),[p,h]=$.useState(""),[g,_]=$.useState(null),[b,y]=$.useState(WD),[x,k]=$.useState([]),L=$.useRef(new Set),M=$.useRef(null),Z=$.useRef(null),I=$.useRef(!1);$.useEffect(()=>{t("/api/wallet").then(A=>A.ok?A.json():null).then(A=>{A!=null&&A.address&&_(A.address)}).catch(()=>{})},[t]),$.useEffect(()=>{try{localStorage.setItem(n0,String(b))}catch{}},[b]),$.useEffect(()=>{const A=()=>{if(!Z.current)return;const R=Z.current.getBoundingClientRect().width-Tf-Af;y(T=>$y(T,R))};return window.addEventListener("resize",A),A(),()=>window.removeEventListener("resize",A)},[]);const Q=$.useCallback(()=>{const A=`_new_${Date.now()}`;k(R=>[...R,A]),s(A),o(null)},[]);$.useEffect(()=>{if(x.length===0)return;const A=setInterval(async()=>{try{const R=await t("/api/stories");if(!R.ok)return;const T=await R.json(),j=new Set(T.stories.filter(H=>H.name!=="_example").map(H=>H.name));for(const H of j)if(!L.current.has(H)&&x.length>0){const oe=x[0];let E=!1;M.current&&(E=await M.current(oe,H).catch(()=>!1)),E&&k(D=>D.slice(1)),s(H),o(null)}L.current=j}catch{}},3e3);return()=>clearInterval(A)},[t,x]),$.useEffect(()=>{t("/api/stories").then(A=>{if(A.ok)return A.json()}).then(A=>{A!=null&&A.stories&&(L.current=new Set(A.stories.filter(R=>R.name!=="_example").map(R=>R.name)))}).catch(()=>{})},[t]);const W=$.useCallback((A,R)=>{s(A),o(R)},[]),O=$.useRef(null),ie=$.useCallback(async A=>{var R,T,j,H;O.current=A,s(A),o(null);try{const oe=await t(`/api/stories/${A}`);if(oe.ok&&O.current===A){const D=(await oe.json()).files||[],C=((R=D.map(J=>{var fe;return{file:J.file,num:(fe=J.file.match(/^plot-(\d+)\.md$/))==null?void 0:fe[1]}}).filter(J=>J.num!=null).sort((J,fe)=>parseInt(fe.num)-parseInt(J.num))[0])==null?void 0:R.file)??((T=D.find(J=>J.file==="genesis.md"))==null?void 0:T.file)??((j=D.find(J=>J.file==="structure.md"))==null?void 0:j.file)??((H=D[0])==null?void 0:H.file);C&&O.current===A&&o(C)}}catch{}},[t]),ue=$.useCallback(A=>{A.preventDefault(),I.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";const R=j=>{if(!I.current||!Z.current)return;const H=Z.current.getBoundingClientRect(),oe=H.width-Tf-Af,E=j.clientX-H.left-Tf;y($y(E/oe,oe))},T=()=>{I.current=!1,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",R),window.removeEventListener("mouseup",T)};window.addEventListener("mousemove",R),window.addEventListener("mouseup",T)},[]),me=$.useCallback(async(A,R,T,j,H)=>{var oe;f(R),h("Reading file...");try{const E=await t(`/api/stories/${A}/${R}`);if(!E.ok)throw new Error("Failed to read file");const D=await E.json(),K=D.content.match(/^#\s+(.+)$/m),C=K?K[1].slice(0,60):R.replace(".md","");let J;if(R.match(/^plot-\d+\.md$/)){try{const Ne=await t(`/api/stories/${A}`);if(Ne.ok){const rt=(await Ne.json()).files.find(et=>et.file==="genesis.md"&&et.storylineId);J=rt==null?void 0:rt.storylineId}}catch{}if(!J){h("Error: Publish genesis first to create the storyline"),setTimeout(()=>{f(null),h("")},3e3);return}}h("Publishing...");const fe=await t("/api/publish/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:A,fileName:R,title:C,content:D.content,genre:T,language:j,isNsfw:H,storylineId:J})});if(!fe.ok){const Ne=await fe.json();throw new Error(Ne.error||"Publish failed")}const de=(oe=fe.body)==null?void 0:oe.getReader(),xe=new TextDecoder;if(de)for(;;){const{done:Ne,value:Ce}=await de.read();if(Ne)break;const et=xe.decode(Ce).split(` -`).filter(ut=>ut.startsWith("data: "));for(const ut of et)try{const we=JSON.parse(ut.slice(6));we.step&&h(we.message||we.step),we.step==="done"&&we.txHash&&await t(`/api/stories/${A}/${R}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:we.txHash,storylineId:we.storylineId,plotIndex:we.plotIndex,contentCid:we.contentCid,gasCost:we.gasCost,indexError:we.indexError})})}catch{}}h("Published!")}catch(E){const D=E instanceof Error?E.message:"Publish failed";h(`Error: ${D}`)}finally{setTimeout(()=>{f(null),h("")},3e3)}},[t]),U=$.useCallback(A=>{A.startsWith("_new_")&&k(R=>R.filter(T=>T!==A))},[]),[le,V]=$.useState(new Set);$.useEffect(()=>{t("/api/stories").then(R=>R.ok?R.json():null).then(R=>{R!=null&&R.stories&&V(new Set(R.stories.filter(T=>T.hasStructure).map(T=>T.name)))}).catch(()=>{});const A=setInterval(async()=>{try{const R=await t("/api/stories");if(R.ok){const T=await R.json();V(new Set(T.stories.filter(j=>j.hasStructure).map(j=>j.name)))}}catch{}},5e3);return()=>clearInterval(A)},[t]);const B=$.useCallback(A=>{n===A&&(s(null),o(null))},[n]);return S.jsxs("div",{ref:Z,className:"h-[calc(100vh-3.5rem)] flex",children:[S.jsx("div",{className:"w-56 border-r border-border flex-shrink-0",children:S.jsx(jx,{authFetch:t,selectedStory:n,selectedFile:a,onSelectFile:W,onNewStory:Q,untitledSessions:x})}),S.jsx("div",{className:"min-w-0 border-r border-border",style:{flex:`${b} 0 0`},children:S.jsx(lk,{token:e,storyName:n,authFetch:t,onSelectStory:ie,onDestroySession:U,onArchiveStory:B,confirmedStories:le,renameRef:M})}),S.jsx("div",{onMouseDown:ue,className:"flex-shrink-0 flex items-center justify-center hover:bg-border/50 transition-colors",style:{width:Af,cursor:"col-resize",background:"var(--border)"},children:S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}})]})}),S.jsxs("div",{className:"min-w-0 flex flex-col",style:{flex:`${1-b} 0 0`},children:[S.jsx(FD,{storyName:n,fileName:a,authFetch:t,onPublish:me,publishingFile:c,walletAddress:g}),p&&S.jsx("div",{className:"px-3 py-1.5 bg-surface border-t border-border text-xs text-muted",children:p})]})]})}function VD({token:e,onComplete:t}){const[n,s]=$.useState(!1),[a,o]=$.useState(null),[c,f]=$.useState(!1),p=async()=>{s(!0),o(null);try{const h=await fetch("/api/wallet/create",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),g=await h.json();if(!h.ok)throw new Error(g.error||"Wallet creation failed");f(!0)}catch(h){o(h instanceof Error?h.message:"Wallet creation failed")}s(!1)};return $.useEffect(()=>{p()},[]),S.jsxs("div",{className:"mx-auto max-w-sm p-6 text-center",children:[S.jsx("h2",{className:"text-accent mb-1 text-lg font-bold",children:"Wallet Setup"}),S.jsx("p",{className:"text-muted mb-6 text-xs",children:"creating your OWS wallet for on-chain publishing"}),n&&S.jsx("p",{className:"text-accent text-sm",children:"creating wallet..."}),a&&S.jsxs("div",{className:"space-y-4",children:[S.jsx("div",{className:"rounded border border-red-700/30 p-3 text-xs text-red-700",children:a}),S.jsx("button",{onClick:p,className:"border-accent text-accent hover:bg-accent/10 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:"retry"})]}),c&&S.jsxs("div",{className:"space-y-4",children:[S.jsx("div",{className:"text-accent text-2xl",children:"✓"}),S.jsx("p",{className:"text-foreground text-sm font-medium",children:"wallet created"}),S.jsx("button",{onClick:t,className:"border-accent text-accent hover:bg-accent/10 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:"continue"})]})]})}function KD({token:e,onLogout:t}){const[n,s]=$.useState("home"),[a,o]=$.useState(0),c=$.useCallback(async(f,p)=>fetch(f,{...p,headers:{...(p==null?void 0:p.headers)||{},Authorization:`Bearer ${e}`}}),[e]);return $.useEffect(()=>{async function f(){try{if(!(await(await c("/api/wallet")).json()).exists){s("wallet-setup");return}const g=await c("/api/stories");if(g.ok){const _=await g.json();o(_.stories.filter(b=>b.name!=="_example").length)}}catch{}}f()},[e]),S.jsxs("div",{className:"flex h-screen flex-col",children:[S.jsxs("header",{className:"border-border flex h-14 items-center justify-between border-b px-4 flex-shrink-0",children:[S.jsxs("div",{className:"flex items-center gap-3",children:[S.jsx("button",{onClick:()=>{n!=="wallet-setup"&&s("home")},className:"flex items-center gap-2 hover:opacity-80",children:S.jsx("span",{className:"text-accent text-sm font-bold tracking-tight",children:"PlotLink OWS"})}),S.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"writer"})]}),n!=="wallet-setup"&&S.jsxs("nav",{className:"flex items-center gap-4",children:[S.jsx("button",{onClick:()=>s("stories"),className:`text-xs transition-colors ${n==="stories"?"text-accent":"text-muted hover:text-foreground"}`,children:"stories"}),S.jsx("button",{onClick:()=>s("dashboard"),className:`text-xs transition-colors ${n==="dashboard"?"text-accent":"text-muted hover:text-foreground"}`,children:"dashboard"}),S.jsx("button",{onClick:()=>s("settings"),className:`text-xs transition-colors ${n==="settings"?"text-accent":"text-muted hover:text-foreground"}`,children:"settings"}),S.jsx("button",{onClick:t,className:"text-muted hover:text-foreground text-xs transition-colors",children:"logout"})]})]}),S.jsxs("main",{className:"flex-1 min-h-0",children:[n==="home"&&S.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-8",children:[S.jsxs("div",{className:"text-center space-y-2",children:[S.jsx("h1",{className:"text-2xl font-serif text-foreground",children:"Write. Publish. Earn."}),S.jsx("p",{className:"text-muted text-sm",children:"Claude CLI writes stories. You publish them on-chain."})]}),S.jsxs("div",{className:"text-center space-y-3",children:[S.jsx("button",{onClick:()=>s("stories"),className:"bg-accent text-white hover:bg-accent-dim px-6 py-2.5 rounded text-sm font-medium transition-colors",children:"Start Writing"}),a>0&&S.jsxs("p",{className:"text-muted text-xs",children:[a," ",a===1?"story":"stories"," in progress"]})]}),S.jsxs("div",{className:"rounded border border-border p-4 space-y-2 text-xs text-muted",children:[S.jsx("p",{className:"font-medium text-foreground text-sm",children:"How it works"}),S.jsxs("ol",{className:"space-y-1.5 list-decimal list-inside",children:[S.jsxs("li",{children:["Open the ",S.jsx("strong",{children:"Stories"})," tab — Claude CLI launches in the terminal"]}),S.jsx("li",{children:"Tell Claude your story idea — it brainstorms, outlines, and writes"}),S.jsx("li",{children:"Review the live preview as Claude creates files"}),S.jsxs("li",{children:["Click ",S.jsx("strong",{children:"Publish"})," to put your story on-chain"]}),S.jsxs("li",{children:["Earn 5% royalties on every trade at ",S.jsx("a",{href:"https://plotlink.xyz",target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"plotlink.xyz"})]})]})]}),S.jsx("div",{className:"text-center",children:S.jsx("a",{href:"https://github.com/realproject7/plotlink-ows#-wallet-setup",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted hover:text-accent underline transition-colors",children:"Wallet Setup Guide"})}),S.jsx(eb,{token:e})]}),n==="stories"&&S.jsx(YD,{token:e,authFetch:c}),n==="dashboard"&&S.jsx(Lx,{token:e}),n==="wallet-setup"&&S.jsx(VD,{token:e,onComplete:()=>s("home")}),n==="settings"&&S.jsx(Bx,{token:e,onLogout:t})]})]})}function XD(){const[e,t]=$.useState(()=>localStorage.getItem("ows-token")),[n,s]=$.useState(null),[a,o]=$.useState(!0);$.useEffect(()=>{fetch("/api/auth/status").then(h=>h.json()).then(h=>s(h.configured)).catch(()=>s(null))},[]),$.useEffect(()=>{if(!e){o(!1);return}fetch("/api/auth/verify",{headers:{Authorization:`Bearer ${e}`}}).then(h=>{h.ok||(localStorage.removeItem("ows-token"),t(null))}).catch(()=>{localStorage.removeItem("ows-token"),t(null)}).finally(()=>o(!1))},[e]);const c=async h=>{try{const g=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:h})}),_=await g.json();return g.ok?(localStorage.setItem("ows-token",_.token),t(_.token),null):_.error||"Login failed"}catch{return"Cannot connect to server"}},f=async h=>{try{const g=await fetch("/api/auth/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:h})}),_=await g.json();return g.ok?(localStorage.setItem("ows-token",_.token),t(_.token),s(!0),null):_.error||"Setup failed"}catch{return"Cannot connect to server"}},p=()=>{localStorage.removeItem("ows-token"),t(null)};return a||n===null?S.jsx("div",{className:"flex h-screen items-center justify-center",children:S.jsx("span",{className:"text-muted text-sm",children:"connecting..."})}):n?e?S.jsx(KD,{token:e,onLogout:p}):S.jsx(Rx,{onLogin:c}):S.jsx(Mx,{onSetup:f})}Dx.createRoot(document.getElementById("root")).render(S.jsx(Sx.StrictMode,{children:S.jsx(XD,{})})); +`))}function p(y,x,k,L){const M=k.enter("tableCell"),Z=k.enter("phrasing"),I=k.containerPhrasing(y,{...L,before:o,after:o});return Z(),M(),I}function h(y,x){return sA(y,{align:x,alignDelimiters:s,padding:n,stringLength:a})}function g(y,x,k){const L=y.children;let M=-1;const Z=[],I=x.enter("table");for(;++M0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const uD={tokenize:gD,partial:!0};function cD(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:pD,continuation:{tokenize:mD},exit:_D}},text:{91:{name:"gfmFootnoteCall",tokenize:dD},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:hD,resolveTo:fD}}}}function hD(e,t,n){const s=this;let a=s.events.length;const o=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let c;for(;a--;){const p=s.events[a][1];if(p.type==="labelImage"){c=p;break}if(p.type==="gfmFootnoteCall"||p.type==="labelLink"||p.type==="label"||p.type==="image"||p.type==="link")break}return f;function f(p){if(!c||!c._balanced)return n(p);const h=Ji(s.sliceSerialize({start:c.end,end:s.now()}));return h.codePointAt(0)!==94||!o.includes(h.slice(1))?n(p):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),t(p))}}function fD(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const s={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},f=[e[n+1],e[n+2],["enter",s,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",c,t],["exit",c,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",s,t]];return e.splice(n,e.length-n+1,...f),e}function dD(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o=0,c;return f;function f(_){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(_),e.exit("gfmFootnoteCallLabelMarker"),p}function p(_){return _!==94?n(_):(e.enter("gfmFootnoteCallMarker"),e.consume(_),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(_){if(o>999||_===93&&!c||_===null||_===91||Qe(_))return n(_);if(_===93){e.exit("chunkString");const b=e.exit("gfmFootnoteCallString");return a.includes(Ji(s.sliceSerialize(b)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(_),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(_)}return Qe(_)||(c=!0),o++,e.consume(_),_===92?g:h}function g(_){return _===91||_===92||_===93?(e.consume(_),o++,h):h(_)}}function pD(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o,c=0,f;return p;function p(x){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(x){return x===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",g):n(x)}function g(x){if(c>999||x===93&&!f||x===null||x===91||Qe(x))return n(x);if(x===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return o=Ji(s.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),b}return Qe(x)||(f=!0),c++,e.consume(x),x===92?_:g}function _(x){return x===91||x===92||x===93?(e.consume(x),c++,g):g(x)}function b(x){return x===58?(e.enter("definitionMarker"),e.consume(x),e.exit("definitionMarker"),a.includes(o)||a.push(o),Ue(e,y,"gfmFootnoteDefinitionWhitespace")):n(x)}function y(x){return t(x)}}function mD(e,t,n){return e.check(Da,t,e.attempt(uD,t,n))}function _D(e){e.exit("gfmFootnoteDefinition")}function gD(e,t,n){const s=this;return Ue(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const c=s.events[s.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?t(o):n(o)}}function vD(e){let n=(e||{}).singleTilde;const s={name:"strikethrough",tokenize:o,resolveAll:a};return n==null&&(n=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function a(c,f){let p=-1;for(;++p1?p(x):(c.consume(x),_++,y);if(_<2&&!n)return p(x);const L=c.exit("strikethroughSequenceTemporary"),M=el(x);return L._open=!M||M===2&&!!k,L._close=!k||k===2&&!!M,f(x)}}}class yD{constructor(){this.map=[]}add(t,n,s){bD(this,t,n,s)}consume(t){if(this.map.sort(function(o,c){return o[0]-c[0]}),this.map.length===0)return;let n=this.map.length;const s=[];for(;n>0;)n-=1,s.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];s.push(t.slice()),t.length=0;let a=s.pop();for(;a;){for(const o of a)t.push(o);a=s.pop()}this.map.length=0}}function bD(e,t,n,s){let a=0;if(!(n===0&&s.length===0)){for(;a-1;){const A=s.events[le][1].type;if(A==="lineEnding"||A==="linePrefix")le--;else break}const V=le>-1?s.events[le][1].type:null,B=V==="tableHead"||V==="tableRow"?O:p;return B===O&&s.parser.lazy[s.now().line]?n(U):B(U)}function p(U){return e.enter("tableHead"),e.enter("tableRow"),h(U)}function h(U){return U===124||(c=!0,o+=1),g(U)}function g(U){return U===null?n(U):be(U)?o>1?(o=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(U),e.exit("lineEnding"),y):n(U):Oe(U)?Ue(e,g,"whitespace")(U):(o+=1,c&&(c=!1,a+=1),U===124?(e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),c=!0,g):(e.enter("data"),_(U)))}function _(U){return U===null||U===124||Qe(U)?(e.exit("data"),g(U)):(e.consume(U),U===92?b:_)}function b(U){return U===92||U===124?(e.consume(U),_):_(U)}function y(U){return s.interrupt=!1,s.parser.lazy[s.now().line]?n(U):(e.enter("tableDelimiterRow"),c=!1,Oe(U)?Ue(e,x,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(U):x(U))}function x(U){return U===45||U===58?L(U):U===124?(c=!0,e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),k):W(U)}function k(U){return Oe(U)?Ue(e,L,"whitespace")(U):L(U)}function L(U){return U===58?(o+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(U),e.exit("tableDelimiterMarker"),M):U===45?(o+=1,M(U)):U===null||be(U)?Q(U):W(U)}function M(U){return U===45?(e.enter("tableDelimiterFiller"),Z(U)):W(U)}function Z(U){return U===45?(e.consume(U),Z):U===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(U),e.exit("tableDelimiterMarker"),I):(e.exit("tableDelimiterFiller"),I(U))}function I(U){return Oe(U)?Ue(e,Q,"whitespace")(U):Q(U)}function Q(U){return U===124?x(U):U===null||be(U)?!c||a!==o?W(U):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(U)):W(U)}function W(U){return n(U)}function O(U){return e.enter("tableRow"),ie(U)}function ie(U){return U===124?(e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),ie):U===null||be(U)?(e.exit("tableRow"),t(U)):Oe(U)?Ue(e,ie,"whitespace")(U):(e.enter("data"),ue(U))}function ue(U){return U===null||U===124||Qe(U)?(e.exit("data"),ie(U)):(e.consume(U),U===92?me:ue)}function me(U){return U===92||U===124?(e.consume(U),ue):ue(U)}}function CD(e,t){let n=-1,s=!0,a=0,o=[0,0,0,0],c=[0,0,0,0],f=!1,p=0,h,g,_;const b=new yD;for(;++nn[2]+1){const x=n[2]+1,k=n[3]-n[2]-1;e.add(x,k,[])}}e.add(n[3]+1,0,[["exit",_,t]])}return a!==void 0&&(o.end=Object.assign({},Gs(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function Yy(e,t,n,s,a){const o=[],c=Gs(t.events,n);a&&(a.end=Object.assign({},c),o.push(["exit",a,t])),s.end=Object.assign({},c),o.push(["exit",s,t]),e.add(n+1,0,o)}function Gs(e,t){const n=e[t],s=n[0]==="enter"?"start":"end";return n[1][s]}const kD={name:"tasklistCheck",tokenize:TD};function ED(){return{text:{91:kD}}}function TD(e,t,n){const s=this;return a;function a(p){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?n(p):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),o)}function o(p){return Qe(p)?(e.enter("taskListCheckValueUnchecked"),e.consume(p),e.exit("taskListCheckValueUnchecked"),c):p===88||p===120?(e.enter("taskListCheckValueChecked"),e.consume(p),e.exit("taskListCheckValueChecked"),c):n(p)}function c(p){return p===93?(e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):n(p)}function f(p){return be(p)?t(p):Oe(p)?e.check({tokenize:AD},t,n)(p):n(p)}}function AD(e,t,n){return Ue(e,s,"whitespace");function s(a){return a===null?n(a):t(a)}}function DD(e){return uS([eD(),cD(),vD(e),xD(),ED()])}const RD={};function MD(e){const t=this,n=e||RD,s=t.data(),a=s.micromarkExtensions||(s.micromarkExtensions=[]),o=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),c=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);a.push(DD(n)),o.push(GA()),c.push(ZA(n))}const $r=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],Vy={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...$r,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...$r],h2:[["className","sr-only"]],img:[...$r,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...$r,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...$r],table:[...$r],ul:[...$r,["className","contains-task-list"]],"*":["abbr","accept","acceptCharset","accessKey","action","align","alt","axis","border","cellPadding","cellSpacing","char","charOff","charSet","checked","clear","colSpan","color","cols","compact","coords","dateTime","dir","encType","frame","hSpace","headers","height","hrefLang","htmlFor","id","isMap","itemProp","label","lang","maxLength","media","method","multiple","name","noHref","noShade","noWrap","open","prompt","readOnly","rev","rowSpan","rows","rules","scope","selected","shape","size","span","start","summary","tabIndex","title","useMap","vAlign","value","width"]},clobber:["ariaDescribedBy","ariaLabelledBy","id","name"],clobberPrefix:"user-content-",protocols:{cite:["http","https"],href:["http","https","irc","ircs","mailto","xmpp"],longDesc:["http","https"],src:["http","https"]},required:{input:{disabled:!0,type:"checkbox"}},strip:["script"],tagNames:["a","b","blockquote","br","code","dd","del","details","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","i","img","input","ins","kbd","li","ol","p","picture","pre","q","rp","rt","ruby","s","samp","section","source","span","strike","strong","sub","summary","sup","table","tbody","td","tfoot","th","thead","tr","tt","ul","var"]},Sr={}.hasOwnProperty;function BD(e,t){let n={type:"root",children:[]};const s={schema:t?{...Vy,...t}:Vy,stack:[]},a=e0(s,e);return a&&(Array.isArray(a)?a.length===1?n=a[0]:n.children=a:n=a),n}function e0(e,t){if(t&&typeof t=="object"){const n=t;switch(typeof n.type=="string"?n.type:""){case"comment":return ND(e,n);case"doctype":return LD(e,n);case"element":return zD(e,n);case"root":return OD(e,n);case"text":return jD(e,n)}}}function ND(e,t){if(e.schema.allowComments){const n=typeof t.value=="string"?t.value:"",s=n.indexOf("-->"),o={type:"comment",value:s<0?n:n.slice(0,s)};return Ma(o,t),o}}function LD(e,t){if(e.schema.allowDoctypes){const n={type:"doctype"};return Ma(n,t),n}}function zD(e,t){const n=typeof t.tagName=="string"?t.tagName:"";e.stack.push(n);const s=t0(e,t.children),a=HD(e,t.properties);e.stack.pop();let o=!1;if(n&&n!=="*"&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(o=!0,e.schema.ancestors&&Sr.call(e.schema.ancestors,n))){const f=e.schema.ancestors[n];let p=-1;for(o=!1;++p1){let a=!1,o=0;for(;++o-1&&o>p||c>-1&&o>c||f>-1&&o>f)return!0;let h=-1;for(;++h4&&t.slice(0,4).toLowerCase()==="data")return n}function ID(e){return function(t){return BD(t,e)}}const Xs=["Romance","Fantasy","Science Fiction","Mystery","Thriller","Horror","Adventure","Historical Fiction","Contemporary Lit","Humor","Poetry","Non-Fiction","Fanfiction","Short Story","Paranormal","Werewolf","LGBTQ+","New Adult","Teen Fiction","Diverse Lit","Others"],$s=["English","Chinese","Korean","Japanese","Spanish","French","Hindi","Arabic","Portuguese","Russian","Others"];function FD({storyName:e,fileName:t,authFetch:n,onPublish:s,publishingFile:a,walletAddress:o}){const[c,f]=G.useState(null),[p,h]=G.useState(!1),[g,_]=G.useState("preview"),[b,y]=G.useState(""),[x,k]=G.useState(!1),[L,M]=G.useState(!1),[Z,I]=G.useState(!1),[Q,W]=G.useState(null),[O,ie]=G.useState(Xs[0]),[ue,me]=G.useState($s[0]),[U,le]=G.useState(!1),V=G.useRef(null),B=G.useRef(!1),[A,R]=G.useState(!1),[T,j]=G.useState(Xs[0]),[H,ae]=G.useState($s[0]),[E,D]=G.useState(!1),[K,C]=G.useState(null),[J,fe]=G.useState(null),[de,xe]=G.useState(!1),[Ne,ke]=G.useState(null),[rt,et]=G.useState(!1),ct=G.useRef(null),we=G.useRef(null),Et=G.useCallback(async()=>{if(!e||!t){f(null);return}const X=`${e}/${t}`,ce=we.current!==X;ce&&(we.current=X);try{const _e=await n(`/api/stories/${e}/${t}`);if(_e.ok){const Ce=await _e.json();f(Ce),(ce||!B.current)&&(y(Ce.content??""),ce&&(M(!1),B.current=!1))}}catch{}},[e,t,n]);G.useEffect(()=>{h(!0),Et().finally(()=>h(!1))},[Et]),G.useEffect(()=>{if(!e||!t||g==="edit"&&L)return;const X=setInterval(Et,3e3);return()=>clearInterval(X)},[e,t,Et,g,L]),G.useEffect(()=>{if(!e)return;let X=!1;return n(`/api/stories/${e}/structure.md`).then(ce=>ce.ok?ce.json():null).then(ce=>{if(X||!(ce!=null&&ce.content))return;const _e=ce.content.match(/\*{0,2}genre\*{0,2}[:\s]+(.+)/i);if(_e){const st=_e[1].replace(/\*+/g,"").trim(),Yt=Xs.find(Tt=>Tt.toLowerCase()===st.toLowerCase());Yt&&ie(Yt)}const Ce=ce.content.match(/\*{0,2}language\*{0,2}[:\s]+(.+)/i);if(Ce){const st=Ce[1].replace(/\*+/g,"").trim(),Yt=$s.find(Tt=>Tt.toLowerCase()===st.toLowerCase());Yt&&me(Yt)}}).catch(()=>{}),()=>{X=!0}},[e,n]);const en=G.useCallback(async()=>{if(!(!e||!t)){k(!0);try{(await n(`/api/stories/${e}/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:b})})).ok&&(M(!1),B.current=!1,f(ce=>ce&&{...ce,content:b}))}catch{}k(!1)}},[e,t,n,b]),Wn=G.useCallback(X=>{var _e;const ce=(_e=X.target.files)==null?void 0:_e[0];if(ce){if(ce.size>500*1024){ke("Image exceeds 500KB limit");return}if(!ce.type.startsWith("image/")){ke("File must be an image");return}C(ce),fe(URL.createObjectURL(ce)),ke(null)}},[]),ss=G.useCallback(async()=>{if(c!=null&&c.storylineId){xe(!0),ke(null),et(!1);try{let X;if(K){const _e=new FormData;_e.append("file",K);const Ce=await n("/api/publish/upload-cover",{method:"POST",body:_e});if(!Ce.ok){const Yt=await Ce.json();throw new Error(Yt.error||"Cover upload failed")}X=(await Ce.json()).cid}const ce=await n("/api/publish/update-storyline",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storylineId:c.storylineId,...X!==void 0&&{coverCid:X},genre:T,language:H,isNsfw:E})});if(!ce.ok){const _e=await ce.json();throw new Error(_e.error||"Update failed")}et(!0),C(null),setTimeout(()=>et(!1),3e3)}catch(X){ke(X instanceof Error?X.message:"Update failed")}finally{xe(!1)}}},[c==null?void 0:c.storylineId,K,T,H,E,n]);G.useEffect(()=>{R(!1),C(null),fe(null),ke(null),et(!1)},[e,t]),G.useEffect(()=>{if(!A||!(c!=null&&c.storylineId))return;const X="https://plotlink.xyz";let ce=!1;return fetch(`${X}/api/storyline/${c.storylineId}`).then(_e=>_e.ok?_e.json():null).then(_e=>{if(!(ce||!_e)){if(_e.genre){const Ce=Xs.find(st=>st.toLowerCase()===_e.genre.toLowerCase());Ce&&j(Ce)}if(_e.language){const Ce=$s.find(st=>st.toLowerCase()===_e.language.toLowerCase());Ce&&ae(Ce)}_e.isNsfw!==void 0&&D(!!_e.isNsfw)}}).catch(()=>{}),()=>{ce=!0}},[A,c==null?void 0:c.storylineId]),G.useEffect(()=>{if(g!=="edit")return;const X=ce=>{(ce.metaKey||ce.ctrlKey)&&ce.key==="s"&&(ce.preventDefault(),en())};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[g,en]),G.useEffect(()=>{if((c==null?void 0:c.status)!=="published-not-indexed"||!c.publishedAt)return;const X=new Date(c.publishedAt).getTime(),ce=300*1e3,_e=()=>{const st=Math.max(0,ce-(Date.now()-X));W(st)};_e();const Ce=setInterval(_e,1e3);return()=>clearInterval(Ce)},[c==null?void 0:c.status,c==null?void 0:c.publishedAt]);const Er=Q!==null&&Q<=0,pn=Q!==null&&Q>0?`${Math.floor(Q/6e4)}:${String(Math.floor(Q%6e4/1e3)).padStart(2,"0")}`:null;if(!e||!t)return S.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:S.jsxs("div",{className:"text-center",children:[S.jsx("p",{className:"text-lg font-serif",children:"Select a file to preview"}),S.jsx("p",{className:"text-sm mt-1",children:"Click a story file in the sidebar"})]})});if(p&&!c)return S.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:"Loading..."});const mn=(g==="edit"?b:(c==null?void 0:c.content)??"").length,_n=t==="genesis.md",gn=t?/^plot-\d+\.md$/.test(t):!1,Wt=(c==null?void 0:c.status)==="published"||(c==null?void 0:c.status)==="published-not-indexed",vn=_n||gn?1e4:null,te=!Wt&&vn!==null&&mn>vn;return S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"border-b border-border",children:[S.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[S.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono text-muted",children:[S.jsxs("span",{children:[e,"/",t]}),(c==null?void 0:c.status)==="published"&&S.jsx("span",{className:"text-green-700 font-medium",children:"Published"}),(c==null?void 0:c.status)==="published-not-indexed"&&S.jsx("span",{className:"text-amber-700 font-medium",title:c.indexError,children:"Published (not indexed)"}),(c==null?void 0:c.status)==="pending"&&S.jsx("span",{className:"text-amber-700 font-medium",children:"Pending"})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsxs("span",{className:`text-xs font-mono ${te?"text-error font-medium":"text-muted"}`,children:[mn.toLocaleString(),vn!==null?`/${vn.toLocaleString()}`:" chars"]}),te&&S.jsxs("span",{className:"text-error text-xs font-medium",children:[(mn-vn).toLocaleString()," over limit"]})]})]}),S.jsxs("div",{className:"flex px-3 gap-1",children:[S.jsx("button",{onClick:()=>_("preview"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${g==="preview"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:"Preview"}),S.jsxs("button",{onClick:()=>_("edit"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${g==="edit"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:["Edit",L&&S.jsx("span",{className:"ml-1 text-amber-600",children:"*"})]})]})]}),g==="preview"?S.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-6 py-4",style:{background:"var(--paper-bg)"},children:c!=null&&c.content?S.jsx("div",{className:"prose max-w-none",children:S.jsx(_3,{remarkPlugins:[T3,MD],rehypePlugins:[ID],children:c.content})}):S.jsx("p",{className:"text-muted italic",children:"No content"})}):S.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",style:{background:"var(--paper-bg)"},children:[S.jsx("textarea",{ref:V,value:b,onChange:X=>{y(X.target.value),M(!0),B.current=!0},className:"flex-1 min-h-0 w-full resize-none px-4 py-3 text-sm leading-relaxed focus:outline-none",style:{fontFamily:'"Geist Mono", ui-monospace, monospace',background:"var(--paper-bg)",color:"var(--text)"},spellCheck:!1}),S.jsxs("div",{className:"px-3 py-1.5 border-t border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs text-muted",children:L?"Unsaved changes":"No changes"}),S.jsx("button",{onClick:en,disabled:!L||x,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:x?"Saving...":"Save"})]})]}),S.jsx("div",{className:"px-3 py-2 border-t border-border flex items-center justify-between",children:t==="structure.md"?S.jsx("p",{className:"text-muted text-xs italic",children:"This is your story outline — not publishable. Ask AI to write the genesis next."}):(c==null?void 0:c.status)==="published-not-indexed"?S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[S.jsx("span",{className:"text-amber-700",children:"Published on-chain but not indexed on PlotLink"}),!Er&&S.jsx("button",{onClick:async()=>{if(!(!e||!t||!c.txHash)){I(!0);try{(await(await n("/api/publish/retry-index",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:e,fileName:t,txHash:c.txHash,content:c.content,storylineId:c.storylineId})})).json()).ok&&(await n(`/api/stories/${e}/${t}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:c.txHash,storylineId:c.storylineId,contentCid:"",gasCost:""})}),Et())}catch{}I(!1)}},disabled:Z,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:Z?"Retrying...":`Retry Index${pn?` (${pn})`:""}`}),gn&&S.jsx("button",{onClick:()=>e&&t&&(s==null?void 0:s(e,t,O,ue,U)),disabled:!!a,className:"px-3 py-1 border border-border text-xs rounded hover:bg-surface disabled:opacity-50",children:a===t?"Publishing...":"Retry Publish"}),c.txHash&&S.jsx("a",{href:`https://basescan.org/tx/${c.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"})]}),S.jsx("p",{className:"text-muted text-xs",children:Er?gn?"Index window expired. Use Retry Publish to create a new on-chain tx.":"Index window expired. Contact support or re-publish manually.":gn?"Try Retry Index first (available for 5 min after publish). If that fails, Retry Publish creates a new on-chain tx.":"Retry Index is available for 5 min after publish."}),c.indexError&&S.jsx("p",{className:"text-error text-xs",children:c.indexError})]}):(c==null?void 0:c.status)==="published"?S.jsxs("div",{className:"flex flex-col gap-2",children:[S.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[S.jsx("span",{className:"text-green-700",children:"Published"}),c.storylineId&&S.jsx("a",{href:(()=>{var _e;const X=`https://plotlink.xyz/story/${c.storylineId}`;if(!gn)return X;const ce=c.plotIndex!=null&&c.plotIndex>0?c.plotIndex:parseInt(((_e=t==null?void 0:t.match(/^plot-(\d+)\.md$/))==null?void 0:_e[1])??"1");return`${X}/${ce}`})(),target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"}),c.txHash&&S.jsx("a",{href:`https://basescan.org/tx/${c.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"}),_n&&o&&c.storylineId&&S.jsx("button",{onClick:()=>R(X=>!X),className:"px-2 py-0.5 border border-border text-xs rounded hover:bg-surface",children:A?"Close Edit":"Edit Story"})]}),A&&_n&&c.storylineId&&S.jsxs("div",{className:"border border-border rounded p-3 flex flex-col gap-3 bg-surface",children:[S.jsxs("div",{className:"flex flex-col gap-1.5",children:[S.jsx("span",{className:"text-xs font-medium text-foreground",children:"Cover Image"}),S.jsxs("div",{className:"flex items-start gap-3",children:[J&&S.jsxs("div",{className:"relative",children:[S.jsx("img",{src:J,alt:"Cover preview",className:"w-16 h-24 object-cover rounded border border-border"}),S.jsx("button",{onClick:()=>{C(null),fe(null),ct.current&&(ct.current.value="")},className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-error text-white rounded-full text-xs flex items-center justify-center",children:"x"})]}),S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsx("input",{ref:ct,type:"file",accept:"image/webp,image/jpeg,image/png",onChange:Wn,className:"text-xs"}),S.jsx("span",{className:"text-xs text-muted",children:"WebP/JPEG, max 500KB, 600x900px recommended"})]})]})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("select",{value:T,onChange:X=>j(X.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:Xs.map(X=>S.jsx("option",{value:X,children:X},X))}),S.jsx("select",{value:H,onChange:X=>ae(X.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:$s.map(X=>S.jsx("option",{value:X,children:X},X))})]}),S.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[S.jsx("input",{type:"checkbox",checked:E,onChange:X=>D(X.target.checked),className:"rounded border-border"}),"This story contains adult content (18+)"]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("button",{onClick:ss,disabled:de,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:de?"Saving...":"Save Changes"}),rt&&S.jsx("span",{className:"text-green-700 text-xs",children:"Updated!"}),Ne&&S.jsx("span",{className:"text-error text-xs",children:Ne})]})]})]}):S.jsxs("div",{className:"flex flex-col gap-2",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[_n&&S.jsxs(S.Fragment,{children:[S.jsx("select",{value:O,onChange:X=>ie(X.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:Xs.map(X=>S.jsx("option",{value:X,children:X},X))}),S.jsx("select",{value:ue,onChange:X=>me(X.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:$s.map(X=>S.jsx("option",{value:X,children:X},X))})]}),S.jsx("button",{onClick:()=>e&&t&&(s==null?void 0:s(e,t,O,ue,U)),disabled:!!a||te,className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:a===t?"Publishing...":"Publish to PlotLink"}),te&&S.jsx("span",{className:"text-error text-xs",children:"Reduce content to publish"})]}),_n&&S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[S.jsx("input",{type:"checkbox",checked:U,onChange:X=>le(X.target.checked),className:"rounded border-border"}),"This story contains adult content (18+)"]}),U&&S.jsx("span",{className:"text-xs text-amber-600",children:"Adult content will be hidden from the default browse view."})]})]})})]})}const n0="plotlink-panel-ratio",qD=.6,$y=300,Tf=224,Af=6;function WD(){try{const e=localStorage.getItem(n0);if(e){const t=parseFloat(e);if(t>0&&t<1)return t}}catch{}return qD}function Gy(e,t){if(t<=0)return e;const n=$y/t,s=1-$y/t;return n>=s?.5:Math.min(s,Math.max(n,e))}function YD({token:e,authFetch:t}){const[n,s]=G.useState(null),[a,o]=G.useState(null),[c,f]=G.useState(null),[p,h]=G.useState(""),[g,_]=G.useState(null),[b,y]=G.useState(WD),[x,k]=G.useState([]),L=G.useRef(new Set),M=G.useRef(null),Z=G.useRef(null),I=G.useRef(!1);G.useEffect(()=>{t("/api/wallet").then(A=>A.ok?A.json():null).then(A=>{A!=null&&A.address&&_(A.address)}).catch(()=>{})},[t]),G.useEffect(()=>{try{localStorage.setItem(n0,String(b))}catch{}},[b]),G.useEffect(()=>{const A=()=>{if(!Z.current)return;const R=Z.current.getBoundingClientRect().width-Tf-Af;y(T=>Gy(T,R))};return window.addEventListener("resize",A),A(),()=>window.removeEventListener("resize",A)},[]);const Q=G.useCallback(()=>{const A=`_new_${Date.now()}`;k(R=>[...R,A]),s(A),o(null)},[]);G.useEffect(()=>{if(x.length===0)return;const A=setInterval(async()=>{try{const R=await t("/api/stories");if(!R.ok)return;const T=await R.json(),j=new Set(T.stories.filter(H=>H.name!=="_example").map(H=>H.name));for(const H of j)if(!L.current.has(H)&&x.length>0){const ae=x[0];let E=!1;M.current&&(E=await M.current(ae,H).catch(()=>!1)),E&&k(D=>D.slice(1)),s(H),o(null)}L.current=j}catch{}},3e3);return()=>clearInterval(A)},[t,x]),G.useEffect(()=>{t("/api/stories").then(A=>{if(A.ok)return A.json()}).then(A=>{A!=null&&A.stories&&(L.current=new Set(A.stories.filter(R=>R.name!=="_example").map(R=>R.name)))}).catch(()=>{})},[t]);const W=G.useCallback((A,R)=>{s(A),o(R)},[]),O=G.useRef(null),ie=G.useCallback(async A=>{var R,T,j,H;O.current=A,s(A),o(null);try{const ae=await t(`/api/stories/${A}`);if(ae.ok&&O.current===A){const D=(await ae.json()).files||[],C=((R=D.map(J=>{var fe;return{file:J.file,num:(fe=J.file.match(/^plot-(\d+)\.md$/))==null?void 0:fe[1]}}).filter(J=>J.num!=null).sort((J,fe)=>parseInt(fe.num)-parseInt(J.num))[0])==null?void 0:R.file)??((T=D.find(J=>J.file==="genesis.md"))==null?void 0:T.file)??((j=D.find(J=>J.file==="structure.md"))==null?void 0:j.file)??((H=D[0])==null?void 0:H.file);C&&O.current===A&&o(C)}}catch{}},[t]),ue=G.useCallback(A=>{A.preventDefault(),I.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";const R=j=>{if(!I.current||!Z.current)return;const H=Z.current.getBoundingClientRect(),ae=H.width-Tf-Af,E=j.clientX-H.left-Tf;y(Gy(E/ae,ae))},T=()=>{I.current=!1,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",R),window.removeEventListener("mouseup",T)};window.addEventListener("mousemove",R),window.addEventListener("mouseup",T)},[]),me=G.useCallback(async(A,R,T,j,H)=>{var ae;f(R),h("Reading file...");try{const E=await t(`/api/stories/${A}/${R}`);if(!E.ok)throw new Error("Failed to read file");const D=await E.json(),K=D.content.match(/^#\s+(.+)$/m),C=K?K[1].slice(0,60):R.replace(".md","");let J;if(R.match(/^plot-\d+\.md$/)){try{const Ne=await t(`/api/stories/${A}`);if(Ne.ok){const rt=(await Ne.json()).files.find(et=>et.file==="genesis.md"&&et.storylineId);J=rt==null?void 0:rt.storylineId}}catch{}if(!J){h("Error: Publish genesis first to create the storyline"),setTimeout(()=>{f(null),h("")},3e3);return}}h("Publishing...");const fe=await t("/api/publish/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:A,fileName:R,title:C,content:D.content,genre:T,language:j,isNsfw:H,storylineId:J})});if(!fe.ok){const Ne=await fe.json();throw new Error(Ne.error||"Publish failed")}const de=(ae=fe.body)==null?void 0:ae.getReader(),xe=new TextDecoder;if(de)for(;;){const{done:Ne,value:ke}=await de.read();if(Ne)break;const et=xe.decode(ke).split(` +`).filter(ct=>ct.startsWith("data: "));for(const ct of et)try{const we=JSON.parse(ct.slice(6));we.step&&h(we.message||we.step),we.step==="done"&&we.txHash&&await t(`/api/stories/${A}/${R}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:we.txHash,storylineId:we.storylineId,plotIndex:we.plotIndex,contentCid:we.contentCid,gasCost:we.gasCost,indexError:we.indexError})})}catch{}}h("Published!")}catch(E){const D=E instanceof Error?E.message:"Publish failed";h(`Error: ${D}`)}finally{setTimeout(()=>{f(null),h("")},3e3)}},[t]),U=G.useCallback(A=>{A.startsWith("_new_")&&k(R=>R.filter(T=>T!==A))},[]),[le,V]=G.useState(new Set);G.useEffect(()=>{t("/api/stories").then(R=>R.ok?R.json():null).then(R=>{R!=null&&R.stories&&V(new Set(R.stories.filter(T=>T.hasStructure).map(T=>T.name)))}).catch(()=>{});const A=setInterval(async()=>{try{const R=await t("/api/stories");if(R.ok){const T=await R.json();V(new Set(T.stories.filter(j=>j.hasStructure).map(j=>j.name)))}}catch{}},5e3);return()=>clearInterval(A)},[t]);const B=G.useCallback(A=>{n===A&&(s(null),o(null))},[n]);return S.jsxs("div",{ref:Z,className:"h-[calc(100vh-3.5rem)] flex",children:[S.jsx("div",{className:"w-56 border-r border-border flex-shrink-0",children:S.jsx(jx,{authFetch:t,selectedStory:n,selectedFile:a,onSelectFile:W,onNewStory:Q,untitledSessions:x})}),S.jsx("div",{className:"min-w-0 border-r border-border",style:{flex:`${b} 0 0`},children:S.jsx(lk,{token:e,storyName:n,authFetch:t,onSelectStory:ie,onDestroySession:U,onArchiveStory:B,confirmedStories:le,renameRef:M})}),S.jsx("div",{onMouseDown:ue,className:"flex-shrink-0 flex items-center justify-center hover:bg-border/50 transition-colors",style:{width:Af,cursor:"col-resize",background:"var(--border)"},children:S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}})]})}),S.jsxs("div",{className:"min-w-0 flex flex-col",style:{flex:`${1-b} 0 0`},children:[S.jsx(FD,{storyName:n,fileName:a,authFetch:t,onPublish:me,publishingFile:c,walletAddress:g}),p&&S.jsx("div",{className:"px-3 py-1.5 bg-surface border-t border-border text-xs text-muted",children:p})]})]})}function VD({token:e,onComplete:t}){const[n,s]=G.useState(!1),[a,o]=G.useState(null),[c,f]=G.useState(!1),p=async()=>{s(!0),o(null);try{const h=await fetch("/api/wallet/create",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),g=await h.json();if(!h.ok)throw new Error(g.error||"Wallet creation failed");f(!0)}catch(h){o(h instanceof Error?h.message:"Wallet creation failed")}s(!1)};return G.useEffect(()=>{p()},[]),S.jsxs("div",{className:"mx-auto max-w-sm p-6 text-center",children:[S.jsx("h2",{className:"text-accent mb-1 text-lg font-bold",children:"Wallet Setup"}),S.jsx("p",{className:"text-muted mb-6 text-xs",children:"creating your OWS wallet for on-chain publishing"}),n&&S.jsx("p",{className:"text-accent text-sm",children:"creating wallet..."}),a&&S.jsxs("div",{className:"space-y-4",children:[S.jsx("div",{className:"rounded border border-red-700/30 p-3 text-xs text-red-700",children:a}),S.jsx("button",{onClick:p,className:"border-accent text-accent hover:bg-accent/10 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:"retry"})]}),c&&S.jsxs("div",{className:"space-y-4",children:[S.jsx("div",{className:"text-accent text-2xl",children:"✓"}),S.jsx("p",{className:"text-foreground text-sm font-medium",children:"wallet created"}),S.jsx("button",{onClick:t,className:"border-accent text-accent hover:bg-accent/10 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:"continue"})]})]})}function KD({token:e,onLogout:t}){const[n,s]=G.useState("home"),[a,o]=G.useState(0),c=G.useCallback(async(f,p)=>fetch(f,{...p,headers:{...(p==null?void 0:p.headers)||{},Authorization:`Bearer ${e}`}}),[e]);return G.useEffect(()=>{async function f(){try{if(!(await(await c("/api/wallet")).json()).exists){s("wallet-setup");return}const g=await c("/api/stories");if(g.ok){const _=await g.json();o(_.stories.filter(b=>b.name!=="_example").length)}}catch{}}f()},[e]),S.jsxs("div",{className:"flex h-screen flex-col",children:[S.jsxs("header",{className:"border-border flex h-14 items-center justify-between border-b px-4 flex-shrink-0",children:[S.jsxs("div",{className:"flex items-center gap-3",children:[S.jsx("button",{onClick:()=>{n!=="wallet-setup"&&s("home")},className:"flex items-center gap-2 hover:opacity-80",children:S.jsx("span",{className:"text-accent text-sm font-bold tracking-tight",children:"PlotLink OWS"})}),S.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"writer"})]}),n!=="wallet-setup"&&S.jsxs("nav",{className:"flex items-center gap-4",children:[S.jsx("button",{onClick:()=>s("stories"),className:`text-xs transition-colors ${n==="stories"?"text-accent":"text-muted hover:text-foreground"}`,children:"stories"}),S.jsx("button",{onClick:()=>s("dashboard"),className:`text-xs transition-colors ${n==="dashboard"?"text-accent":"text-muted hover:text-foreground"}`,children:"dashboard"}),S.jsx("button",{onClick:()=>s("settings"),className:`text-xs transition-colors ${n==="settings"?"text-accent":"text-muted hover:text-foreground"}`,children:"settings"}),S.jsx("button",{onClick:t,className:"text-muted hover:text-foreground text-xs transition-colors",children:"logout"})]})]}),S.jsxs("main",{className:"flex-1 min-h-0",children:[n==="home"&&S.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-8",children:[S.jsxs("div",{className:"text-center space-y-2",children:[S.jsx("h1",{className:"text-2xl font-serif text-foreground",children:"Write. Publish. Earn."}),S.jsx("p",{className:"text-muted text-sm",children:"Claude CLI writes stories. You publish them on-chain."})]}),S.jsxs("div",{className:"text-center space-y-3",children:[S.jsx("button",{onClick:()=>s("stories"),className:"bg-accent text-white hover:bg-accent-dim px-6 py-2.5 rounded text-sm font-medium transition-colors",children:"Start Writing"}),a>0&&S.jsxs("p",{className:"text-muted text-xs",children:[a," ",a===1?"story":"stories"," in progress"]})]}),S.jsxs("div",{className:"rounded border border-border p-4 space-y-2 text-xs text-muted",children:[S.jsx("p",{className:"font-medium text-foreground text-sm",children:"How it works"}),S.jsxs("ol",{className:"space-y-1.5 list-decimal list-inside",children:[S.jsxs("li",{children:["Open the ",S.jsx("strong",{children:"Stories"})," tab — Claude CLI launches in the terminal"]}),S.jsx("li",{children:"Tell Claude your story idea — it brainstorms, outlines, and writes"}),S.jsx("li",{children:"Review the live preview as Claude creates files"}),S.jsxs("li",{children:["Click ",S.jsx("strong",{children:"Publish"})," to put your story on-chain"]}),S.jsxs("li",{children:["Earn 5% royalties on every trade at ",S.jsx("a",{href:"https://plotlink.xyz",target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"plotlink.xyz"})]})]})]}),S.jsx("div",{className:"text-center",children:S.jsx("a",{href:"https://github.com/realproject7/plotlink-ows#-wallet-setup",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted hover:text-accent underline transition-colors",children:"Wallet Setup Guide"})}),S.jsx(eb,{token:e})]}),n==="stories"&&S.jsx(YD,{token:e,authFetch:c}),n==="dashboard"&&S.jsx(Lx,{token:e}),n==="wallet-setup"&&S.jsx(VD,{token:e,onComplete:()=>s("home")}),n==="settings"&&S.jsx(Bx,{token:e,onLogout:t})]})]})}function XD(){const[e,t]=G.useState(()=>localStorage.getItem("ows-token")),[n,s]=G.useState(null),[a,o]=G.useState(!0);G.useEffect(()=>{fetch("/api/auth/status").then(h=>h.json()).then(h=>s(h.configured)).catch(()=>s(null))},[]),G.useEffect(()=>{if(!e){o(!1);return}fetch("/api/auth/verify",{headers:{Authorization:`Bearer ${e}`}}).then(h=>{h.ok||(localStorage.removeItem("ows-token"),t(null))}).catch(()=>{localStorage.removeItem("ows-token"),t(null)}).finally(()=>o(!1))},[e]);const c=async h=>{try{const g=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:h})}),_=await g.json();return g.ok?(localStorage.setItem("ows-token",_.token),t(_.token),null):_.error||"Login failed"}catch{return"Cannot connect to server"}},f=async h=>{try{const g=await fetch("/api/auth/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:h})}),_=await g.json();return g.ok?(localStorage.setItem("ows-token",_.token),t(_.token),s(!0),null):_.error||"Setup failed"}catch{return"Cannot connect to server"}},p=()=>{localStorage.removeItem("ows-token"),t(null)};return a||n===null?S.jsx("div",{className:"flex h-screen items-center justify-center",children:S.jsx("span",{className:"text-muted text-sm",children:"connecting..."})}):n?e?S.jsx(KD,{token:e,onLogout:p}):S.jsx(Rx,{onLogin:c}):S.jsx(Mx,{onSetup:f})}Dx.createRoot(document.getElementById("root")).render(S.jsx(Sx.StrictMode,{children:S.jsx(XD,{})})); diff --git a/app/web/dist/index.html b/app/web/dist/index.html index 4bb3642..e34701c 100644 --- a/app/web/dist/index.html +++ b/app/web/dist/index.html @@ -7,7 +7,7 @@ - + From efcf5f92ef5194129441438590cc9e6cf02d701d Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Sat, 9 May 2026 13:50:39 +0900 Subject: [PATCH 3/5] [#177] Gate edit panel on confirmed authorship Store authorAddress in publish status when publishing. Edit button now only shows when the current wallet matches the stored author address (case-insensitive), with backwards compat for pre-existing published stories that lack the field. Co-Authored-By: Claude Opus 4.6 (1M context) --- app/routes/stories.ts | 3 +++ app/web/components/PreviewPanel.tsx | 3 ++- app/web/components/StoriesPage.tsx | 1 + app/web/dist/assets/{index-xXd0uHn_.js => index-jC7525tk.js} | 4 ++-- app/web/dist/index.html | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) rename app/web/dist/assets/{index-xXd0uHn_.js => index-jC7525tk.js} (97%) diff --git a/app/routes/stories.ts b/app/routes/stories.ts index f51d82a..e77384c 100644 --- a/app/routes/stories.ts +++ b/app/routes/stories.ts @@ -23,6 +23,7 @@ interface FileStatus { publishedAt?: string; gasCost?: string; indexError?: string; + authorAddress?: string; } interface StoryInfo { @@ -243,6 +244,7 @@ stories.post("/:name/:file/publish-status", async (c) => { contentCid: string; gasCost?: string; indexError?: string; + authorAddress?: string; }>(); const status = readPublishStatus(storyDir); @@ -255,6 +257,7 @@ stories.post("/:name/:file/publish-status", async (c) => { plotIndex: body.plotIndex ?? existing?.plotIndex, contentCid: body.contentCid || existing?.contentCid, gasCost: body.gasCost || existing?.gasCost, + authorAddress: body.authorAddress || existing?.authorAddress, publishedAt: new Date().toISOString(), ...(body.indexError ? { indexError: body.indexError } : {}), }; diff --git a/app/web/components/PreviewPanel.tsx b/app/web/components/PreviewPanel.tsx index af28834..543765f 100644 --- a/app/web/components/PreviewPanel.tsx +++ b/app/web/components/PreviewPanel.tsx @@ -23,6 +23,7 @@ interface FileData { plotIndex?: number; indexError?: string; publishedAt?: string; + authorAddress?: string; } type Tab = "preview" | "edit"; @@ -510,7 +511,7 @@ export function PreviewPanel({ storyName, fileName, authFetch, onPublish, publis BaseScan )} - {isGenesis && walletAddress && fileData.storylineId && ( + {isGenesis && walletAddress && fileData.storylineId && (!fileData.authorAddress || fileData.authorAddress.toLowerCase() === walletAddress.toLowerCase()) && ( {editSuccess && Updated!} {editError && {editError}} diff --git a/app/web/dist/assets/index-jC7525tk.js b/app/web/dist/assets/index-9T4gFznD.js similarity index 60% rename from app/web/dist/assets/index-jC7525tk.js rename to app/web/dist/assets/index-9T4gFznD.js index a5dd9a3..34f1729 100644 --- a/app/web/dist/assets/index-jC7525tk.js +++ b/app/web/dist/assets/index-9T4gFznD.js @@ -1,4 +1,4 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();function xu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Wh={exports:{}},Gl={};/** +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();function xu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Wh={exports:{}},$l={};/** * @license React * react-jsx-runtime.production.js * @@ -6,7 +6,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var $g;function vx(){if($g)return Gl;$g=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,a,o){var c=null;if(o!==void 0&&(c=""+o),a.key!==void 0&&(c=""+a.key),"key"in a){o={};for(var f in a)f!=="key"&&(o[f]=a[f])}else o=a;return a=o.ref,{$$typeof:e,type:s,key:c,ref:a!==void 0?a:null,props:o}}return Gl.Fragment=t,Gl.jsx=n,Gl.jsxs=n,Gl}var Gg;function yx(){return Gg||(Gg=1,Wh.exports=vx()),Wh.exports}var S=yx(),Yh={exports:{}},Te={};/** + */var $g;function vx(){if($g)return $l;$g=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,a,o){var c=null;if(o!==void 0&&(c=""+o),a.key!==void 0&&(c=""+a.key),"key"in a){o={};for(var f in a)f!=="key"&&(o[f]=a[f])}else o=a;return a=o.ref,{$$typeof:e,type:s,key:c,ref:a!==void 0?a:null,props:o}}return $l.Fragment=t,$l.jsx=n,$l.jsxs=n,$l}var Gg;function yx(){return Gg||(Gg=1,Wh.exports=vx()),Wh.exports}var S=yx(),Yh={exports:{}},Ae={};/** * @license React * react.production.js * @@ -14,7 +14,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Zg;function bx(){if(Zg)return Te;Zg=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),b=Symbol.iterator;function y(D){return D===null||typeof D!="object"?null:(D=b&&D[b]||D["@@iterator"],typeof D=="function"?D:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,L={};function M(D,K,C){this.props=D,this.context=K,this.refs=L,this.updater=C||x}M.prototype.isReactComponent={},M.prototype.setState=function(D,K){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,K,"setState")},M.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function Z(){}Z.prototype=M.prototype;function I(D,K,C){this.props=D,this.context=K,this.refs=L,this.updater=C||x}var Q=I.prototype=new Z;Q.constructor=I,k(Q,M.prototype),Q.isPureReactComponent=!0;var W=Array.isArray;function O(){}var ie={H:null,A:null,T:null,S:null},ue=Object.prototype.hasOwnProperty;function me(D,K,C){var J=C.ref;return{$$typeof:e,type:D,key:K,ref:J!==void 0?J:null,props:C}}function U(D,K){return me(D.type,K,D.props)}function le(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function V(D){var K={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(C){return K[C]})}var B=/\/+/g;function A(D,K){return typeof D=="object"&&D!==null&&D.key!=null?V(""+D.key):K.toString(36)}function R(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(O,O):(D.status="pending",D.then(function(K){D.status==="pending"&&(D.status="fulfilled",D.value=K)},function(K){D.status==="pending"&&(D.status="rejected",D.reason=K)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function T(D,K,C,J,fe){var de=typeof D;(de==="undefined"||de==="boolean")&&(D=null);var xe=!1;if(D===null)xe=!0;else switch(de){case"bigint":case"string":case"number":xe=!0;break;case"object":switch(D.$$typeof){case e:case t:xe=!0;break;case g:return xe=D._init,T(xe(D._payload),K,C,J,fe)}}if(xe)return fe=fe(D),xe=J===""?"."+A(D,0):J,W(fe)?(C="",xe!=null&&(C=xe.replace(B,"$&/")+"/"),T(fe,K,C,"",function(rt){return rt})):fe!=null&&(le(fe)&&(fe=U(fe,C+(fe.key==null||D&&D.key===fe.key?"":(""+fe.key).replace(B,"$&/")+"/")+xe)),K.push(fe)),1;xe=0;var Ne=J===""?".":J+":";if(W(D))for(var ke=0;ke>>1,E=T[ae];if(0>>1;aea(C,H))Ja(fe,C)?(T[ae]=fe,T[J]=H,ae=J):(T[ae]=C,T[K]=H,ae=K);else if(Ja(fe,H))T[ae]=fe,T[J]=H,ae=J;else break e}}return j}function a(T,j){var H=T.sortIndex-j.sortIndex;return H!==0?H:T.id-j.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,f=c.now();e.unstable_now=function(){return c.now()-f}}var p=[],h=[],g=1,_=null,b=3,y=!1,x=!1,k=!1,L=!1,M=typeof setTimeout=="function"?setTimeout:null,Z=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;function Q(T){for(var j=n(h);j!==null;){if(j.callback===null)s(h);else if(j.startTime<=T)s(h),j.sortIndex=j.expirationTime,t(p,j);else break;j=n(h)}}function W(T){if(k=!1,Q(T),!x)if(n(p)!==null)x=!0,O||(O=!0,V());else{var j=n(h);j!==null&&R(W,j.startTime-T)}}var O=!1,ie=-1,ue=5,me=-1;function U(){return L?!0:!(e.unstable_now()-meT&&U());){var ae=_.callback;if(typeof ae=="function"){_.callback=null,b=_.priorityLevel;var E=ae(_.expirationTime<=T);if(T=e.unstable_now(),typeof E=="function"){_.callback=E,Q(T),j=!0;break t}_===n(p)&&s(p),Q(T)}else s(p);_=n(p)}if(_!==null)j=!0;else{var D=n(h);D!==null&&R(W,D.startTime-T),j=!1}}break e}finally{_=null,b=H,y=!1}j=void 0}}finally{j?V():O=!1}}}var V;if(typeof I=="function")V=function(){I(le)};else if(typeof MessageChannel<"u"){var B=new MessageChannel,A=B.port2;B.port1.onmessage=le,V=function(){A.postMessage(null)}}else V=function(){M(le,0)};function R(T,j){ie=M(function(){T(e.unstable_now())},j)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(T){T.callback=null},e.unstable_forceFrameRate=function(T){0>T||125ae?(T.sortIndex=H,t(h,T),n(p)===null&&T===n(h)&&(k?(Z(ie),ie=-1):k=!0,R(W,H-ae))):(T.sortIndex=E,t(p,T),x||y||(x=!0,O||(O=!0,V()))),T},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(T){var j=b;return function(){var H=b;b=j;try{return T.apply(this,arguments)}finally{b=H}}}})(Xh)),Xh}var ev;function wx(){return ev||(ev=1,Kh.exports=xx()),Kh.exports}var $h={exports:{}},ei={};/** + */var Jg;function xx(){return Jg||(Jg=1,(function(e){function t(T,j){var H=T.length;T.push(j);e:for(;0>>1,E=T[ae];if(0>>1;aea(C,H))Qa(fe,C)?(T[ae]=fe,T[Q]=H,ae=Q):(T[ae]=C,T[K]=H,ae=K);else if(Qa(fe,H))T[ae]=fe,T[Q]=H,ae=Q;else break e}}return j}function a(T,j){var H=T.sortIndex-j.sortIndex;return H!==0?H:T.id-j.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,f=c.now();e.unstable_now=function(){return c.now()-f}}var p=[],h=[],g=1,_=null,b=3,y=!1,x=!1,k=!1,L=!1,M=typeof setTimeout=="function"?setTimeout:null,G=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;function Z(T){for(var j=n(h);j!==null;){if(j.callback===null)s(h);else if(j.startTime<=T)s(h),j.sortIndex=j.expirationTime,t(p,j);else break;j=n(h)}}function W(T){if(k=!1,Z(T),!x)if(n(p)!==null)x=!0,O||(O=!0,V());else{var j=n(h);j!==null&&R(W,j.startTime-T)}}var O=!1,te=-1,ue=5,_e=-1;function U(){return L?!0:!(e.unstable_now()-_eT&&U());){var ae=_.callback;if(typeof ae=="function"){_.callback=null,b=_.priorityLevel;var E=ae(_.expirationTime<=T);if(T=e.unstable_now(),typeof E=="function"){_.callback=E,Z(T),j=!0;break t}_===n(p)&&s(p),Z(T)}else s(p);_=n(p)}if(_!==null)j=!0;else{var D=n(h);D!==null&&R(W,D.startTime-T),j=!1}}break e}finally{_=null,b=H,y=!1}j=void 0}}finally{j?V():O=!1}}}var V;if(typeof I=="function")V=function(){I(se)};else if(typeof MessageChannel<"u"){var B=new MessageChannel,A=B.port2;B.port1.onmessage=se,V=function(){A.postMessage(null)}}else V=function(){M(se,0)};function R(T,j){te=M(function(){T(e.unstable_now())},j)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(T){T.callback=null},e.unstable_forceFrameRate=function(T){0>T||125ae?(T.sortIndex=H,t(h,T),n(p)===null&&T===n(h)&&(k?(G(te),te=-1):k=!0,R(W,H-ae))):(T.sortIndex=E,t(p,T),x||y||(x=!0,O||(O=!0,V()))),T},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(T){var j=b;return function(){var H=b;b=j;try{return T.apply(this,arguments)}finally{b=H}}}})(Xh)),Xh}var ev;function wx(){return ev||(ev=1,Kh.exports=xx()),Kh.exports}var $h={exports:{}},ti={};/** * @license React * react-dom.production.js * @@ -30,7 +30,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var tv;function Cx(){if(tv)return ei;tv=1;var e=wd();function t(p){var h="https://react.dev/errors/"+p;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),$h.exports=Cx(),$h.exports}/** + */var tv;function Cx(){if(tv)return ti;tv=1;var e=wd();function t(p){var h="https://react.dev/errors/"+p;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),$h.exports=Cx(),$h.exports}/** * @license React * react-dom-client.production.js * @@ -38,15 +38,15 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var nv;function Ex(){if(nv)return Zl;nv=1;var e=wx(),t=wd(),n=kx();function s(i){var r="https://react.dev/errors/"+i;if(1E||(i.current=ae[E],ae[E]=null,E--)}function C(i,r){E++,ae[E]=i.current,i.current=r}var J=D(null),fe=D(null),de=D(null),xe=D(null);function Ne(i,r){switch(C(de,r),C(fe,i),C(J,null),r.nodeType){case 9:case 11:i=(i=r.documentElement)&&(i=i.namespaceURI)?vg(i):0;break;default:if(i=r.tagName,r=r.namespaceURI)r=vg(r),i=yg(r,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}K(J),C(J,i)}function ke(){K(J),K(fe),K(de)}function rt(i){i.memoizedState!==null&&C(xe,i);var r=J.current,l=yg(r,i.type);r!==l&&(C(fe,i),C(J,l))}function et(i){fe.current===i&&(K(J),K(fe)),xe.current===i&&(K(xe),Vl._currentValue=H)}var ct,we;function Et(i){if(ct===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);ct=r&&r[1]||"",we=-1E||(i.current=ae[E],ae[E]=null,E--)}function C(i,r){E++,ae[E]=i.current,i.current=r}var Q=D(null),fe=D(null),de=D(null),Ce=D(null);function Le(i,r){switch(C(de,r),C(fe,i),C(Q,null),r.nodeType){case 9:case 11:i=(i=r.documentElement)&&(i=i.namespaceURI)?vg(i):0;break;default:if(i=r.tagName,r=r.namespaceURI)r=vg(r),i=yg(r,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}K(Q),C(Q,i)}function Ee(){K(Q),K(fe),K(de)}function st(i){i.memoizedState!==null&&C(Ce,i);var r=Q.current,l=yg(r,i.type);r!==l&&(C(fe,i),C(Q,l))}function Ye(i){fe.current===i&&(K(Q),K(fe)),Ce.current===i&&(K(Ce),Yl._currentValue=H)}var xt,xe;function Vt(i){if(xt===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);xt=r&&r[1]||"",xe=-1)":-1d||N[u]!==q[d]){var ee=` -`+N[u].replace(" at new "," at ");return i.displayName&&ee.includes("")&&(ee=ee.replace("",i.displayName)),ee}while(1<=u&&0<=d);break}}}finally{en=!1,Error.prepareStackTrace=l}return(l=i?i.displayName||i.name:"")?Et(l):""}function ss(i,r){switch(i.tag){case 26:case 27:case 5:return Et(i.type);case 16:return Et("Lazy");case 13:return i.child!==r&&r!==null?Et("Suspense Fallback"):Et("Suspense");case 19:return Et("SuspenseList");case 0:case 15:return Wn(i.type,!1);case 11:return Wn(i.type.render,!1);case 1:return Wn(i.type,!0);case 31:return Et("Activity");default:return""}}function Er(i){try{var r="",l=null;do r+=ss(i,l),l=i,i=i.return;while(i);return r}catch(u){return` +`);for(d=u=0;ud||N[u]!==q[d]){var J=` +`+N[u].replace(" at new "," at ");return i.displayName&&J.includes("")&&(J=J.replace("",i.displayName)),J}while(1<=u&&0<=d);break}}}finally{pn=!1,Error.prepareStackTrace=l}return(l=i?i.displayName||i.name:"")?Vt(l):""}function Fn(i,r){switch(i.tag){case 26:case 27:case 5:return Vt(i.type);case 16:return Vt("Lazy");case 13:return i.child!==r&&r!==null?Vt("Suspense Fallback"):Vt("Suspense");case 19:return Vt("SuspenseList");case 0:case 15:return Ni(i.type,!1);case 11:return Ni(i.type.render,!1);case 1:return Ni(i.type,!0);case 31:return Vt("Activity");default:return""}}function rs(i){try{var r="",l=null;do r+=Fn(i,l),l=i,i=i.return;while(i);return r}catch(u){return` Error generating stack: `+u.message+` -`+u.stack}}var pn=Object.prototype.hasOwnProperty,Tr=e.unstable_scheduleCallback,mn=e.unstable_cancelCallback,_n=e.unstable_shouldYield,gn=e.unstable_requestPaint,Wt=e.unstable_now,vn=e.unstable_getCurrentPriorityLevel,te=e.unstable_ImmediatePriority,X=e.unstable_UserBlockingPriority,ce=e.unstable_NormalPriority,_e=e.unstable_LowPriority,Ce=e.unstable_IdlePriority,st=e.log,Yt=e.unstable_setDisableYieldValue,Tt=null,At=null;function hi(i){if(typeof st=="function"&&Yt(i),At&&typeof At.setStrictMode=="function")try{At.setStrictMode(Tt,i)}catch{}}var Ge=Math.clz32?Math.clz32:r0,Yn=Math.log,Xi=Math.LN2;function r0(i){return i>>>=0,i===0?32:31-(Yn(i)/Xi|0)|0}var Ba=256,Na=262144,La=4194304;function Ar(i){var r=i&42;if(r!==0)return r;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function za(i,r,l){var u=i.pendingLanes;if(u===0)return 0;var d=0,m=i.suspendedLanes,v=i.pingedLanes;i=i.warmLanes;var w=u&134217727;return w!==0?(u=w&~m,u!==0?d=Ar(u):(v&=w,v!==0?d=Ar(v):l||(l=w&~i,l!==0&&(d=Ar(l))))):(w=u&~m,w!==0?d=Ar(w):v!==0?d=Ar(v):l||(l=u&~i,l!==0&&(d=Ar(l)))),d===0?0:r!==0&&r!==d&&(r&m)===0&&(m=d&-d,l=r&-r,m>=l||m===32&&(l&4194048)!==0)?r:d}function sl(i,r){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&r)===0}function s0(i,r){switch(i){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Jd(){var i=La;return La<<=1,(La&62914560)===0&&(La=4194304),i}function Bu(i){for(var r=[],l=0;31>l;l++)r.push(i);return r}function ll(i,r){i.pendingLanes|=r,r!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function l0(i,r,l,u,d,m){var v=i.pendingLanes;i.pendingLanes=l,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=l,i.entangledLanes&=l,i.errorRecoveryDisabledLanes&=l,i.shellSuspendCounter=0;var w=i.entanglements,N=i.expirationTimes,q=i.hiddenUpdates;for(l=v&~l;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var f0=/[\n"\\]/g;function Li(i){return i.replace(f0,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Hu(i,r,l,u,d,m,v,w){i.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?i.type=v:i.removeAttribute("type"),r!=null?v==="number"?(r===0&&i.value===""||i.value!=r)&&(i.value=""+Ni(r)):i.value!==""+Ni(r)&&(i.value=""+Ni(r)):v!=="submit"&&v!=="reset"||i.removeAttribute("value"),r!=null?Pu(i,v,Ni(r)):l!=null?Pu(i,v,Ni(l)):u!=null&&i.removeAttribute("value"),d==null&&m!=null&&(i.defaultChecked=!!m),d!=null&&(i.checked=d&&typeof d!="function"&&typeof d!="symbol"),w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?i.name=""+Ni(w):i.removeAttribute("name")}function fp(i,r,l,u,d,m,v,w){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(i.type=m),r!=null||l!=null){if(!(m!=="submit"&&m!=="reset"||r!=null)){ju(i);return}l=l!=null?""+Ni(l):"",r=r!=null?""+Ni(r):l,w||r===i.value||(i.value=r),i.defaultValue=r}u=u??d,u=typeof u!="function"&&typeof u!="symbol"&&!!u,i.checked=w?i.checked:!!u,i.defaultChecked=!!u,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(i.name=v),ju(i)}function Pu(i,r,l){r==="number"&&Ha(i.ownerDocument)===i||i.defaultValue===""+l||(i.defaultValue=""+l)}function hs(i,r,l,u){if(i=i.options,r){r={};for(var d=0;d"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Wu=!1;if(Sn)try{var cl={};Object.defineProperty(cl,"passive",{get:function(){Wu=!0}}),window.addEventListener("test",cl,cl),window.removeEventListener("test",cl,cl)}catch{Wu=!1}var Kn=null,Yu=null,Ua=null;function yp(){if(Ua)return Ua;var i,r=Yu,l=r.length,u,d="value"in Kn?Kn.value:Kn.textContent,m=d.length;for(i=0;i=dl),kp=" ",Ep=!1;function Tp(i,r){switch(i){case"keyup":return U0.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ap(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var ms=!1;function F0(i,r){switch(i){case"compositionend":return Ap(r);case"keypress":return r.which!==32?null:(Ep=!0,kp);case"textInput":return i=r.data,i===kp&&Ep?null:i;default:return null}}function q0(i,r){if(ms)return i==="compositionend"||!Gu&&Tp(i,r)?(i=yp(),Ua=Yu=Kn=null,ms=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1=r)return{node:l,offset:r-i};i=u}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Op(l)}}function Hp(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?Hp(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function Pp(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var r=Ha(i.document);r instanceof i.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)i=r.contentWindow;else break;r=Ha(i.document)}return r}function Ju(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}var Z0=Sn&&"documentMode"in document&&11>=document.documentMode,_s=null,ec=null,gl=null,tc=!1;function Up(i,r,l){var u=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;tc||_s==null||_s!==Ha(u)||(u=_s,"selectionStart"in u&&Ju(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),gl&&_l(gl,u)||(gl=u,u=Lo(ec,"onSelect"),0>=v,d-=v,tn=1<<32-Ge(r)+d|l<De?(He=ve,ve=null):He=ve.sibling;var Fe=Y(P,ve,F[De],ne);if(Fe===null){ve===null&&(ve=He);break}i&&ve&&Fe.alternate===null&&r(P,ve),z=m(Fe,z,De),Ie===null?ye=Fe:Ie.sibling=Fe,Ie=Fe,ve=He}if(De===F.length)return l(P,ve),Pe&&wn(P,De),ye;if(ve===null){for(;DeDe?(He=ve,ve=null):He=ve.sibling;var mr=Y(P,ve,Fe.value,ne);if(mr===null){ve===null&&(ve=He);break}i&&ve&&mr.alternate===null&&r(P,ve),z=m(mr,z,De),Ie===null?ye=mr:Ie.sibling=mr,Ie=mr,ve=He}if(Fe.done)return l(P,ve),Pe&&wn(P,De),ye;if(ve===null){for(;!Fe.done;De++,Fe=F.next())Fe=re(P,Fe.value,ne),Fe!==null&&(z=m(Fe,z,De),Ie===null?ye=Fe:Ie.sibling=Fe,Ie=Fe);return Pe&&wn(P,De),ye}for(ve=u(ve);!Fe.done;De++,Fe=F.next())Fe=$(ve,P,De,Fe.value,ne),Fe!==null&&(i&&Fe.alternate!==null&&ve.delete(Fe.key===null?De:Fe.key),z=m(Fe,z,De),Ie===null?ye=Fe:Ie.sibling=Fe,Ie=Fe);return i&&ve.forEach(function(gx){return r(P,gx)}),Pe&&wn(P,De),ye}function Xe(P,z,F,ne){if(typeof F=="object"&&F!==null&&F.type===k&&F.key===null&&(F=F.props.children),typeof F=="object"&&F!==null){switch(F.$$typeof){case y:e:{for(var ye=F.key;z!==null;){if(z.key===ye){if(ye=F.type,ye===k){if(z.tag===7){l(P,z.sibling),ne=d(z,F.props.children),ne.return=P,P=ne;break e}}else if(z.elementType===ye||typeof ye=="object"&&ye!==null&&ye.$$typeof===ue&&Pr(ye)===z.type){l(P,z.sibling),ne=d(z,F.props),wl(ne,F),ne.return=P,P=ne;break e}l(P,z);break}else r(P,z);z=z.sibling}F.type===k?(ne=Lr(F.props.children,P.mode,ne,F.key),ne.return=P,P=ne):(ne=Ga(F.type,F.key,F.props,null,P.mode,ne),wl(ne,F),ne.return=P,P=ne)}return v(P);case x:e:{for(ye=F.key;z!==null;){if(z.key===ye)if(z.tag===4&&z.stateNode.containerInfo===F.containerInfo&&z.stateNode.implementation===F.implementation){l(P,z.sibling),ne=d(z,F.children||[]),ne.return=P,P=ne;break e}else{l(P,z);break}else r(P,z);z=z.sibling}ne=oc(F,P.mode,ne),ne.return=P,P=ne}return v(P);case ue:return F=Pr(F),Xe(P,z,F,ne)}if(R(F))return ge(P,z,F,ne);if(V(F)){if(ye=V(F),typeof ye!="function")throw Error(s(150));return F=ye.call(F),Se(P,z,F,ne)}if(typeof F.then=="function")return Xe(P,z,no(F),ne);if(F.$$typeof===I)return Xe(P,z,Ja(P,F),ne);ro(P,F)}return typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint"?(F=""+F,z!==null&&z.tag===6?(l(P,z.sibling),ne=d(z,F),ne.return=P,P=ne):(l(P,z),ne=ac(F,P.mode,ne),ne.return=P,P=ne),v(P)):l(P,z)}return function(P,z,F,ne){try{xl=0;var ye=Xe(P,z,F,ne);return Ts=null,ye}catch(ve){if(ve===Es||ve===to)throw ve;var Ie=wi(29,ve,null,P.mode);return Ie.lanes=ne,Ie.return=P,Ie}finally{}}}var Ir=um(!0),cm=um(!1),Qn=!1;function bc(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Sc(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function Jn(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function er(i,r,l){var u=i.updateQueue;if(u===null)return null;if(u=u.shared,(qe&2)!==0){var d=u.pending;return d===null?r.next=r:(r.next=d.next,d.next=r),u.pending=r,r=$a(i),Kp(i,null,l),r}return Xa(i,u,r,l),$a(i)}function Cl(i,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194048)!==0)){var u=r.lanes;u&=i.pendingLanes,l|=u,r.lanes=l,tp(i,l)}}function xc(i,r){var l=i.updateQueue,u=i.alternate;if(u!==null&&(u=u.updateQueue,l===u)){var d=null,m=null;if(l=l.firstBaseUpdate,l!==null){do{var v={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};m===null?d=m=v:m=m.next=v,l=l.next}while(l!==null);m===null?d=m=r:m=m.next=r}else d=m=r;l={baseState:u.baseState,firstBaseUpdate:d,lastBaseUpdate:m,shared:u.shared,callbacks:u.callbacks},i.updateQueue=l;return}i=l.lastBaseUpdate,i===null?l.firstBaseUpdate=r:i.next=r,l.lastBaseUpdate=r}var wc=!1;function kl(){if(wc){var i=ks;if(i!==null)throw i}}function El(i,r,l,u){wc=!1;var d=i.updateQueue;Qn=!1;var m=d.firstBaseUpdate,v=d.lastBaseUpdate,w=d.shared.pending;if(w!==null){d.shared.pending=null;var N=w,q=N.next;N.next=null,v===null?m=q:v.next=q,v=N;var ee=i.alternate;ee!==null&&(ee=ee.updateQueue,w=ee.lastBaseUpdate,w!==v&&(w===null?ee.firstBaseUpdate=q:w.next=q,ee.lastBaseUpdate=N))}if(m!==null){var re=d.baseState;v=0,ee=q=N=null,w=m;do{var Y=w.lane&-536870913,$=Y!==w.lane;if($?(je&Y)===Y:(u&Y)===Y){Y!==0&&Y===Cs&&(wc=!0),ee!==null&&(ee=ee.next={lane:0,tag:w.tag,payload:w.payload,callback:null,next:null});e:{var ge=i,Se=w;Y=r;var Xe=l;switch(Se.tag){case 1:if(ge=Se.payload,typeof ge=="function"){re=ge.call(Xe,re,Y);break e}re=ge;break e;case 3:ge.flags=ge.flags&-65537|128;case 0:if(ge=Se.payload,Y=typeof ge=="function"?ge.call(Xe,re,Y):ge,Y==null)break e;re=_({},re,Y);break e;case 2:Qn=!0}}Y=w.callback,Y!==null&&(i.flags|=64,$&&(i.flags|=8192),$=d.callbacks,$===null?d.callbacks=[Y]:$.push(Y))}else $={lane:Y,tag:w.tag,payload:w.payload,callback:w.callback,next:null},ee===null?(q=ee=$,N=re):ee=ee.next=$,v|=Y;if(w=w.next,w===null){if(w=d.shared.pending,w===null)break;$=w,w=$.next,$.next=null,d.lastBaseUpdate=$,d.shared.pending=null}}while(!0);ee===null&&(N=re),d.baseState=N,d.firstBaseUpdate=q,d.lastBaseUpdate=ee,m===null&&(d.shared.lanes=0),sr|=v,i.lanes=v,i.memoizedState=re}}function hm(i,r){if(typeof i!="function")throw Error(s(191,i));i.call(r)}function fm(i,r){var l=i.callbacks;if(l!==null)for(i.callbacks=null,i=0;im?m:8;var v=T.T,w={};T.T=w,Fc(i,!1,r,l);try{var N=d(),q=T.S;if(q!==null&&q(w,N),N!==null&&typeof N=="object"&&typeof N.then=="function"){var ee=l1(N,u);Dl(i,r,ee,Ai(i))}else Dl(i,r,u,Ai(i))}catch(re){Dl(i,r,{then:function(){},status:"rejected",reason:re},Ai())}finally{j.p=m,v!==null&&w.types!==null&&(v.types=w.types),T.T=v}}function f1(){}function Uc(i,r,l,u){if(i.tag!==5)throw Error(s(476));var d=Wm(i).queue;qm(i,d,r,H,l===null?f1:function(){return Ym(i),l(u)})}function Wm(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:H,baseState:H,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Tn,lastRenderedState:H},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Tn,lastRenderedState:l},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function Ym(i){var r=Wm(i);r.next===null&&(r=i.alternate.memoizedState),Dl(i,r.next.queue,{},Ai())}function Ic(){return Xt(Vl)}function Vm(){return gt().memoizedState}function Km(){return gt().memoizedState}function d1(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var l=Ai();i=Jn(l);var u=er(r,i,l);u!==null&&(vi(u,r,l),Cl(u,r,l)),r={cache:_c()},i.payload=r;return}r=r.return}}function p1(i,r,l){var u=Ai();l={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},mo(i)?$m(r,l):(l=sc(i,r,l,u),l!==null&&(vi(l,i,u),Gm(l,r,u)))}function Xm(i,r,l){var u=Ai();Dl(i,r,l,u)}function Dl(i,r,l,u){var d={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(mo(i))$m(r,d);else{var m=i.alternate;if(i.lanes===0&&(m===null||m.lanes===0)&&(m=r.lastRenderedReducer,m!==null))try{var v=r.lastRenderedState,w=m(v,l);if(d.hasEagerState=!0,d.eagerState=w,xi(w,v))return Xa(i,r,d,0),Ze===null&&Ka(),!1}catch{}finally{}if(l=sc(i,r,d,u),l!==null)return vi(l,i,u),Gm(l,r,u),!0}return!1}function Fc(i,r,l,u){if(u={lane:2,revertLane:bh(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},mo(i)){if(r)throw Error(s(479))}else r=sc(i,l,u,2),r!==null&&vi(r,i,2)}function mo(i){var r=i.alternate;return i===Ae||r!==null&&r===Ae}function $m(i,r){Ds=ao=!0;var l=i.pending;l===null?r.next=r:(r.next=l.next,l.next=r),i.pending=r}function Gm(i,r,l){if((l&4194048)!==0){var u=r.lanes;u&=i.pendingLanes,l|=u,r.lanes=l,tp(i,l)}}var Rl={readContext:Xt,use:co,useCallback:ht,useContext:ht,useEffect:ht,useImperativeHandle:ht,useLayoutEffect:ht,useInsertionEffect:ht,useMemo:ht,useReducer:ht,useRef:ht,useState:ht,useDebugValue:ht,useDeferredValue:ht,useTransition:ht,useSyncExternalStore:ht,useId:ht,useHostTransitionStatus:ht,useFormState:ht,useActionState:ht,useOptimistic:ht,useMemoCache:ht,useCacheRefresh:ht};Rl.useEffectEvent=ht;var Zm={readContext:Xt,use:co,useCallback:function(i,r){return si().memoizedState=[i,r===void 0?null:r],i},useContext:Xt,useEffect:Lm,useImperativeHandle:function(i,r,l){l=l!=null?l.concat([i]):null,fo(4194308,4,Hm.bind(null,r,i),l)},useLayoutEffect:function(i,r){return fo(4194308,4,i,r)},useInsertionEffect:function(i,r){fo(4,2,i,r)},useMemo:function(i,r){var l=si();r=r===void 0?null:r;var u=i();if(Fr){hi(!0);try{i()}finally{hi(!1)}}return l.memoizedState=[u,r],u},useReducer:function(i,r,l){var u=si();if(l!==void 0){var d=l(r);if(Fr){hi(!0);try{l(r)}finally{hi(!1)}}}else d=r;return u.memoizedState=u.baseState=d,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:d},u.queue=i,i=i.dispatch=p1.bind(null,Ae,i),[u.memoizedState,i]},useRef:function(i){var r=si();return i={current:i},r.memoizedState=i},useState:function(i){i=zc(i);var r=i.queue,l=Xm.bind(null,Ae,r);return r.dispatch=l,[i.memoizedState,l]},useDebugValue:Hc,useDeferredValue:function(i,r){var l=si();return Pc(l,i,r)},useTransition:function(){var i=zc(!1);return i=qm.bind(null,Ae,i.queue,!0,!1),si().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,l){var u=Ae,d=si();if(Pe){if(l===void 0)throw Error(s(407));l=l()}else{if(l=r(),Ze===null)throw Error(s(349));(je&127)!==0||vm(u,r,l)}d.memoizedState=l;var m={value:l,getSnapshot:r};return d.queue=m,Lm(bm.bind(null,u,m,i),[i]),u.flags|=2048,Ms(9,{destroy:void 0},ym.bind(null,u,m,l,r),null),l},useId:function(){var i=si(),r=Ze.identifierPrefix;if(Pe){var l=nn,u=tn;l=(u&~(1<<32-Ge(u)-1)).toString(32)+l,r="_"+r+"R_"+l,l=oo++,0<\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof u.is=="string"?v.createElement("select",{is:u.is}):v.createElement("select"),u.multiple?m.multiple=!0:u.size&&(m.size=u.size);break;default:m=typeof u.is=="string"?v.createElement(d,{is:u.is}):v.createElement(d)}}m[Vt]=r,m[fi]=u;e:for(v=r.child;v!==null;){if(v.tag===5||v.tag===6)m.appendChild(v.stateNode);else if(v.tag!==4&&v.tag!==27&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===r)break e;for(;v.sibling===null;){if(v.return===null||v.return===r)break e;v=v.return}v.sibling.return=v.return,v=v.sibling}r.stateNode=m;e:switch(Gt(m,d,u),d){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&Dn(r)}}return it(r),ih(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,l),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==u&&Dn(r);else{if(typeof u!="string"&&r.stateNode===null)throw Error(s(166));if(i=de.current,xs(r)){if(i=r.stateNode,l=r.memoizedProps,u=null,d=Kt,d!==null)switch(d.tag){case 27:case 5:u=d.memoizedProps}i[Vt]=r,i=!!(i.nodeValue===l||u!==null&&u.suppressHydrationWarning===!0||_g(i.nodeValue,l)),i||Gn(r,!0)}else i=zo(i).createTextNode(u),i[Vt]=r,r.stateNode=i}return it(r),null;case 31:if(l=r.memoizedState,i===null||i.memoizedState!==null){if(u=xs(r),l!==null){if(i===null){if(!u)throw Error(s(318));if(i=r.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[Vt]=r}else zr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;it(r),i=!1}else l=fc(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=l),i=!0;if(!i)return r.flags&256?(ki(r),r):(ki(r),null);if((r.flags&128)!==0)throw Error(s(558))}return it(r),null;case 13:if(u=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(d=xs(r),u!==null&&u.dehydrated!==null){if(i===null){if(!d)throw Error(s(318));if(d=r.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(s(317));d[Vt]=r}else zr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;it(r),d=!1}else d=fc(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=d),d=!0;if(!d)return r.flags&256?(ki(r),r):(ki(r),null)}return ki(r),(r.flags&128)!==0?(r.lanes=l,r):(l=u!==null,i=i!==null&&i.memoizedState!==null,l&&(u=r.child,d=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(d=u.alternate.memoizedState.cachePool.pool),m=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(m=u.memoizedState.cachePool.pool),m!==d&&(u.flags|=2048)),l!==i&&l&&(r.child.flags|=8192),bo(r,r.updateQueue),it(r),null);case 4:return ke(),i===null&&Ch(r.stateNode.containerInfo),it(r),null;case 10:return kn(r.type),it(r),null;case 19:if(K(_t),u=r.memoizedState,u===null)return it(r),null;if(d=(r.flags&128)!==0,m=u.rendering,m===null)if(d)Bl(u,!1);else{if(ft!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(m=lo(i),m!==null){for(r.flags|=128,Bl(u,!1),i=m.updateQueue,r.updateQueue=i,bo(r,i),r.subtreeFlags=0,i=l,l=r.child;l!==null;)Xp(l,i),l=l.sibling;return C(_t,_t.current&1|2),Pe&&wn(r,u.treeForkCount),r.child}i=i.sibling}u.tail!==null&&Wt()>ko&&(r.flags|=128,d=!0,Bl(u,!1),r.lanes=4194304)}else{if(!d)if(i=lo(m),i!==null){if(r.flags|=128,d=!0,i=i.updateQueue,r.updateQueue=i,bo(r,i),Bl(u,!0),u.tail===null&&u.tailMode==="hidden"&&!m.alternate&&!Pe)return it(r),null}else 2*Wt()-u.renderingStartTime>ko&&l!==536870912&&(r.flags|=128,d=!0,Bl(u,!1),r.lanes=4194304);u.isBackwards?(m.sibling=r.child,r.child=m):(i=u.last,i!==null?i.sibling=m:r.child=m,u.last=m)}return u.tail!==null?(i=u.tail,u.rendering=i,u.tail=i.sibling,u.renderingStartTime=Wt(),i.sibling=null,l=_t.current,C(_t,d?l&1|2:l&1),Pe&&wn(r,u.treeForkCount),i):(it(r),null);case 22:case 23:return ki(r),kc(),u=r.memoizedState!==null,i!==null?i.memoizedState!==null!==u&&(r.flags|=8192):u&&(r.flags|=8192),u?(l&536870912)!==0&&(r.flags&128)===0&&(it(r),r.subtreeFlags&6&&(r.flags|=8192)):it(r),l=r.updateQueue,l!==null&&bo(r,l.retryQueue),l=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(l=i.memoizedState.cachePool.pool),u=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),u!==l&&(r.flags|=2048),i!==null&&K(Hr),null;case 24:return l=null,i!==null&&(l=i.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),kn(yt),it(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function y1(i,r){switch(cc(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return kn(yt),ke(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return et(r),null;case 31:if(r.memoizedState!==null){if(ki(r),r.alternate===null)throw Error(s(340));zr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(ki(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(s(340));zr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return K(_t),null;case 4:return ke(),null;case 10:return kn(r.type),null;case 22:case 23:return ki(r),kc(),i!==null&&K(Hr),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return kn(yt),null;case 25:return null;default:return null}}function S_(i,r){switch(cc(r),r.tag){case 3:kn(yt),ke();break;case 26:case 27:case 5:et(r);break;case 4:ke();break;case 31:r.memoizedState!==null&&ki(r);break;case 13:ki(r);break;case 19:K(_t);break;case 10:kn(r.type);break;case 22:case 23:ki(r),kc(),i!==null&&K(Hr);break;case 24:kn(yt)}}function Nl(i,r){try{var l=r.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var d=u.next;l=d;do{if((l.tag&i)===i){u=void 0;var m=l.create,v=l.inst;u=m(),v.destroy=u}l=l.next}while(l!==d)}}catch(w){Ye(r,r.return,w)}}function nr(i,r,l){try{var u=r.updateQueue,d=u!==null?u.lastEffect:null;if(d!==null){var m=d.next;u=m;do{if((u.tag&i)===i){var v=u.inst,w=v.destroy;if(w!==void 0){v.destroy=void 0,d=r;var N=l,q=w;try{q()}catch(ee){Ye(d,N,ee)}}}u=u.next}while(u!==m)}}catch(ee){Ye(r,r.return,ee)}}function x_(i){var r=i.updateQueue;if(r!==null){var l=i.stateNode;try{fm(r,l)}catch(u){Ye(i,i.return,u)}}}function w_(i,r,l){l.props=qr(i.type,i.memoizedProps),l.state=i.memoizedState;try{l.componentWillUnmount()}catch(u){Ye(i,r,u)}}function Ll(i,r){try{var l=i.ref;if(l!==null){switch(i.tag){case 26:case 27:case 5:var u=i.stateNode;break;case 30:u=i.stateNode;break;default:u=i.stateNode}typeof l=="function"?i.refCleanup=l(u):l.current=u}}catch(d){Ye(i,r,d)}}function rn(i,r){var l=i.ref,u=i.refCleanup;if(l!==null)if(typeof u=="function")try{u()}catch(d){Ye(i,r,d)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(d){Ye(i,r,d)}else l.current=null}function C_(i){var r=i.type,l=i.memoizedProps,u=i.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":l.autoFocus&&u.focus();break e;case"img":l.src?u.src=l.src:l.srcSet&&(u.srcset=l.srcSet)}}catch(d){Ye(i,i.return,d)}}function nh(i,r,l){try{var u=i.stateNode;I1(u,i.type,l,r),u[fi]=r}catch(d){Ye(i,i.return,d)}}function k_(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&cr(i.type)||i.tag===4}function rh(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||k_(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&cr(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function sh(i,r,l){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(i,r):(r=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,r.appendChild(i),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=bn));else if(u!==4&&(u===27&&cr(i.type)&&(l=i.stateNode,r=null),i=i.child,i!==null))for(sh(i,r,l),i=i.sibling;i!==null;)sh(i,r,l),i=i.sibling}function So(i,r,l){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?l.insertBefore(i,r):l.appendChild(i);else if(u!==4&&(u===27&&cr(i.type)&&(l=i.stateNode),i=i.child,i!==null))for(So(i,r,l),i=i.sibling;i!==null;)So(i,r,l),i=i.sibling}function E_(i){var r=i.stateNode,l=i.memoizedProps;try{for(var u=i.type,d=r.attributes;d.length;)r.removeAttributeNode(d[0]);Gt(r,u,l),r[Vt]=i,r[fi]=l}catch(m){Ye(i,i.return,m)}}var Rn=!1,xt=!1,lh=!1,T_=typeof WeakSet=="function"?WeakSet:Set,zt=null;function b1(i,r){if(i=i.containerInfo,Th=Fo,i=Pp(i),Ju(i)){if("selectionStart"in i)var l={start:i.selectionStart,end:i.selectionEnd};else e:{l=(l=i.ownerDocument)&&l.defaultView||window;var u=l.getSelection&&l.getSelection();if(u&&u.rangeCount!==0){l=u.anchorNode;var d=u.anchorOffset,m=u.focusNode;u=u.focusOffset;try{l.nodeType,m.nodeType}catch{l=null;break e}var v=0,w=-1,N=-1,q=0,ee=0,re=i,Y=null;t:for(;;){for(var $;re!==l||d!==0&&re.nodeType!==3||(w=v+d),re!==m||u!==0&&re.nodeType!==3||(N=v+u),re.nodeType===3&&(v+=re.nodeValue.length),($=re.firstChild)!==null;)Y=re,re=$;for(;;){if(re===i)break t;if(Y===l&&++q===d&&(w=v),Y===m&&++ee===u&&(N=v),($=re.nextSibling)!==null)break;re=Y,Y=re.parentNode}re=$}l=w===-1||N===-1?null:{start:w,end:N}}else l=null}l=l||{start:0,end:0}}else l=null;for(Ah={focusedElem:i,selectionRange:l},Fo=!1,zt=r;zt!==null;)if(r=zt,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,zt=i;else for(;zt!==null;){switch(r=zt,m=r.alternate,i=r.flags,r.tag){case 0:if((i&4)!==0&&(i=r.updateQueue,i=i!==null?i.events:null,i!==null))for(l=0;l title"))),Gt(m,u,l),m[Vt]=i,Lt(m),u=m;break e;case"link":var v=Ng("link","href",d).get(u+(l.href||""));if(v){for(var w=0;wXe&&(v=Xe,Xe=Se,Se=v);var P=jp(w,Se),z=jp(w,Xe);if(P&&z&&($.rangeCount!==1||$.anchorNode!==P.node||$.anchorOffset!==P.offset||$.focusNode!==z.node||$.focusOffset!==z.offset)){var F=re.createRange();F.setStart(P.node,P.offset),$.removeAllRanges(),Se>Xe?($.addRange(F),$.extend(z.node,z.offset)):(F.setEnd(z.node,z.offset),$.addRange(F))}}}}for(re=[],$=w;$=$.parentNode;)$.nodeType===1&&re.push({element:$,left:$.scrollLeft,top:$.scrollTop});for(typeof w.focus=="function"&&w.focus(),w=0;wl?32:l,T.T=null,l=dh,dh=null;var m=ar,v=zn;if(Dt=0,Os=ar=null,zn=0,(qe&6)!==0)throw Error(s(331));var w=qe;if(qe|=4,H_(m.current),z_(m,m.current,v,l),qe=w,Ul(0,!1),At&&typeof At.onPostCommitFiberRoot=="function")try{At.onPostCommitFiberRoot(Tt,m)}catch{}return!0}finally{j.p=d,T.T=u,ig(i,r)}}function rg(i,r,l){r=Oi(l,r),r=Vc(i.stateNode,r,2),i=er(i,r,2),i!==null&&(ll(i,2),sn(i))}function Ye(i,r,l){if(i.tag===3)rg(i,i,l);else for(;r!==null;){if(r.tag===3){rg(r,i,l);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(lr===null||!lr.has(u))){i=Oi(l,i),l=s_(2),u=er(r,l,2),u!==null&&(l_(l,u,r,i),ll(u,2),sn(u));break}}r=r.return}}function gh(i,r,l){var u=i.pingCache;if(u===null){u=i.pingCache=new w1;var d=new Set;u.set(r,d)}else d=u.get(r),d===void 0&&(d=new Set,u.set(r,d));d.has(l)||(uh=!0,d.add(l),i=A1.bind(null,i,r,l),r.then(i,i))}function A1(i,r,l){var u=i.pingCache;u!==null&&u.delete(r),i.pingedLanes|=i.suspendedLanes&l,i.warmLanes&=~l,Ze===i&&(je&l)===l&&(ft===4||ft===3&&(je&62914560)===je&&300>Wt()-Co?(qe&2)===0&&js(i,0):ch|=l,zs===je&&(zs=0)),sn(i)}function sg(i,r){r===0&&(r=Jd()),i=Nr(i,r),i!==null&&(ll(i,r),sn(i))}function D1(i){var r=i.memoizedState,l=0;r!==null&&(l=r.retryLane),sg(i,l)}function R1(i,r){var l=0;switch(i.tag){case 31:case 13:var u=i.stateNode,d=i.memoizedState;d!==null&&(l=d.retryLane);break;case 19:u=i.stateNode;break;case 22:u=i.stateNode._retryCache;break;default:throw Error(s(314))}u!==null&&u.delete(r),sg(i,l)}function M1(i,r){return Tr(i,r)}var Mo=null,Ps=null,vh=!1,Bo=!1,yh=!1,ur=0;function sn(i){i!==Ps&&i.next===null&&(Ps===null?Mo=Ps=i:Ps=Ps.next=i),Bo=!0,vh||(vh=!0,N1())}function Ul(i,r){if(!yh&&Bo){yh=!0;do for(var l=!1,u=Mo;u!==null;){if(i!==0){var d=u.pendingLanes;if(d===0)var m=0;else{var v=u.suspendedLanes,w=u.pingedLanes;m=(1<<31-Ge(42|i)+1)-1,m&=d&~(v&~w),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(l=!0,ug(u,m))}else m=je,m=za(u,u===Ze?m:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(m&3)===0||sl(u,m)||(l=!0,ug(u,m));u=u.next}while(l);yh=!1}}function B1(){lg()}function lg(){Bo=vh=!1;var i=0;ur!==0&&q1()&&(i=ur);for(var r=Wt(),l=null,u=Mo;u!==null;){var d=u.next,m=ag(u,r);m===0?(u.next=null,l===null?Mo=d:l.next=d,d===null&&(Ps=l)):(l=u,(i!==0||(m&3)!==0)&&(Bo=!0)),u=d}Dt!==0&&Dt!==5||Ul(i),ur!==0&&(ur=0)}function ag(i,r){for(var l=i.suspendedLanes,u=i.pingedLanes,d=i.expirationTimes,m=i.pendingLanes&-62914561;0w)break;var ee=N.transferSize,re=N.initiatorType;ee&&gg(re)&&(N=N.responseEnd,v+=ee*(N"u"?null:document;function Dg(i,r,l){var u=Us;if(u&&typeof r=="string"&&r){var d=Li(r);d='link[rel="'+i+'"][href="'+d+'"]',typeof l=="string"&&(d+='[crossorigin="'+l+'"]'),Ag.has(d)||(Ag.add(d),i={rel:i,crossOrigin:l,href:r},u.querySelector(d)===null&&(r=u.createElement("link"),Gt(r,"link",i),Lt(r),u.head.appendChild(r)))}}function Q1(i){On.D(i),Dg("dns-prefetch",i,null)}function J1(i,r){On.C(i,r),Dg("preconnect",i,r)}function ex(i,r,l){On.L(i,r,l);var u=Us;if(u&&i&&r){var d='link[rel="preload"][as="'+Li(r)+'"]';r==="image"&&l&&l.imageSrcSet?(d+='[imagesrcset="'+Li(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(d+='[imagesizes="'+Li(l.imageSizes)+'"]')):d+='[href="'+Li(i)+'"]';var m=d;switch(r){case"style":m=Is(i);break;case"script":m=Fs(i)}Fi.has(m)||(i=_({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:i,as:r},l),Fi.set(m,i),u.querySelector(d)!==null||r==="style"&&u.querySelector(Wl(m))||r==="script"&&u.querySelector(Yl(m))||(r=u.createElement("link"),Gt(r,"link",i),Lt(r),u.head.appendChild(r)))}}function tx(i,r){On.m(i,r);var l=Us;if(l&&i){var u=r&&typeof r.as=="string"?r.as:"script",d='link[rel="modulepreload"][as="'+Li(u)+'"][href="'+Li(i)+'"]',m=d;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=Fs(i)}if(!Fi.has(m)&&(i=_({rel:"modulepreload",href:i},r),Fi.set(m,i),l.querySelector(d)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Yl(m)))return}u=l.createElement("link"),Gt(u,"link",i),Lt(u),l.head.appendChild(u)}}}function ix(i,r,l){On.S(i,r,l);var u=Us;if(u&&i){var d=us(u).hoistableStyles,m=Is(i);r=r||"default";var v=d.get(m);if(!v){var w={loading:0,preload:null};if(v=u.querySelector(Wl(m)))w.loading=5;else{i=_({rel:"stylesheet",href:i,"data-precedence":r},l),(l=Fi.get(m))&&zh(i,l);var N=v=u.createElement("link");Lt(N),Gt(N,"link",i),N._p=new Promise(function(q,ee){N.onload=q,N.onerror=ee}),N.addEventListener("load",function(){w.loading|=1}),N.addEventListener("error",function(){w.loading|=2}),w.loading|=4,jo(v,r,u)}v={type:"stylesheet",instance:v,count:1,state:w},d.set(m,v)}}}function nx(i,r){On.X(i,r);var l=Us;if(l&&i){var u=us(l).hoistableScripts,d=Fs(i),m=u.get(d);m||(m=l.querySelector(Yl(d)),m||(i=_({src:i,async:!0},r),(r=Fi.get(d))&&Oh(i,r),m=l.createElement("script"),Lt(m),Gt(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(d,m))}}function rx(i,r){On.M(i,r);var l=Us;if(l&&i){var u=us(l).hoistableScripts,d=Fs(i),m=u.get(d);m||(m=l.querySelector(Yl(d)),m||(i=_({src:i,async:!0,type:"module"},r),(r=Fi.get(d))&&Oh(i,r),m=l.createElement("script"),Lt(m),Gt(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(d,m))}}function Rg(i,r,l,u){var d=(d=de.current)?Oo(d):null;if(!d)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(r=Is(l.href),l=us(d).hoistableStyles,u=l.get(r),u||(u={type:"style",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){i=Is(l.href);var m=us(d).hoistableStyles,v=m.get(i);if(v||(d=d.ownerDocument||d,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(i,v),(m=d.querySelector(Wl(i)))&&!m._p&&(v.instance=m,v.state.loading=5),Fi.has(i)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Fi.set(i,l),m||sx(d,i,l,v.state))),r&&u===null)throw Error(s(528,""));return v}if(r&&u!==null)throw Error(s(529,""));return null;case"script":return r=l.async,l=l.src,typeof l=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Fs(l),l=us(d).hoistableScripts,u=l.get(r),u||(u={type:"script",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,i))}}function Is(i){return'href="'+Li(i)+'"'}function Wl(i){return'link[rel="stylesheet"]['+i+"]"}function Mg(i){return _({},i,{"data-precedence":i.precedence,precedence:null})}function sx(i,r,l,u){i.querySelector('link[rel="preload"][as="style"]['+r+"]")?u.loading=1:(r=i.createElement("link"),u.preload=r,r.addEventListener("load",function(){return u.loading|=1}),r.addEventListener("error",function(){return u.loading|=2}),Gt(r,"link",l),Lt(r),i.head.appendChild(r))}function Fs(i){return'[src="'+Li(i)+'"]'}function Yl(i){return"script[async]"+i}function Bg(i,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var u=i.querySelector('style[data-href~="'+Li(l.href)+'"]');if(u)return r.instance=u,Lt(u),u;var d=_({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return u=(i.ownerDocument||i).createElement("style"),Lt(u),Gt(u,"style",d),jo(u,l.precedence,i),r.instance=u;case"stylesheet":d=Is(l.href);var m=i.querySelector(Wl(d));if(m)return r.state.loading|=4,r.instance=m,Lt(m),m;u=Mg(l),(d=Fi.get(d))&&zh(u,d),m=(i.ownerDocument||i).createElement("link"),Lt(m);var v=m;return v._p=new Promise(function(w,N){v.onload=w,v.onerror=N}),Gt(m,"link",u),r.state.loading|=4,jo(m,l.precedence,i),r.instance=m;case"script":return m=Fs(l.src),(d=i.querySelector(Yl(m)))?(r.instance=d,Lt(d),d):(u=l,(d=Fi.get(m))&&(u=_({},l),Oh(u,d)),i=i.ownerDocument||i,d=i.createElement("script"),Lt(d),Gt(d,"link",u),i.head.appendChild(d),r.instance=d);case"void":return null;default:throw Error(s(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(u=r.instance,r.state.loading|=4,jo(u,l.precedence,i));return r.instance}function jo(i,r,l){for(var u=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=u.length?u[u.length-1]:null,m=d,v=0;v title"):null)}function lx(i,r,l){if(l===1||r.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return i=r.disabled,typeof r.precedence=="string"&&i==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function zg(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function ax(i,r,l,u){if(l.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var d=Is(u.href),m=r.querySelector(Wl(d));if(m){r=m._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=Po.bind(i),r.then(i,i)),l.state.loading|=4,l.instance=m,Lt(m);return}m=r.ownerDocument||r,u=Mg(u),(d=Fi.get(d))&&zh(u,d),m=m.createElement("link"),Lt(m);var v=m;v._p=new Promise(function(w,N){v.onload=w,v.onerror=N}),Gt(m,"link",u),l.instance=m}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(l,r),(r=l.state.preload)&&(l.state.loading&3)===0&&(i.count++,l=Po.bind(i),r.addEventListener("load",l),r.addEventListener("error",l))}}var jh=0;function ox(i,r){return i.stylesheets&&i.count===0&&Io(i,i.stylesheets),0jh?50:800)+r);return i.unsuspend=l,function(){i.unsuspend=null,clearTimeout(u),clearTimeout(d)}}:null}function Po(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Io(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Uo=null;function Io(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Uo=new Map,r.forEach(ux,i),Uo=null,Po.call(i))}function ux(i,r){if(!(r.state.loading&4)){var l=Uo.get(i);if(l)var u=l.get(null);else{l=new Map,Uo.set(i,l);for(var d=i.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Vh.exports=Ex(),Vh.exports}var Ax=Tx();const Dx=xu(Ax);function Rx({onLogin:e}){const[t,n]=G.useState(""),[s,a]=G.useState(null),[o,c]=G.useState(!1),f=async p=>{if(p.preventDefault(),!t.trim())return;c(!0),a(null);const h=await e(t);h&&a(h),c(!1)};return S.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:S.jsxs("div",{className:"w-full max-w-sm",children:[S.jsxs("div",{className:"border-border rounded border p-6",children:[S.jsxs("div",{className:"mb-6 text-center",children:[S.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),S.jsx("p",{className:"text-muted mt-1 text-xs",children:"local writer agent"})]}),S.jsxs("form",{onSubmit:f,className:"space-y-4",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),S.jsx("input",{type:"password",value:t,onChange:p=>n(p.target.value),placeholder:"enter your passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),s&&S.jsx("p",{className:"text-error text-xs",children:s}),S.jsx("button",{type:"submit",disabled:o||!t.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:o?"authenticating...":"unlock"})]})]}),S.jsx("p",{className:"text-muted mt-4 text-center text-[10px]",children:"enter your passphrase to unlock"})]})})}function Mx({onSetup:e}){const[t,n]=G.useState(""),[s,a]=G.useState(""),[o,c]=G.useState(null),[f,p]=G.useState(!1),h=async g=>{if(g.preventDefault(),!t.trim()||t.length<4){c("Passphrase must be at least 4 characters");return}if(t!==s){c("Passphrases do not match");return}p(!0),c(null);const _=await e(t);_&&c(_),p(!1)};return S.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:S.jsx("div",{className:"w-full max-w-sm",children:S.jsxs("div",{className:"border-border rounded border p-6",children:[S.jsxs("div",{className:"mb-6 text-center",children:[S.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),S.jsx("p",{className:"text-muted mt-1 text-xs",children:"first-time setup"})]}),S.jsx("p",{className:"text-muted mb-4 text-xs leading-relaxed",children:"Choose a passphrase to protect your local writer agent. This will be used to unlock the app and secure your OWS wallet."}),S.jsxs("form",{onSubmit:h,className:"space-y-4",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),S.jsx("input",{type:"password",value:t,onChange:g=>n(g.target.value),placeholder:"choose a passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Confirm"}),S.jsx("input",{type:"password",value:s,onChange:g=>a(g.target.value),placeholder:"repeat passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),o&&S.jsx("p",{className:"text-error text-xs",children:o}),S.jsx("button",{type:"submit",disabled:f||!t.trim()||!s.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:f?"setting up...":"create passphrase"})]})]})})})}const sv="http://localhost:7777";function eb({token:e}){const[t,n]=G.useState(null),[s,a]=G.useState(!1),[o,c]=G.useState(!1),[f,p]=G.useState(null),h=(x,k)=>fetch(x,{...k,headers:{...k==null?void 0:k.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),g=()=>{h(`${sv}/api/wallet`).then(x=>x.json()).then(x=>n(x)).catch(()=>n({exists:!1,error:"Failed to load wallet"}))};G.useEffect(()=>{g()},[]);const _=async()=>{a(!0),p(null);try{const x=await h(`${sv}/api/wallet/create`,{method:"POST"}),k=await x.json();if(!x.ok)throw new Error(k.error||"Creation failed");g()}catch(x){p(x instanceof Error?x.message:"Failed to create wallet")}a(!1)},b=()=>{t!=null&&t.address&&(navigator.clipboard.writeText(t.address),c(!0),setTimeout(()=>c(!1),2e3))},y=x=>`${x.slice(0,6)}...${x.slice(-4)}`;return S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"OWS Wallet"}),!t&&S.jsx("p",{className:"text-muted text-xs",children:"loading..."}),t&&!t.exists&&S.jsxs("div",{className:"space-y-3",children:[S.jsx("p",{className:"text-muted text-xs",children:"No wallet created yet. Create one to enable autonomous transactions."}),f&&S.jsx("p",{className:"text-error text-xs",children:f}),S.jsx("button",{onClick:_,disabled:s,className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 rounded border px-4 py-2 text-xs font-medium transition-colors",children:s?"creating...":"create wallet"})]}),t&&t.exists&&t.address&&S.jsxs("div",{className:"space-y-3",children:[S.jsxs("div",{className:"flex items-center justify-between",children:[S.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"Address (Base)"}),S.jsx("span",{className:`rounded border px-1.5 py-0.5 text-[9px] ${t.ethBalance&&parseFloat(t.ethBalance)>0?"border-accent/30 text-accent":"border-accent-dim/30 text-accent-dim"}`,children:t.ethBalance&&parseFloat(t.ethBalance)>0?"active":"no balance"})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("code",{className:"text-foreground bg-surface rounded px-2 py-1 text-xs font-mono",children:y(t.address)}),S.jsx("button",{onClick:b,className:"text-muted hover:text-accent text-xs transition-colors",children:o?"copied":"copy"})]}),S.jsxs("div",{className:"border-border space-y-1 border-t pt-3",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"ETH"}),S.jsxs("span",{className:"text-foreground font-medium",children:[t.ethBalance||"0.000000"," ETH"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"USDC"}),S.jsxs("span",{className:"text-foreground font-medium",children:["$",t.usdcBalance||"0.00"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"PLOT"}),S.jsxs("span",{className:"text-foreground font-medium",children:[t.plotBalance||"0.0000"," PLOT"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Network"}),S.jsx("span",{className:"text-foreground",children:"Base"})]})]}),S.jsxs("div",{className:"border-border border-t pt-3",children:[S.jsx("p",{className:"text-muted mb-2 text-[10px] font-medium uppercase tracking-wider",children:"Fund Wallet"}),S.jsx("p",{className:"text-muted text-[10px]",children:"Send ETH on Base for gas (~$0.01 per publish):"}),S.jsx("code",{className:"text-foreground bg-surface mt-1 block break-all rounded px-2 py-1.5 text-[10px] font-mono",children:t.address})]})]})]})}function Bx({token:e,onLogout:t}){const[n,s]=G.useState(""),[a,o]=G.useState(""),[c,f]=G.useState(null),[p,h]=G.useState(!1),[g,_]=G.useState(!1),[b,y]=G.useState(null),[x,k]=G.useState("AI Writer"),[L,M]=G.useState(""),[Z,I]=G.useState(""),[Q,W]=G.useState(!1),[O,ie]=G.useState(null),[ue,me]=G.useState(""),[U,le]=G.useState(null),[V,B]=G.useState(!1),[A,R]=G.useState(null),[T,j]=G.useState(null),H=G.useCallback((C,J)=>fetch(C,{...J,headers:{...J==null?void 0:J.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]);G.useEffect(()=>{H("/api/settings/link-status").then(C=>C.json()).then(C=>y(C)).catch(()=>y({linked:!1}))},[]);const ae=async()=>{if(!x.trim()){ie("Agent name is required");return}if(!L.trim()){ie("Description is required");return}W(!0),ie(null);try{const C=await H("/api/settings/register-agent",{method:"POST",body:JSON.stringify({name:x,description:L,...Z.trim()&&{genre:Z}})}),J=await C.json();if(!C.ok)throw new Error(J.error||"Registration failed");y({linked:!0,agentId:J.agentId,owsWallet:J.owsWallet,txHash:J.txHash})}catch(C){ie(C instanceof Error?C.message:"Registration failed")}W(!1)},E=async()=>{if(!ue.trim()||!/^0x[a-fA-F0-9]{40}$/.test(ue)){R("Enter a valid wallet address (0x...)");return}B(!0),R(null),le(null);try{const C=await H("/api/settings/generate-binding",{method:"POST",body:JSON.stringify({humanWallet:ue})}),J=await C.json();if(!C.ok)throw new Error(J.error||"Failed to generate binding code");le(J)}catch(C){R(C instanceof Error?C.message:"Failed to generate binding code")}B(!1)},D=async(C,J)=>{await navigator.clipboard.writeText(C),j(J),setTimeout(()=>j(null),2e3)},K=async()=>{if(f(null),h(!1),!n||n.length<4){f("Passphrase must be at least 4 characters");return}if(n!==a){f("Passphrases do not match");return}_(!0);try{const C=await H("/api/auth/reset-passphrase",{method:"POST",body:JSON.stringify({passphrase:n})});if(!C.ok){const J=await C.json();throw new Error(J.error||"Reset failed")}h(!0),s(""),o(""),setTimeout(()=>h(!1),3e3)}catch(C){f(C instanceof Error?C.message:"Reset failed")}_(!1)};return S.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-6",children:[S.jsx("h2",{className:"text-accent text-lg font-bold",children:"Settings"}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Identity"}),b!=null&&b.linked?S.jsxs("div",{className:"space-y-2",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"text-sm font-medium text-accent",children:"Registered"}),S.jsxs("span",{className:"text-muted text-xs",children:["Agent #",b.agentId]})]}),b.owsWallet&&S.jsxs("p",{className:"text-muted text-xs font-mono",children:["Wallet: ",b.owsWallet.slice(0,6),"...",b.owsWallet.slice(-4)]}),b.owner&&S.jsxs("p",{className:"text-muted text-xs font-mono",children:["Owner: ",b.owner.slice(0,6),"...",b.owner.slice(-4)]}),b.txHash&&S.jsx("p",{className:"text-muted text-xs",children:S.jsx("a",{href:`https://basescan.org/tx/${b.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View transaction on BaseScan"})}),S.jsx("p",{className:"text-muted text-xs",children:S.jsx("a",{href:`https://plotlink.xyz/profile/${b.owsWallet}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View agent profile on plotlink.xyz"})})]}):S.jsxs("div",{className:"space-y-3",children:[S.jsx("p",{className:"text-muted text-xs",children:"Register this AI writer on-chain via ERC-8004. Uses your OWS wallet's existing ETH balance for gas."}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Name"}),S.jsx("input",{value:x,onChange:C=>k(C.target.value),placeholder:"AI Writer",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Description"}),S.jsx("input",{value:L,onChange:C=>M(C.target.value),placeholder:"An AI writing assistant for fiction stories",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Genre (optional)"}),S.jsx("input",{value:Z,onChange:C=>I(C.target.value),placeholder:"e.g. Fiction, Sci-Fi, Fantasy",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),O&&S.jsx("p",{className:"text-error text-xs",children:O}),S.jsx("button",{onClick:ae,disabled:Q||!x.trim()||!L.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:Q?"Registering...":"Register Agent Identity"})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Link to PlotLink"}),b!=null&&b.owner?S.jsxs("p",{className:"text-muted text-xs",children:["Linked to owner ",S.jsxs("span",{className:"font-mono",children:[b.owner.slice(0,6),"...",b.owner.slice(-4)]})]}):S.jsxs("div",{className:"space-y-3",children:[S.jsx("p",{className:"text-muted text-xs",children:"Link this OWS wallet to your PlotLink account so your stories appear under your profile on plotlink.xyz."}),S.jsxs("div",{className:"text-muted text-xs space-y-1 pl-3",children:[S.jsx("p",{children:"1. Enter your PlotLink wallet address below"}),S.jsx("p",{children:'2. Click "Generate Binding Code"'}),S.jsx("p",{children:"3. Copy the code and paste it on plotlink.xyz → Agents → Link AI Writer"})]}),S.jsx("input",{value:ue,onChange:C=>me(C.target.value),placeholder:"Your PlotLink wallet address (0x...)",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent font-mono"}),A&&S.jsx("p",{className:"text-error text-xs",children:A}),S.jsx("button",{onClick:E,disabled:V||!ue.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:V?"Generating...":"Generate Binding Code"}),U&&S.jsxs("div",{className:"space-y-3 mt-3",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Binding Code (signature)"}),S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:U.signature}),S.jsx("button",{onClick:()=>D(U.signature,"signature"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:T==="signature"?"Copied!":"Copy"})]})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"OWS Wallet Address"}),S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:U.owsWallet}),S.jsx("button",{onClick:()=>D(U.owsWallet,"wallet"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:T==="wallet"?"Copied!":"Copy"})]})]}),U.agentId&&S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Agent ID"}),S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono text-foreground pr-16",children:U.agentId}),S.jsx("button",{onClick:()=>D(String(U.agentId),"agentId"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:T==="agentId"?"Copied!":"Copy"})]})]}),S.jsx("p",{className:"text-xs text-accent",children:'Now go to plotlink.xyz/agents and paste the values in the "Link AI Writer" section.'})]})]})]}),S.jsx(eb,{token:e}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Reset Passphrase"}),S.jsxs("div",{className:"space-y-3",children:[S.jsx("input",{type:"password",value:n,onChange:C=>s(C.target.value),placeholder:"new passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),S.jsx("input",{type:"password",value:a,onChange:C=>o(C.target.value),placeholder:"confirm passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),c&&S.jsx("p",{className:"text-error text-xs",children:c}),p&&S.jsx("p",{className:"text-xs text-accent",children:"passphrase updated"}),S.jsx("button",{onClick:K,disabled:g||!n.trim(),className:"border-border text-muted hover:border-accent hover:text-accent disabled:opacity-40 w-full rounded border px-4 py-2 text-xs font-medium transition-colors",children:g?"updating...":"update passphrase"})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Session"}),S.jsx("button",{onClick:t,className:"border-border text-muted hover:border-error hover:text-error rounded border px-4 py-2 text-xs font-medium transition-colors",children:"logout"})]})]})}const Nx="http://localhost:7777";function Lx({token:e}){const[t,n]=G.useState(null),s=(f,p)=>fetch(f,{...p,headers:{...p==null?void 0:p.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),a=()=>{s(`${Nx}/api/dashboard`).then(f=>f.json()).then(n)};G.useEffect(()=>{a()},[]);const o=f=>`${f.slice(0,6)}...${f.slice(-4)}`,c=f=>{if(!f)return"Unknown date";const p=new Date(f);return isNaN(p.getTime())?"Unknown date":p.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})};return t?S.jsxs("div",{className:"mx-auto max-w-2xl space-y-6 p-6",children:[S.jsx("h2",{className:"text-accent text-lg font-bold",children:"Writer Dashboard"}),S.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-accent text-lg font-bold",children:t.stories.totalPublished}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"published"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.pendingFiles}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"pending"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalStories}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"stories"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalFiles}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"files"})]})]}),t.wallet&&S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Wallet"}),S.jsxs("div",{className:"space-y-1.5",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Address"}),S.jsx("code",{className:"text-foreground font-mono text-[10px]",children:o(t.wallet.address)})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"ETH Balance"}),S.jsxs("span",{className:"text-foreground",children:[t.wallet.ethFormatted," ETH"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"USDC Balance"}),S.jsxs("span",{className:"text-foreground",children:["$",t.wallet.usdcBalance]})]})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Profit & Loss"}),S.jsxs("div",{className:"space-y-1.5",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Total costs (gas)"}),S.jsxs("span",{className:"text-error",children:["-",t.pnl.totalCostsEth," ETH (~$",t.pnl.totalCostsUsd,")"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Royalties earned"}),S.jsxs("span",{className:"text-accent",children:["+",t.pnl.totalRoyaltiesPlot," PLOT"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Unclaimed royalties"}),S.jsxs("span",{className:"text-foreground",children:[t.royalties.unclaimed," PLOT"]})]}),S.jsxs("div",{className:"border-border flex justify-between border-t pt-1.5 text-xs font-medium",children:[S.jsx("span",{className:"text-muted",children:"Net P&L (USD)"}),S.jsxs("span",{className:parseFloat(t.pnl.netPnlUsd)>=0?"text-accent":"text-error",children:[parseFloat(t.pnl.netPnlUsd)>=0?"+":"","$",t.pnl.netPnlUsd]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Stories published"}),S.jsx("span",{className:"text-foreground",children:t.costs.storiesPublished})]})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Published Stories"}),t.stories.published.length===0?S.jsx("p",{className:"text-muted text-xs",children:"no published stories yet"}):S.jsx("div",{className:"space-y-3",children:t.stories.published.map(f=>S.jsxs("div",{className:"bg-surface rounded border border-border p-4",children:[S.jsxs("div",{className:"flex items-start justify-between",children:[S.jsxs("div",{children:[f.genre&&S.jsx("span",{className:"bg-accent/10 text-accent rounded px-2 py-0.5 text-[10px] font-medium",children:f.genre}),S.jsx("h4",{className:"text-foreground mt-1 text-sm font-serif font-medium",children:f.title}),S.jsx("p",{className:"text-muted mt-0.5 text-[10px] font-mono",children:f.storyName})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[f.hasNotIndexed&&S.jsx("span",{className:"rounded border border-amber-600/30 px-1.5 py-0.5 text-[9px] text-amber-700",children:"not indexed"}),S.jsxs("span",{className:"rounded border border-green-700/30 px-1.5 py-0.5 text-[9px] text-green-700",children:[f.publishedFiles," published"]})]})]}),S.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-center",children:[S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium",children:f.plotCount}),S.jsx("div",{className:"text-muted text-[9px]",children:"Plots"})]}),S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium font-mono",children:f.storylineId?`#${f.storylineId}`:"—"}),S.jsx("div",{className:"text-muted text-[9px]",children:"Storyline"})]}),S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium",children:f.totalGasCostEth??"—"}),S.jsx("div",{className:"text-muted text-[9px]",children:"Gas (ETH)"})]})]}),S.jsx("div",{className:"mt-2 space-y-1",children:f.files.map(p=>S.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[S.jsxs("div",{className:"flex items-center gap-1.5",children:[S.jsx("span",{className:p.status==="published-not-indexed"?"text-amber-700":"text-green-700",children:p.status==="published-not-indexed"?"⚠":"✓"}),S.jsx("span",{className:"text-muted font-mono",children:p.file})]}),p.txHash&&S.jsxs("a",{href:`https://basescan.org/tx/${p.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-accent font-mono",children:["tx:",p.txHash.slice(0,8),"..."]})]},p.file))}),S.jsxs("div",{className:"mt-2 flex items-center justify-between text-[10px]",children:[S.jsx("span",{className:"text-muted",children:c(f.latestPublishedAt)}),f.storylineId&&S.jsx("a",{href:`https://plotlink.xyz/story/${f.storylineId}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"})]})]},f.id))})]}),t.stories.pendingFiles>0&&S.jsx("div",{className:"border-border rounded border p-4",children:S.jsxs("p",{className:"text-muted text-xs",children:[t.stories.pendingFiles," file(s) pending publish — go to Stories to publish them."]})})]}):S.jsx("div",{className:"flex h-full items-center justify-center",children:S.jsx("span",{className:"text-muted text-sm",children:"loading dashboard..."})})}const zx={published:"✓","published-not-indexed":"⚠",pending:"⏳",draft:"📝"},Ox={published:"text-green-700","published-not-indexed":"text-amber-700",pending:"text-amber-700",draft:"text-muted"};function jx({authFetch:e,selectedStory:t,selectedFile:n,onSelectFile:s,onNewStory:a,untitledSessions:o=[]}){const[c,f]=G.useState([]),[p,h]=G.useState([]),[g,_]=G.useState(new Set),[b,y]=G.useState(!1),x=G.useCallback(async()=>{try{const W=await e("/api/stories");if(W.ok){const O=await W.json();f(O.stories)}}catch{}},[e]),k=G.useCallback(async()=>{try{const W=await e("/api/stories/archived");if(W.ok){const O=await W.json();h(O.stories)}}catch{}},[e]),L=G.useCallback(async W=>{try{(await e("/api/stories/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:W})})).ok&&(k(),x())}catch{}},[e,k,x]);G.useEffect(()=>{x();const W=setInterval(x,5e3);return()=>clearInterval(W)},[x]),G.useEffect(()=>{b&&k()},[b,k]),G.useEffect(()=>{t&&_(W=>new Set(W).add(t))},[t]);const M=W=>{var ie;const O=W.map(ue=>{var me;return{file:ue.file,num:(me=ue.file.match(/^plot-(\d+)\.md$/))==null?void 0:me[1]}}).filter(ue=>ue.num!=null).sort((ue,me)=>parseInt(me.num)-parseInt(ue.num));return O.length>0?O[0].file:W.some(ue=>ue.file==="genesis.md")?"genesis.md":W.some(ue=>ue.file==="structure.md")?"structure.md":((ie=W[0])==null?void 0:ie.file)??null},Z=W=>{_(O=>{const ie=new Set(O);return ie.has(W)?ie.delete(W):ie.add(W),ie})},I=W=>{if(Z(W.name),!g.has(W.name)){const O=M(W.files);O&&s(W.name,O)}},Q=W=>{const O=ie=>{if(ie==="structure.md")return 0;if(ie==="genesis.md")return 1;const ue=ie.match(/^plot-(\d+)\.md$/);return ue?2+parseInt(ue[1]):100};return[...W].sort((ie,ue)=>O(ie.file)-O(ue.file))};return b?S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs font-mono text-muted",children:"Archives"}),S.jsx("span",{className:"text-xs text-muted",children:p.length})]}),S.jsx("div",{className:"px-3 py-2 border-b border-border",children:S.jsxs("button",{onClick:()=>y(!1),className:"w-full px-3 py-1.5 text-sm text-muted hover:text-foreground hover:bg-surface rounded flex items-center gap-1.5",children:[S.jsx("span",{children:"←"}),S.jsx("span",{children:"Back"})]})}),S.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:p.length===0?S.jsx("div",{className:"p-3 text-sm text-muted",children:S.jsx("p",{children:"No archived stories."})}):p.map(W=>S.jsxs("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-surface",children:[S.jsx("span",{className:"text-sm font-medium truncate",title:W.name,children:W.title||W.name}),S.jsx("button",{onClick:()=>L(W.name),className:"text-xs text-accent hover:text-accent-dim flex-shrink-0 ml-2",children:"Restore"})]},W.name))})]}):S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs font-mono text-muted",children:"Stories"}),S.jsx("span",{className:"text-xs text-muted",children:c.length})]}),a&&S.jsx("div",{className:"px-3 py-2 border-b border-border",children:S.jsxs("button",{onClick:a,className:"w-full px-3 py-1.5 text-sm bg-accent text-white rounded hover:bg-accent-dim flex items-center justify-center gap-1.5",children:[S.jsx("span",{children:"+"}),S.jsx("span",{children:"New Story"})]})}),S.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[o.map(W=>S.jsx("div",{children:S.jsxs("button",{onClick:()=>s(W,""),className:`w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm ${t===W?"bg-surface":""}`,children:[S.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-600 flex-shrink-0"}),S.jsx("span",{className:"font-medium italic text-muted",children:"Untitled"})]})},W)),c.length===0&&o.length===0?S.jsxs("div",{className:"p-3 text-sm text-muted",children:[S.jsx("p",{children:"No stories yet."}),S.jsx("p",{className:"mt-1 text-xs",children:'Click "+ New Story" above to start writing.'})]}):c.filter(W=>W.name!=="_example").map(W=>S.jsxs("div",{children:[S.jsxs("button",{onClick:()=>I(W),className:"w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm",children:[S.jsx("span",{className:"text-xs text-muted",children:g.has(W.name)?"▼":"▶"}),S.jsx("span",{className:"font-medium truncate",title:W.name,children:W.title||W.name}),S.jsxs("span",{className:"ml-auto text-xs text-muted",children:[W.publishedCount,"/",W.files.length]})]}),g.has(W.name)&&S.jsx("div",{className:"pl-4",children:Q(W.files).map(O=>{const ie=t===W.name&&n===O.file;return S.jsxs("button",{onClick:()=>s(W.name,O.file),className:`w-full px-3 py-1.5 text-left flex items-center gap-2 text-xs hover:bg-surface ${ie?"bg-surface font-medium":""}`,children:[S.jsx("span",{className:Ox[O.status],children:zx[O.status]}),S.jsx("span",{className:"truncate font-mono",children:O.file})]},O.file)})})]},W.name))]}),S.jsx("div",{className:"px-3 py-2 border-t border-border",children:S.jsx("button",{onClick:()=>y(!0),className:"w-full px-3 py-1.5 text-xs text-muted hover:text-foreground hover:bg-surface rounded flex items-center justify-center gap-1.5",children:S.jsx("span",{children:"Archives"})})})]})}/** +`+u.stack}}var qn=Object.prototype.hasOwnProperty,mn=e.unstable_scheduleCallback,Wn=e.unstable_cancelCallback,Ma=e.unstable_shouldYield,Er=e.unstable_requestPaint,vt=e.unstable_now,_n=e.unstable_getCurrentPriorityLevel,ee=e.unstable_ImmediatePriority,ce=e.unstable_UserBlockingPriority,be=e.unstable_NormalPriority,le=e.unstable_LowPriority,me=e.unstable_IdlePriority,Te=e.log,Qe=e.unstable_setDisableYieldValue,nt=null,Je=null;function zt(i){if(typeof Te=="function"&&Qe(i),Je&&typeof Je.setStrictMode=="function")try{Je.setStrictMode(nt,i)}catch{}}var et=Math.clz32?Math.clz32:r0,Yn=Math.log,$i=Math.LN2;function r0(i){return i>>>=0,i===0?32:31-(Yn(i)/$i|0)|0}var Ba=256,Na=262144,La=4194304;function Tr(i){var r=i&42;if(r!==0)return r;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function za(i,r,l){var u=i.pendingLanes;if(u===0)return 0;var d=0,m=i.suspendedLanes,v=i.pingedLanes;i=i.warmLanes;var w=u&134217727;return w!==0?(u=w&~m,u!==0?d=Tr(u):(v&=w,v!==0?d=Tr(v):l||(l=w&~i,l!==0&&(d=Tr(l))))):(w=u&~m,w!==0?d=Tr(w):v!==0?d=Tr(v):l||(l=u&~i,l!==0&&(d=Tr(l)))),d===0?0:r!==0&&r!==d&&(r&m)===0&&(m=d&-d,l=r&-r,m>=l||m===32&&(l&4194048)!==0)?r:d}function rl(i,r){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&r)===0}function s0(i,r){switch(i){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Jd(){var i=La;return La<<=1,(La&62914560)===0&&(La=4194304),i}function Bu(i){for(var r=[],l=0;31>l;l++)r.push(i);return r}function sl(i,r){i.pendingLanes|=r,r!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function l0(i,r,l,u,d,m){var v=i.pendingLanes;i.pendingLanes=l,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=l,i.entangledLanes&=l,i.errorRecoveryDisabledLanes&=l,i.shellSuspendCounter=0;var w=i.entanglements,N=i.expirationTimes,q=i.hiddenUpdates;for(l=v&~l;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var f0=/[\n"\\]/g;function zi(i){return i.replace(f0,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Hu(i,r,l,u,d,m,v,w){i.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?i.type=v:i.removeAttribute("type"),r!=null?v==="number"?(r===0&&i.value===""||i.value!=r)&&(i.value=""+Li(r)):i.value!==""+Li(r)&&(i.value=""+Li(r)):v!=="submit"&&v!=="reset"||i.removeAttribute("value"),r!=null?Pu(i,v,Li(r)):l!=null?Pu(i,v,Li(l)):u!=null&&i.removeAttribute("value"),d==null&&m!=null&&(i.defaultChecked=!!m),d!=null&&(i.checked=d&&typeof d!="function"&&typeof d!="symbol"),w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?i.name=""+Li(w):i.removeAttribute("name")}function fp(i,r,l,u,d,m,v,w){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(i.type=m),r!=null||l!=null){if(!(m!=="submit"&&m!=="reset"||r!=null)){ju(i);return}l=l!=null?""+Li(l):"",r=r!=null?""+Li(r):l,w||r===i.value||(i.value=r),i.defaultValue=r}u=u??d,u=typeof u!="function"&&typeof u!="symbol"&&!!u,i.checked=w?i.checked:!!u,i.defaultChecked=!!u,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(i.name=v),ju(i)}function Pu(i,r,l){r==="number"&&Ha(i.ownerDocument)===i||i.defaultValue===""+l||(i.defaultValue=""+l)}function cs(i,r,l,u){if(i=i.options,r){r={};for(var d=0;d"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Wu=!1;if(yn)try{var ul={};Object.defineProperty(ul,"passive",{get:function(){Wu=!0}}),window.addEventListener("test",ul,ul),window.removeEventListener("test",ul,ul)}catch{Wu=!1}var Kn=null,Yu=null,Ua=null;function yp(){if(Ua)return Ua;var i,r=Yu,l=r.length,u,d="value"in Kn?Kn.value:Kn.textContent,m=d.length;for(i=0;i=fl),kp=" ",Ep=!1;function Tp(i,r){switch(i){case"keyup":return U0.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ap(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var ps=!1;function F0(i,r){switch(i){case"compositionend":return Ap(r);case"keypress":return r.which!==32?null:(Ep=!0,kp);case"textInput":return i=r.data,i===kp&&Ep?null:i;default:return null}}function q0(i,r){if(ps)return i==="compositionend"||!Gu&&Tp(i,r)?(i=yp(),Ua=Yu=Kn=null,ps=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1=r)return{node:l,offset:r-i};i=u}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Op(l)}}function Hp(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?Hp(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function Pp(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var r=Ha(i.document);r instanceof i.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)i=r.contentWindow;else break;r=Ha(i.document)}return r}function Ju(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}var Z0=yn&&"documentMode"in document&&11>=document.documentMode,ms=null,ec=null,_l=null,tc=!1;function Up(i,r,l){var u=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;tc||ms==null||ms!==Ha(u)||(u=ms,"selectionStart"in u&&Ju(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),_l&&ml(_l,u)||(_l=u,u=Lo(ec,"onSelect"),0>=v,d-=v,tn=1<<32-et(r)+d|l<Re?(Pe=ve,ve=null):Pe=ve.sibling;var qe=Y(P,ve,F[Re],ie);if(qe===null){ve===null&&(ve=Pe);break}i&&ve&&qe.alternate===null&&r(P,ve),z=m(qe,z,Re),Fe===null?ye=qe:Fe.sibling=qe,Fe=qe,ve=Pe}if(Re===F.length)return l(P,ve),Ue&&Sn(P,Re),ye;if(ve===null){for(;ReRe?(Pe=ve,ve=null):Pe=ve.sibling;var mr=Y(P,ve,qe.value,ie);if(mr===null){ve===null&&(ve=Pe);break}i&&ve&&mr.alternate===null&&r(P,ve),z=m(mr,z,Re),Fe===null?ye=mr:Fe.sibling=mr,Fe=mr,ve=Pe}if(qe.done)return l(P,ve),Ue&&Sn(P,Re),ye;if(ve===null){for(;!qe.done;Re++,qe=F.next())qe=ne(P,qe.value,ie),qe!==null&&(z=m(qe,z,Re),Fe===null?ye=qe:Fe.sibling=qe,Fe=qe);return Ue&&Sn(P,Re),ye}for(ve=u(ve);!qe.done;Re++,qe=F.next())qe=X(ve,P,Re,qe.value,ie),qe!==null&&(i&&qe.alternate!==null&&ve.delete(qe.key===null?Re:qe.key),z=m(qe,z,Re),Fe===null?ye=qe:Fe.sibling=qe,Fe=qe);return i&&ve.forEach(function(gx){return r(P,gx)}),Ue&&Sn(P,Re),ye}function Ge(P,z,F,ie){if(typeof F=="object"&&F!==null&&F.type===k&&F.key===null&&(F=F.props.children),typeof F=="object"&&F!==null){switch(F.$$typeof){case y:e:{for(var ye=F.key;z!==null;){if(z.key===ye){if(ye=F.type,ye===k){if(z.tag===7){l(P,z.sibling),ie=d(z,F.props.children),ie.return=P,P=ie;break e}}else if(z.elementType===ye||typeof ye=="object"&&ye!==null&&ye.$$typeof===ue&&Hr(ye)===z.type){l(P,z.sibling),ie=d(z,F.props),xl(ie,F),ie.return=P,P=ie;break e}l(P,z);break}else r(P,z);z=z.sibling}F.type===k?(ie=Nr(F.props.children,P.mode,ie,F.key),ie.return=P,P=ie):(ie=Ga(F.type,F.key,F.props,null,P.mode,ie),xl(ie,F),ie.return=P,P=ie)}return v(P);case x:e:{for(ye=F.key;z!==null;){if(z.key===ye)if(z.tag===4&&z.stateNode.containerInfo===F.containerInfo&&z.stateNode.implementation===F.implementation){l(P,z.sibling),ie=d(z,F.children||[]),ie.return=P,P=ie;break e}else{l(P,z);break}else r(P,z);z=z.sibling}ie=oc(F,P.mode,ie),ie.return=P,P=ie}return v(P);case ue:return F=Hr(F),Ge(P,z,F,ie)}if(R(F))return ge(P,z,F,ie);if(V(F)){if(ye=V(F),typeof ye!="function")throw Error(s(150));return F=ye.call(F),we(P,z,F,ie)}if(typeof F.then=="function")return Ge(P,z,no(F),ie);if(F.$$typeof===I)return Ge(P,z,Ja(P,F),ie);ro(P,F)}return typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint"?(F=""+F,z!==null&&z.tag===6?(l(P,z.sibling),ie=d(z,F),ie.return=P,P=ie):(l(P,z),ie=ac(F,P.mode,ie),ie.return=P,P=ie),v(P)):l(P,z)}return function(P,z,F,ie){try{Sl=0;var ye=Ge(P,z,F,ie);return Es=null,ye}catch(ve){if(ve===ks||ve===to)throw ve;var Fe=wi(29,ve,null,P.mode);return Fe.lanes=ie,Fe.return=P,Fe}finally{}}}var Ur=um(!0),cm=um(!1),Qn=!1;function bc(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Sc(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function Jn(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function er(i,r,l){var u=i.updateQueue;if(u===null)return null;if(u=u.shared,(We&2)!==0){var d=u.pending;return d===null?r.next=r:(r.next=d.next,d.next=r),u.pending=r,r=$a(i),Kp(i,null,l),r}return Xa(i,u,r,l),$a(i)}function wl(i,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194048)!==0)){var u=r.lanes;u&=i.pendingLanes,l|=u,r.lanes=l,tp(i,l)}}function xc(i,r){var l=i.updateQueue,u=i.alternate;if(u!==null&&(u=u.updateQueue,l===u)){var d=null,m=null;if(l=l.firstBaseUpdate,l!==null){do{var v={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};m===null?d=m=v:m=m.next=v,l=l.next}while(l!==null);m===null?d=m=r:m=m.next=r}else d=m=r;l={baseState:u.baseState,firstBaseUpdate:d,lastBaseUpdate:m,shared:u.shared,callbacks:u.callbacks},i.updateQueue=l;return}i=l.lastBaseUpdate,i===null?l.firstBaseUpdate=r:i.next=r,l.lastBaseUpdate=r}var wc=!1;function Cl(){if(wc){var i=Cs;if(i!==null)throw i}}function kl(i,r,l,u){wc=!1;var d=i.updateQueue;Qn=!1;var m=d.firstBaseUpdate,v=d.lastBaseUpdate,w=d.shared.pending;if(w!==null){d.shared.pending=null;var N=w,q=N.next;N.next=null,v===null?m=q:v.next=q,v=N;var J=i.alternate;J!==null&&(J=J.updateQueue,w=J.lastBaseUpdate,w!==v&&(w===null?J.firstBaseUpdate=q:w.next=q,J.lastBaseUpdate=N))}if(m!==null){var ne=d.baseState;v=0,J=q=N=null,w=m;do{var Y=w.lane&-536870913,X=Y!==w.lane;if(X?(He&Y)===Y:(u&Y)===Y){Y!==0&&Y===ws&&(wc=!0),J!==null&&(J=J.next={lane:0,tag:w.tag,payload:w.payload,callback:null,next:null});e:{var ge=i,we=w;Y=r;var Ge=l;switch(we.tag){case 1:if(ge=we.payload,typeof ge=="function"){ne=ge.call(Ge,ne,Y);break e}ne=ge;break e;case 3:ge.flags=ge.flags&-65537|128;case 0:if(ge=we.payload,Y=typeof ge=="function"?ge.call(Ge,ne,Y):ge,Y==null)break e;ne=_({},ne,Y);break e;case 2:Qn=!0}}Y=w.callback,Y!==null&&(i.flags|=64,X&&(i.flags|=8192),X=d.callbacks,X===null?d.callbacks=[Y]:X.push(Y))}else X={lane:Y,tag:w.tag,payload:w.payload,callback:w.callback,next:null},J===null?(q=J=X,N=ne):J=J.next=X,v|=Y;if(w=w.next,w===null){if(w=d.shared.pending,w===null)break;X=w,w=X.next,X.next=null,d.lastBaseUpdate=X,d.shared.pending=null}}while(!0);J===null&&(N=ne),d.baseState=N,d.firstBaseUpdate=q,d.lastBaseUpdate=J,m===null&&(d.shared.lanes=0),sr|=v,i.lanes=v,i.memoizedState=ne}}function hm(i,r){if(typeof i!="function")throw Error(s(191,i));i.call(r)}function fm(i,r){var l=i.callbacks;if(l!==null)for(i.callbacks=null,i=0;im?m:8;var v=T.T,w={};T.T=w,Fc(i,!1,r,l);try{var N=d(),q=T.S;if(q!==null&&q(w,N),N!==null&&typeof N=="object"&&typeof N.then=="function"){var J=l1(N,u);Al(i,r,J,Ai(i))}else Al(i,r,u,Ai(i))}catch(ne){Al(i,r,{then:function(){},status:"rejected",reason:ne},Ai())}finally{j.p=m,v!==null&&w.types!==null&&(v.types=w.types),T.T=v}}function f1(){}function Uc(i,r,l,u){if(i.tag!==5)throw Error(s(476));var d=Wm(i).queue;qm(i,d,r,H,l===null?f1:function(){return Ym(i),l(u)})}function Wm(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:H,baseState:H,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:kn,lastRenderedState:H},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:kn,lastRenderedState:l},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function Ym(i){var r=Wm(i);r.next===null&&(r=i.alternate.memoizedState),Al(i,r.next.queue,{},Ai())}function Ic(){return $t(Yl)}function Vm(){return bt().memoizedState}function Km(){return bt().memoizedState}function d1(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var l=Ai();i=Jn(l);var u=er(r,i,l);u!==null&&(vi(u,r,l),wl(u,r,l)),r={cache:_c()},i.payload=r;return}r=r.return}}function p1(i,r,l){var u=Ai();l={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},mo(i)?$m(r,l):(l=sc(i,r,l,u),l!==null&&(vi(l,i,u),Gm(l,r,u)))}function Xm(i,r,l){var u=Ai();Al(i,r,l,u)}function Al(i,r,l,u){var d={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(mo(i))$m(r,d);else{var m=i.alternate;if(i.lanes===0&&(m===null||m.lanes===0)&&(m=r.lastRenderedReducer,m!==null))try{var v=r.lastRenderedState,w=m(v,l);if(d.hasEagerState=!0,d.eagerState=w,xi(w,v))return Xa(i,r,d,0),tt===null&&Ka(),!1}catch{}finally{}if(l=sc(i,r,d,u),l!==null)return vi(l,i,u),Gm(l,r,u),!0}return!1}function Fc(i,r,l,u){if(u={lane:2,revertLane:bh(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},mo(i)){if(r)throw Error(s(479))}else r=sc(i,l,u,2),r!==null&&vi(r,i,2)}function mo(i){var r=i.alternate;return i===De||r!==null&&r===De}function $m(i,r){As=ao=!0;var l=i.pending;l===null?r.next=r:(r.next=l.next,l.next=r),i.pending=r}function Gm(i,r,l){if((l&4194048)!==0){var u=r.lanes;u&=i.pendingLanes,l|=u,r.lanes=l,tp(i,l)}}var Dl={readContext:$t,use:co,useCallback:dt,useContext:dt,useEffect:dt,useImperativeHandle:dt,useLayoutEffect:dt,useInsertionEffect:dt,useMemo:dt,useReducer:dt,useRef:dt,useState:dt,useDebugValue:dt,useDeferredValue:dt,useTransition:dt,useSyncExternalStore:dt,useId:dt,useHostTransitionStatus:dt,useFormState:dt,useActionState:dt,useOptimistic:dt,useMemoCache:dt,useCacheRefresh:dt};Dl.useEffectEvent=dt;var Zm={readContext:$t,use:co,useCallback:function(i,r){return li().memoizedState=[i,r===void 0?null:r],i},useContext:$t,useEffect:Lm,useImperativeHandle:function(i,r,l){l=l!=null?l.concat([i]):null,fo(4194308,4,Hm.bind(null,r,i),l)},useLayoutEffect:function(i,r){return fo(4194308,4,i,r)},useInsertionEffect:function(i,r){fo(4,2,i,r)},useMemo:function(i,r){var l=li();r=r===void 0?null:r;var u=i();if(Ir){zt(!0);try{i()}finally{zt(!1)}}return l.memoizedState=[u,r],u},useReducer:function(i,r,l){var u=li();if(l!==void 0){var d=l(r);if(Ir){zt(!0);try{l(r)}finally{zt(!1)}}}else d=r;return u.memoizedState=u.baseState=d,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:d},u.queue=i,i=i.dispatch=p1.bind(null,De,i),[u.memoizedState,i]},useRef:function(i){var r=li();return i={current:i},r.memoizedState=i},useState:function(i){i=zc(i);var r=i.queue,l=Xm.bind(null,De,r);return r.dispatch=l,[i.memoizedState,l]},useDebugValue:Hc,useDeferredValue:function(i,r){var l=li();return Pc(l,i,r)},useTransition:function(){var i=zc(!1);return i=qm.bind(null,De,i.queue,!0,!1),li().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,l){var u=De,d=li();if(Ue){if(l===void 0)throw Error(s(407));l=l()}else{if(l=r(),tt===null)throw Error(s(349));(He&127)!==0||vm(u,r,l)}d.memoizedState=l;var m={value:l,getSnapshot:r};return d.queue=m,Lm(bm.bind(null,u,m,i),[i]),u.flags|=2048,Rs(9,{destroy:void 0},ym.bind(null,u,m,l,r),null),l},useId:function(){var i=li(),r=tt.identifierPrefix;if(Ue){var l=nn,u=tn;l=(u&~(1<<32-et(u)-1)).toString(32)+l,r="_"+r+"R_"+l,l=oo++,0<\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof u.is=="string"?v.createElement("select",{is:u.is}):v.createElement("select"),u.multiple?m.multiple=!0:u.size&&(m.size=u.size);break;default:m=typeof u.is=="string"?v.createElement(d,{is:u.is}):v.createElement(d)}}m[Kt]=r,m[fi]=u;e:for(v=r.child;v!==null;){if(v.tag===5||v.tag===6)m.appendChild(v.stateNode);else if(v.tag!==4&&v.tag!==27&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===r)break e;for(;v.sibling===null;){if(v.return===null||v.return===r)break e;v=v.return}v.sibling.return=v.return,v=v.sibling}r.stateNode=m;e:switch(Zt(m,d,u),d){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&Tn(r)}}return at(r),ih(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,l),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==u&&Tn(r);else{if(typeof u!="string"&&r.stateNode===null)throw Error(s(166));if(i=de.current,Ss(r)){if(i=r.stateNode,l=r.memoizedProps,u=null,d=Xt,d!==null)switch(d.tag){case 27:case 5:u=d.memoizedProps}i[Kt]=r,i=!!(i.nodeValue===l||u!==null&&u.suppressHydrationWarning===!0||_g(i.nodeValue,l)),i||Gn(r,!0)}else i=zo(i).createTextNode(u),i[Kt]=r,r.stateNode=i}return at(r),null;case 31:if(l=r.memoizedState,i===null||i.memoizedState!==null){if(u=Ss(r),l!==null){if(i===null){if(!u)throw Error(s(318));if(i=r.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[Kt]=r}else Lr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;at(r),i=!1}else l=fc(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=l),i=!0;if(!i)return r.flags&256?(ki(r),r):(ki(r),null);if((r.flags&128)!==0)throw Error(s(558))}return at(r),null;case 13:if(u=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(d=Ss(r),u!==null&&u.dehydrated!==null){if(i===null){if(!d)throw Error(s(318));if(d=r.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(s(317));d[Kt]=r}else Lr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;at(r),d=!1}else d=fc(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=d),d=!0;if(!d)return r.flags&256?(ki(r),r):(ki(r),null)}return ki(r),(r.flags&128)!==0?(r.lanes=l,r):(l=u!==null,i=i!==null&&i.memoizedState!==null,l&&(u=r.child,d=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(d=u.alternate.memoizedState.cachePool.pool),m=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(m=u.memoizedState.cachePool.pool),m!==d&&(u.flags|=2048)),l!==i&&l&&(r.child.flags|=8192),bo(r,r.updateQueue),at(r),null);case 4:return Ee(),i===null&&Ch(r.stateNode.containerInfo),at(r),null;case 10:return wn(r.type),at(r),null;case 19:if(K(yt),u=r.memoizedState,u===null)return at(r),null;if(d=(r.flags&128)!==0,m=u.rendering,m===null)if(d)Ml(u,!1);else{if(pt!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(m=lo(i),m!==null){for(r.flags|=128,Ml(u,!1),i=m.updateQueue,r.updateQueue=i,bo(r,i),r.subtreeFlags=0,i=l,l=r.child;l!==null;)Xp(l,i),l=l.sibling;return C(yt,yt.current&1|2),Ue&&Sn(r,u.treeForkCount),r.child}i=i.sibling}u.tail!==null&&vt()>ko&&(r.flags|=128,d=!0,Ml(u,!1),r.lanes=4194304)}else{if(!d)if(i=lo(m),i!==null){if(r.flags|=128,d=!0,i=i.updateQueue,r.updateQueue=i,bo(r,i),Ml(u,!0),u.tail===null&&u.tailMode==="hidden"&&!m.alternate&&!Ue)return at(r),null}else 2*vt()-u.renderingStartTime>ko&&l!==536870912&&(r.flags|=128,d=!0,Ml(u,!1),r.lanes=4194304);u.isBackwards?(m.sibling=r.child,r.child=m):(i=u.last,i!==null?i.sibling=m:r.child=m,u.last=m)}return u.tail!==null?(i=u.tail,u.rendering=i,u.tail=i.sibling,u.renderingStartTime=vt(),i.sibling=null,l=yt.current,C(yt,d?l&1|2:l&1),Ue&&Sn(r,u.treeForkCount),i):(at(r),null);case 22:case 23:return ki(r),kc(),u=r.memoizedState!==null,i!==null?i.memoizedState!==null!==u&&(r.flags|=8192):u&&(r.flags|=8192),u?(l&536870912)!==0&&(r.flags&128)===0&&(at(r),r.subtreeFlags&6&&(r.flags|=8192)):at(r),l=r.updateQueue,l!==null&&bo(r,l.retryQueue),l=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(l=i.memoizedState.cachePool.pool),u=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),u!==l&&(r.flags|=2048),i!==null&&K(jr),null;case 24:return l=null,i!==null&&(l=i.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),wn(wt),at(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function y1(i,r){switch(cc(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return wn(wt),Ee(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return Ye(r),null;case 31:if(r.memoizedState!==null){if(ki(r),r.alternate===null)throw Error(s(340));Lr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(ki(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(s(340));Lr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return K(yt),null;case 4:return Ee(),null;case 10:return wn(r.type),null;case 22:case 23:return ki(r),kc(),i!==null&&K(jr),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return wn(wt),null;case 25:return null;default:return null}}function S_(i,r){switch(cc(r),r.tag){case 3:wn(wt),Ee();break;case 26:case 27:case 5:Ye(r);break;case 4:Ee();break;case 31:r.memoizedState!==null&&ki(r);break;case 13:ki(r);break;case 19:K(yt);break;case 10:wn(r.type);break;case 22:case 23:ki(r),kc(),i!==null&&K(jr);break;case 24:wn(wt)}}function Bl(i,r){try{var l=r.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var d=u.next;l=d;do{if((l.tag&i)===i){u=void 0;var m=l.create,v=l.inst;u=m(),v.destroy=u}l=l.next}while(l!==d)}}catch(w){Ke(r,r.return,w)}}function nr(i,r,l){try{var u=r.updateQueue,d=u!==null?u.lastEffect:null;if(d!==null){var m=d.next;u=m;do{if((u.tag&i)===i){var v=u.inst,w=v.destroy;if(w!==void 0){v.destroy=void 0,d=r;var N=l,q=w;try{q()}catch(J){Ke(d,N,J)}}}u=u.next}while(u!==m)}}catch(J){Ke(r,r.return,J)}}function x_(i){var r=i.updateQueue;if(r!==null){var l=i.stateNode;try{fm(r,l)}catch(u){Ke(i,i.return,u)}}}function w_(i,r,l){l.props=Fr(i.type,i.memoizedProps),l.state=i.memoizedState;try{l.componentWillUnmount()}catch(u){Ke(i,r,u)}}function Nl(i,r){try{var l=i.ref;if(l!==null){switch(i.tag){case 26:case 27:case 5:var u=i.stateNode;break;case 30:u=i.stateNode;break;default:u=i.stateNode}typeof l=="function"?i.refCleanup=l(u):l.current=u}}catch(d){Ke(i,r,d)}}function rn(i,r){var l=i.ref,u=i.refCleanup;if(l!==null)if(typeof u=="function")try{u()}catch(d){Ke(i,r,d)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(d){Ke(i,r,d)}else l.current=null}function C_(i){var r=i.type,l=i.memoizedProps,u=i.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":l.autoFocus&&u.focus();break e;case"img":l.src?u.src=l.src:l.srcSet&&(u.srcset=l.srcSet)}}catch(d){Ke(i,i.return,d)}}function nh(i,r,l){try{var u=i.stateNode;I1(u,i.type,l,r),u[fi]=r}catch(d){Ke(i,i.return,d)}}function k_(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&cr(i.type)||i.tag===4}function rh(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||k_(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&cr(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function sh(i,r,l){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(i,r):(r=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,r.appendChild(i),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=vn));else if(u!==4&&(u===27&&cr(i.type)&&(l=i.stateNode,r=null),i=i.child,i!==null))for(sh(i,r,l),i=i.sibling;i!==null;)sh(i,r,l),i=i.sibling}function So(i,r,l){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?l.insertBefore(i,r):l.appendChild(i);else if(u!==4&&(u===27&&cr(i.type)&&(l=i.stateNode),i=i.child,i!==null))for(So(i,r,l),i=i.sibling;i!==null;)So(i,r,l),i=i.sibling}function E_(i){var r=i.stateNode,l=i.memoizedProps;try{for(var u=i.type,d=r.attributes;d.length;)r.removeAttributeNode(d[0]);Zt(r,u,l),r[Kt]=i,r[fi]=l}catch(m){Ke(i,i.return,m)}}var An=!1,Et=!1,lh=!1,T_=typeof WeakSet=="function"?WeakSet:Set,jt=null;function b1(i,r){if(i=i.containerInfo,Th=Fo,i=Pp(i),Ju(i)){if("selectionStart"in i)var l={start:i.selectionStart,end:i.selectionEnd};else e:{l=(l=i.ownerDocument)&&l.defaultView||window;var u=l.getSelection&&l.getSelection();if(u&&u.rangeCount!==0){l=u.anchorNode;var d=u.anchorOffset,m=u.focusNode;u=u.focusOffset;try{l.nodeType,m.nodeType}catch{l=null;break e}var v=0,w=-1,N=-1,q=0,J=0,ne=i,Y=null;t:for(;;){for(var X;ne!==l||d!==0&&ne.nodeType!==3||(w=v+d),ne!==m||u!==0&&ne.nodeType!==3||(N=v+u),ne.nodeType===3&&(v+=ne.nodeValue.length),(X=ne.firstChild)!==null;)Y=ne,ne=X;for(;;){if(ne===i)break t;if(Y===l&&++q===d&&(w=v),Y===m&&++J===u&&(N=v),(X=ne.nextSibling)!==null)break;ne=Y,Y=ne.parentNode}ne=X}l=w===-1||N===-1?null:{start:w,end:N}}else l=null}l=l||{start:0,end:0}}else l=null;for(Ah={focusedElem:i,selectionRange:l},Fo=!1,jt=r;jt!==null;)if(r=jt,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,jt=i;else for(;jt!==null;){switch(r=jt,m=r.alternate,i=r.flags,r.tag){case 0:if((i&4)!==0&&(i=r.updateQueue,i=i!==null?i.events:null,i!==null))for(l=0;l title"))),Zt(m,u,l),m[Kt]=i,Ot(m),u=m;break e;case"link":var v=Ng("link","href",d).get(u+(l.href||""));if(v){for(var w=0;wGe&&(v=Ge,Ge=we,we=v);var P=jp(w,we),z=jp(w,Ge);if(P&&z&&(X.rangeCount!==1||X.anchorNode!==P.node||X.anchorOffset!==P.offset||X.focusNode!==z.node||X.focusOffset!==z.offset)){var F=ne.createRange();F.setStart(P.node,P.offset),X.removeAllRanges(),we>Ge?(X.addRange(F),X.extend(z.node,z.offset)):(F.setEnd(z.node,z.offset),X.addRange(F))}}}}for(ne=[],X=w;X=X.parentNode;)X.nodeType===1&&ne.push({element:X,left:X.scrollLeft,top:X.scrollTop});for(typeof w.focus=="function"&&w.focus(),w=0;wl?32:l,T.T=null,l=dh,dh=null;var m=ar,v=Nn;if(Rt=0,zs=ar=null,Nn=0,(We&6)!==0)throw Error(s(331));var w=We;if(We|=4,H_(m.current),z_(m,m.current,v,l),We=w,Pl(0,!1),Je&&typeof Je.onPostCommitFiberRoot=="function")try{Je.onPostCommitFiberRoot(nt,m)}catch{}return!0}finally{j.p=d,T.T=u,ig(i,r)}}function rg(i,r,l){r=ji(l,r),r=Vc(i.stateNode,r,2),i=er(i,r,2),i!==null&&(sl(i,2),sn(i))}function Ke(i,r,l){if(i.tag===3)rg(i,i,l);else for(;r!==null;){if(r.tag===3){rg(r,i,l);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(lr===null||!lr.has(u))){i=ji(l,i),l=s_(2),u=er(r,l,2),u!==null&&(l_(l,u,r,i),sl(u,2),sn(u));break}}r=r.return}}function gh(i,r,l){var u=i.pingCache;if(u===null){u=i.pingCache=new w1;var d=new Set;u.set(r,d)}else d=u.get(r),d===void 0&&(d=new Set,u.set(r,d));d.has(l)||(uh=!0,d.add(l),i=A1.bind(null,i,r,l),r.then(i,i))}function A1(i,r,l){var u=i.pingCache;u!==null&&u.delete(r),i.pingedLanes|=i.suspendedLanes&l,i.warmLanes&=~l,tt===i&&(He&l)===l&&(pt===4||pt===3&&(He&62914560)===He&&300>vt()-Co?(We&2)===0&&Os(i,0):ch|=l,Ls===He&&(Ls=0)),sn(i)}function sg(i,r){r===0&&(r=Jd()),i=Br(i,r),i!==null&&(sl(i,r),sn(i))}function D1(i){var r=i.memoizedState,l=0;r!==null&&(l=r.retryLane),sg(i,l)}function R1(i,r){var l=0;switch(i.tag){case 31:case 13:var u=i.stateNode,d=i.memoizedState;d!==null&&(l=d.retryLane);break;case 19:u=i.stateNode;break;case 22:u=i.stateNode._retryCache;break;default:throw Error(s(314))}u!==null&&u.delete(r),sg(i,l)}function M1(i,r){return mn(i,r)}var Mo=null,Hs=null,vh=!1,Bo=!1,yh=!1,ur=0;function sn(i){i!==Hs&&i.next===null&&(Hs===null?Mo=Hs=i:Hs=Hs.next=i),Bo=!0,vh||(vh=!0,N1())}function Pl(i,r){if(!yh&&Bo){yh=!0;do for(var l=!1,u=Mo;u!==null;){if(i!==0){var d=u.pendingLanes;if(d===0)var m=0;else{var v=u.suspendedLanes,w=u.pingedLanes;m=(1<<31-et(42|i)+1)-1,m&=d&~(v&~w),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(l=!0,ug(u,m))}else m=He,m=za(u,u===tt?m:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(m&3)===0||rl(u,m)||(l=!0,ug(u,m));u=u.next}while(l);yh=!1}}function B1(){lg()}function lg(){Bo=vh=!1;var i=0;ur!==0&&q1()&&(i=ur);for(var r=vt(),l=null,u=Mo;u!==null;){var d=u.next,m=ag(u,r);m===0?(u.next=null,l===null?Mo=d:l.next=d,d===null&&(Hs=l)):(l=u,(i!==0||(m&3)!==0)&&(Bo=!0)),u=d}Rt!==0&&Rt!==5||Pl(i),ur!==0&&(ur=0)}function ag(i,r){for(var l=i.suspendedLanes,u=i.pingedLanes,d=i.expirationTimes,m=i.pendingLanes&-62914561;0w)break;var J=N.transferSize,ne=N.initiatorType;J&&gg(ne)&&(N=N.responseEnd,v+=J*(N"u"?null:document;function Dg(i,r,l){var u=Ps;if(u&&typeof r=="string"&&r){var d=zi(r);d='link[rel="'+i+'"][href="'+d+'"]',typeof l=="string"&&(d+='[crossorigin="'+l+'"]'),Ag.has(d)||(Ag.add(d),i={rel:i,crossOrigin:l,href:r},u.querySelector(d)===null&&(r=u.createElement("link"),Zt(r,"link",i),Ot(r),u.head.appendChild(r)))}}function Q1(i){Ln.D(i),Dg("dns-prefetch",i,null)}function J1(i,r){Ln.C(i,r),Dg("preconnect",i,r)}function ex(i,r,l){Ln.L(i,r,l);var u=Ps;if(u&&i&&r){var d='link[rel="preload"][as="'+zi(r)+'"]';r==="image"&&l&&l.imageSrcSet?(d+='[imagesrcset="'+zi(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(d+='[imagesizes="'+zi(l.imageSizes)+'"]')):d+='[href="'+zi(i)+'"]';var m=d;switch(r){case"style":m=Us(i);break;case"script":m=Is(i)}qi.has(m)||(i=_({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:i,as:r},l),qi.set(m,i),u.querySelector(d)!==null||r==="style"&&u.querySelector(ql(m))||r==="script"&&u.querySelector(Wl(m))||(r=u.createElement("link"),Zt(r,"link",i),Ot(r),u.head.appendChild(r)))}}function tx(i,r){Ln.m(i,r);var l=Ps;if(l&&i){var u=r&&typeof r.as=="string"?r.as:"script",d='link[rel="modulepreload"][as="'+zi(u)+'"][href="'+zi(i)+'"]',m=d;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=Is(i)}if(!qi.has(m)&&(i=_({rel:"modulepreload",href:i},r),qi.set(m,i),l.querySelector(d)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Wl(m)))return}u=l.createElement("link"),Zt(u,"link",i),Ot(u),l.head.appendChild(u)}}}function ix(i,r,l){Ln.S(i,r,l);var u=Ps;if(u&&i){var d=os(u).hoistableStyles,m=Us(i);r=r||"default";var v=d.get(m);if(!v){var w={loading:0,preload:null};if(v=u.querySelector(ql(m)))w.loading=5;else{i=_({rel:"stylesheet",href:i,"data-precedence":r},l),(l=qi.get(m))&&zh(i,l);var N=v=u.createElement("link");Ot(N),Zt(N,"link",i),N._p=new Promise(function(q,J){N.onload=q,N.onerror=J}),N.addEventListener("load",function(){w.loading|=1}),N.addEventListener("error",function(){w.loading|=2}),w.loading|=4,jo(v,r,u)}v={type:"stylesheet",instance:v,count:1,state:w},d.set(m,v)}}}function nx(i,r){Ln.X(i,r);var l=Ps;if(l&&i){var u=os(l).hoistableScripts,d=Is(i),m=u.get(d);m||(m=l.querySelector(Wl(d)),m||(i=_({src:i,async:!0},r),(r=qi.get(d))&&Oh(i,r),m=l.createElement("script"),Ot(m),Zt(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(d,m))}}function rx(i,r){Ln.M(i,r);var l=Ps;if(l&&i){var u=os(l).hoistableScripts,d=Is(i),m=u.get(d);m||(m=l.querySelector(Wl(d)),m||(i=_({src:i,async:!0,type:"module"},r),(r=qi.get(d))&&Oh(i,r),m=l.createElement("script"),Ot(m),Zt(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(d,m))}}function Rg(i,r,l,u){var d=(d=de.current)?Oo(d):null;if(!d)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(r=Us(l.href),l=os(d).hoistableStyles,u=l.get(r),u||(u={type:"style",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){i=Us(l.href);var m=os(d).hoistableStyles,v=m.get(i);if(v||(d=d.ownerDocument||d,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(i,v),(m=d.querySelector(ql(i)))&&!m._p&&(v.instance=m,v.state.loading=5),qi.has(i)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},qi.set(i,l),m||sx(d,i,l,v.state))),r&&u===null)throw Error(s(528,""));return v}if(r&&u!==null)throw Error(s(529,""));return null;case"script":return r=l.async,l=l.src,typeof l=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Is(l),l=os(d).hoistableScripts,u=l.get(r),u||(u={type:"script",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,i))}}function Us(i){return'href="'+zi(i)+'"'}function ql(i){return'link[rel="stylesheet"]['+i+"]"}function Mg(i){return _({},i,{"data-precedence":i.precedence,precedence:null})}function sx(i,r,l,u){i.querySelector('link[rel="preload"][as="style"]['+r+"]")?u.loading=1:(r=i.createElement("link"),u.preload=r,r.addEventListener("load",function(){return u.loading|=1}),r.addEventListener("error",function(){return u.loading|=2}),Zt(r,"link",l),Ot(r),i.head.appendChild(r))}function Is(i){return'[src="'+zi(i)+'"]'}function Wl(i){return"script[async]"+i}function Bg(i,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var u=i.querySelector('style[data-href~="'+zi(l.href)+'"]');if(u)return r.instance=u,Ot(u),u;var d=_({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return u=(i.ownerDocument||i).createElement("style"),Ot(u),Zt(u,"style",d),jo(u,l.precedence,i),r.instance=u;case"stylesheet":d=Us(l.href);var m=i.querySelector(ql(d));if(m)return r.state.loading|=4,r.instance=m,Ot(m),m;u=Mg(l),(d=qi.get(d))&&zh(u,d),m=(i.ownerDocument||i).createElement("link"),Ot(m);var v=m;return v._p=new Promise(function(w,N){v.onload=w,v.onerror=N}),Zt(m,"link",u),r.state.loading|=4,jo(m,l.precedence,i),r.instance=m;case"script":return m=Is(l.src),(d=i.querySelector(Wl(m)))?(r.instance=d,Ot(d),d):(u=l,(d=qi.get(m))&&(u=_({},l),Oh(u,d)),i=i.ownerDocument||i,d=i.createElement("script"),Ot(d),Zt(d,"link",u),i.head.appendChild(d),r.instance=d);case"void":return null;default:throw Error(s(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(u=r.instance,r.state.loading|=4,jo(u,l.precedence,i));return r.instance}function jo(i,r,l){for(var u=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=u.length?u[u.length-1]:null,m=d,v=0;v title"):null)}function lx(i,r,l){if(l===1||r.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return i=r.disabled,typeof r.precedence=="string"&&i==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function zg(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function ax(i,r,l,u){if(l.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var d=Us(u.href),m=r.querySelector(ql(d));if(m){r=m._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=Po.bind(i),r.then(i,i)),l.state.loading|=4,l.instance=m,Ot(m);return}m=r.ownerDocument||r,u=Mg(u),(d=qi.get(d))&&zh(u,d),m=m.createElement("link"),Ot(m);var v=m;v._p=new Promise(function(w,N){v.onload=w,v.onerror=N}),Zt(m,"link",u),l.instance=m}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(l,r),(r=l.state.preload)&&(l.state.loading&3)===0&&(i.count++,l=Po.bind(i),r.addEventListener("load",l),r.addEventListener("error",l))}}var jh=0;function ox(i,r){return i.stylesheets&&i.count===0&&Io(i,i.stylesheets),0jh?50:800)+r);return i.unsuspend=l,function(){i.unsuspend=null,clearTimeout(u),clearTimeout(d)}}:null}function Po(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Io(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Uo=null;function Io(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Uo=new Map,r.forEach(ux,i),Uo=null,Po.call(i))}function ux(i,r){if(!(r.state.loading&4)){var l=Uo.get(i);if(l)var u=l.get(null);else{l=new Map,Uo.set(i,l);for(var d=i.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Vh.exports=Ex(),Vh.exports}var Ax=Tx();const Dx=xu(Ax);function Rx({onLogin:e}){const[t,n]=$.useState(""),[s,a]=$.useState(null),[o,c]=$.useState(!1),f=async p=>{if(p.preventDefault(),!t.trim())return;c(!0),a(null);const h=await e(t);h&&a(h),c(!1)};return S.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:S.jsxs("div",{className:"w-full max-w-sm",children:[S.jsxs("div",{className:"border-border rounded border p-6",children:[S.jsxs("div",{className:"mb-6 text-center",children:[S.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),S.jsx("p",{className:"text-muted mt-1 text-xs",children:"local writer agent"})]}),S.jsxs("form",{onSubmit:f,className:"space-y-4",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),S.jsx("input",{type:"password",value:t,onChange:p=>n(p.target.value),placeholder:"enter your passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),s&&S.jsx("p",{className:"text-error text-xs",children:s}),S.jsx("button",{type:"submit",disabled:o||!t.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:o?"authenticating...":"unlock"})]})]}),S.jsx("p",{className:"text-muted mt-4 text-center text-[10px]",children:"enter your passphrase to unlock"})]})})}function Mx({onSetup:e}){const[t,n]=$.useState(""),[s,a]=$.useState(""),[o,c]=$.useState(null),[f,p]=$.useState(!1),h=async g=>{if(g.preventDefault(),!t.trim()||t.length<4){c("Passphrase must be at least 4 characters");return}if(t!==s){c("Passphrases do not match");return}p(!0),c(null);const _=await e(t);_&&c(_),p(!1)};return S.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:S.jsx("div",{className:"w-full max-w-sm",children:S.jsxs("div",{className:"border-border rounded border p-6",children:[S.jsxs("div",{className:"mb-6 text-center",children:[S.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),S.jsx("p",{className:"text-muted mt-1 text-xs",children:"first-time setup"})]}),S.jsx("p",{className:"text-muted mb-4 text-xs leading-relaxed",children:"Choose a passphrase to protect your local writer agent. This will be used to unlock the app and secure your OWS wallet."}),S.jsxs("form",{onSubmit:h,className:"space-y-4",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),S.jsx("input",{type:"password",value:t,onChange:g=>n(g.target.value),placeholder:"choose a passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Confirm"}),S.jsx("input",{type:"password",value:s,onChange:g=>a(g.target.value),placeholder:"repeat passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),o&&S.jsx("p",{className:"text-error text-xs",children:o}),S.jsx("button",{type:"submit",disabled:f||!t.trim()||!s.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:f?"setting up...":"create passphrase"})]})]})})})}const sv="http://localhost:7777";function eb({token:e}){const[t,n]=$.useState(null),[s,a]=$.useState(!1),[o,c]=$.useState(!1),[f,p]=$.useState(null),h=(x,k)=>fetch(x,{...k,headers:{...k==null?void 0:k.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),g=()=>{h(`${sv}/api/wallet`).then(x=>x.json()).then(x=>n(x)).catch(()=>n({exists:!1,error:"Failed to load wallet"}))};$.useEffect(()=>{g()},[]);const _=async()=>{a(!0),p(null);try{const x=await h(`${sv}/api/wallet/create`,{method:"POST"}),k=await x.json();if(!x.ok)throw new Error(k.error||"Creation failed");g()}catch(x){p(x instanceof Error?x.message:"Failed to create wallet")}a(!1)},b=()=>{t!=null&&t.address&&(navigator.clipboard.writeText(t.address),c(!0),setTimeout(()=>c(!1),2e3))},y=x=>`${x.slice(0,6)}...${x.slice(-4)}`;return S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"OWS Wallet"}),!t&&S.jsx("p",{className:"text-muted text-xs",children:"loading..."}),t&&!t.exists&&S.jsxs("div",{className:"space-y-3",children:[S.jsx("p",{className:"text-muted text-xs",children:"No wallet created yet. Create one to enable autonomous transactions."}),f&&S.jsx("p",{className:"text-error text-xs",children:f}),S.jsx("button",{onClick:_,disabled:s,className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 rounded border px-4 py-2 text-xs font-medium transition-colors",children:s?"creating...":"create wallet"})]}),t&&t.exists&&t.address&&S.jsxs("div",{className:"space-y-3",children:[S.jsxs("div",{className:"flex items-center justify-between",children:[S.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"Address (Base)"}),S.jsx("span",{className:`rounded border px-1.5 py-0.5 text-[9px] ${t.ethBalance&&parseFloat(t.ethBalance)>0?"border-accent/30 text-accent":"border-accent-dim/30 text-accent-dim"}`,children:t.ethBalance&&parseFloat(t.ethBalance)>0?"active":"no balance"})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("code",{className:"text-foreground bg-surface rounded px-2 py-1 text-xs font-mono",children:y(t.address)}),S.jsx("button",{onClick:b,className:"text-muted hover:text-accent text-xs transition-colors",children:o?"copied":"copy"})]}),S.jsxs("div",{className:"border-border space-y-1 border-t pt-3",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"ETH"}),S.jsxs("span",{className:"text-foreground font-medium",children:[t.ethBalance||"0.000000"," ETH"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"USDC"}),S.jsxs("span",{className:"text-foreground font-medium",children:["$",t.usdcBalance||"0.00"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"PLOT"}),S.jsxs("span",{className:"text-foreground font-medium",children:[t.plotBalance||"0.0000"," PLOT"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Network"}),S.jsx("span",{className:"text-foreground",children:"Base"})]})]}),S.jsxs("div",{className:"border-border border-t pt-3",children:[S.jsx("p",{className:"text-muted mb-2 text-[10px] font-medium uppercase tracking-wider",children:"Fund Wallet"}),S.jsx("p",{className:"text-muted text-[10px]",children:"Send ETH on Base for gas (~$0.01 per publish):"}),S.jsx("code",{className:"text-foreground bg-surface mt-1 block break-all rounded px-2 py-1.5 text-[10px] font-mono",children:t.address})]})]})]})}function Bx({token:e,onLogout:t}){const[n,s]=$.useState(""),[a,o]=$.useState(""),[c,f]=$.useState(null),[p,h]=$.useState(!1),[g,_]=$.useState(!1),[b,y]=$.useState(null),[x,k]=$.useState("AI Writer"),[L,M]=$.useState(""),[G,I]=$.useState(""),[Z,W]=$.useState(!1),[O,te]=$.useState(null),[ue,_e]=$.useState(""),[U,se]=$.useState(null),[V,B]=$.useState(!1),[A,R]=$.useState(null),[T,j]=$.useState(null),H=$.useCallback((C,Q)=>fetch(C,{...Q,headers:{...Q==null?void 0:Q.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]);$.useEffect(()=>{H("/api/settings/link-status").then(C=>C.json()).then(C=>y(C)).catch(()=>y({linked:!1}))},[]);const ae=async()=>{if(!x.trim()){te("Agent name is required");return}if(!L.trim()){te("Description is required");return}W(!0),te(null);try{const C=await H("/api/settings/register-agent",{method:"POST",body:JSON.stringify({name:x,description:L,...G.trim()&&{genre:G}})}),Q=await C.json();if(!C.ok)throw new Error(Q.error||"Registration failed");y({linked:!0,agentId:Q.agentId,owsWallet:Q.owsWallet,txHash:Q.txHash})}catch(C){te(C instanceof Error?C.message:"Registration failed")}W(!1)},E=async()=>{if(!ue.trim()||!/^0x[a-fA-F0-9]{40}$/.test(ue)){R("Enter a valid wallet address (0x...)");return}B(!0),R(null),se(null);try{const C=await H("/api/settings/generate-binding",{method:"POST",body:JSON.stringify({humanWallet:ue})}),Q=await C.json();if(!C.ok)throw new Error(Q.error||"Failed to generate binding code");se(Q)}catch(C){R(C instanceof Error?C.message:"Failed to generate binding code")}B(!1)},D=async(C,Q)=>{await navigator.clipboard.writeText(C),j(Q),setTimeout(()=>j(null),2e3)},K=async()=>{if(f(null),h(!1),!n||n.length<4){f("Passphrase must be at least 4 characters");return}if(n!==a){f("Passphrases do not match");return}_(!0);try{const C=await H("/api/auth/reset-passphrase",{method:"POST",body:JSON.stringify({passphrase:n})});if(!C.ok){const Q=await C.json();throw new Error(Q.error||"Reset failed")}h(!0),s(""),o(""),setTimeout(()=>h(!1),3e3)}catch(C){f(C instanceof Error?C.message:"Reset failed")}_(!1)};return S.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-6",children:[S.jsx("h2",{className:"text-accent text-lg font-bold",children:"Settings"}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Identity"}),b!=null&&b.linked?S.jsxs("div",{className:"space-y-2",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"text-sm font-medium text-accent",children:"Registered"}),S.jsxs("span",{className:"text-muted text-xs",children:["Agent #",b.agentId]})]}),b.owsWallet&&S.jsxs("p",{className:"text-muted text-xs font-mono",children:["Wallet: ",b.owsWallet.slice(0,6),"...",b.owsWallet.slice(-4)]}),b.owner&&S.jsxs("p",{className:"text-muted text-xs font-mono",children:["Owner: ",b.owner.slice(0,6),"...",b.owner.slice(-4)]}),b.txHash&&S.jsx("p",{className:"text-muted text-xs",children:S.jsx("a",{href:`https://basescan.org/tx/${b.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View transaction on BaseScan"})}),S.jsx("p",{className:"text-muted text-xs",children:S.jsx("a",{href:`https://plotlink.xyz/profile/${b.owsWallet}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View agent profile on plotlink.xyz"})})]}):S.jsxs("div",{className:"space-y-3",children:[S.jsx("p",{className:"text-muted text-xs",children:"Register this AI writer on-chain via ERC-8004. Uses your OWS wallet's existing ETH balance for gas."}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Name"}),S.jsx("input",{value:x,onChange:C=>k(C.target.value),placeholder:"AI Writer",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Description"}),S.jsx("input",{value:L,onChange:C=>M(C.target.value),placeholder:"An AI writing assistant for fiction stories",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Genre (optional)"}),S.jsx("input",{value:G,onChange:C=>I(C.target.value),placeholder:"e.g. Fiction, Sci-Fi, Fantasy",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),O&&S.jsx("p",{className:"text-error text-xs",children:O}),S.jsx("button",{onClick:ae,disabled:Z||!x.trim()||!L.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:Z?"Registering...":"Register Agent Identity"})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Link to PlotLink"}),b!=null&&b.owner?S.jsxs("p",{className:"text-muted text-xs",children:["Linked to owner ",S.jsxs("span",{className:"font-mono",children:[b.owner.slice(0,6),"...",b.owner.slice(-4)]})]}):S.jsxs("div",{className:"space-y-3",children:[S.jsx("p",{className:"text-muted text-xs",children:"Link this OWS wallet to your PlotLink account so your stories appear under your profile on plotlink.xyz."}),S.jsxs("div",{className:"text-muted text-xs space-y-1 pl-3",children:[S.jsx("p",{children:"1. Enter your PlotLink wallet address below"}),S.jsx("p",{children:'2. Click "Generate Binding Code"'}),S.jsx("p",{children:"3. Copy the code and paste it on plotlink.xyz → Agents → Link AI Writer"})]}),S.jsx("input",{value:ue,onChange:C=>_e(C.target.value),placeholder:"Your PlotLink wallet address (0x...)",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent font-mono"}),A&&S.jsx("p",{className:"text-error text-xs",children:A}),S.jsx("button",{onClick:E,disabled:V||!ue.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:V?"Generating...":"Generate Binding Code"}),U&&S.jsxs("div",{className:"space-y-3 mt-3",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Binding Code (signature)"}),S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:U.signature}),S.jsx("button",{onClick:()=>D(U.signature,"signature"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:T==="signature"?"Copied!":"Copy"})]})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"OWS Wallet Address"}),S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:U.owsWallet}),S.jsx("button",{onClick:()=>D(U.owsWallet,"wallet"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:T==="wallet"?"Copied!":"Copy"})]})]}),U.agentId&&S.jsxs("div",{children:[S.jsx("label",{className:"text-muted text-xs block mb-1",children:"Agent ID"}),S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono text-foreground pr-16",children:U.agentId}),S.jsx("button",{onClick:()=>D(String(U.agentId),"agentId"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:T==="agentId"?"Copied!":"Copy"})]})]}),S.jsx("p",{className:"text-xs text-accent",children:'Now go to plotlink.xyz/agents and paste the values in the "Link AI Writer" section.'})]})]})]}),S.jsx(eb,{token:e}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Reset Passphrase"}),S.jsxs("div",{className:"space-y-3",children:[S.jsx("input",{type:"password",value:n,onChange:C=>s(C.target.value),placeholder:"new passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),S.jsx("input",{type:"password",value:a,onChange:C=>o(C.target.value),placeholder:"confirm passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),c&&S.jsx("p",{className:"text-error text-xs",children:c}),p&&S.jsx("p",{className:"text-xs text-accent",children:"passphrase updated"}),S.jsx("button",{onClick:K,disabled:g||!n.trim(),className:"border-border text-muted hover:border-accent hover:text-accent disabled:opacity-40 w-full rounded border px-4 py-2 text-xs font-medium transition-colors",children:g?"updating...":"update passphrase"})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Session"}),S.jsx("button",{onClick:t,className:"border-border text-muted hover:border-error hover:text-error rounded border px-4 py-2 text-xs font-medium transition-colors",children:"logout"})]})]})}const Nx="http://localhost:7777";function Lx({token:e}){const[t,n]=$.useState(null),s=(f,p)=>fetch(f,{...p,headers:{...p==null?void 0:p.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),a=()=>{s(`${Nx}/api/dashboard`).then(f=>f.json()).then(n)};$.useEffect(()=>{a()},[]);const o=f=>`${f.slice(0,6)}...${f.slice(-4)}`,c=f=>{if(!f)return"Unknown date";const p=new Date(f);return isNaN(p.getTime())?"Unknown date":p.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})};return t?S.jsxs("div",{className:"mx-auto max-w-2xl space-y-6 p-6",children:[S.jsx("h2",{className:"text-accent text-lg font-bold",children:"Writer Dashboard"}),S.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-accent text-lg font-bold",children:t.stories.totalPublished}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"published"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.pendingFiles}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"pending"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalStories}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"stories"})]}),S.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[S.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalFiles}),S.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"files"})]})]}),t.wallet&&S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Wallet"}),S.jsxs("div",{className:"space-y-1.5",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Address"}),S.jsx("code",{className:"text-foreground font-mono text-[10px]",children:o(t.wallet.address)})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"ETH Balance"}),S.jsxs("span",{className:"text-foreground",children:[t.wallet.ethFormatted," ETH"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"USDC Balance"}),S.jsxs("span",{className:"text-foreground",children:["$",t.wallet.usdcBalance]})]})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Profit & Loss"}),S.jsxs("div",{className:"space-y-1.5",children:[S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Total costs (gas)"}),S.jsxs("span",{className:"text-error",children:["-",t.pnl.totalCostsEth," ETH (~$",t.pnl.totalCostsUsd,")"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Royalties earned"}),S.jsxs("span",{className:"text-accent",children:["+",t.pnl.totalRoyaltiesPlot," PLOT"]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Unclaimed royalties"}),S.jsxs("span",{className:"text-foreground",children:[t.royalties.unclaimed," PLOT"]})]}),S.jsxs("div",{className:"border-border flex justify-between border-t pt-1.5 text-xs font-medium",children:[S.jsx("span",{className:"text-muted",children:"Net P&L (USD)"}),S.jsxs("span",{className:parseFloat(t.pnl.netPnlUsd)>=0?"text-accent":"text-error",children:[parseFloat(t.pnl.netPnlUsd)>=0?"+":"","$",t.pnl.netPnlUsd]})]}),S.jsxs("div",{className:"flex justify-between text-xs",children:[S.jsx("span",{className:"text-muted",children:"Stories published"}),S.jsx("span",{className:"text-foreground",children:t.costs.storiesPublished})]})]})]}),S.jsxs("div",{className:"border-border rounded border p-4",children:[S.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Published Stories"}),t.stories.published.length===0?S.jsx("p",{className:"text-muted text-xs",children:"no published stories yet"}):S.jsx("div",{className:"space-y-3",children:t.stories.published.map(f=>S.jsxs("div",{className:"bg-surface rounded border border-border p-4",children:[S.jsxs("div",{className:"flex items-start justify-between",children:[S.jsxs("div",{children:[f.genre&&S.jsx("span",{className:"bg-accent/10 text-accent rounded px-2 py-0.5 text-[10px] font-medium",children:f.genre}),S.jsx("h4",{className:"text-foreground mt-1 text-sm font-serif font-medium",children:f.title}),S.jsx("p",{className:"text-muted mt-0.5 text-[10px] font-mono",children:f.storyName})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[f.hasNotIndexed&&S.jsx("span",{className:"rounded border border-amber-600/30 px-1.5 py-0.5 text-[9px] text-amber-700",children:"not indexed"}),S.jsxs("span",{className:"rounded border border-green-700/30 px-1.5 py-0.5 text-[9px] text-green-700",children:[f.publishedFiles," published"]})]})]}),S.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-center",children:[S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium",children:f.plotCount}),S.jsx("div",{className:"text-muted text-[9px]",children:"Plots"})]}),S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium font-mono",children:f.storylineId?`#${f.storylineId}`:"—"}),S.jsx("div",{className:"text-muted text-[9px]",children:"Storyline"})]}),S.jsxs("div",{className:"rounded bg-background p-1.5",children:[S.jsx("div",{className:"text-foreground text-sm font-medium",children:f.totalGasCostEth??"—"}),S.jsx("div",{className:"text-muted text-[9px]",children:"Gas (ETH)"})]})]}),S.jsx("div",{className:"mt-2 space-y-1",children:f.files.map(p=>S.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[S.jsxs("div",{className:"flex items-center gap-1.5",children:[S.jsx("span",{className:p.status==="published-not-indexed"?"text-amber-700":"text-green-700",children:p.status==="published-not-indexed"?"⚠":"✓"}),S.jsx("span",{className:"text-muted font-mono",children:p.file})]}),p.txHash&&S.jsxs("a",{href:`https://basescan.org/tx/${p.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-accent font-mono",children:["tx:",p.txHash.slice(0,8),"..."]})]},p.file))}),S.jsxs("div",{className:"mt-2 flex items-center justify-between text-[10px]",children:[S.jsx("span",{className:"text-muted",children:c(f.latestPublishedAt)}),f.storylineId&&S.jsx("a",{href:`https://plotlink.xyz/story/${f.storylineId}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"})]})]},f.id))})]}),t.stories.pendingFiles>0&&S.jsx("div",{className:"border-border rounded border p-4",children:S.jsxs("p",{className:"text-muted text-xs",children:[t.stories.pendingFiles," file(s) pending publish — go to Stories to publish them."]})})]}):S.jsx("div",{className:"flex h-full items-center justify-center",children:S.jsx("span",{className:"text-muted text-sm",children:"loading dashboard..."})})}const zx={published:"✓","published-not-indexed":"⚠",pending:"⏳",draft:"📝"},Ox={published:"text-green-700","published-not-indexed":"text-amber-700",pending:"text-amber-700",draft:"text-muted"};function jx({authFetch:e,selectedStory:t,selectedFile:n,onSelectFile:s,onNewStory:a,untitledSessions:o=[]}){const[c,f]=$.useState([]),[p,h]=$.useState([]),[g,_]=$.useState(new Set),[b,y]=$.useState(!1),x=$.useCallback(async()=>{try{const W=await e("/api/stories");if(W.ok){const O=await W.json();f(O.stories)}}catch{}},[e]),k=$.useCallback(async()=>{try{const W=await e("/api/stories/archived");if(W.ok){const O=await W.json();h(O.stories)}}catch{}},[e]),L=$.useCallback(async W=>{try{(await e("/api/stories/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:W})})).ok&&(k(),x())}catch{}},[e,k,x]);$.useEffect(()=>{x();const W=setInterval(x,5e3);return()=>clearInterval(W)},[x]),$.useEffect(()=>{b&&k()},[b,k]),$.useEffect(()=>{t&&_(W=>new Set(W).add(t))},[t]);const M=W=>{var te;const O=W.map(ue=>{var _e;return{file:ue.file,num:(_e=ue.file.match(/^plot-(\d+)\.md$/))==null?void 0:_e[1]}}).filter(ue=>ue.num!=null).sort((ue,_e)=>parseInt(_e.num)-parseInt(ue.num));return O.length>0?O[0].file:W.some(ue=>ue.file==="genesis.md")?"genesis.md":W.some(ue=>ue.file==="structure.md")?"structure.md":((te=W[0])==null?void 0:te.file)??null},G=W=>{_(O=>{const te=new Set(O);return te.has(W)?te.delete(W):te.add(W),te})},I=W=>{if(G(W.name),!g.has(W.name)){const O=M(W.files);O&&s(W.name,O)}},Z=W=>{const O=te=>{if(te==="structure.md")return 0;if(te==="genesis.md")return 1;const ue=te.match(/^plot-(\d+)\.md$/);return ue?2+parseInt(ue[1]):100};return[...W].sort((te,ue)=>O(te.file)-O(ue.file))};return b?S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs font-mono text-muted",children:"Archives"}),S.jsx("span",{className:"text-xs text-muted",children:p.length})]}),S.jsx("div",{className:"px-3 py-2 border-b border-border",children:S.jsxs("button",{onClick:()=>y(!1),className:"w-full px-3 py-1.5 text-sm text-muted hover:text-foreground hover:bg-surface rounded flex items-center gap-1.5",children:[S.jsx("span",{children:"←"}),S.jsx("span",{children:"Back"})]})}),S.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:p.length===0?S.jsx("div",{className:"p-3 text-sm text-muted",children:S.jsx("p",{children:"No archived stories."})}):p.map(W=>S.jsxs("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-surface",children:[S.jsx("span",{className:"text-sm font-medium truncate",title:W.name,children:W.title||W.name}),S.jsx("button",{onClick:()=>L(W.name),className:"text-xs text-accent hover:text-accent-dim flex-shrink-0 ml-2",children:"Restore"})]},W.name))})]}):S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs font-mono text-muted",children:"Stories"}),S.jsx("span",{className:"text-xs text-muted",children:c.length})]}),a&&S.jsx("div",{className:"px-3 py-2 border-b border-border",children:S.jsxs("button",{onClick:a,className:"w-full px-3 py-1.5 text-sm bg-accent text-white rounded hover:bg-accent-dim flex items-center justify-center gap-1.5",children:[S.jsx("span",{children:"+"}),S.jsx("span",{children:"New Story"})]})}),S.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[o.map(W=>S.jsx("div",{children:S.jsxs("button",{onClick:()=>s(W,""),className:`w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm ${t===W?"bg-surface":""}`,children:[S.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-600 flex-shrink-0"}),S.jsx("span",{className:"font-medium italic text-muted",children:"Untitled"})]})},W)),c.length===0&&o.length===0?S.jsxs("div",{className:"p-3 text-sm text-muted",children:[S.jsx("p",{children:"No stories yet."}),S.jsx("p",{className:"mt-1 text-xs",children:'Click "+ New Story" above to start writing.'})]}):c.filter(W=>W.name!=="_example").map(W=>S.jsxs("div",{children:[S.jsxs("button",{onClick:()=>I(W),className:"w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm",children:[S.jsx("span",{className:"text-xs text-muted",children:g.has(W.name)?"▼":"▶"}),S.jsx("span",{className:"font-medium truncate",title:W.name,children:W.title||W.name}),S.jsxs("span",{className:"ml-auto text-xs text-muted",children:[W.publishedCount,"/",W.files.length]})]}),g.has(W.name)&&S.jsx("div",{className:"pl-4",children:Z(W.files).map(O=>{const te=t===W.name&&n===O.file;return S.jsxs("button",{onClick:()=>s(W.name,O.file),className:`w-full px-3 py-1.5 text-left flex items-center gap-2 text-xs hover:bg-surface ${te?"bg-surface font-medium":""}`,children:[S.jsx("span",{className:Ox[O.status],children:zx[O.status]}),S.jsx("span",{className:"truncate font-mono",children:O.file})]},O.file)})})]},W.name))]}),S.jsx("div",{className:"px-3 py-2 border-t border-border",children:S.jsx("button",{onClick:()=>y(!0),className:"w-full px-3 py-1.5 text-xs text-muted hover:text-foreground hover:bg-surface rounded flex items-center justify-center gap-1.5",children:S.jsx("span",{children:"Archives"})})})]})}/** * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. * @license MIT * @@ -57,21 +57,21 @@ Error generating stack: `+u.message+` * Fabrice Bellard's javascript vt100 for jslinux: * http://bellard.org/jslinux/ * Copyright (c) 2011 Fabrice Bellard - */var tb=Object.defineProperty,Hx=Object.getOwnPropertyDescriptor,Px=(e,t)=>{for(var n in t)tb(e,n,{get:t[n],enumerable:!0})},mt=(e,t,n,s)=>{for(var a=s>1?void 0:s?Hx(t,n):t,o=e.length-1,c;o>=0;o--)(c=e[o])&&(a=(s?c(t,n,a):c(a))||a);return s&&a&&tb(t,n,a),a},pe=(e,t)=>(n,s)=>t(n,s,e),lv="Terminal input",Df={get:()=>lv,set:e=>lv=e},av="Too much output to announce, navigate to rows manually to read",Rf={get:()=>av,set:e=>av=e};function Ux(e){return e.replace(/\r?\n/g,"\r")}function Ix(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Fx(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function qx(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let a=e.clipboardData.getData("text/plain");ib(a,t,n,s)}}function ib(e,t,n,s){e=Ux(e),e=Ix(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function nb(e,t,n){let s=n.getBoundingClientRect(),a=e.clientX-s.left-10,o=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${a}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function ov(e,t,n,s,a){nb(e,t,n),a&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function br(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function wu(e,t=0,n=e.length){let s="";for(let a=t;a65535?(o-=65536,s+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):s+=String.fromCharCode(o)}return s}var Wx=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let s=0,a=0;if(this._interim){let o=e.charCodeAt(a++);56320<=o&&o<=57343?t[s++]=(this._interim-55296)*1024+o-56320+65536:(t[s++]=this._interim,t[s++]=o),this._interim=0}for(let o=a;o=n)return this._interim=c,s;let f=e.charCodeAt(o);56320<=f&&f<=57343?t[s++]=(c-55296)*1024+f-56320+65536:(t[s++]=c,t[s++]=f);continue}c!==65279&&(t[s++]=c)}return s}},Yx=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let s=0,a,o,c,f,p=0,h=0;if(this.interim[0]){let b=!1,y=this.interim[0];y&=(y&224)===192?31:(y&240)===224?15:7;let x=0,k;for(;(k=this.interim[++x]&63)&&x<4;)y<<=6,y|=k;let L=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,M=L-x;for(;h=n)return 0;if(k=e[h++],(k&192)!==128){h--,b=!0;break}else this.interim[x++]=k,y<<=6,y|=k&63}b||(L===2?y<128?h--:t[s++]=y:L===3?y<2048||y>=55296&&y<=57343||y===65279||(t[s++]=y):y<65536||y>1114111||(t[s++]=y)),this.interim.fill(0)}let g=n-4,_=h;for(;_=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(p=(a&31)<<6|o&63,p<128){_--;continue}t[s++]=p}else if((a&240)===224){if(_>=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[_++],(c&192)!==128){_--;continue}if(p=(a&15)<<12|(o&63)<<6|c&63,p<2048||p>=55296&&p<=57343||p===65279)continue;t[s++]=p}else if((a&248)===240){if(_>=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[_++],(c&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,this.interim[2]=c,s;if(f=e[_++],(f&192)!==128){_--;continue}if(p=(a&7)<<18|(o&63)<<12|(c&63)<<6|f&63,p<65536||p>1114111)continue;t[s++]=p}}return s}},rb="",xr=" ",Ca=class sb{constructor(){this.fg=0,this.bg=0,this.extended=new du}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new sb;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},du=class lb{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new lb(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ki=class ab extends Ca{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new du,this.combinedData=""}static fromCharData(t){let n=new ab;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?br(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let a=t[1].charCodeAt(1);56320<=a&&a<=57343?this.content=(s-55296)*1024+a-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},uv="di$target",Mf="di$dependencies",Gh=new Map;function Vx(e){return e[Mf]||[]}function qt(e){if(Gh.has(e))return Gh.get(e);let t=function(n,s,a){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Kx(t,n,a)};return t._id=e,Gh.set(e,t),t}function Kx(e,t,n){t[uv]===t?t[Mf].push({id:e,index:n}):(t[Mf]=[{id:e,index:n}],t[uv]=t)}var ui=qt("BufferService"),ob=qt("CoreMouseService"),ns=qt("CoreService"),Xx=qt("CharsetService"),Cd=qt("InstantiationService"),ub=qt("LogService"),ci=qt("OptionsService"),cb=qt("OscLinkService"),$x=qt("UnicodeService"),ka=qt("DecorationService"),Bf=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var g;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],a=this._optionsService.rawOptions.linkHandler,o=new Ki,c=n.getTrimmedLength(),f=-1,p=-1,h=!1;for(let _=0;_a?a.activate(k,L,y):Gx(k,L),hover:(k,L)=>{var M;return(M=a==null?void 0:a.hover)==null?void 0:M.call(a,k,L,y)},leave:(k,L)=>{var M;return(M=a==null?void 0:a.leave)==null?void 0:M.call(a,k,L,y)}})}h=!1,o.hasExtendedAttrs()&&o.extended.urlId?(p=_,f=o.extended.urlId):(p=-1,f=-1)}}t(s)}};Bf=mt([pe(0,ui),pe(1,ci),pe(2,cb)],Bf);function Gx(e,t){if(confirm(`Do you want to navigate to ${t}? + */var tb=Object.defineProperty,Hx=Object.getOwnPropertyDescriptor,Px=(e,t)=>{for(var n in t)tb(e,n,{get:t[n],enumerable:!0})},gt=(e,t,n,s)=>{for(var a=s>1?void 0:s?Hx(t,n):t,o=e.length-1,c;o>=0;o--)(c=e[o])&&(a=(s?c(t,n,a):c(a))||a);return s&&a&&tb(t,n,a),a},pe=(e,t)=>(n,s)=>t(n,s,e),lv="Terminal input",Df={get:()=>lv,set:e=>lv=e},av="Too much output to announce, navigate to rows manually to read",Rf={get:()=>av,set:e=>av=e};function Ux(e){return e.replace(/\r?\n/g,"\r")}function Ix(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Fx(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function qx(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let a=e.clipboardData.getData("text/plain");ib(a,t,n,s)}}function ib(e,t,n,s){e=Ux(e),e=Ix(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function nb(e,t,n){let s=n.getBoundingClientRect(),a=e.clientX-s.left-10,o=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${a}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function ov(e,t,n,s,a){nb(e,t,n),a&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function br(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function wu(e,t=0,n=e.length){let s="";for(let a=t;a65535?(o-=65536,s+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):s+=String.fromCharCode(o)}return s}var Wx=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let s=0,a=0;if(this._interim){let o=e.charCodeAt(a++);56320<=o&&o<=57343?t[s++]=(this._interim-55296)*1024+o-56320+65536:(t[s++]=this._interim,t[s++]=o),this._interim=0}for(let o=a;o=n)return this._interim=c,s;let f=e.charCodeAt(o);56320<=f&&f<=57343?t[s++]=(c-55296)*1024+f-56320+65536:(t[s++]=c,t[s++]=f);continue}c!==65279&&(t[s++]=c)}return s}},Yx=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let s=0,a,o,c,f,p=0,h=0;if(this.interim[0]){let b=!1,y=this.interim[0];y&=(y&224)===192?31:(y&240)===224?15:7;let x=0,k;for(;(k=this.interim[++x]&63)&&x<4;)y<<=6,y|=k;let L=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,M=L-x;for(;h=n)return 0;if(k=e[h++],(k&192)!==128){h--,b=!0;break}else this.interim[x++]=k,y<<=6,y|=k&63}b||(L===2?y<128?h--:t[s++]=y:L===3?y<2048||y>=55296&&y<=57343||y===65279||(t[s++]=y):y<65536||y>1114111||(t[s++]=y)),this.interim.fill(0)}let g=n-4,_=h;for(;_=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(p=(a&31)<<6|o&63,p<128){_--;continue}t[s++]=p}else if((a&240)===224){if(_>=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[_++],(c&192)!==128){_--;continue}if(p=(a&15)<<12|(o&63)<<6|c&63,p<2048||p>=55296&&p<=57343||p===65279)continue;t[s++]=p}else if((a&248)===240){if(_>=n)return this.interim[0]=a,s;if(o=e[_++],(o&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[_++],(c&192)!==128){_--;continue}if(_>=n)return this.interim[0]=a,this.interim[1]=o,this.interim[2]=c,s;if(f=e[_++],(f&192)!==128){_--;continue}if(p=(a&7)<<18|(o&63)<<12|(c&63)<<6|f&63,p<65536||p>1114111)continue;t[s++]=p}}return s}},rb="",xr=" ",wa=class sb{constructor(){this.fg=0,this.bg=0,this.extended=new du}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new sb;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},du=class lb{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new lb(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Xi=class ab extends wa{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new du,this.combinedData=""}static fromCharData(t){let n=new ab;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?br(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let a=t[1].charCodeAt(1);56320<=a&&a<=57343?this.content=(s-55296)*1024+a-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},uv="di$target",Mf="di$dependencies",Gh=new Map;function Vx(e){return e[Mf]||[]}function Yt(e){if(Gh.has(e))return Gh.get(e);let t=function(n,s,a){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Kx(t,n,a)};return t._id=e,Gh.set(e,t),t}function Kx(e,t,n){t[uv]===t?t[Mf].push({id:e,index:n}):(t[Mf]=[{id:e,index:n}],t[uv]=t)}var ci=Yt("BufferService"),ob=Yt("CoreMouseService"),is=Yt("CoreService"),Xx=Yt("CharsetService"),Cd=Yt("InstantiationService"),ub=Yt("LogService"),hi=Yt("OptionsService"),cb=Yt("OscLinkService"),$x=Yt("UnicodeService"),Ca=Yt("DecorationService"),Bf=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var g;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],a=this._optionsService.rawOptions.linkHandler,o=new Xi,c=n.getTrimmedLength(),f=-1,p=-1,h=!1;for(let _=0;_a?a.activate(k,L,y):Gx(k,L),hover:(k,L)=>{var M;return(M=a==null?void 0:a.hover)==null?void 0:M.call(a,k,L,y)},leave:(k,L)=>{var M;return(M=a==null?void 0:a.leave)==null?void 0:M.call(a,k,L,y)}})}h=!1,o.hasExtendedAttrs()&&o.extended.urlId?(p=_,f=o.extended.urlId):(p=-1,f=-1)}}t(s)}};Bf=gt([pe(0,ci),pe(1,hi),pe(2,cb)],Bf);function Gx(e,t){if(confirm(`Do you want to navigate to ${t}? -WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Cu=qt("CharSizeService"),In=qt("CoreBrowserService"),kd=qt("MouseService"),Fn=qt("RenderService"),Zx=qt("SelectionService"),hb=qt("CharacterJoinerService"),tl=qt("ThemeService"),fb=qt("LinkProviderService"),Qx=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?cv.isErrorNoTelemetry(e)?new cv(e.message+` +WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Cu=Yt("CharSizeService"),Pn=Yt("CoreBrowserService"),kd=Yt("MouseService"),Un=Yt("RenderService"),Zx=Yt("SelectionService"),hb=Yt("CharacterJoinerService"),el=Yt("ThemeService"),fb=Yt("LinkProviderService"),Qx=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?cv.isErrorNoTelemetry(e)?new cv(e.message+` `+e.stack):new Error(e.message+` -`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},Jx=new Qx;function su(e){ew(e)||Jx.onUnexpectedError(e)}var Nf="Canceled";function ew(e){return e instanceof tw?!0:e instanceof Error&&e.name===Nf&&e.message===Nf}var tw=class extends Error{constructor(){super(Nf),this.name=this.message}};function iw(e){return new Error(`Illegal argument: ${e}`)}var cv=class Lf extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Lf)return t;let n=new Lf;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},zf=class db extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,db.prototype)}};function Di(e,t=0){return e[e.length-(1+t)]}var nw;(e=>{function t(o){return o<0}e.isLessThan=t;function n(o){return o<=0}e.isLessThanOrEqual=n;function s(o){return o>0}e.isGreaterThan=s;function a(o){return o===0}e.isNeitherLessOrGreaterThan=a,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(nw||(nw={}));function rw(e,t){let n=this,s=!1,a;return function(){return s||(s=!0,t||(a=e.apply(n,arguments))),a}}var pb;(e=>{function t(Q){return Q&&typeof Q=="object"&&typeof Q[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*a(Q){yield Q}e.single=a;function o(Q){return t(Q)?Q:a(Q)}e.wrap=o;function c(Q){return Q||n}e.from=c;function*f(Q){for(let W=Q.length-1;W>=0;W--)yield Q[W]}e.reverse=f;function p(Q){return!Q||Q[Symbol.iterator]().next().done===!0}e.isEmpty=p;function h(Q){return Q[Symbol.iterator]().next().value}e.first=h;function g(Q,W){let O=0;for(let ie of Q)if(W(ie,O++))return!0;return!1}e.some=g;function _(Q,W){for(let O of Q)if(W(O))return O}e.find=_;function*b(Q,W){for(let O of Q)W(O)&&(yield O)}e.filter=b;function*y(Q,W){let O=0;for(let ie of Q)yield W(ie,O++)}e.map=y;function*x(Q,W){let O=0;for(let ie of Q)yield*W(ie,O++)}e.flatMap=x;function*k(...Q){for(let W of Q)yield*W}e.concat=k;function L(Q,W,O){let ie=O;for(let ue of Q)ie=W(ie,ue);return ie}e.reduce=L;function*M(Q,W,O=Q.length){for(W<0&&(W+=Q.length),O<0?O+=Q.length:O>Q.length&&(O=Q.length);W1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function sw(...e){return at(()=>es(e))}function at(e){return{dispose:rw(()=>{e()})}}var mb=class _b{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{es(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?_b.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};mb.DISABLE_DISPOSED_WARNING=!1;var wr=mb,Be=class{constructor(){this._store=new wr,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Be.None=Object.freeze({dispose(){}});var Js=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Un=typeof window=="object"?window:globalThis,Of=class jf{constructor(t){this.element=t,this.next=jf.Undefined,this.prev=jf.Undefined}};Of.Undefined=new Of(void 0);var ot=Of,hv=class{constructor(){this._first=ot.Undefined,this._last=ot.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ot.Undefined}clear(){let e=this._first;for(;e!==ot.Undefined;){let t=e.next;e.prev=ot.Undefined,e.next=ot.Undefined,e=t}this._first=ot.Undefined,this._last=ot.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new ot(e);if(this._first===ot.Undefined)this._first=n,this._last=n;else if(t){let a=this._last;this._last=n,n.prev=a,a.next=n}else{let a=this._first;this._first=n,n.next=a,a.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first!==ot.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ot.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ot.Undefined&&e.next!==ot.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ot.Undefined&&e.next===ot.Undefined?(this._first=ot.Undefined,this._last=ot.Undefined):e.next===ot.Undefined?(this._last=this._last.prev,this._last.next=ot.Undefined):e.prev===ot.Undefined&&(this._first=this._first.next,this._first.prev=ot.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ot.Undefined;)yield e.element,e=e.next}},lw=globalThis.performance&&typeof globalThis.performance.now=="function",aw=class gb{static create(t){return new gb(t)}constructor(t){this._now=lw&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Jt;(e=>{e.None=()=>Be.None;function t(V,B){return _(V,()=>{},0,void 0,!0,void 0,B)}e.defer=t;function n(V){return(B,A=null,R)=>{let T=!1,j;return j=V(H=>{if(!T)return j?j.dispose():T=!0,B.call(A,H)},null,R),T&&j.dispose(),j}}e.once=n;function s(V,B,A){return h((R,T=null,j)=>V(H=>R.call(T,B(H)),null,j),A)}e.map=s;function a(V,B,A){return h((R,T=null,j)=>V(H=>{B(H),R.call(T,H)},null,j),A)}e.forEach=a;function o(V,B,A){return h((R,T=null,j)=>V(H=>B(H)&&R.call(T,H),null,j),A)}e.filter=o;function c(V){return V}e.signal=c;function f(...V){return(B,A=null,R)=>{let T=sw(...V.map(j=>j(H=>B.call(A,H))));return g(T,R)}}e.any=f;function p(V,B,A,R){let T=A;return s(V,j=>(T=B(T,j),T),R)}e.reduce=p;function h(V,B){let A,R={onWillAddFirstListener(){A=V(T.fire,T)},onDidRemoveLastListener(){A==null||A.dispose()}},T=new he(R);return B==null||B.add(T),T.event}function g(V,B){return B instanceof Array?B.push(V):B&&B.add(V),V}function _(V,B,A=100,R=!1,T=!1,j,H){let ae,E,D,K=0,C,J={leakWarningThreshold:j,onWillAddFirstListener(){ae=V(de=>{K++,E=B(E,de),R&&!D&&(fe.fire(E),E=void 0),C=()=>{let xe=E;E=void 0,D=void 0,(!R||K>1)&&fe.fire(xe),K=0},typeof A=="number"?(clearTimeout(D),D=setTimeout(C,A)):D===void 0&&(D=0,queueMicrotask(C))})},onWillRemoveListener(){T&&K>0&&(C==null||C())},onDidRemoveLastListener(){C=void 0,ae.dispose()}},fe=new he(J);return H==null||H.add(fe),fe.event}e.debounce=_;function b(V,B=0,A){return e.debounce(V,(R,T)=>R?(R.push(T),R):[T],B,void 0,!0,void 0,A)}e.accumulate=b;function y(V,B=(R,T)=>R===T,A){let R=!0,T;return o(V,j=>{let H=R||!B(j,T);return R=!1,T=j,H},A)}e.latch=y;function x(V,B,A){return[e.filter(V,B,A),e.filter(V,R=>!B(R),A)]}e.split=x;function k(V,B=!1,A=[],R){let T=A.slice(),j=V(E=>{T?T.push(E):ae.fire(E)});R&&R.add(j);let H=()=>{T==null||T.forEach(E=>ae.fire(E)),T=null},ae=new he({onWillAddFirstListener(){j||(j=V(E=>ae.fire(E)),R&&R.add(j))},onDidAddFirstListener(){T&&(B?setTimeout(H):H())},onDidRemoveLastListener(){j&&j.dispose(),j=null}});return R&&R.add(ae),ae.event}e.buffer=k;function L(V,B){return(A,R,T)=>{let j=B(new Z);return V(function(H){let ae=j.evaluate(H);ae!==M&&A.call(R,ae)},void 0,T)}}e.chain=L;let M=Symbol("HaltChainable");class Z{constructor(){this.steps=[]}map(B){return this.steps.push(B),this}forEach(B){return this.steps.push(A=>(B(A),A)),this}filter(B){return this.steps.push(A=>B(A)?A:M),this}reduce(B,A){let R=A;return this.steps.push(T=>(R=B(R,T),R)),this}latch(B=(A,R)=>A===R){let A=!0,R;return this.steps.push(T=>{let j=A||!B(T,R);return A=!1,R=T,j?T:M}),this}evaluate(B){for(let A of this.steps)if(B=A(B),B===M)break;return B}}function I(V,B,A=R=>R){let R=(...ae)=>H.fire(A(...ae)),T=()=>V.on(B,R),j=()=>V.removeListener(B,R),H=new he({onWillAddFirstListener:T,onDidRemoveLastListener:j});return H.event}e.fromNodeEventEmitter=I;function Q(V,B,A=R=>R){let R=(...ae)=>H.fire(A(...ae)),T=()=>V.addEventListener(B,R),j=()=>V.removeEventListener(B,R),H=new he({onWillAddFirstListener:T,onDidRemoveLastListener:j});return H.event}e.fromDOMEventEmitter=Q;function W(V){return new Promise(B=>n(V)(B))}e.toPromise=W;function O(V){let B=new he;return V.then(A=>{B.fire(A)},()=>{B.fire(void 0)}).finally(()=>{B.dispose()}),B.event}e.fromPromise=O;function ie(V,B){return V(A=>B.fire(A))}e.forward=ie;function ue(V,B,A){return B(A),V(R=>B(R))}e.runAndSubscribe=ue;class me{constructor(B,A){this._observable=B,this._counter=0,this._hasChanged=!1;let R={onWillAddFirstListener:()=>{B.addObserver(this)},onDidRemoveLastListener:()=>{B.removeObserver(this)}};this.emitter=new he(R),A&&A.add(this.emitter)}beginUpdate(B){this._counter++}handlePossibleChange(B){}handleChange(B,A){this._hasChanged=!0}endUpdate(B){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function U(V,B){return new me(V,B).emitter.event}e.fromObservable=U;function le(V){return(B,A,R)=>{let T=0,j=!1,H={beginUpdate(){T++},endUpdate(){T--,T===0&&(V.reportChanges(),j&&(j=!1,B.call(A)))},handlePossibleChange(){},handleChange(){j=!0}};V.addObserver(H),V.reportChanges();let ae={dispose(){V.removeObserver(H)}};return R instanceof wr?R.add(ae):Array.isArray(R)&&R.push(ae),ae}}e.fromObservableLight=le})(Jt||(Jt={}));var Hf=class Pf{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Pf._idPool++}`,Pf.all.add(this)}start(t){this._stopWatch=new aw,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Hf.all=new Set,Hf._idPool=0;var ow=Hf,uw=-1,vb=class yb{constructor(t,n,s=(yb._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let s=this.threshold;if(s<=0||n{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[s,a]of this._stacks)(!t||n{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},Jx=new Qx;function su(e){ew(e)||Jx.onUnexpectedError(e)}var Nf="Canceled";function ew(e){return e instanceof tw?!0:e instanceof Error&&e.name===Nf&&e.message===Nf}var tw=class extends Error{constructor(){super(Nf),this.name=this.message}};function iw(e){return new Error(`Illegal argument: ${e}`)}var cv=class Lf extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Lf)return t;let n=new Lf;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},zf=class db extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,db.prototype)}};function Di(e,t=0){return e[e.length-(1+t)]}var nw;(e=>{function t(o){return o<0}e.isLessThan=t;function n(o){return o<=0}e.isLessThanOrEqual=n;function s(o){return o>0}e.isGreaterThan=s;function a(o){return o===0}e.isNeitherLessOrGreaterThan=a,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(nw||(nw={}));function rw(e,t){let n=this,s=!1,a;return function(){return s||(s=!0,t||(a=e.apply(n,arguments))),a}}var pb;(e=>{function t(Z){return Z&&typeof Z=="object"&&typeof Z[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*a(Z){yield Z}e.single=a;function o(Z){return t(Z)?Z:a(Z)}e.wrap=o;function c(Z){return Z||n}e.from=c;function*f(Z){for(let W=Z.length-1;W>=0;W--)yield Z[W]}e.reverse=f;function p(Z){return!Z||Z[Symbol.iterator]().next().done===!0}e.isEmpty=p;function h(Z){return Z[Symbol.iterator]().next().value}e.first=h;function g(Z,W){let O=0;for(let te of Z)if(W(te,O++))return!0;return!1}e.some=g;function _(Z,W){for(let O of Z)if(W(O))return O}e.find=_;function*b(Z,W){for(let O of Z)W(O)&&(yield O)}e.filter=b;function*y(Z,W){let O=0;for(let te of Z)yield W(te,O++)}e.map=y;function*x(Z,W){let O=0;for(let te of Z)yield*W(te,O++)}e.flatMap=x;function*k(...Z){for(let W of Z)yield*W}e.concat=k;function L(Z,W,O){let te=O;for(let ue of Z)te=W(te,ue);return te}e.reduce=L;function*M(Z,W,O=Z.length){for(W<0&&(W+=Z.length),O<0?O+=Z.length:O>Z.length&&(O=Z.length);W1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function sw(...e){return ct(()=>Jr(e))}function ct(e){return{dispose:rw(()=>{e()})}}var mb=class _b{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Jr(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?_b.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};mb.DISABLE_DISPOSED_WARNING=!1;var wr=mb,Ne=class{constructor(){this._store=new wr,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Ne.None=Object.freeze({dispose(){}});var Qs=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Hn=typeof window=="object"?window:globalThis,Of=class jf{constructor(t){this.element=t,this.next=jf.Undefined,this.prev=jf.Undefined}};Of.Undefined=new Of(void 0);var ht=Of,hv=class{constructor(){this._first=ht.Undefined,this._last=ht.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ht.Undefined}clear(){let e=this._first;for(;e!==ht.Undefined;){let t=e.next;e.prev=ht.Undefined,e.next=ht.Undefined,e=t}this._first=ht.Undefined,this._last=ht.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new ht(e);if(this._first===ht.Undefined)this._first=n,this._last=n;else if(t){let a=this._last;this._last=n,n.prev=a,a.next=n}else{let a=this._first;this._first=n,n.next=a,a.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first!==ht.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ht.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ht.Undefined&&e.next!==ht.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ht.Undefined&&e.next===ht.Undefined?(this._first=ht.Undefined,this._last=ht.Undefined):e.next===ht.Undefined?(this._last=this._last.prev,this._last.next=ht.Undefined):e.prev===ht.Undefined&&(this._first=this._first.next,this._first.prev=ht.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ht.Undefined;)yield e.element,e=e.next}},lw=globalThis.performance&&typeof globalThis.performance.now=="function",aw=class gb{static create(t){return new gb(t)}constructor(t){this._now=lw&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},ei;(e=>{e.None=()=>Ne.None;function t(V,B){return _(V,()=>{},0,void 0,!0,void 0,B)}e.defer=t;function n(V){return(B,A=null,R)=>{let T=!1,j;return j=V(H=>{if(!T)return j?j.dispose():T=!0,B.call(A,H)},null,R),T&&j.dispose(),j}}e.once=n;function s(V,B,A){return h((R,T=null,j)=>V(H=>R.call(T,B(H)),null,j),A)}e.map=s;function a(V,B,A){return h((R,T=null,j)=>V(H=>{B(H),R.call(T,H)},null,j),A)}e.forEach=a;function o(V,B,A){return h((R,T=null,j)=>V(H=>B(H)&&R.call(T,H),null,j),A)}e.filter=o;function c(V){return V}e.signal=c;function f(...V){return(B,A=null,R)=>{let T=sw(...V.map(j=>j(H=>B.call(A,H))));return g(T,R)}}e.any=f;function p(V,B,A,R){let T=A;return s(V,j=>(T=B(T,j),T),R)}e.reduce=p;function h(V,B){let A,R={onWillAddFirstListener(){A=V(T.fire,T)},onDidRemoveLastListener(){A==null||A.dispose()}},T=new he(R);return B==null||B.add(T),T.event}function g(V,B){return B instanceof Array?B.push(V):B&&B.add(V),V}function _(V,B,A=100,R=!1,T=!1,j,H){let ae,E,D,K=0,C,Q={leakWarningThreshold:j,onWillAddFirstListener(){ae=V(de=>{K++,E=B(E,de),R&&!D&&(fe.fire(E),E=void 0),C=()=>{let Ce=E;E=void 0,D=void 0,(!R||K>1)&&fe.fire(Ce),K=0},typeof A=="number"?(clearTimeout(D),D=setTimeout(C,A)):D===void 0&&(D=0,queueMicrotask(C))})},onWillRemoveListener(){T&&K>0&&(C==null||C())},onDidRemoveLastListener(){C=void 0,ae.dispose()}},fe=new he(Q);return H==null||H.add(fe),fe.event}e.debounce=_;function b(V,B=0,A){return e.debounce(V,(R,T)=>R?(R.push(T),R):[T],B,void 0,!0,void 0,A)}e.accumulate=b;function y(V,B=(R,T)=>R===T,A){let R=!0,T;return o(V,j=>{let H=R||!B(j,T);return R=!1,T=j,H},A)}e.latch=y;function x(V,B,A){return[e.filter(V,B,A),e.filter(V,R=>!B(R),A)]}e.split=x;function k(V,B=!1,A=[],R){let T=A.slice(),j=V(E=>{T?T.push(E):ae.fire(E)});R&&R.add(j);let H=()=>{T==null||T.forEach(E=>ae.fire(E)),T=null},ae=new he({onWillAddFirstListener(){j||(j=V(E=>ae.fire(E)),R&&R.add(j))},onDidAddFirstListener(){T&&(B?setTimeout(H):H())},onDidRemoveLastListener(){j&&j.dispose(),j=null}});return R&&R.add(ae),ae.event}e.buffer=k;function L(V,B){return(A,R,T)=>{let j=B(new G);return V(function(H){let ae=j.evaluate(H);ae!==M&&A.call(R,ae)},void 0,T)}}e.chain=L;let M=Symbol("HaltChainable");class G{constructor(){this.steps=[]}map(B){return this.steps.push(B),this}forEach(B){return this.steps.push(A=>(B(A),A)),this}filter(B){return this.steps.push(A=>B(A)?A:M),this}reduce(B,A){let R=A;return this.steps.push(T=>(R=B(R,T),R)),this}latch(B=(A,R)=>A===R){let A=!0,R;return this.steps.push(T=>{let j=A||!B(T,R);return A=!1,R=T,j?T:M}),this}evaluate(B){for(let A of this.steps)if(B=A(B),B===M)break;return B}}function I(V,B,A=R=>R){let R=(...ae)=>H.fire(A(...ae)),T=()=>V.on(B,R),j=()=>V.removeListener(B,R),H=new he({onWillAddFirstListener:T,onDidRemoveLastListener:j});return H.event}e.fromNodeEventEmitter=I;function Z(V,B,A=R=>R){let R=(...ae)=>H.fire(A(...ae)),T=()=>V.addEventListener(B,R),j=()=>V.removeEventListener(B,R),H=new he({onWillAddFirstListener:T,onDidRemoveLastListener:j});return H.event}e.fromDOMEventEmitter=Z;function W(V){return new Promise(B=>n(V)(B))}e.toPromise=W;function O(V){let B=new he;return V.then(A=>{B.fire(A)},()=>{B.fire(void 0)}).finally(()=>{B.dispose()}),B.event}e.fromPromise=O;function te(V,B){return V(A=>B.fire(A))}e.forward=te;function ue(V,B,A){return B(A),V(R=>B(R))}e.runAndSubscribe=ue;class _e{constructor(B,A){this._observable=B,this._counter=0,this._hasChanged=!1;let R={onWillAddFirstListener:()=>{B.addObserver(this)},onDidRemoveLastListener:()=>{B.removeObserver(this)}};this.emitter=new he(R),A&&A.add(this.emitter)}beginUpdate(B){this._counter++}handlePossibleChange(B){}handleChange(B,A){this._hasChanged=!0}endUpdate(B){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function U(V,B){return new _e(V,B).emitter.event}e.fromObservable=U;function se(V){return(B,A,R)=>{let T=0,j=!1,H={beginUpdate(){T++},endUpdate(){T--,T===0&&(V.reportChanges(),j&&(j=!1,B.call(A)))},handlePossibleChange(){},handleChange(){j=!0}};V.addObserver(H),V.reportChanges();let ae={dispose(){V.removeObserver(H)}};return R instanceof wr?R.add(ae):Array.isArray(R)&&R.push(ae),ae}}e.fromObservableLight=se})(ei||(ei={}));var Hf=class Pf{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Pf._idPool++}`,Pf.all.add(this)}start(t){this._stopWatch=new aw,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Hf.all=new Set,Hf._idPool=0;var ow=Hf,uw=-1,vb=class yb{constructor(t,n,s=(yb._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let s=this.threshold;if(s<=0||n{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[s,a]of this._stacks)(!t||n{var f,p,h,g,_;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let b=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(b);let y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],x=new dw(`${b}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((f=this._options)==null?void 0:f.onListenerError)||su)(x),Be.None}if(this._disposed)return Be.None;n&&(t=t.bind(n));let a=new Zh(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(a.stack=hw.create(),o=this._leakageMon.check(a.stack,this._size+1)),this._listeners?this._listeners instanceof Zh?(this._deliveryQueue??(this._deliveryQueue=new gw),this._listeners=[this._listeners,a]):this._listeners.push(a):((h=(p=this._options)==null?void 0:p.onWillAddFirstListener)==null||h.call(p,this),this._listeners=a,(_=(g=this._options)==null?void 0:g.onDidAddFirstListener)==null||_.call(g,this)),this._size++;let c=at(()=>{o==null||o(),this._removeListener(a)});return s instanceof wr?s.add(c):Array.isArray(s)&&s.push(c),c}),this._event}_removeListener(t){var o,c,f,p;if((c=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||c.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(p=(f=this._options)==null?void 0:f.onDidRemoveLastListener)==null||p.call(f,this),this._size=0;return}let n=this._listeners,s=n.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,n[s]=void 0;let a=this._deliveryQueue.current===this;if(this._size*mw<=n.length){let h=0;for(let g=0;g0}},gw=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Uf=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new he,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new he,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Uf.INSTANCE=new Uf;var Ed=Uf;function vw(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Ed.INSTANCE.onDidChangeZoomLevel;function yw(e){return Ed.INSTANCE.getZoomFactor(e)}Ed.INSTANCE.onDidChangeFullscreen;var il=typeof navigator=="object"?navigator.userAgent:"",If=il.indexOf("Firefox")>=0,bw=il.indexOf("AppleWebKit")>=0,Td=il.indexOf("Chrome")>=0,Sw=!Td&&il.indexOf("Safari")>=0;il.indexOf("Electron/")>=0;il.indexOf("Android")>=0;var Qh=!1;if(typeof Un.matchMedia=="function"){let e=Un.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Un.matchMedia("(display-mode: fullscreen)");Qh=e.matches,vw(Un,e,({matches:n})=>{Qh&&t.matches||(Qh=n)})}var Zs="en",Ff=!1,qf=!1,lu=!1,Sb=!1,$o,au=Zs,fv=Zs,xw,Qi,Jr=globalThis,Qt,Zy;typeof Jr.vscode<"u"&&typeof Jr.vscode.process<"u"?Qt=Jr.vscode.process:typeof process<"u"&&typeof((Zy=process==null?void 0:process.versions)==null?void 0:Zy.node)=="string"&&(Qt=process);var Qy,ww=typeof((Qy=Qt==null?void 0:Qt.versions)==null?void 0:Qy.electron)=="string",Cw=ww&&(Qt==null?void 0:Qt.type)==="renderer",Jy;if(typeof Qt=="object"){Ff=Qt.platform==="win32",qf=Qt.platform==="darwin",lu=Qt.platform==="linux",lu&&Qt.env.SNAP&&Qt.env.SNAP_REVISION,Qt.env.CI||Qt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,$o=Zs,au=Zs;let e=Qt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);$o=t.userLocale,fv=t.osLocale,au=t.resolvedLanguage||Zs,xw=(Jy=t.languagePack)==null?void 0:Jy.translationsConfigFile}catch{}Sb=!0}else typeof navigator=="object"&&!Cw?(Qi=navigator.userAgent,Ff=Qi.indexOf("Windows")>=0,qf=Qi.indexOf("Macintosh")>=0,(Qi.indexOf("Macintosh")>=0||Qi.indexOf("iPad")>=0||Qi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,lu=Qi.indexOf("Linux")>=0,(Qi==null?void 0:Qi.indexOf("Mobi"))>=0,au=globalThis._VSCODE_NLS_LANGUAGE||Zs,$o=navigator.language.toLowerCase(),fv=$o):console.error("Unable to resolve platform.");var xb=Ff,hn=qf,kw=lu,dv=Sb,fn=Qi,_r=au,Ew;(e=>{function t(){return _r}e.value=t;function n(){return _r.length===2?_r==="en":_r.length>=3?_r[0]==="e"&&_r[1]==="n"&&_r[2]==="-":!1}e.isDefaultVariant=n;function s(){return _r==="en"}e.isDefault=s})(Ew||(Ew={}));var Tw=typeof Jr.postMessage=="function"&&!Jr.importScripts;(()=>{if(Tw){let e=[];Jr.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,a=e.length;s{let s=++t;e.push({id:s,callback:n}),Jr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var Aw=!!(fn&&fn.indexOf("Chrome")>=0);fn&&fn.indexOf("Firefox")>=0;!Aw&&fn&&fn.indexOf("Safari")>=0;fn&&fn.indexOf("Edg/")>=0;fn&&fn.indexOf("Android")>=0;var Ws=typeof navigator=="object"?navigator:{};dv||document.queryCommandSupported&&document.queryCommandSupported("copy")||Ws&&Ws.clipboard&&Ws.clipboard.writeText,dv||Ws&&Ws.clipboard&&Ws.clipboard.readText;var Ad=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Jh=new Ad,pv=new Ad,mv=new Ad,Dw=new Array(230),wb;(e=>{function t(f){return Jh.keyCodeToStr(f)}e.toString=t;function n(f){return Jh.strToKeyCode(f)}e.fromString=n;function s(f){return pv.keyCodeToStr(f)}e.toUserSettingsUS=s;function a(f){return mv.keyCodeToStr(f)}e.toUserSettingsGeneral=a;function o(f){return pv.strToKeyCode(f)||mv.strToKeyCode(f)}e.fromUserSettings=o;function c(f){if(f>=98&&f<=113)return null;switch(f){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Jh.keyCodeToStr(f)}e.toElectronAccelerator=c})(wb||(wb={}));var Rw=class Cb{constructor(t,n,s,a,o){this.ctrlKey=t,this.shiftKey=n,this.altKey=s,this.metaKey=a,this.keyCode=o}equals(t){return t instanceof Cb&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",s=this.altKey?"1":"0",a=this.metaKey?"1":"0";return`K${t}${n}${s}${a}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Mw([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Mw=class{constructor(e){if(e.length===0)throw iw("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t{function t(n){return n===e.None||n===e.Cancelled||n instanceof Uw?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Jt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:kb})})(Pw||(Pw={}));var Uw=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?kb:(this._emitter||(this._emitter=new he),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Dd=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new zf("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new zf("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Iw=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new zf("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=at(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Fw;(e=>{async function t(s){let a,o=await Promise.all(s.map(c=>c.then(f=>f,f=>{a||(a=f)})));if(typeof a<"u")throw a;return o}e.settled=t;function n(s){return new Promise(async(a,o)=>{try{await s(a,o)}catch(c){o(c)}})}e.withAsyncBody=n})(Fw||(Fw={}));var yv=class Wi{static fromArray(t){return new Wi(n=>{n.emitMany(t)})}static fromPromise(t){return new Wi(async n=>{n.emitMany(await t)})}static fromPromises(t){return new Wi(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new Wi(async n=>{await Promise.all(t.map(async s=>{for await(let a of s)n.emitOne(a)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new he,queueMicrotask(async()=>{let s={emitOne:a=>this.emitOne(a),emitMany:a=>this.emitMany(a),reject:a=>this.reject(a)};try{await Promise.resolve(t(s)),this.resolve()}catch(a){this.reject(a)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(t,n){return new Wi(async s=>{for await(let a of t)s.emitOne(n(a))})}map(t){return Wi.map(this,t)}static filter(t,n){return new Wi(async s=>{for await(let a of t)n(a)&&s.emitOne(a)})}filter(t){return Wi.filter(this,t)}static coalesce(t){return Wi.filter(t,n=>!!n)}coalesce(){return Wi.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return Wi.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};yv.EMPTY=yv.fromArray([]);var{getWindow:cn,getWindowId:qw,onDidRegisterWindow:Ww}=(function(){let e=new Map,t={window:Un,disposables:new wr};e.set(Un.vscodeWindowId,t);let n=new he,s=new he,a=new he;function o(c,f){return(typeof c=="number"?e.get(c):void 0)??(f?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:a.event,onDidUnregisterWindow:s.event,registerWindow(c){if(e.has(c.vscodeWindowId))return Be.None;let f=new wr,p={window:c,disposables:f.add(new wr)};return e.set(c.vscodeWindowId,p),f.add(at(()=>{e.delete(c.vscodeWindowId),s.fire(c)})),f.add(Ee(c,Ot.BEFORE_UNLOAD,()=>{a.fire(c)})),n.fire(p),f},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return e.has(c)},getWindowById:o,getWindow(c){var h;let f=c;if((h=f==null?void 0:f.ownerDocument)!=null&&h.defaultView)return f.ownerDocument.defaultView.window;let p=c;return p!=null&&p.view?p.view.window:Un},getDocument(c){return cn(c).document}}})(),Yw=class{constructor(e,t,n,s){this._node=e,this._type=t,this._handler=n,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Ee(e,t,n,s){return new Yw(e,t,n,s)}var bv=function(e,t,n,s){return Ee(e,t,n,s)},Rd,Vw=class extends Iw{constructor(e){super(),this.defaultTarget=e&&cn(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Sv=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){su(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,s=new Map,a=o=>{n.set(o,!1);let c=e.get(o)??[];for(t.set(o,c),e.set(o,[]),s.set(o,!0);c.length>0;)c.sort(Sv.sort),c.shift().execute();s.set(o,!1)};Rd=(o,c,f=0)=>{let p=qw(o),h=new Sv(c,f),g=e.get(p);return g||(g=[],e.set(p,g)),g.push(h),n.get(p)||(n.set(p,!0),o.requestAnimationFrame(()=>a(p))),h}})();function Kw(e){let t=e.getBoundingClientRect(),n=cn(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Ot={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Xw=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=yi(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=yi(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=yi(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=yi(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=yi(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=yi(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=yi(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=yi(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=yi(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=yi(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=yi(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=yi(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=yi(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=yi(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function yi(e){return typeof e=="number"?`${e}px`:e}function pa(e){return new Xw(e)}var Eb=class{constructor(){this._hooks=new wr,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,s,a){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=a;let o=e;try{e.setPointerCapture(t),this._hooks.add(at(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=cn(e)}this._hooks.add(Ee(o,Ot.POINTER_MOVE,c=>{if(c.buttons!==n){this.stopMonitoring(!0);return}c.preventDefault(),this._pointerMoveCallback(c)})),this._hooks.add(Ee(o,Ot.POINTER_UP,c=>this.stopMonitoring(!0)))}};function $w(e,t,n){let s=null,a=null;if(typeof n.value=="function"?(s="value",a=n.value,a.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",a=n.get),!a)throw new Error("not supported");let o=`$memoize$${t}`;n[s]=function(...c){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:a.apply(this,c)}),this[o]}}var on;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(on||(on={}));var ua=class ti extends Be{constructor(){super(),this.dispatched=!1,this.targets=new hv,this.ignoreTargets=new hv,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Jt.runAndSubscribe(Ww,({window:t,disposables:n})=>{n.add(Ee(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(Ee(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(Ee(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Un,disposables:this._store}))}static addTarget(t){if(!ti.isTouchDevice())return Be.None;ti.INSTANCE||(ti.INSTANCE=new ti);let n=ti.INSTANCE.targets.push(t);return at(n)}static ignoreTarget(t){if(!ti.isTouchDevice())return Be.None;ti.INSTANCE||(ti.INSTANCE=new ti);let n=ti.INSTANCE.ignoreTargets.push(t);return at(n)}static isTouchDevice(){return"ontouchstart"in Un||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,a=t.targetTouches.length;s=ti.HOLD_DELAY&&Math.abs(p.initialPageX-Di(p.rollingPageX))<30&&Math.abs(p.initialPageY-Di(p.rollingPageY))<30){let g=this.newGestureEvent(on.Contextmenu,p.initialTarget);g.pageX=Di(p.rollingPageX),g.pageY=Di(p.rollingPageY),this.dispatchEvent(g)}else if(a===1){let g=Di(p.rollingPageX),_=Di(p.rollingPageY),b=Di(p.rollingTimestamps)-p.rollingTimestamps[0],y=g-p.rollingPageX[0],x=_-p.rollingPageY[0],k=[...this.targets].filter(L=>p.initialTarget instanceof Node&&L.contains(p.initialTarget));this.inertia(t,k,s,Math.abs(y)/b,y>0?1:-1,g,Math.abs(x)/b,x>0?1:-1,_)}this.dispatchEvent(this.newGestureEvent(on.End,p.initialTarget)),delete this.activeTouches[f.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(t){if(t.type===on.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>ti.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===on.Change||t.type===on.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let n=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let a=0,o=t.initialTarget;for(;o&&o!==s;)a++,o=o.parentElement;n.push([a,s])}n.sort((s,a)=>s[0]-a[0]);for(let[s,a]of n)a.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,s,a,o,c,f,p,h){this.handle=Rd(t,()=>{let g=Date.now(),_=g-s,b=0,y=0,x=!0;a+=ti.SCROLL_FRICTION*_,f+=ti.SCROLL_FRICTION*_,a>0&&(x=!1,b=o*a*_),f>0&&(x=!1,y=p*f*_);let k=this.newGestureEvent(on.Change);k.translationX=b,k.translationY=y,n.forEach(L=>L.dispatchEvent(k)),x||this.inertia(t,n,g,a,o,c+b,f,p,h+y)})}onTouchMove(t){let n=Date.now();for(let s=0,a=t.changedTouches.length;s3&&(c.rollingPageX.shift(),c.rollingPageY.shift(),c.rollingTimestamps.shift()),c.rollingPageX.push(o.pageX),c.rollingPageY.push(o.pageY),c.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};ua.SCROLL_FRICTION=-.005,ua.HOLD_DELAY=700,ua.CLEAR_TAP_COUNT_TIME=400,mt([$w],ua,"isTouchDevice",1);var Gw=ua,Md=class extends Be{onclick(e,t){this._register(Ee(e,Ot.CLICK,n=>t(new Go(cn(e),n))))}onmousedown(e,t){this._register(Ee(e,Ot.MOUSE_DOWN,n=>t(new Go(cn(e),n))))}onmouseover(e,t){this._register(Ee(e,Ot.MOUSE_OVER,n=>t(new Go(cn(e),n))))}onmouseleave(e,t){this._register(Ee(e,Ot.MOUSE_LEAVE,n=>t(new Go(cn(e),n))))}onkeydown(e,t){this._register(Ee(e,Ot.KEY_DOWN,n=>t(new _v(n))))}onkeyup(e,t){this._register(Ee(e,Ot.KEY_UP,n=>t(new _v(n))))}oninput(e,t){this._register(Ee(e,Ot.INPUT,t))}onblur(e,t){this._register(Ee(e,Ot.BLUR,t))}onfocus(e,t){this._register(Ee(e,Ot.FOCUS,t))}onchange(e,t){this._register(Ee(e,Ot.CHANGE,t))}ignoreGesture(e){return Gw.ignoreTarget(e)}},xv=11,Zw=class extends Md{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=xv+"px",this.domNode.style.height=xv+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new Eb),this._register(bv(this.bgDomNode,Ot.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(bv(this.domNode,Ot.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Vw),this._pointerdownScheduleRepeatTimer=this._register(new Dd)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,cn(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Qw=class Wf{constructor(t,n,s,a,o,c,f){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,a=a|0,o=o|0,c=c|0,f=f|0),this.rawScrollLeft=a,this.rawScrollTop=f,n<0&&(n=0),a+n>s&&(a=s-n),a<0&&(a=0),o<0&&(o=0),f+o>c&&(f=c-o),f<0&&(f=0),this.width=n,this.scrollWidth=s,this.scrollLeft=a,this.height=o,this.scrollHeight=c,this.scrollTop=f}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new Wf(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Wf(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let s=this.width!==t.width,a=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,c=this.height!==t.height,f=this.scrollHeight!==t.scrollHeight,p=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:a,scrollLeftChanged:o,heightChanged:c,scrollHeightChanged:f,scrollTopChanged:p}}},Jw=class extends Be{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new he),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Qw(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let s;t?s=new Cv(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=Cv.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},wv=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function ef(e,t){let n=t-e;return function(s){return e+n*iC(s)}}function eC(e,t,n){return function(s){return s2.5*s){let a,o;return t{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},rC=140,Tb=class extends Md{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new nC(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Eb),this._shouldRender=!0,this.domNode=pa(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Ee(this.domNode.domNode,Ot.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Zw(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=pa(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ee(this.slider.domNode,Ot.POINTER_DOWN,a=>{a.button===0&&(a.preventDefault(),this._sliderPointerDown(a))})),this.onclick(this.slider.domNode,a=>{a.leftButton&&a.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),a=this._sliderPointerPosition(e);n<=a&&a<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let a=Kw(this.domNode.domNode);t=e.pageX-a.left,n=e.pageY-a.top}let s=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,a=>{let o=this._sliderOrthogonalPointerPosition(a),c=Math.abs(o-n);if(xb&&c>rC){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let f=this._sliderPointerPosition(a)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(f))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Ab=class Vf{constructor(t,n,s,a,o,c){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=a,this._scrollSize=o,this._scrollPosition=c,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Vf(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,s,a,o){let c=Math.max(0,s-t),f=Math.max(0,c-2*n),p=a>0&&a>s;if(!p)return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(f),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(s*f/a))),g=(f-h)/(a-s),_=o*g;return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(h),computedSliderRatio:g,computedSliderPosition:Math.round(_)}}_refreshComputedValues(){let t=Vf._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,s=this._scrollPosition;return n0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),n){let a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),c=Math.abs(n.deltaX),f=Math.abs(n.deltaY),p=Math.max(Math.min(a,c),1),h=Math.max(Math.min(o,f),1),g=Math.max(a,c),_=Math.max(o,f);g%p===0&&_%h===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Kf.INSTANCE=new Kf;var uC=Kf,cC=class extends Md{constructor(e,t,n){super(),this._onScroll=this._register(new he),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new he),this.onWillScroll=this._onWillScroll.event,this._options=fC(t),this._scrollable=n,this._register(this._scrollable.onScroll(a=>{this._onWillScroll.fire(a),this._onDidScroll(a),this._onScroll.fire(a)}));let s={onMouseWheel:a=>this._onMouseWheel(a),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new lC(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new sC(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=pa(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=pa(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=pa(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,a=>this._onMouseOver(a)),this.onmouseleave(this._listenOnDomNode,a=>this._onMouseLeave(a)),this._hideTimeout=this._register(new Dd),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=es(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,hn&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new vv(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=es(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new vv(n))};this._mouseWheelToDispose.push(Ee(this._listenOnDomNode,Ot.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var a;if((a=e.browserEvent)!=null&&a.defaultPrevented)return;let t=uC.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+o===0?c=o=0:Math.abs(o)>=Math.abs(c)?c=0:o=0),this._options.flipAxes&&([o,c]=[c,o]);let f=!hn&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||f)&&!c&&(c=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),h={};if(o){let g=kv*o,_=p.scrollTop-(g<0?Math.floor(g):Math.ceil(g));this._verticalScrollbar.writeScrollPosition(h,_)}if(c){let g=kv*c,_=p.scrollLeft-(g<0?Math.floor(g):Math.ceil(g));this._horizontalScrollbar.writeScrollPosition(h,_)}h=this._scrollable.validateScrollPosition(h),(p.scrollLeft!==h.scrollLeft||p.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),n=!0)}let s=n;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,s=n?" left":"",a=t?" top":"",o=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${a}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${a}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),aC)}},hC=class extends cC{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function fC(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,hn&&(t.className+=" mac"),t}var Xf=class extends Be{constructor(e,t,n,s,a,o,c,f){super(),this._bufferService=n,this._optionsService=c,this._renderService=f,this._onRequestScrollLines=this._register(new he),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new Jw({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Rd(s.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new hC(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},p)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(a.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Jt.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(at(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(at(()=>this._styleElement.remove())),this._register(Jt.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(` -`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(h=>this._handleScroll(h)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};Xf=mt([pe(2,ui),pe(3,In),pe(4,ob),pe(5,tl),pe(6,ci),pe(7,Fn)],Xf);var $f=class extends Be{constructor(e,t,n,s,a){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=s,this._renderService=a,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(at(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};$f=mt([pe(1,ui),pe(2,In),pe(3,ka),pe(4,Fn)],$f);var dC=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},ln={full:0,left:0,center:0,right:0},gr={full:0,left:0,center:0,right:0},Ql={full:0,left:0,center:0,right:0},pu=class extends Be{constructor(e,t,n,s,a,o,c,f){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=a,this._optionsService=o,this._themeService=c,this._coreBrowserService=f,this._colorZoneStore=new dC,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(h=this._viewportElement.parentElement)==null||h.insertBefore(this._canvas,this._viewportElement),this._register(at(()=>{var g;return(g=this._canvas)==null?void 0:g.remove()}));let p=this._canvas.getContext("2d");if(p)this._ctx=p;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);gr.full=this._canvas.width,gr.left=e,gr.center=t,gr.right=e,this._refreshDrawHeightConstants(),Ql.full=1,Ql.left=1,Ql.center=1+gr.left,Ql.right=1+gr.left+gr.center}_refreshDrawHeightConstants(){ln.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);ln.left=t,ln.center=t,ln.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Ql[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ln[e.position||"full"]/2),gr[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ln[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};pu=mt([pe(2,ui),pe(3,ka),pe(4,Fn),pe(5,ci),pe(6,tl),pe(7,In)],pu);var se;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=` -`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(se||(se={}));var ou;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(ou||(ou={}));var Db;(e=>e.ST=`${se.ESC}\\`)(Db||(Db={}));var Gf=class{constructor(e,t,n,s,a,o){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=s,this._coreService=a,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.lengththis.updateCompositionElements(!0),0)}}};Gf=mt([pe(2,ui),pe(3,ci),pe(4,ns),pe(5,Fn)],Gf);var jt=0,Ht=0,Pt=0,dt=0,Ev={css:"#00000000",rgba:0},kt;(e=>{function t(a,o,c,f){return f!==void 0?`#${Vr(a)}${Vr(o)}${Vr(c)}${Vr(f)}`:`#${Vr(a)}${Vr(o)}${Vr(c)}`}e.toCss=t;function n(a,o,c,f=255){return(a<<24|o<<16|c<<8|f)>>>0}e.toRgba=n;function s(a,o,c,f){return{css:e.toCss(a,o,c,f),rgba:e.toRgba(a,o,c,f)}}e.toColor=s})(kt||(kt={}));var nt;(e=>{function t(p,h){if(dt=(h.rgba&255)/255,dt===1)return{css:h.css,rgba:h.rgba};let g=h.rgba>>24&255,_=h.rgba>>16&255,b=h.rgba>>8&255,y=p.rgba>>24&255,x=p.rgba>>16&255,k=p.rgba>>8&255;jt=y+Math.round((g-y)*dt),Ht=x+Math.round((_-x)*dt),Pt=k+Math.round((b-k)*dt);let L=kt.toCss(jt,Ht,Pt),M=kt.toRgba(jt,Ht,Pt);return{css:L,rgba:M}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,h,g){let _=uu.ensureContrastRatio(p.rgba,h.rgba,g);if(_)return kt.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function a(p){let h=(p.rgba|255)>>>0;return[jt,Ht,Pt]=uu.toChannels(h),{css:kt.toCss(jt,Ht,Pt),rgba:h}}e.opaque=a;function o(p,h){return dt=Math.round(h*255),[jt,Ht,Pt]=uu.toChannels(p.rgba),{css:kt.toCss(jt,Ht,Pt,dt),rgba:kt.toRgba(jt,Ht,Pt,dt)}}e.opacity=o;function c(p,h){return dt=p.rgba&255,o(p,dt*h/255)}e.multiplyOpacity=c;function f(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=f})(nt||(nt={}));var ut;(e=>{let t,n;try{let a=document.createElement("canvas");a.width=1,a.height=1;let o=a.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return jt=parseInt(a.slice(1,2).repeat(2),16),Ht=parseInt(a.slice(2,3).repeat(2),16),Pt=parseInt(a.slice(3,4).repeat(2),16),kt.toColor(jt,Ht,Pt);case 5:return jt=parseInt(a.slice(1,2).repeat(2),16),Ht=parseInt(a.slice(2,3).repeat(2),16),Pt=parseInt(a.slice(3,4).repeat(2),16),dt=parseInt(a.slice(4,5).repeat(2),16),kt.toColor(jt,Ht,Pt,dt);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let o=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return jt=parseInt(o[1]),Ht=parseInt(o[2]),Pt=parseInt(o[3]),dt=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),kt.toColor(jt,Ht,Pt,dt);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[jt,Ht,Pt,dt]=t.getImageData(0,0,1,1).data,dt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:kt.toRgba(jt,Ht,Pt,dt),css:a}}e.toColor=s})(ut||(ut={}));var li;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,a,o){let c=s/255,f=a/255,p=o/255,h=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),_=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return h*.2126+g*.7152+_*.0722}e.relativeLuminance2=n})(li||(li={}));var uu;(e=>{function t(c,f){if(dt=(f&255)/255,dt===1)return f;let p=f>>24&255,h=f>>16&255,g=f>>8&255,_=c>>24&255,b=c>>16&255,y=c>>8&255;return jt=_+Math.round((p-_)*dt),Ht=b+Math.round((h-b)*dt),Pt=y+Math.round((g-y)*dt),kt.toRgba(jt,Ht,Pt)}e.blend=t;function n(c,f,p){let h=li.relativeLuminance(c>>8),g=li.relativeLuminance(f>>8);if(jn(h,g)>8));if(x>8));return x>L?y:k}return y}let _=a(c,f,p),b=jn(h,li.relativeLuminance(_>>8));if(b>8));return b>x?_:y}return _}}e.ensureContrastRatio=n;function s(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=jn(li.relativeLuminance2(b,y,x),li.relativeLuminance2(h,g,_));for(;k0||y>0||x>0);)b-=Math.max(0,Math.ceil(b*.1)),y-=Math.max(0,Math.ceil(y*.1)),x-=Math.max(0,Math.ceil(x*.1)),k=jn(li.relativeLuminance2(b,y,x),li.relativeLuminance2(h,g,_));return(b<<24|y<<16|x<<8|255)>>>0}e.reduceLuminance=s;function a(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=jn(li.relativeLuminance2(b,y,x),li.relativeLuminance2(h,g,_));for(;k>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(uu||(uu={}));function Vr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function jn(e,t){return e1){let g=this._getJoinedRanges(s,c,o,t,a);for(let _=0;_1){let h=this._getJoinedRanges(s,c,o,t,a);for(let g=0;g=U,j=B,H=this._workCell;if(b.length>0&&B===b[0][0]&&T){let we=b.shift(),Et=this._isCellInSelection(we[0],t);for(Z=we[0]+1;Z=we[1]),T?(R=!0,H=new pC(this._workCell,e.translateToString(!0,we[0],we[1]),we[1]-we[0]),j=we[1]-1,A=H.getWidth()):U=we[1]}let ae=this._isCellInSelection(B,t),E=n&&B===o,D=V&&B>=h&&B<=g,K=!1;this._decorationService.forEachDecorationAtCell(B,t,void 0,we=>{K=!0});let C=H.getChars()||xr;if(C===" "&&(H.isUnderline()||H.isOverline())&&(C=" "),me=A*f-p.get(C,H.isBold(),H.isItalic()),!k)k=this._document.createElement("span");else if(L&&(ae&&ue||!ae&&!ue&&H.bg===I)&&(ae&&ue&&y.selectionForeground||H.fg===Q)&&H.extended.ext===W&&D===O&&me===ie&&!E&&!R&&!K&&T){H.isInvisible()?M+=xr:M+=C,L++;continue}else L&&(k.textContent=M),k=this._document.createElement("span"),L=0,M="";if(I=H.bg,Q=H.fg,W=H.extended.ext,O=D,ie=me,ue=ae,R&&o>=B&&o<=j&&(o=B),!this._coreService.isCursorHidden&&E&&this._coreService.isCursorInitialized){if(le.push("xterm-cursor"),this._coreBrowserService.isFocused)c&&le.push("xterm-cursor-blink"),le.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":le.push("xterm-cursor-outline");break;case"block":le.push("xterm-cursor-block");break;case"bar":le.push("xterm-cursor-bar");break;case"underline":le.push("xterm-cursor-underline");break}}if(H.isBold()&&le.push("xterm-bold"),H.isItalic()&&le.push("xterm-italic"),H.isDim()&&le.push("xterm-dim"),H.isInvisible()?M=xr:M=H.getChars()||xr,H.isUnderline()&&(le.push(`xterm-underline-${H.extended.underlineStyle}`),M===" "&&(M=" "),!H.isUnderlineColorDefault()))if(H.isUnderlineColorRGB())k.style.textDecorationColor=`rgb(${Ca.toColorRGB(H.getUnderlineColor()).join(",")})`;else{let we=H.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&H.isBold()&&we<8&&(we+=8),k.style.textDecorationColor=y.ansi[we].css}H.isOverline()&&(le.push("xterm-overline"),M===" "&&(M=" ")),H.isStrikethrough()&&le.push("xterm-strikethrough"),D&&(k.style.textDecoration="underline");let J=H.getFgColor(),fe=H.getFgColorMode(),de=H.getBgColor(),xe=H.getBgColorMode(),Ne=!!H.isInverse();if(Ne){let we=J;J=de,de=we;let Et=fe;fe=xe,xe=Et}let ke,rt,et=!1;this._decorationService.forEachDecorationAtCell(B,t,void 0,we=>{we.options.layer!=="top"&&et||(we.backgroundColorRGB&&(xe=50331648,de=we.backgroundColorRGB.rgba>>8&16777215,ke=we.backgroundColorRGB),we.foregroundColorRGB&&(fe=50331648,J=we.foregroundColorRGB.rgba>>8&16777215,rt=we.foregroundColorRGB),et=we.options.layer==="top")}),!et&&ae&&(ke=this._coreBrowserService.isFocused?y.selectionBackgroundOpaque:y.selectionInactiveBackgroundOpaque,de=ke.rgba>>8&16777215,xe=50331648,et=!0,y.selectionForeground&&(fe=50331648,J=y.selectionForeground.rgba>>8&16777215,rt=y.selectionForeground)),et&&le.push("xterm-decoration-top");let ct;switch(xe){case 16777216:case 33554432:ct=y.ansi[de],le.push(`xterm-bg-${de}`);break;case 50331648:ct=kt.toColor(de>>16,de>>8&255,de&255),this._addStyle(k,`background-color:#${Tv((de>>>0).toString(16),"0",6)}`);break;case 0:default:Ne?(ct=y.foreground,le.push("xterm-bg-257")):ct=y.background}switch(ke||H.isDim()&&(ke=nt.multiplyOpacity(ct,.5)),fe){case 16777216:case 33554432:H.isBold()&&J<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(J+=8),this._applyMinimumContrast(k,ct,y.ansi[J],H,ke,void 0)||le.push(`xterm-fg-${J}`);break;case 50331648:let we=kt.toColor(J>>16&255,J>>8&255,J&255);this._applyMinimumContrast(k,ct,we,H,ke,rt)||this._addStyle(k,`color:#${Tv(J.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(k,ct,y.foreground,H,ke,rt)||Ne&&le.push("xterm-fg-257")}le.length&&(k.className=le.join(" "),le.length=0),!E&&!R&&!K&&T?L++:k.textContent=M,me!==this.defaultSpacing&&(k.style.letterSpacing=`${me}px`),_.push(k),B=j}return k&&L&&(k.textContent=M),_}_applyMinimumContrast(e,t,n,s,a,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||gC(s.getCode()))return!1;let c=this._getContrastCache(s),f;if(!a&&!o&&(f=c.getColor(t.rgba,n.rgba)),f===void 0){let p=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);f=nt.ensureContrastRatio(a||t,o||n,p),c.setColor((a||t).rgba,(o||n).rgba,f??null)}return f?(this._addStyle(e,`color:${f.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t=n[0]&&e=n[0]}};Zf=mt([pe(1,hb),pe(2,ci),pe(3,In),pe(4,ns),pe(5,ka),pe(6,tl)],Zf);function Tv(e,t,n){for(;e.length0&&(this._flat[s]=c),c}let a=e;t&&(a+="B"),n&&(a+="I");let o=this._holey.get(a);if(o===void 0){let c=0;t&&(c|=1),n&&(c|=2),o=this._measure(e,c),o>0&&this._holey.set(a,o)}return o}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},bC=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let a=e.buffers.active.ydisp,o=t[1]-a,c=n[1]-a,f=Math.max(o,0),p=Math.min(c,e.rows-1);if(f>=e.rows||p<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=o,this.viewportEndRow=c,this.viewportCappedStartRow=f,this.viewportCappedEndRow=p,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n=this.startCol&&t=this.startCol):!1}};function SC(){return new bC}var tf="xterm-dom-renderer-owner-",qi="xterm-rows",Qo="xterm-fg-",Av="xterm-bg-",Jl="xterm-focus",Jo="xterm-selection",xC=1,Qf=class extends Be{constructor(e,t,n,s,a,o,c,f,p,h,g,_,b,y){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=a,this._helperContainer=o,this._linkifier2=c,this._charSizeService=p,this._optionsService=h,this._bufferService=g,this._coreService=_,this._coreBrowserService=b,this._themeService=y,this._terminalClass=xC++,this._rowElements=[],this._selectionRenderModel=SC(),this.onRequestRedraw=this._register(new he).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(qi),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Jo),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=vC(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(x=>this._injectCss(x))),this._injectCss(this._themeService.colors),this._rowFactory=f.createInstance(Zf,document),this._element.classList.add(tf+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(x=>this._handleLinkHover(x))),this._register(this._linkifier2.onHideLinkUnderline(x=>this._handleLinkLeave(x))),this._register(at(()=>{this._element.classList.remove(tf+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new yC(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${qi} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${qi} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${qi} .xterm-dim { color: ${nt.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,a=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${a} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${qi}.${Jl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${qi}.${Jl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${qi}.${Jl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${qi} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${qi} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${qi} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${qi} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${qi} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Jo} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Jo} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Jo} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,c]of e.ansi.entries())t+=`${this._terminalSelector} .${Qo}${o} { color: ${c.css}; }${this._terminalSelector} .${Qo}${o}.xterm-dim { color: ${nt.multiplyOpacity(c,.5).css}; }${this._terminalSelector} .${Av}${o} { background-color: ${c.css}; }`;t+=`${this._terminalSelector} .${Qo}257 { color: ${nt.opaque(e.background).css}; }${this._terminalSelector} .${Qo}257.xterm-dim { color: ${nt.multiplyOpacity(nt.opaque(e.background),.5).css}; }${this._terminalSelector} .${Av}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Jl),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Jl),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,a=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,c=this._selectionRenderModel.viewportCappedEndRow,f=this._document.createDocumentFragment();if(n){let p=e[0]>t[0];f.appendChild(this._createSelectionElement(o,p?t[0]:e[0],p?e[0]:t[0],c-o+1))}else{let p=s===o?e[0]:0,h=o===a?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(o,p,h));let g=c-o-1;if(f.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,g)),o!==c){let _=a===c?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(c,0,_))}}this._selectionContainer.appendChild(f)}_createSelectionElement(e,t,n,s=1){let a=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,c=this.dimensions.css.cell.width*(n-t);return o+c>this.dimensions.css.canvas.width&&(c=this.dimensions.css.canvas.width-o),a.style.height=`${s*this.dimensions.css.cell.height}px`,a.style.top=`${e*this.dimensions.css.cell.height}px`,a.style.left=`${o}px`,a.style.width=`${c}px`,a}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,s=n.ybase+n.y,a=Math.min(n.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,c=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=e;p<=t;p++){let h=p+n.ydisp,g=this._rowElements[p],_=n.lines.get(h);if(!g||!_)break;g.replaceChildren(...this._rowFactory.createRow(_,h,h===s,c,f,a,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${tf}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,s,a,o){n<0&&(e=0),s<0&&(t=0);let c=this._bufferService.rows-1;n=Math.max(Math.min(n,c),0),s=Math.max(Math.min(s,c),0),a=Math.min(a,this._bufferService.cols);let f=this._bufferService.buffer,p=f.ybase+f.y,h=Math.min(f.x,a-1),g=this._optionsService.rawOptions.cursorBlink,_=this._optionsService.rawOptions.cursorStyle,b=this._optionsService.rawOptions.cursorInactiveStyle;for(let y=n;y<=s;++y){let x=y+f.ydisp,k=this._rowElements[y],L=f.lines.get(x);if(!k||!L)break;k.replaceChildren(...this._rowFactory.createRow(L,x,x===p,_,b,h,g,this.dimensions.css.cell.width,this._widthCache,o?y===n?e:0:-1,o?(y===s?t:a)-1:-1))}}};Qf=mt([pe(7,Cd),pe(8,Cu),pe(9,ci),pe(10,ui),pe(11,ns),pe(12,In),pe(13,tl)],Qf);var Jf=class extends Be{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new he),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new CC(this._optionsService))}catch{this._measureStrategy=this._register(new wC(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Jf=mt([pe(2,ci)],Jf);var Rb=class extends Be{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},wC=class extends Rb{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},CC=class extends Rb{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},kC=class extends Be{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new EC(this._window)),this._onDprChange=this._register(new he),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new he),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Jt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ee(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ee(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},EC=class extends Be{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Js),this._onDprChange=this._register(new he),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(at(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ee(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},TC=class extends Be{constructor(){super(),this.linkProviders=[],this._register(at(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Bd(e,t,n){let s=n.getBoundingClientRect(),a=e.getComputedStyle(n),o=parseInt(a.getPropertyValue("padding-left")),c=parseInt(a.getPropertyValue("padding-top"));return[t.clientX-s.left-o,t.clientY-s.top-c]}function AC(e,t,n,s,a,o,c,f,p){if(!o)return;let h=Bd(e,t,n);if(h)return h[0]=Math.ceil((h[0]+(p?c/2:0))/c),h[1]=Math.ceil(h[1]/f),h[0]=Math.min(Math.max(h[0],1),s+(p?1:0)),h[1]=Math.min(Math.max(h[1],1),a),h}var ed=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,a){return AC(window,e,t,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,a)}getMouseReportCoords(e,t){let n=Bd(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};ed=mt([pe(0,Fn),pe(1,Cu)],ed);var DC=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Mb={};Px(Mb,{getSafariVersion:()=>MC,isChromeOS:()=>zb,isFirefox:()=>Bb,isIpad:()=>BC,isIphone:()=>NC,isLegacyEdge:()=>RC,isLinux:()=>Nd,isMac:()=>_u,isNode:()=>ku,isSafari:()=>Nb,isWindows:()=>Lb});var ku=typeof process<"u"&&"title"in process,Ea=ku?"node":navigator.userAgent,Ta=ku?"node":navigator.platform,Bb=Ea.includes("Firefox"),RC=Ea.includes("Edge"),Nb=/^((?!chrome|android).)*safari/i.test(Ea);function MC(){if(!Nb)return 0;let e=Ea.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var _u=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Ta),BC=Ta==="iPad",NC=Ta==="iPhone",Lb=["Windows","Win16","Win32","WinCE"].includes(Ta),Nd=Ta.indexOf("Linux")>=0,zb=/\bCrOS\b/.test(Ea),Ob=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._ia){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=a}this.clear()}},LC=class extends Ob{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},zC=class extends Ob{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},gu=!ku&&"requestIdleCallback"in window?zC:LC,OC=class{constructor(){this._queue=new gu}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},td=class extends Be{constructor(e,t,n,s,a,o,c,f,p){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=a,this._coreBrowserService=f,this._renderer=this._register(new Js),this._pausedResizeTask=new OC,this._observerDisposable=this._register(new Js),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new he),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new he),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new he),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new he),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new DC((h,g)=>this._renderRows(h,g),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new jC(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(at(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(c.onResize(()=>this._fullRefresh())),this._register(c.buffers.onBufferActivate(()=>{var h;return(h=this._renderer.value)==null?void 0:h.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(c.cols,c.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(c.buffer.y,c.buffer.y,!0))),this._register(p.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(h=>this._registerIntersectionObserver(h,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=at(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var n;return(n=this._renderer.value)==null?void 0:n.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,n){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};td=mt([pe(2,ci),pe(3,Cu),pe(4,ns),pe(5,ka),pe(6,ui),pe(7,In),pe(8,tl)],td);var jC=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function HC(e,t,n,s){let a=n.buffer.x,o=n.buffer.y;if(!n.buffer.hasScrollback)return IC(a,o,e,t,n,s)+Eu(o,t,n,s)+FC(a,o,e,t,n,s);let c;if(o===t)return c=a>e?"D":"C",ya(Math.abs(a-e),va(c,s));c=o>t?"D":"C";let f=Math.abs(o-t),p=UC(o>t?e:a,n)+(f-1)*n.cols+1+PC(o>t?a:e);return ya(p,va(c,s))}function PC(e,t){return e-1}function UC(e,t){return t.cols-e}function IC(e,t,n,s,a,o){return Eu(t,s,a,o).length===0?"":ya(Hb(e,t,e,t-ts(t,a),!1,a).length,va("D",o))}function Eu(e,t,n,s){let a=e-ts(e,n),o=t-ts(t,n),c=Math.abs(a-o)-qC(e,t,n);return ya(c,va(jb(e,t),s))}function FC(e,t,n,s,a,o){let c;Eu(t,s,a,o).length>0?c=s-ts(s,a):c=t;let f=s,p=WC(e,t,n,s,a,o);return ya(Hb(e,c,n,f,p==="C",a).length,va(p,o))}function qC(e,t,n){var c;let s=0,a=e-ts(e,n),o=t-ts(t,n);for(let f=0;f=0&&e0?c=s-ts(s,a):c=t,e=n&&ct?"A":"B"}function Hb(e,t,n,s,a,o){let c=e,f=t,p="";for(;(c!==n||f!==s)&&f>=0&&fo.cols-1?(p+=o.buffer.translateBufferLineToString(f,!1,e,c),c=0,e=0,f++):!a&&c<0&&(p+=o.buffer.translateBufferLineToString(f,!1,0,e+1),c=o.cols-1,e=c,f--);return p+o.buffer.translateBufferLineToString(f,!1,e,c)}function va(e,t){let n=t?"O":"[";return se.ESC+n+e}function ya(e,t){e=Math.floor(e);let n="";for(let s=0;sthis._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Dv(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var nf=50,VC=15,KC=50,XC=500,$C=" ",GC=new RegExp($C,"g"),id=class extends Be{constructor(e,t,n,s,a,o,c,f,p){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=a,this._mouseService=o,this._optionsService=c,this._renderService=f,this._coreBrowserService=p,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Ki,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new he),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new he),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new he),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new he),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=h=>this._handleMouseMove(h),this._mouseUpListener=h=>this._handleMouseUp(h),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(h=>this._handleTrim(h)),this._register(this._bufferService.buffers.onBufferActivate(h=>this._handleBufferActivate(h))),this.enable(),this._model=new YC(this._bufferService),this._activeSelectionMode=0,this._register(at(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(h=>{h.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let a=e[0]a.replace(GC," ")).join(Lb?`\r +`))}},fw=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},dw=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},pw=0,Zh=class{constructor(e){this.value=e,this.id=pw++}},mw=2,_w,he=class{constructor(t){var n,s,a,o;this._size=0,this._options=t,this._leakageMon=(n=this._options)!=null&&n.leakWarningThreshold?new cw((t==null?void 0:t.onListenerError)??su,((s=this._options)==null?void 0:s.leakWarningThreshold)??uw):void 0,this._perfMon=(a=this._options)!=null&&a._profName?new ow(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var t,n,s,a;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(s=(n=this._options)==null?void 0:n.onDidRemoveLastListener)==null||s.call(n),(a=this._leakageMon)==null||a.dispose())}get event(){return this._event??(this._event=(t,n,s)=>{var f,p,h,g,_;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let b=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(b);let y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],x=new dw(`${b}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((f=this._options)==null?void 0:f.onListenerError)||su)(x),Ne.None}if(this._disposed)return Ne.None;n&&(t=t.bind(n));let a=new Zh(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(a.stack=hw.create(),o=this._leakageMon.check(a.stack,this._size+1)),this._listeners?this._listeners instanceof Zh?(this._deliveryQueue??(this._deliveryQueue=new gw),this._listeners=[this._listeners,a]):this._listeners.push(a):((h=(p=this._options)==null?void 0:p.onWillAddFirstListener)==null||h.call(p,this),this._listeners=a,(_=(g=this._options)==null?void 0:g.onDidAddFirstListener)==null||_.call(g,this)),this._size++;let c=ct(()=>{o==null||o(),this._removeListener(a)});return s instanceof wr?s.add(c):Array.isArray(s)&&s.push(c),c}),this._event}_removeListener(t){var o,c,f,p;if((c=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||c.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(p=(f=this._options)==null?void 0:f.onDidRemoveLastListener)==null||p.call(f,this),this._size=0;return}let n=this._listeners,s=n.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,n[s]=void 0;let a=this._deliveryQueue.current===this;if(this._size*mw<=n.length){let h=0;for(let g=0;g0}},gw=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Uf=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new he,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new he,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Uf.INSTANCE=new Uf;var Ed=Uf;function vw(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Ed.INSTANCE.onDidChangeZoomLevel;function yw(e){return Ed.INSTANCE.getZoomFactor(e)}Ed.INSTANCE.onDidChangeFullscreen;var tl=typeof navigator=="object"?navigator.userAgent:"",If=tl.indexOf("Firefox")>=0,bw=tl.indexOf("AppleWebKit")>=0,Td=tl.indexOf("Chrome")>=0,Sw=!Td&&tl.indexOf("Safari")>=0;tl.indexOf("Electron/")>=0;tl.indexOf("Android")>=0;var Qh=!1;if(typeof Hn.matchMedia=="function"){let e=Hn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Hn.matchMedia("(display-mode: fullscreen)");Qh=e.matches,vw(Hn,e,({matches:n})=>{Qh&&t.matches||(Qh=n)})}var Gs="en",Ff=!1,qf=!1,lu=!1,Sb=!1,$o,au=Gs,fv=Gs,xw,Ji,Qr=globalThis,Jt,Zy;typeof Qr.vscode<"u"&&typeof Qr.vscode.process<"u"?Jt=Qr.vscode.process:typeof process<"u"&&typeof((Zy=process==null?void 0:process.versions)==null?void 0:Zy.node)=="string"&&(Jt=process);var Qy,ww=typeof((Qy=Jt==null?void 0:Jt.versions)==null?void 0:Qy.electron)=="string",Cw=ww&&(Jt==null?void 0:Jt.type)==="renderer",Jy;if(typeof Jt=="object"){Ff=Jt.platform==="win32",qf=Jt.platform==="darwin",lu=Jt.platform==="linux",lu&&Jt.env.SNAP&&Jt.env.SNAP_REVISION,Jt.env.CI||Jt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,$o=Gs,au=Gs;let e=Jt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);$o=t.userLocale,fv=t.osLocale,au=t.resolvedLanguage||Gs,xw=(Jy=t.languagePack)==null?void 0:Jy.translationsConfigFile}catch{}Sb=!0}else typeof navigator=="object"&&!Cw?(Ji=navigator.userAgent,Ff=Ji.indexOf("Windows")>=0,qf=Ji.indexOf("Macintosh")>=0,(Ji.indexOf("Macintosh")>=0||Ji.indexOf("iPad")>=0||Ji.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,lu=Ji.indexOf("Linux")>=0,(Ji==null?void 0:Ji.indexOf("Mobi"))>=0,au=globalThis._VSCODE_NLS_LANGUAGE||Gs,$o=navigator.language.toLowerCase(),fv=$o):console.error("Unable to resolve platform.");var xb=Ff,hn=qf,kw=lu,dv=Sb,fn=Ji,_r=au,Ew;(e=>{function t(){return _r}e.value=t;function n(){return _r.length===2?_r==="en":_r.length>=3?_r[0]==="e"&&_r[1]==="n"&&_r[2]==="-":!1}e.isDefaultVariant=n;function s(){return _r==="en"}e.isDefault=s})(Ew||(Ew={}));var Tw=typeof Qr.postMessage=="function"&&!Qr.importScripts;(()=>{if(Tw){let e=[];Qr.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,a=e.length;s{let s=++t;e.push({id:s,callback:n}),Qr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var Aw=!!(fn&&fn.indexOf("Chrome")>=0);fn&&fn.indexOf("Firefox")>=0;!Aw&&fn&&fn.indexOf("Safari")>=0;fn&&fn.indexOf("Edg/")>=0;fn&&fn.indexOf("Android")>=0;var qs=typeof navigator=="object"?navigator:{};dv||document.queryCommandSupported&&document.queryCommandSupported("copy")||qs&&qs.clipboard&&qs.clipboard.writeText,dv||qs&&qs.clipboard&&qs.clipboard.readText;var Ad=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Jh=new Ad,pv=new Ad,mv=new Ad,Dw=new Array(230),wb;(e=>{function t(f){return Jh.keyCodeToStr(f)}e.toString=t;function n(f){return Jh.strToKeyCode(f)}e.fromString=n;function s(f){return pv.keyCodeToStr(f)}e.toUserSettingsUS=s;function a(f){return mv.keyCodeToStr(f)}e.toUserSettingsGeneral=a;function o(f){return pv.strToKeyCode(f)||mv.strToKeyCode(f)}e.fromUserSettings=o;function c(f){if(f>=98&&f<=113)return null;switch(f){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Jh.keyCodeToStr(f)}e.toElectronAccelerator=c})(wb||(wb={}));var Rw=class Cb{constructor(t,n,s,a,o){this.ctrlKey=t,this.shiftKey=n,this.altKey=s,this.metaKey=a,this.keyCode=o}equals(t){return t instanceof Cb&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",s=this.altKey?"1":"0",a=this.metaKey?"1":"0";return`K${t}${n}${s}${a}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Mw([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Mw=class{constructor(e){if(e.length===0)throw iw("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t{function t(n){return n===e.None||n===e.Cancelled||n instanceof Uw?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ei.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:kb})})(Pw||(Pw={}));var Uw=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?kb:(this._emitter||(this._emitter=new he),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Dd=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new zf("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new zf("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Iw=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new zf("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=ct(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Fw;(e=>{async function t(s){let a,o=await Promise.all(s.map(c=>c.then(f=>f,f=>{a||(a=f)})));if(typeof a<"u")throw a;return o}e.settled=t;function n(s){return new Promise(async(a,o)=>{try{await s(a,o)}catch(c){o(c)}})}e.withAsyncBody=n})(Fw||(Fw={}));var yv=class Yi{static fromArray(t){return new Yi(n=>{n.emitMany(t)})}static fromPromise(t){return new Yi(async n=>{n.emitMany(await t)})}static fromPromises(t){return new Yi(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new Yi(async n=>{await Promise.all(t.map(async s=>{for await(let a of s)n.emitOne(a)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new he,queueMicrotask(async()=>{let s={emitOne:a=>this.emitOne(a),emitMany:a=>this.emitMany(a),reject:a=>this.reject(a)};try{await Promise.resolve(t(s)),this.resolve()}catch(a){this.reject(a)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(t,n){return new Yi(async s=>{for await(let a of t)s.emitOne(n(a))})}map(t){return Yi.map(this,t)}static filter(t,n){return new Yi(async s=>{for await(let a of t)n(a)&&s.emitOne(a)})}filter(t){return Yi.filter(this,t)}static coalesce(t){return Yi.filter(t,n=>!!n)}coalesce(){return Yi.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return Yi.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};yv.EMPTY=yv.fromArray([]);var{getWindow:cn,getWindowId:qw,onDidRegisterWindow:Ww}=(function(){let e=new Map,t={window:Hn,disposables:new wr};e.set(Hn.vscodeWindowId,t);let n=new he,s=new he,a=new he;function o(c,f){return(typeof c=="number"?e.get(c):void 0)??(f?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:a.event,onDidUnregisterWindow:s.event,registerWindow(c){if(e.has(c.vscodeWindowId))return Ne.None;let f=new wr,p={window:c,disposables:f.add(new wr)};return e.set(c.vscodeWindowId,p),f.add(ct(()=>{e.delete(c.vscodeWindowId),s.fire(c)})),f.add(ke(c,Ht.BEFORE_UNLOAD,()=>{a.fire(c)})),n.fire(p),f},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return e.has(c)},getWindowById:o,getWindow(c){var h;let f=c;if((h=f==null?void 0:f.ownerDocument)!=null&&h.defaultView)return f.ownerDocument.defaultView.window;let p=c;return p!=null&&p.view?p.view.window:Hn},getDocument(c){return cn(c).document}}})(),Yw=class{constructor(e,t,n,s){this._node=e,this._type=t,this._handler=n,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function ke(e,t,n,s){return new Yw(e,t,n,s)}var bv=function(e,t,n,s){return ke(e,t,n,s)},Rd,Vw=class extends Iw{constructor(e){super(),this.defaultTarget=e&&cn(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Sv=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){su(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,s=new Map,a=o=>{n.set(o,!1);let c=e.get(o)??[];for(t.set(o,c),e.set(o,[]),s.set(o,!0);c.length>0;)c.sort(Sv.sort),c.shift().execute();s.set(o,!1)};Rd=(o,c,f=0)=>{let p=qw(o),h=new Sv(c,f),g=e.get(p);return g||(g=[],e.set(p,g)),g.push(h),n.get(p)||(n.set(p,!0),o.requestAnimationFrame(()=>a(p))),h}})();function Kw(e){let t=e.getBoundingClientRect(),n=cn(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Ht={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Xw=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=yi(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=yi(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=yi(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=yi(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=yi(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=yi(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=yi(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=yi(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=yi(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=yi(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=yi(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=yi(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=yi(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=yi(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function yi(e){return typeof e=="number"?`${e}px`:e}function da(e){return new Xw(e)}var Eb=class{constructor(){this._hooks=new wr,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,s,a){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=a;let o=e;try{e.setPointerCapture(t),this._hooks.add(ct(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=cn(e)}this._hooks.add(ke(o,Ht.POINTER_MOVE,c=>{if(c.buttons!==n){this.stopMonitoring(!0);return}c.preventDefault(),this._pointerMoveCallback(c)})),this._hooks.add(ke(o,Ht.POINTER_UP,c=>this.stopMonitoring(!0)))}};function $w(e,t,n){let s=null,a=null;if(typeof n.value=="function"?(s="value",a=n.value,a.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",a=n.get),!a)throw new Error("not supported");let o=`$memoize$${t}`;n[s]=function(...c){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:a.apply(this,c)}),this[o]}}var on;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(on||(on={}));var oa=class ii extends Ne{constructor(){super(),this.dispatched=!1,this.targets=new hv,this.ignoreTargets=new hv,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(ei.runAndSubscribe(Ww,({window:t,disposables:n})=>{n.add(ke(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(ke(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(ke(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Hn,disposables:this._store}))}static addTarget(t){if(!ii.isTouchDevice())return Ne.None;ii.INSTANCE||(ii.INSTANCE=new ii);let n=ii.INSTANCE.targets.push(t);return ct(n)}static ignoreTarget(t){if(!ii.isTouchDevice())return Ne.None;ii.INSTANCE||(ii.INSTANCE=new ii);let n=ii.INSTANCE.ignoreTargets.push(t);return ct(n)}static isTouchDevice(){return"ontouchstart"in Hn||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,a=t.targetTouches.length;s=ii.HOLD_DELAY&&Math.abs(p.initialPageX-Di(p.rollingPageX))<30&&Math.abs(p.initialPageY-Di(p.rollingPageY))<30){let g=this.newGestureEvent(on.Contextmenu,p.initialTarget);g.pageX=Di(p.rollingPageX),g.pageY=Di(p.rollingPageY),this.dispatchEvent(g)}else if(a===1){let g=Di(p.rollingPageX),_=Di(p.rollingPageY),b=Di(p.rollingTimestamps)-p.rollingTimestamps[0],y=g-p.rollingPageX[0],x=_-p.rollingPageY[0],k=[...this.targets].filter(L=>p.initialTarget instanceof Node&&L.contains(p.initialTarget));this.inertia(t,k,s,Math.abs(y)/b,y>0?1:-1,g,Math.abs(x)/b,x>0?1:-1,_)}this.dispatchEvent(this.newGestureEvent(on.End,p.initialTarget)),delete this.activeTouches[f.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(t){if(t.type===on.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>ii.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===on.Change||t.type===on.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let n=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let a=0,o=t.initialTarget;for(;o&&o!==s;)a++,o=o.parentElement;n.push([a,s])}n.sort((s,a)=>s[0]-a[0]);for(let[s,a]of n)a.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,s,a,o,c,f,p,h){this.handle=Rd(t,()=>{let g=Date.now(),_=g-s,b=0,y=0,x=!0;a+=ii.SCROLL_FRICTION*_,f+=ii.SCROLL_FRICTION*_,a>0&&(x=!1,b=o*a*_),f>0&&(x=!1,y=p*f*_);let k=this.newGestureEvent(on.Change);k.translationX=b,k.translationY=y,n.forEach(L=>L.dispatchEvent(k)),x||this.inertia(t,n,g,a,o,c+b,f,p,h+y)})}onTouchMove(t){let n=Date.now();for(let s=0,a=t.changedTouches.length;s3&&(c.rollingPageX.shift(),c.rollingPageY.shift(),c.rollingTimestamps.shift()),c.rollingPageX.push(o.pageX),c.rollingPageY.push(o.pageY),c.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};oa.SCROLL_FRICTION=-.005,oa.HOLD_DELAY=700,oa.CLEAR_TAP_COUNT_TIME=400,gt([$w],oa,"isTouchDevice",1);var Gw=oa,Md=class extends Ne{onclick(e,t){this._register(ke(e,Ht.CLICK,n=>t(new Go(cn(e),n))))}onmousedown(e,t){this._register(ke(e,Ht.MOUSE_DOWN,n=>t(new Go(cn(e),n))))}onmouseover(e,t){this._register(ke(e,Ht.MOUSE_OVER,n=>t(new Go(cn(e),n))))}onmouseleave(e,t){this._register(ke(e,Ht.MOUSE_LEAVE,n=>t(new Go(cn(e),n))))}onkeydown(e,t){this._register(ke(e,Ht.KEY_DOWN,n=>t(new _v(n))))}onkeyup(e,t){this._register(ke(e,Ht.KEY_UP,n=>t(new _v(n))))}oninput(e,t){this._register(ke(e,Ht.INPUT,t))}onblur(e,t){this._register(ke(e,Ht.BLUR,t))}onfocus(e,t){this._register(ke(e,Ht.FOCUS,t))}onchange(e,t){this._register(ke(e,Ht.CHANGE,t))}ignoreGesture(e){return Gw.ignoreTarget(e)}},xv=11,Zw=class extends Md{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=xv+"px",this.domNode.style.height=xv+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new Eb),this._register(bv(this.bgDomNode,Ht.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(bv(this.domNode,Ht.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Vw),this._pointerdownScheduleRepeatTimer=this._register(new Dd)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,cn(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Qw=class Wf{constructor(t,n,s,a,o,c,f){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,a=a|0,o=o|0,c=c|0,f=f|0),this.rawScrollLeft=a,this.rawScrollTop=f,n<0&&(n=0),a+n>s&&(a=s-n),a<0&&(a=0),o<0&&(o=0),f+o>c&&(f=c-o),f<0&&(f=0),this.width=n,this.scrollWidth=s,this.scrollLeft=a,this.height=o,this.scrollHeight=c,this.scrollTop=f}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new Wf(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Wf(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let s=this.width!==t.width,a=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,c=this.height!==t.height,f=this.scrollHeight!==t.scrollHeight,p=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:a,scrollLeftChanged:o,heightChanged:c,scrollHeightChanged:f,scrollTopChanged:p}}},Jw=class extends Ne{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new he),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Qw(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let s;t?s=new Cv(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=Cv.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},wv=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function ef(e,t){let n=t-e;return function(s){return e+n*iC(s)}}function eC(e,t,n){return function(s){return s2.5*s){let a,o;return t{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},rC=140,Tb=class extends Md{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new nC(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Eb),this._shouldRender=!0,this.domNode=da(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(ke(this.domNode.domNode,Ht.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Zw(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=da(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(ke(this.slider.domNode,Ht.POINTER_DOWN,a=>{a.button===0&&(a.preventDefault(),this._sliderPointerDown(a))})),this.onclick(this.slider.domNode,a=>{a.leftButton&&a.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),a=this._sliderPointerPosition(e);n<=a&&a<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let a=Kw(this.domNode.domNode);t=e.pageX-a.left,n=e.pageY-a.top}let s=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,a=>{let o=this._sliderOrthogonalPointerPosition(a),c=Math.abs(o-n);if(xb&&c>rC){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let f=this._sliderPointerPosition(a)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(f))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Ab=class Vf{constructor(t,n,s,a,o,c){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=a,this._scrollSize=o,this._scrollPosition=c,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Vf(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,s,a,o){let c=Math.max(0,s-t),f=Math.max(0,c-2*n),p=a>0&&a>s;if(!p)return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(f),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(s*f/a))),g=(f-h)/(a-s),_=o*g;return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(h),computedSliderRatio:g,computedSliderPosition:Math.round(_)}}_refreshComputedValues(){let t=Vf._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,s=this._scrollPosition;return n0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),n){let a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),c=Math.abs(n.deltaX),f=Math.abs(n.deltaY),p=Math.max(Math.min(a,c),1),h=Math.max(Math.min(o,f),1),g=Math.max(a,c),_=Math.max(o,f);g%p===0&&_%h===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Kf.INSTANCE=new Kf;var uC=Kf,cC=class extends Md{constructor(e,t,n){super(),this._onScroll=this._register(new he),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new he),this.onWillScroll=this._onWillScroll.event,this._options=fC(t),this._scrollable=n,this._register(this._scrollable.onScroll(a=>{this._onWillScroll.fire(a),this._onDidScroll(a),this._onScroll.fire(a)}));let s={onMouseWheel:a=>this._onMouseWheel(a),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new lC(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new sC(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=da(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=da(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=da(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,a=>this._onMouseOver(a)),this.onmouseleave(this._listenOnDomNode,a=>this._onMouseLeave(a)),this._hideTimeout=this._register(new Dd),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Jr(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,hn&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new vv(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Jr(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new vv(n))};this._mouseWheelToDispose.push(ke(this._listenOnDomNode,Ht.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var a;if((a=e.browserEvent)!=null&&a.defaultPrevented)return;let t=uC.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+o===0?c=o=0:Math.abs(o)>=Math.abs(c)?c=0:o=0),this._options.flipAxes&&([o,c]=[c,o]);let f=!hn&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||f)&&!c&&(c=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),h={};if(o){let g=kv*o,_=p.scrollTop-(g<0?Math.floor(g):Math.ceil(g));this._verticalScrollbar.writeScrollPosition(h,_)}if(c){let g=kv*c,_=p.scrollLeft-(g<0?Math.floor(g):Math.ceil(g));this._horizontalScrollbar.writeScrollPosition(h,_)}h=this._scrollable.validateScrollPosition(h),(p.scrollLeft!==h.scrollLeft||p.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),n=!0)}let s=n;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,s=n?" left":"",a=t?" top":"",o=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${a}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${a}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),aC)}},hC=class extends cC{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function fC(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,hn&&(t.className+=" mac"),t}var Xf=class extends Ne{constructor(e,t,n,s,a,o,c,f){super(),this._bufferService=n,this._optionsService=c,this._renderService=f,this._onRequestScrollLines=this._register(new he),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new Jw({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Rd(s.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new hC(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},p)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(a.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(ei.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ct(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ct(()=>this._styleElement.remove())),this._register(ei.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(` +`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(h=>this._handleScroll(h)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};Xf=gt([pe(2,ci),pe(3,Pn),pe(4,ob),pe(5,el),pe(6,hi),pe(7,Un)],Xf);var $f=class extends Ne{constructor(e,t,n,s,a){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=s,this._renderService=a,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(ct(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};$f=gt([pe(1,ci),pe(2,Pn),pe(3,Ca),pe(4,Un)],$f);var dC=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},ln={full:0,left:0,center:0,right:0},gr={full:0,left:0,center:0,right:0},Zl={full:0,left:0,center:0,right:0},pu=class extends Ne{constructor(e,t,n,s,a,o,c,f){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=a,this._optionsService=o,this._themeService=c,this._coreBrowserService=f,this._colorZoneStore=new dC,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(h=this._viewportElement.parentElement)==null||h.insertBefore(this._canvas,this._viewportElement),this._register(ct(()=>{var g;return(g=this._canvas)==null?void 0:g.remove()}));let p=this._canvas.getContext("2d");if(p)this._ctx=p;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);gr.full=this._canvas.width,gr.left=e,gr.center=t,gr.right=e,this._refreshDrawHeightConstants(),Zl.full=1,Zl.left=1,Zl.center=1+gr.left,Zl.right=1+gr.left+gr.center}_refreshDrawHeightConstants(){ln.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);ln.left=t,ln.center=t,ln.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Zl[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ln[e.position||"full"]/2),gr[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ln[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};pu=gt([pe(2,ci),pe(3,Ca),pe(4,Un),pe(5,hi),pe(6,el),pe(7,Pn)],pu);var re;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=` +`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(re||(re={}));var ou;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(ou||(ou={}));var Db;(e=>e.ST=`${re.ESC}\\`)(Db||(Db={}));var Gf=class{constructor(e,t,n,s,a,o){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=s,this._coreService=a,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.lengththis.updateCompositionElements(!0),0)}}};Gf=gt([pe(2,ci),pe(3,hi),pe(4,is),pe(5,Un)],Gf);var Pt=0,Ut=0,It=0,mt=0,Ev={css:"#00000000",rgba:0},Dt;(e=>{function t(a,o,c,f){return f!==void 0?`#${Yr(a)}${Yr(o)}${Yr(c)}${Yr(f)}`:`#${Yr(a)}${Yr(o)}${Yr(c)}`}e.toCss=t;function n(a,o,c,f=255){return(a<<24|o<<16|c<<8|f)>>>0}e.toRgba=n;function s(a,o,c,f){return{css:e.toCss(a,o,c,f),rgba:e.toRgba(a,o,c,f)}}e.toColor=s})(Dt||(Dt={}));var ot;(e=>{function t(p,h){if(mt=(h.rgba&255)/255,mt===1)return{css:h.css,rgba:h.rgba};let g=h.rgba>>24&255,_=h.rgba>>16&255,b=h.rgba>>8&255,y=p.rgba>>24&255,x=p.rgba>>16&255,k=p.rgba>>8&255;Pt=y+Math.round((g-y)*mt),Ut=x+Math.round((_-x)*mt),It=k+Math.round((b-k)*mt);let L=Dt.toCss(Pt,Ut,It),M=Dt.toRgba(Pt,Ut,It);return{css:L,rgba:M}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,h,g){let _=uu.ensureContrastRatio(p.rgba,h.rgba,g);if(_)return Dt.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function a(p){let h=(p.rgba|255)>>>0;return[Pt,Ut,It]=uu.toChannels(h),{css:Dt.toCss(Pt,Ut,It),rgba:h}}e.opaque=a;function o(p,h){return mt=Math.round(h*255),[Pt,Ut,It]=uu.toChannels(p.rgba),{css:Dt.toCss(Pt,Ut,It,mt),rgba:Dt.toRgba(Pt,Ut,It,mt)}}e.opacity=o;function c(p,h){return mt=p.rgba&255,o(p,mt*h/255)}e.multiplyOpacity=c;function f(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=f})(ot||(ot={}));var ft;(e=>{let t,n;try{let a=document.createElement("canvas");a.width=1,a.height=1;let o=a.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return Pt=parseInt(a.slice(1,2).repeat(2),16),Ut=parseInt(a.slice(2,3).repeat(2),16),It=parseInt(a.slice(3,4).repeat(2),16),Dt.toColor(Pt,Ut,It);case 5:return Pt=parseInt(a.slice(1,2).repeat(2),16),Ut=parseInt(a.slice(2,3).repeat(2),16),It=parseInt(a.slice(3,4).repeat(2),16),mt=parseInt(a.slice(4,5).repeat(2),16),Dt.toColor(Pt,Ut,It,mt);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let o=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Pt=parseInt(o[1]),Ut=parseInt(o[2]),It=parseInt(o[3]),mt=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Dt.toColor(Pt,Ut,It,mt);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Pt,Ut,It,mt]=t.getImageData(0,0,1,1).data,mt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Dt.toRgba(Pt,Ut,It,mt),css:a}}e.toColor=s})(ft||(ft={}));var ai;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,a,o){let c=s/255,f=a/255,p=o/255,h=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),_=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return h*.2126+g*.7152+_*.0722}e.relativeLuminance2=n})(ai||(ai={}));var uu;(e=>{function t(c,f){if(mt=(f&255)/255,mt===1)return f;let p=f>>24&255,h=f>>16&255,g=f>>8&255,_=c>>24&255,b=c>>16&255,y=c>>8&255;return Pt=_+Math.round((p-_)*mt),Ut=b+Math.round((h-b)*mt),It=y+Math.round((g-y)*mt),Dt.toRgba(Pt,Ut,It)}e.blend=t;function n(c,f,p){let h=ai.relativeLuminance(c>>8),g=ai.relativeLuminance(f>>8);if(zn(h,g)>8));if(x>8));return x>L?y:k}return y}let _=a(c,f,p),b=zn(h,ai.relativeLuminance(_>>8));if(b>8));return b>x?_:y}return _}}e.ensureContrastRatio=n;function s(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=zn(ai.relativeLuminance2(b,y,x),ai.relativeLuminance2(h,g,_));for(;k0||y>0||x>0);)b-=Math.max(0,Math.ceil(b*.1)),y-=Math.max(0,Math.ceil(y*.1)),x-=Math.max(0,Math.ceil(x*.1)),k=zn(ai.relativeLuminance2(b,y,x),ai.relativeLuminance2(h,g,_));return(b<<24|y<<16|x<<8|255)>>>0}e.reduceLuminance=s;function a(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=zn(ai.relativeLuminance2(b,y,x),ai.relativeLuminance2(h,g,_));for(;k>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(uu||(uu={}));function Yr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function zn(e,t){return e1){let g=this._getJoinedRanges(s,c,o,t,a);for(let _=0;_1){let h=this._getJoinedRanges(s,c,o,t,a);for(let g=0;g=U,j=B,H=this._workCell;if(b.length>0&&B===b[0][0]&&T){let xe=b.shift(),Vt=this._isCellInSelection(xe[0],t);for(G=xe[0]+1;G=xe[1]),T?(R=!0,H=new pC(this._workCell,e.translateToString(!0,xe[0],xe[1]),xe[1]-xe[0]),j=xe[1]-1,A=H.getWidth()):U=xe[1]}let ae=this._isCellInSelection(B,t),E=n&&B===o,D=V&&B>=h&&B<=g,K=!1;this._decorationService.forEachDecorationAtCell(B,t,void 0,xe=>{K=!0});let C=H.getChars()||xr;if(C===" "&&(H.isUnderline()||H.isOverline())&&(C=" "),_e=A*f-p.get(C,H.isBold(),H.isItalic()),!k)k=this._document.createElement("span");else if(L&&(ae&&ue||!ae&&!ue&&H.bg===I)&&(ae&&ue&&y.selectionForeground||H.fg===Z)&&H.extended.ext===W&&D===O&&_e===te&&!E&&!R&&!K&&T){H.isInvisible()?M+=xr:M+=C,L++;continue}else L&&(k.textContent=M),k=this._document.createElement("span"),L=0,M="";if(I=H.bg,Z=H.fg,W=H.extended.ext,O=D,te=_e,ue=ae,R&&o>=B&&o<=j&&(o=B),!this._coreService.isCursorHidden&&E&&this._coreService.isCursorInitialized){if(se.push("xterm-cursor"),this._coreBrowserService.isFocused)c&&se.push("xterm-cursor-blink"),se.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":se.push("xterm-cursor-outline");break;case"block":se.push("xterm-cursor-block");break;case"bar":se.push("xterm-cursor-bar");break;case"underline":se.push("xterm-cursor-underline");break}}if(H.isBold()&&se.push("xterm-bold"),H.isItalic()&&se.push("xterm-italic"),H.isDim()&&se.push("xterm-dim"),H.isInvisible()?M=xr:M=H.getChars()||xr,H.isUnderline()&&(se.push(`xterm-underline-${H.extended.underlineStyle}`),M===" "&&(M=" "),!H.isUnderlineColorDefault()))if(H.isUnderlineColorRGB())k.style.textDecorationColor=`rgb(${wa.toColorRGB(H.getUnderlineColor()).join(",")})`;else{let xe=H.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&H.isBold()&&xe<8&&(xe+=8),k.style.textDecorationColor=y.ansi[xe].css}H.isOverline()&&(se.push("xterm-overline"),M===" "&&(M=" ")),H.isStrikethrough()&&se.push("xterm-strikethrough"),D&&(k.style.textDecoration="underline");let Q=H.getFgColor(),fe=H.getFgColorMode(),de=H.getBgColor(),Ce=H.getBgColorMode(),Le=!!H.isInverse();if(Le){let xe=Q;Q=de,de=xe;let Vt=fe;fe=Ce,Ce=Vt}let Ee,st,Ye=!1;this._decorationService.forEachDecorationAtCell(B,t,void 0,xe=>{xe.options.layer!=="top"&&Ye||(xe.backgroundColorRGB&&(Ce=50331648,de=xe.backgroundColorRGB.rgba>>8&16777215,Ee=xe.backgroundColorRGB),xe.foregroundColorRGB&&(fe=50331648,Q=xe.foregroundColorRGB.rgba>>8&16777215,st=xe.foregroundColorRGB),Ye=xe.options.layer==="top")}),!Ye&&ae&&(Ee=this._coreBrowserService.isFocused?y.selectionBackgroundOpaque:y.selectionInactiveBackgroundOpaque,de=Ee.rgba>>8&16777215,Ce=50331648,Ye=!0,y.selectionForeground&&(fe=50331648,Q=y.selectionForeground.rgba>>8&16777215,st=y.selectionForeground)),Ye&&se.push("xterm-decoration-top");let xt;switch(Ce){case 16777216:case 33554432:xt=y.ansi[de],se.push(`xterm-bg-${de}`);break;case 50331648:xt=Dt.toColor(de>>16,de>>8&255,de&255),this._addStyle(k,`background-color:#${Tv((de>>>0).toString(16),"0",6)}`);break;case 0:default:Le?(xt=y.foreground,se.push("xterm-bg-257")):xt=y.background}switch(Ee||H.isDim()&&(Ee=ot.multiplyOpacity(xt,.5)),fe){case 16777216:case 33554432:H.isBold()&&Q<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Q+=8),this._applyMinimumContrast(k,xt,y.ansi[Q],H,Ee,void 0)||se.push(`xterm-fg-${Q}`);break;case 50331648:let xe=Dt.toColor(Q>>16&255,Q>>8&255,Q&255);this._applyMinimumContrast(k,xt,xe,H,Ee,st)||this._addStyle(k,`color:#${Tv(Q.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(k,xt,y.foreground,H,Ee,st)||Le&&se.push("xterm-fg-257")}se.length&&(k.className=se.join(" "),se.length=0),!E&&!R&&!K&&T?L++:k.textContent=M,_e!==this.defaultSpacing&&(k.style.letterSpacing=`${_e}px`),_.push(k),B=j}return k&&L&&(k.textContent=M),_}_applyMinimumContrast(e,t,n,s,a,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||gC(s.getCode()))return!1;let c=this._getContrastCache(s),f;if(!a&&!o&&(f=c.getColor(t.rgba,n.rgba)),f===void 0){let p=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);f=ot.ensureContrastRatio(a||t,o||n,p),c.setColor((a||t).rgba,(o||n).rgba,f??null)}return f?(this._addStyle(e,`color:${f.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t=n[0]&&e=n[0]}};Zf=gt([pe(1,hb),pe(2,hi),pe(3,Pn),pe(4,is),pe(5,Ca),pe(6,el)],Zf);function Tv(e,t,n){for(;e.length0&&(this._flat[s]=c),c}let a=e;t&&(a+="B"),n&&(a+="I");let o=this._holey.get(a);if(o===void 0){let c=0;t&&(c|=1),n&&(c|=2),o=this._measure(e,c),o>0&&this._holey.set(a,o)}return o}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},bC=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let a=e.buffers.active.ydisp,o=t[1]-a,c=n[1]-a,f=Math.max(o,0),p=Math.min(c,e.rows-1);if(f>=e.rows||p<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=o,this.viewportEndRow=c,this.viewportCappedStartRow=f,this.viewportCappedEndRow=p,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n=this.startCol&&t=this.startCol):!1}};function SC(){return new bC}var tf="xterm-dom-renderer-owner-",Wi="xterm-rows",Qo="xterm-fg-",Av="xterm-bg-",Ql="xterm-focus",Jo="xterm-selection",xC=1,Qf=class extends Ne{constructor(e,t,n,s,a,o,c,f,p,h,g,_,b,y){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=a,this._helperContainer=o,this._linkifier2=c,this._charSizeService=p,this._optionsService=h,this._bufferService=g,this._coreService=_,this._coreBrowserService=b,this._themeService=y,this._terminalClass=xC++,this._rowElements=[],this._selectionRenderModel=SC(),this.onRequestRedraw=this._register(new he).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Wi),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Jo),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=vC(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(x=>this._injectCss(x))),this._injectCss(this._themeService.colors),this._rowFactory=f.createInstance(Zf,document),this._element.classList.add(tf+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(x=>this._handleLinkHover(x))),this._register(this._linkifier2.onHideLinkUnderline(x=>this._handleLinkLeave(x))),this._register(ct(()=>{this._element.classList.remove(tf+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new yC(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Wi} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Wi} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Wi} .xterm-dim { color: ${ot.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,a=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${a} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Wi}.${Ql} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Wi}.${Ql} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Wi}.${Ql} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${Wi} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Wi} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Wi} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Wi} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Wi} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Jo} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Jo} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Jo} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,c]of e.ansi.entries())t+=`${this._terminalSelector} .${Qo}${o} { color: ${c.css}; }${this._terminalSelector} .${Qo}${o}.xterm-dim { color: ${ot.multiplyOpacity(c,.5).css}; }${this._terminalSelector} .${Av}${o} { background-color: ${c.css}; }`;t+=`${this._terminalSelector} .${Qo}257 { color: ${ot.opaque(e.background).css}; }${this._terminalSelector} .${Qo}257.xterm-dim { color: ${ot.multiplyOpacity(ot.opaque(e.background),.5).css}; }${this._terminalSelector} .${Av}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Ql),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ql),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,a=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,c=this._selectionRenderModel.viewportCappedEndRow,f=this._document.createDocumentFragment();if(n){let p=e[0]>t[0];f.appendChild(this._createSelectionElement(o,p?t[0]:e[0],p?e[0]:t[0],c-o+1))}else{let p=s===o?e[0]:0,h=o===a?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(o,p,h));let g=c-o-1;if(f.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,g)),o!==c){let _=a===c?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(c,0,_))}}this._selectionContainer.appendChild(f)}_createSelectionElement(e,t,n,s=1){let a=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,c=this.dimensions.css.cell.width*(n-t);return o+c>this.dimensions.css.canvas.width&&(c=this.dimensions.css.canvas.width-o),a.style.height=`${s*this.dimensions.css.cell.height}px`,a.style.top=`${e*this.dimensions.css.cell.height}px`,a.style.left=`${o}px`,a.style.width=`${c}px`,a}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,s=n.ybase+n.y,a=Math.min(n.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,c=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=e;p<=t;p++){let h=p+n.ydisp,g=this._rowElements[p],_=n.lines.get(h);if(!g||!_)break;g.replaceChildren(...this._rowFactory.createRow(_,h,h===s,c,f,a,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${tf}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,s,a,o){n<0&&(e=0),s<0&&(t=0);let c=this._bufferService.rows-1;n=Math.max(Math.min(n,c),0),s=Math.max(Math.min(s,c),0),a=Math.min(a,this._bufferService.cols);let f=this._bufferService.buffer,p=f.ybase+f.y,h=Math.min(f.x,a-1),g=this._optionsService.rawOptions.cursorBlink,_=this._optionsService.rawOptions.cursorStyle,b=this._optionsService.rawOptions.cursorInactiveStyle;for(let y=n;y<=s;++y){let x=y+f.ydisp,k=this._rowElements[y],L=f.lines.get(x);if(!k||!L)break;k.replaceChildren(...this._rowFactory.createRow(L,x,x===p,_,b,h,g,this.dimensions.css.cell.width,this._widthCache,o?y===n?e:0:-1,o?(y===s?t:a)-1:-1))}}};Qf=gt([pe(7,Cd),pe(8,Cu),pe(9,hi),pe(10,ci),pe(11,is),pe(12,Pn),pe(13,el)],Qf);var Jf=class extends Ne{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new he),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new CC(this._optionsService))}catch{this._measureStrategy=this._register(new wC(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Jf=gt([pe(2,hi)],Jf);var Rb=class extends Ne{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},wC=class extends Rb{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},CC=class extends Rb{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},kC=class extends Ne{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new EC(this._window)),this._onDprChange=this._register(new he),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new he),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(ei.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(ke(this._textarea,"focus",()=>this._isFocused=!0)),this._register(ke(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},EC=class extends Ne{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Qs),this._onDprChange=this._register(new he),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ct(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=ke(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},TC=class extends Ne{constructor(){super(),this.linkProviders=[],this._register(ct(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Bd(e,t,n){let s=n.getBoundingClientRect(),a=e.getComputedStyle(n),o=parseInt(a.getPropertyValue("padding-left")),c=parseInt(a.getPropertyValue("padding-top"));return[t.clientX-s.left-o,t.clientY-s.top-c]}function AC(e,t,n,s,a,o,c,f,p){if(!o)return;let h=Bd(e,t,n);if(h)return h[0]=Math.ceil((h[0]+(p?c/2:0))/c),h[1]=Math.ceil(h[1]/f),h[0]=Math.min(Math.max(h[0],1),s+(p?1:0)),h[1]=Math.min(Math.max(h[1],1),a),h}var ed=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,a){return AC(window,e,t,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,a)}getMouseReportCoords(e,t){let n=Bd(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};ed=gt([pe(0,Un),pe(1,Cu)],ed);var DC=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Mb={};Px(Mb,{getSafariVersion:()=>MC,isChromeOS:()=>zb,isFirefox:()=>Bb,isIpad:()=>BC,isIphone:()=>NC,isLegacyEdge:()=>RC,isLinux:()=>Nd,isMac:()=>_u,isNode:()=>ku,isSafari:()=>Nb,isWindows:()=>Lb});var ku=typeof process<"u"&&"title"in process,ka=ku?"node":navigator.userAgent,Ea=ku?"node":navigator.platform,Bb=ka.includes("Firefox"),RC=ka.includes("Edge"),Nb=/^((?!chrome|android).)*safari/i.test(ka);function MC(){if(!Nb)return 0;let e=ka.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var _u=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Ea),BC=Ea==="iPad",NC=Ea==="iPhone",Lb=["Windows","Win16","Win32","WinCE"].includes(Ea),Nd=Ea.indexOf("Linux")>=0,zb=/\bCrOS\b/.test(ka),Ob=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._ia){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=a}this.clear()}},LC=class extends Ob{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},zC=class extends Ob{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},gu=!ku&&"requestIdleCallback"in window?zC:LC,OC=class{constructor(){this._queue=new gu}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},td=class extends Ne{constructor(e,t,n,s,a,o,c,f,p){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=a,this._coreBrowserService=f,this._renderer=this._register(new Qs),this._pausedResizeTask=new OC,this._observerDisposable=this._register(new Qs),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new he),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new he),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new he),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new he),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new DC((h,g)=>this._renderRows(h,g),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new jC(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ct(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(c.onResize(()=>this._fullRefresh())),this._register(c.buffers.onBufferActivate(()=>{var h;return(h=this._renderer.value)==null?void 0:h.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(c.cols,c.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(c.buffer.y,c.buffer.y,!0))),this._register(p.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(h=>this._registerIntersectionObserver(h,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=ct(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var n;return(n=this._renderer.value)==null?void 0:n.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,n){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};td=gt([pe(2,hi),pe(3,Cu),pe(4,is),pe(5,Ca),pe(6,ci),pe(7,Pn),pe(8,el)],td);var jC=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function HC(e,t,n,s){let a=n.buffer.x,o=n.buffer.y;if(!n.buffer.hasScrollback)return IC(a,o,e,t,n,s)+Eu(o,t,n,s)+FC(a,o,e,t,n,s);let c;if(o===t)return c=a>e?"D":"C",va(Math.abs(a-e),ga(c,s));c=o>t?"D":"C";let f=Math.abs(o-t),p=UC(o>t?e:a,n)+(f-1)*n.cols+1+PC(o>t?a:e);return va(p,ga(c,s))}function PC(e,t){return e-1}function UC(e,t){return t.cols-e}function IC(e,t,n,s,a,o){return Eu(t,s,a,o).length===0?"":va(Hb(e,t,e,t-es(t,a),!1,a).length,ga("D",o))}function Eu(e,t,n,s){let a=e-es(e,n),o=t-es(t,n),c=Math.abs(a-o)-qC(e,t,n);return va(c,ga(jb(e,t),s))}function FC(e,t,n,s,a,o){let c;Eu(t,s,a,o).length>0?c=s-es(s,a):c=t;let f=s,p=WC(e,t,n,s,a,o);return va(Hb(e,c,n,f,p==="C",a).length,ga(p,o))}function qC(e,t,n){var c;let s=0,a=e-es(e,n),o=t-es(t,n);for(let f=0;f=0&&e0?c=s-es(s,a):c=t,e=n&&ct?"A":"B"}function Hb(e,t,n,s,a,o){let c=e,f=t,p="";for(;(c!==n||f!==s)&&f>=0&&fo.cols-1?(p+=o.buffer.translateBufferLineToString(f,!1,e,c),c=0,e=0,f++):!a&&c<0&&(p+=o.buffer.translateBufferLineToString(f,!1,0,e+1),c=o.cols-1,e=c,f--);return p+o.buffer.translateBufferLineToString(f,!1,e,c)}function ga(e,t){let n=t?"O":"[";return re.ESC+n+e}function va(e,t){e=Math.floor(e);let n="";for(let s=0;sthis._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Dv(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var nf=50,VC=15,KC=50,XC=500,$C=" ",GC=new RegExp($C,"g"),id=class extends Ne{constructor(e,t,n,s,a,o,c,f,p){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=a,this._mouseService=o,this._optionsService=c,this._renderService=f,this._coreBrowserService=p,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Xi,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new he),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new he),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new he),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new he),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=h=>this._handleMouseMove(h),this._mouseUpListener=h=>this._handleMouseUp(h),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(h=>this._handleTrim(h)),this._register(this._bufferService.buffers.onBufferActivate(h=>this._handleBufferActivate(h))),this.enable(),this._model=new YC(this._bufferService),this._activeSelectionMode=0,this._register(ct(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(h=>{h.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let a=e[0]a.replace(GC," ")).join(Lb?`\r `:` -`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Nd&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s||!t?!1:this._areCoordsInSelection(t,n,s)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,t],n,s)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){var a,o;let n=(o=(a=this._linkifier.currentLink)==null?void 0:a.link)==null?void 0:o.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=Dv(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Bd(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-nf),nf),t/=nf,t/Math.abs(t)+Math.round(t*(VC-1)))}shouldForceSelection(e){return _u?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),KC)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(_u&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&tthis._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let s=0;t>=s;s++){let a=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:a>1&&t!==s&&(n+=a-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let a=this._bufferService.buffer,o=a.lines.get(e[1]);if(!o)return;let c=a.translateBufferLineToString(e[1],!1),f=this._convertViewportColToCharacterIndex(o,e[0]),p=f,h=e[0]-f,g=0,_=0,b=0,y=0;if(c.charAt(f)===" "){for(;f>0&&c.charAt(f-1)===" ";)f--;for(;p1&&(y+=Z-1,p+=Z-1);L>0&&f>0&&!this._isCharWordSeparator(o.loadCell(L-1,this._workCell));){o.loadCell(L-1,this._workCell);let I=this._workCell.getChars().length;this._workCell.getWidth()===0?(g++,L--):I>1&&(b+=I-1,f-=I-1),f--,L--}for(;M1&&(y+=I-1,p+=I-1),p++,M++}}p++;let x=f+h-g+b,k=Math.min(this._bufferService.cols,p-f+g+_-b-y);if(!(!t&&c.slice(f,p).trim()==="")){if(n&&x===0&&o.getCodePoint(0)!==32){let L=a.lines.get(e[1]-1);if(L&&o.isWrapped&&L.getCodePoint(this._bufferService.cols-1)!==32){let M=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(M){let Z=this._bufferService.cols-M.start;x-=Z,k+=Z}}}if(s&&x+k===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let L=a.lines.get(e[1]+1);if(L!=null&&L.isWrapped&&L.getCodePoint(0)!==32){let M=this._getWordAt([0,e[1]+1],!1,!1,!0);M&&(k+=M.length)}}return{start:x,length:k}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Dv(n,this._bufferService.cols)}};id=mt([pe(3,ui),pe(4,ns),pe(5,kd),pe(6,ci),pe(7,Fn),pe(8,In)],id);var Rv=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Mv=class{constructor(){this._color=new Rv,this._css=new Rv}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Rt=Object.freeze((()=>{let e=[ut.toColor("#2e3436"),ut.toColor("#cc0000"),ut.toColor("#4e9a06"),ut.toColor("#c4a000"),ut.toColor("#3465a4"),ut.toColor("#75507b"),ut.toColor("#06989a"),ut.toColor("#d3d7cf"),ut.toColor("#555753"),ut.toColor("#ef2929"),ut.toColor("#8ae234"),ut.toColor("#fce94f"),ut.toColor("#729fcf"),ut.toColor("#ad7fa8"),ut.toColor("#34e2e2"),ut.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],a=t[n/6%6|0],o=t[n%6];e.push({css:kt.toCss(s,a,o),rgba:kt.toRgba(s,a,o)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:kt.toCss(s,s,s),rgba:kt.toRgba(s,s,s)})}return e})()),Gr=ut.toColor("#ffffff"),ca=ut.toColor("#000000"),Bv=ut.toColor("#ffffff"),Nv=ca,ea={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},ZC=Gr,nd=class extends Be{constructor(e){super(),this._optionsService=e,this._contrastCache=new Mv,this._halfContrastCache=new Mv,this._onChangeColors=this._register(new he),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Gr,background:ca,cursor:Bv,cursorAccent:Nv,selectionForeground:void 0,selectionBackgroundTransparent:ea,selectionBackgroundOpaque:nt.blend(ca,ea),selectionInactiveBackgroundTransparent:ea,selectionInactiveBackgroundOpaque:nt.blend(ca,ea),scrollbarSliderBackground:nt.opacity(Gr,.2),scrollbarSliderHoverBackground:nt.opacity(Gr,.4),scrollbarSliderActiveBackground:nt.opacity(Gr,.5),overviewRulerBorder:Gr,ansi:Rt.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=$e(e.foreground,Gr),t.background=$e(e.background,ca),t.cursor=nt.blend(t.background,$e(e.cursor,Bv)),t.cursorAccent=nt.blend(t.background,$e(e.cursorAccent,Nv)),t.selectionBackgroundTransparent=$e(e.selectionBackground,ea),t.selectionBackgroundOpaque=nt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=$e(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=nt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?$e(e.selectionForeground,Ev):void 0,t.selectionForeground===Ev&&(t.selectionForeground=void 0),nt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=nt.opacity(t.selectionBackgroundTransparent,.3)),nt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=nt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=$e(e.scrollbarSliderBackground,nt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=$e(e.scrollbarSliderHoverBackground,nt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=$e(e.scrollbarSliderActiveBackground,nt.opacity(t.foreground,.5)),t.overviewRulerBorder=$e(e.overviewRulerBorder,ZC),t.ansi=Rt.slice(),t.ansi[0]=$e(e.black,Rt[0]),t.ansi[1]=$e(e.red,Rt[1]),t.ansi[2]=$e(e.green,Rt[2]),t.ansi[3]=$e(e.yellow,Rt[3]),t.ansi[4]=$e(e.blue,Rt[4]),t.ansi[5]=$e(e.magenta,Rt[5]),t.ansi[6]=$e(e.cyan,Rt[6]),t.ansi[7]=$e(e.white,Rt[7]),t.ansi[8]=$e(e.brightBlack,Rt[8]),t.ansi[9]=$e(e.brightRed,Rt[9]),t.ansi[10]=$e(e.brightGreen,Rt[10]),t.ansi[11]=$e(e.brightYellow,Rt[11]),t.ansi[12]=$e(e.brightBlue,Rt[12]),t.ansi[13]=$e(e.brightMagenta,Rt[13]),t.ansi[14]=$e(e.brightCyan,Rt[14]),t.ansi[15]=$e(e.brightWhite,Rt[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;so.index-c.index),s=[];for(let o of n){let c=this._services.get(o.id);if(!c)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);s.push(c)}let a=n.length>0?n[0].index:t.length;if(t.length!==a)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${a+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},e2={trace:0,debug:1,info:2,warn:3,error:4,off:5},t2="xterm.js: ",rd=class extends Be{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=e2[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;s--)this._array[this._getCyclicIndex(s+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;sthis._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let a=t-1;a>=0;a--)this.set(e+a+n,this.get(e+a));let s=e+t+n-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*Me+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Me+0]=t|2097152|n[2]<<22):this._data[t*Me+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Me+0]>>22}hasWidth(t){return this._data[t*Me+0]&12582912}getFg(t){return this._data[t*Me+1]}getBg(t){return this._data[t*Me+2]}hasContent(t){return this._data[t*Me+0]&4194303}getCodePoint(t){let n=this._data[t*Me+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Me+0]&2097152}getString(t){let n=this._data[t*Me+0];return n&2097152?this._combined[t]:n&2097151?br(n&2097151):""}isProtected(t){return this._data[t*Me+2]&536870912}loadCell(t,n){return eu=t*Me,n.content=this._data[eu+0],n.fg=this._data[eu+1],n.bg=this._data[eu+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*Me+0]=n.content,this._data[t*Me+1]=n.fg,this._data[t*Me+2]=n.bg}setCellFromCodepoint(t,n,s,a){a.bg&268435456&&(this._extendedAttrs[t]=a.extended),this._data[t*Me+0]=n|s<<22,this._data[t*Me+1]=a.fg,this._data[t*Me+2]=a.bg}addCodepointToCell(t,n,s){let a=this._data[t*Me+0];a&2097152?this._combined[t]+=br(n):a&2097151?(this._combined[t]=br(a&2097151)+br(n),a&=-2097152,a|=2097152):a=n|1<<22,s&&(a&=-12582913,a|=s<<22),this._data[t*Me+0]=a}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n=0;--o)this.setCell(t+n+o,this.loadCell(t+o,a));for(let o=0;othis.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let a=new Uint32Array(s);a.set(this._data),this._data=a}for(let a=this.length;a=t&&delete this._combined[f]}let o=Object.keys(this._extendedAttrs);for(let c=0;c=t&&delete this._extendedAttrs[f]}}return this.length=t,s*4*rf=0;--t)if(this._data[t*Me+0]&4194303)return t+(this._data[t*Me+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Me+0]&4194303||this._data[t*Me+2]&50331648)return t+(this._data[t*Me+0]>>22);return 0}copyCellsFrom(t,n,s,a,o){let c=t._data;if(o)for(let p=a-1;p>=0;p--){for(let h=0;h=n&&(this._combined[h-n+s]=t._combined[h])}}translateToString(t,n,s,a){n=n??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),a&&(a.length=0);let o="";for(;n>22||1}return a&&a.push(n),o}};function i2(e,t,n,s,a,o){let c=[];for(let f=0;f=f&&s0&&(L>_||g[L].getTrimmedLength()===0);L--)k++;k>0&&(c.push(f+g.length-k),c.push(k)),f+=g.length-1}return c}function n2(e,t){let n=[],s=0,a=t[s],o=0;for(let c=0;cba(e,h,t)).reduce((p,h)=>p+h),o=0,c=0,f=0;for(;fp&&(o-=p,c++);let h=e[c].getWidth(o-1)===2;h&&o--;let g=h?n-1:n;s.push(g),f+=g}return s}function ba(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,a=e[t+1].getWidth(0)===2;return s&&a?n-1:n}var Ub=class Ib{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Ib._nextId++,this._onDispose=this.register(new he),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),es(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Ub._nextId=1;var l2=Ub,Nt={},Zr=Nt.B;Nt[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Nt.A={"#":"£"};Nt.B=void 0;Nt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Nt.C=Nt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Nt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Nt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Nt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Nt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Nt.E=Nt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Nt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Nt.H=Nt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Nt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var zv=4294967295,Ov=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Ct.clone(),this.savedCharset=Zr,this.markers=[],this._nullCell=Ki.fromCharData([0,rb,1,0]),this._whitespaceCell=Ki.fromCharData([0,xr,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new gu,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Lv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new du),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new du),this._whitespaceCell}getBlankLine(e,t){return new ha(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&ezv?zv:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ct);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Lv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Ct),s=0,a=this._getCorrectBufferLength(t);if(a>this.lines.maxLength&&(this.lines.maxLength=a),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new ha(e,n)));else for(let c=this._rows;c>t;c--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(a0&&(this.lines.trimStart(c),this.ybase=Math.max(this.ybase-c,0),this.ydisp=Math.max(this.ydisp-c,0),this.savedY=Math.max(this.savedY-c,0)),this.lines.maxLength=a}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let o=0;o.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=i2(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ct),n);if(s.length>0){let a=n2(this.lines,s);r2(this.lines,a.layout),this._reflowLargerAdjustViewport(e,t,a.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(Ct),a=n;for(;a-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;c--){let f=this.lines.get(c);if(!f||!f.isWrapped&&f.getTrimmedLength()<=e)continue;let p=[f];for(;f.isWrapped&&c>0;)f=this.lines.get(--c),p.unshift(f);if(!n){let I=this.ybase+this.y;if(I>=c&&I0&&(a.push({start:c+p.length+o,newLines:y}),o+=y.length),p.push(...y);let x=g.length-1,k=g[x];k===0&&(x--,k=g[x]);let L=p.length-_-1,M=h;for(;L>=0;){let I=Math.min(M,k);if(p[x]===void 0)break;if(p[x].copyCellsFrom(p[L],M-I,k-I,I,!0),k-=I,k===0&&(x--,k=g[x]),M-=I,M===0){L--;let Q=Math.max(L,0);M=ba(p,Q,this._cols)}}for(let I=0;I0;)this.ybase===0?this.y0){let c=[],f=[];for(let k=0;k=0;k--)if(_&&_.start>h+b){for(let L=_.newLines.length-1;L>=0;L--)this.lines.set(k--,_.newLines[L]);k++,c.push({index:h+1,amount:_.newLines.length}),b+=_.newLines.length,_=a[++g]}else this.lines.set(k,f[h--]);let y=0;for(let k=c.length-1;k>=0;k--)c[k].index+=y,this.lines.onInsertEmitter.fire(c[k]),y+=c[k].amount;let x=Math.max(0,p+o-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(e,t,n=0,s){let a=this.lines.get(e);return a?a.translateToString(t,n,s):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+10;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.linen.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},a2=class extends Be{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new he),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new Ov(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Ov(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},Fb=2,qb=1,sd=class extends Be{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new he),this.onResize=this._onResize.event,this._onScroll=this._register(new he),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Fb),this.rows=Math.max(e.rawOptions.rows||0,qb),this.buffers=this._register(new a2(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=n.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let a=n.ybase+n.scrollTop,o=n.ybase+n.scrollBottom;if(n.scrollTop===0){let c=n.lines.isFull;o===n.lines.length-1?c?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(o+1,0,s.clone()),c?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let c=o-a+1;n.lines.shiftElements(a+1,c-1,-1),n.lines.set(o,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),s!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};sd=mt([pe(0,ci)],sd);var Ys={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:_u,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},o2=["normal","bold","100","200","300","400","500","600","700","800","900"],u2=class extends Be{constructor(e){super(),this._onOptionChange=this._register(new he),this.onOptionChange=this._onOptionChange.event;let t={...Ys};for(let n in e)if(n in t)try{let s=e[n];t[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(at(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in Ys))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in Ys))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Ys[e]),!c2(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Ys[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=o2.includes(t)?t:Ys[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function c2(e){return e==="block"||e==="underline"||e==="bar"}function fa(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let s in e)n[s]=t<=1?e[s]:e[s]&&fa(e[s],t-1);return n}var jv=Object.freeze({insertMode:!1}),Hv=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),ld=class extends Be{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new he),this.onData=this._onData.event,this._onUserInput=this._register(new he),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new he),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new he),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=fa(jv),this.decPrivateModes=fa(Hv)}reset(){this.modes=fa(jv),this.decPrivateModes=fa(Hv)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};ld=mt([pe(0,ui),pe(1,ub),pe(2,ci)],ld);var Pv={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function sf(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var lf=String.fromCharCode,Uv={DEFAULT:e=>{let t=[sf(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${lf(t[0])}${lf(t[1])}${lf(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${sf(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${sf(e,!0)};${e.x};${e.y}${t}`}},ad=class extends Be{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new he),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Pv))this.addProtocol(s,Pv[s]);for(let s of Object.keys(Uv))this.addEncoding(s,Uv[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let s=t/n,a=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(a/=s+0,Math.abs(e.deltaY)<50&&(a*=.3),this._wheelPartialScroll+=a,a=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(a*=this._bufferService.rows),a}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};ad=mt([pe(0,ui),pe(1,ns),pe(2,ci)],ad);var af=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],h2=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Mt;function f2(e,t){let n=0,s=t.length-1,a;if(et[s][1])return!1;for(;s>=n;)if(a=n+s>>1,e>t[a][1])n=a+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let a=Qr.extractWidth(t);a===0?s=!1:a>n&&(n=a)}return Qr.createPropertyValue(0,n,s)}},Qr=class cu{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new he,this.onChange=this._onChange.event;let t=new d2;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,s=!1){return(t&16777215)<<3|(n&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,s=0,a=t.length;for(let o=0;o=a)return n+this.wcwidth(c);let h=t.charCodeAt(o);56320<=h&&h<=57343?c=(c-55296)*1024+h-56320+65536:n+=this.wcwidth(h)}let f=this.charProperties(c,s),p=cu.extractWidth(f);cu.extractShouldJoin(f)&&(p-=cu.extractWidth(s)),n+=p,s=f}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},p2=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Iv(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var ta=2147483647,m2=256,Wb=class od{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>m2)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new od;if(!t.length)return n;for(let s=Array.isArray(t[0])?1:0;s>8,a=this._subParamsIdx[n]&255;a-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,a))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>ta?ta:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>ta?ta:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let t={};for(let n=0;n>8,a=this._subParamsIdx[n]&255;a-s>0&&(t[n]=this._subParams.slice(s,a))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,a=s[n-1];s[n-1]=~a?Math.min(a*10+t,ta):t}},ia=[],_2=class{constructor(){this._state=0,this._active=ia,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ia}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=ia,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ia,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",wu(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=ia,this._id=-1,this._state=0}}},Ri=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=wu(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},na=[],g2=class{constructor(){this._handlers=Object.create(null),this._active=na,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=na}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=na,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||na,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",wu(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=na,this._ident=0}},da=new Wb;da.addParam(0);var Fv=class{constructor(e){this._handler=e,this._data="",this._params=da,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():da,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=wu(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=da,this._data="",this._hitLimit=!1,n));return this._params=da,this._data="",this._hitLimit=!1,t}},v2=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let a=0;ap),n=(f,p)=>t.slice(f,p),s=n(32,127),a=n(0,24);a.push(25),a.push.apply(a,n(28,32));let o=n(0,14),c;e.setDefault(1,0),e.addMany(s,0,2,0);for(c in o)e.addMany([24,26,153,154],c,3,0),e.addMany(n(128,144),c,3,0),e.addMany(n(144,152),c,3,0),e.add(156,c,0,0),e.add(27,c,11,1),e.add(157,c,4,8),e.addMany([152,158,159],c,0,7),e.add(155,c,11,3),e.add(144,c,11,9);return e.addMany(a,0,3,0),e.addMany(a,1,3,1),e.add(127,1,0,1),e.addMany(a,8,0,8),e.addMany(a,3,3,3),e.add(127,3,0,3),e.addMany(a,4,3,4),e.add(127,4,0,4),e.addMany(a,6,3,6),e.addMany(a,5,3,5),e.add(127,5,0,5),e.addMany(a,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(a,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(a,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(a,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(a,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(a,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(a,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Yi,0,2,0),e.add(Yi,8,5,8),e.add(Yi,6,0,6),e.add(Yi,11,0,11),e.add(Yi,13,13,13),e})(),b2=class extends Be{constructor(e=y2){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Wb,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(at(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new _2),this._dcsParser=this._register(new g2),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let a=0;ao||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=s,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];return s.push(t),{dispose:()=>{let a=s.indexOf(t);a!==-1&&s.splice(a,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];return s.push(t),{dispose:()=>{let a=s.indexOf(t);a!==-1&&s.splice(a,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,s,a){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=a}parse(e,t,n){let s=0,a=0,o=0,c;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let f=this._parseStack.handlers,p=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&p>-1){for(;p>=0&&(c=f[p](this._params),c!==!0);p--)if(c instanceof Promise)return this._parseStack.handlerPos=p,c}this._parseStack.handlers=[];break;case 4:if(n===!1&&p>-1){for(;p>=0&&(c=f[p](),c!==!0);p--)if(c instanceof Promise)return this._parseStack.handlerPos=p,c}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],c=this._dcsParser.unhook(s!==24&&s!==26,n),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],c=this._oscParser.end(s!==24&&s!==26,n),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let f=o;f>4){case 2:for(let b=f+1;;++b){if(b>=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=0&&(c=p[h](this._params),c!==!0);h--)if(c instanceof Promise)return this._preserveStack(3,p,h,a,f),c;h<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++f47&&s<60);f--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let g=this._escHandlers[this._collect<<8|s],_=g?g.length-1:-1;for(;_>=0&&(c=g[_](),c!==!0);_--)if(c instanceof Promise)return this._preserveStack(4,g,_,a,f),c;_<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let b=f+1;;++b)if(b>=t||(s=e[b])===24||s===26||s===27||s>127&&s=t||(s=e[b])<32||s>127&&s>4:o>>8}return s}}function of(e,t){let n=e.toString(16),s=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function w2(e,t=16){let[n,s,a]=e;return`rgb:${of(n,t)}/${of(s,t)}/${of(a,t)}`}var C2={"(":0,")":1,"*":2,"+":3,"-":1,".":2},vr=131072,Wv=10;function Yv(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Vv=5e3,Kv=0,k2=class extends Be{constructor(e,t,n,s,a,o,c,f,p=new b2){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=a,this._oscLinkService=o,this._coreMouseService=c,this._unicodeService=f,this._parser=p,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Wx,this._utf8Decoder=new Yx,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ct.clone(),this._eraseAttrDataInternal=Ct.clone(),this._onRequestBell=this._register(new he),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new he),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new he),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new he),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new he),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new he),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new he),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new he),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new he),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new he),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new he),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new he),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new he),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new ud(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,g)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:g.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,g,_)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:g,data:_})}),this._parser.setDcsHandlerFallback((h,g,_)=>{g==="HOOK"&&(_=_.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:g,payload:_})}),this._parser.setPrintHandler((h,g,_)=>this.print(h,g,_)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler(se.BEL,()=>this.bell()),this._parser.setExecuteHandler(se.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(se.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(se.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(se.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(se.BS,()=>this.backspace()),this._parser.setExecuteHandler(se.HT,()=>this.tab()),this._parser.setExecuteHandler(se.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(se.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ou.IND,()=>this.index()),this._parser.setExecuteHandler(ou.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ou.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ri(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new Ri(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new Ri(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new Ri(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new Ri(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new Ri(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new Ri(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new Ri(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new Ri(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new Ri(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new Ri(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new Ri(h=>this.restoreCursorColor(h))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let h in Nt)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Fv((h,g)=>this.requestStatusString(h,g)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),Vv))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Vv} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,a=this._activeBuffer.y,o=0,c=this._parseStack.paused;if(c){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,a=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>vr&&(o=this._parseStack.position+vr)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(h=>h.charCodeAt(0)):e),this._parseBuffer.lengthvr)for(let h=o;h0&&_.getWidth(this._activeBuffer.x-1)===2&&_.setCellFromCodepoint(this._activeBuffer.x-1,0,1,g);let b=this._parser.precedingJoinState;for(let y=t;yf){if(p){let M=_,Z=this._activeBuffer.x-L;for(this._activeBuffer.x=L,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),_=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),L>0&&_ instanceof ha&&_.copyCellsFrom(M,Z,0,L,!1);Z=0;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,g);continue}if(h&&(_.insertCells(this._activeBuffer.x,a-L,this._activeBuffer.getNullCell(g)),_.getWidth(f-1)===2&&_.setCellFromCodepoint(f-1,0,1,g)),_.setCellFromCodepoint(this._activeBuffer.x++,s,a,g),a>0)for(;--a;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,g)}this._parser.precedingJoinState=b,this._activeBuffer.x0&&_.getWidth(this._activeBuffer.x)===0&&!_.hasContent(this._activeBuffer.x)&&_.setCellFromCodepoint(this._activeBuffer.x,0,1,g),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>Yv(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Fv(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ri(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,s=!1,a=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),a),s&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&s.getTrimmedLength()););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let a=this._activeBuffer.lines.length-this._bufferService.rows;a>0&&(this._activeBuffer.lines.trimStart(a),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-a,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-a,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y65535?2:1}let p=f;for(let h=1;h0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(se.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(se.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(se.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(se.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(se.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t(k[k.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",k[k.SET=1]="SET",k[k.RESET=2]="RESET",k[k.PERMANENTLY_SET=3]="PERMANENTLY_SET",k[k.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:a,activeEncoding:o}=this._coreMouseService,c=this._coreService,{buffers:f,cols:p}=this._bufferService,{active:h,alt:g}=f,_=this._optionsService.rawOptions,b=(k,L)=>(c.triggerDataEvent(`${se.ESC}[${t?"":"?"}${k};${L}$y`),!0),y=k=>k?1:2,x=e.params[0];return t?x===2?b(x,4):x===4?b(x,y(c.modes.insertMode)):x===12?b(x,3):x===20?b(x,y(_.convertEol)):b(x,0):x===1?b(x,y(s.applicationCursorKeys)):x===3?b(x,_.windowOptions.setWinLines?p===80?2:p===132?1:0:0):x===6?b(x,y(s.origin)):x===7?b(x,y(s.wraparound)):x===8?b(x,3):x===9?b(x,y(a==="X10")):x===12?b(x,y(_.cursorBlink)):x===25?b(x,y(!c.isCursorHidden)):x===45?b(x,y(s.reverseWraparound)):x===66?b(x,y(s.applicationKeypad)):x===67?b(x,4):x===1e3?b(x,y(a==="VT200")):x===1002?b(x,y(a==="DRAG")):x===1003?b(x,y(a==="ANY")):x===1004?b(x,y(s.sendFocus)):x===1005?b(x,4):x===1006?b(x,y(o==="SGR")):x===1015?b(x,4):x===1016?b(x,y(o==="SGR_PIXELS")):x===1048?b(x,1):x===47||x===1047||x===1049?b(x,y(h===g)):x===2004?b(x,y(s.bracketedPasteMode)):x===2026?b(x,y(s.synchronizedOutput)):b(x,0)}_updateAttrColor(e,t,n,s,a){return t===2?(e|=50331648,e&=-16777216,e|=Ca.fromColorRGB([n,s,a])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let s=[0,0,-1,0,0,0],a=0,o=0;do{if(s[o+a]=e.params[t+o],e.hasSubParams(t+o)){let c=e.getSubParams(t+o),f=0;do s[1]===5&&(a=1),s[o+f+1+a]=c[f];while(++f=2||s[1]===2&&o+a>=5)break;s[1]&&(a=1)}while(++o+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Ct.fg,e.bg=Ct.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,s=this._curAttrData;for(let a=0;a=30&&n<=37?(s.fg&=-50331904,s.fg|=16777216|n-30):n>=40&&n<=47?(s.bg&=-50331904,s.bg|=16777216|n-40):n>=90&&n<=97?(s.fg&=-50331904,s.fg|=16777216|n-90|8):n>=100&&n<=107?(s.bg&=-50331904,s.bg|=16777216|n-100|8):n===0?this._processSGR0(s):n===1?s.fg|=134217728:n===3?s.bg|=67108864:n===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(a)?e.getSubParams(a)[0]:1,s)):n===5?s.fg|=536870912:n===7?s.fg|=67108864:n===8?s.fg|=1073741824:n===9?s.fg|=2147483648:n===2?s.bg|=134217728:n===21?this._processUnderline(2,s):n===22?(s.fg&=-134217729,s.bg&=-134217729):n===23?s.bg&=-67108865:n===24?(s.fg&=-268435457,this._processUnderline(0,s)):n===25?s.fg&=-536870913:n===27?s.fg&=-67108865:n===28?s.fg&=-1073741825:n===29?s.fg&=2147483647:n===39?(s.fg&=-67108864,s.fg|=Ct.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=Ct.bg&16777215):n===38||n===48||n===58?a+=this._extractColor(e,a,s):n===53?s.bg|=1073741824:n===55?s.bg&=-1073741825:n===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):n===100?(s.fg&=-67108864,s.fg|=Ct.fg&16777215,s.bg&=-67108864,s.bg|=Ct.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${se.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${se.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${se.ESC}[?${t};${n}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Ct.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Yv(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${se.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Wv&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Wv&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let s=n.shift(),a=n.shift();if(/^\d+$/.exec(s)){let o=parseInt(s);if(Xv(o))if(a==="?")t.push({type:0,index:o});else{let c=qv(a);c&&t.push({type:1,index:o,color:c})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),s,a=n.findIndex(o=>o.startsWith("id="));return a!==-1&&(s=n[a].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let s=0;s=this._specialColors.length);++s,++t)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let a=qv(n[s]);a&&this._onColor.fire([{type:1,index:this._specialColors[t],color:a}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let s=0;s=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Ct.clone(),this._eraseAttrDataInternal=Ct.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Ki;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t(this._coreService.triggerDataEvent(`${se.ESC}${c}${se.ESC}\\`),!0),s=this._bufferService.buffer,a=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[a.cursorStyle]-(a.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},ud=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){ethis.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Kv=e,e=t,t=Kv),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};ud=mt([pe(0,ui)],ud);function Xv(e){return 0<=e&&e<256}var E2=5e7,$v=12,T2=50,A2=class extends Be{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new he),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>E2)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],a=this._action(s,t);if(a){let c=f=>performance.now()-n>=$v?setTimeout(()=>this._innerWrite(0,f)):this._innerWrite(n,f);a.catch(f=>(queueMicrotask(()=>{throw f}),Promise.resolve(!1))).then(c);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=$v)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>T2&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},cd=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let f=t.addMarker(t.ybase+t.y),p={data:e,id:this._nextId++,lines:[f]};return f.onDispose(()=>this._removeMarkerFromLink(p,f)),this._dataByLinkId.set(p.id,p),p.id}let n=e,s=this._getEntryIdKey(n),a=this._entriesWithId.get(s);if(a)return this.addLineToLink(a.id,t.ybase+t.y),a.id;let o=t.addMarker(t.ybase+t.y),c={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(c,o)),this._entriesWithId.set(c.key,c),this._dataByLinkId.set(c.id,c),c.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};cd=mt([pe(0,ui)],cd);var Gv=!1,D2=class extends Be{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Js),this._onBinary=this._register(new he),this.onBinary=this._onBinary.event,this._onData=this._register(new he),this.onData=this._onData.event,this._onLineFeed=this._register(new he),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new he),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new he),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new he),this._instantiationService=new JC,this.optionsService=this._register(new u2(e)),this._instantiationService.setService(ci,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(sd)),this._instantiationService.setService(ui,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(rd)),this._instantiationService.setService(ub,this._logService),this.coreService=this._register(this._instantiationService.createInstance(ld)),this._instantiationService.setService(ns,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(ad)),this._instantiationService.setService(ob,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Qr)),this._instantiationService.setService($x,this.unicodeService),this._charsetService=this._instantiationService.createInstance(p2),this._instantiationService.setService(Xx,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(cd),this._instantiationService.setService(cb,this._oscLinkService),this._inputHandler=this._register(new k2(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Jt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Jt.forward(this._bufferService.onResize,this._onResize)),this._register(Jt.forward(this.coreService.onData,this._onData)),this._register(Jt.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new A2((t,n)=>this._inputHandler.parse(t,n))),this._register(Jt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new he),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Gv&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Gv=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,Fb),t=Math.max(t,qb),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Iv.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Iv(this._bufferService),!1))),this._windowsWrappingHeuristics.value=at(()=>{for(let t of e)t.dispose()})}}},R2={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function M2(e,t,n,s){var c;let a={type:0,cancel:!1,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?a.key=se.ESC+"OA":a.key=se.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?a.key=se.ESC+"OD":a.key=se.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?a.key=se.ESC+"OC":a.key=se.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?a.key=se.ESC+"OB":a.key=se.ESC+"[B");break;case 8:a.key=e.ctrlKey?"\b":se.DEL,e.altKey&&(a.key=se.ESC+a.key);break;case 9:if(e.shiftKey){a.key=se.ESC+"[Z";break}a.key=se.HT,a.cancel=!0;break;case 13:a.key=e.altKey?se.ESC+se.CR:se.CR,a.cancel=!0;break;case 27:a.key=se.ESC,e.altKey&&(a.key=se.ESC+se.ESC),a.cancel=!0;break;case 37:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"D":t?a.key=se.ESC+"OD":a.key=se.ESC+"[D";break;case 39:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"C":t?a.key=se.ESC+"OC":a.key=se.ESC+"[C";break;case 38:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"A":t?a.key=se.ESC+"OA":a.key=se.ESC+"[A";break;case 40:if(e.metaKey)break;o?a.key=se.ESC+"[1;"+(o+1)+"B":t?a.key=se.ESC+"OB":a.key=se.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(a.key=se.ESC+"[2~");break;case 46:o?a.key=se.ESC+"[3;"+(o+1)+"~":a.key=se.ESC+"[3~";break;case 36:o?a.key=se.ESC+"[1;"+(o+1)+"H":t?a.key=se.ESC+"OH":a.key=se.ESC+"[H";break;case 35:o?a.key=se.ESC+"[1;"+(o+1)+"F":t?a.key=se.ESC+"OF":a.key=se.ESC+"[F";break;case 33:e.shiftKey?a.type=2:e.ctrlKey?a.key=se.ESC+"[5;"+(o+1)+"~":a.key=se.ESC+"[5~";break;case 34:e.shiftKey?a.type=3:e.ctrlKey?a.key=se.ESC+"[6;"+(o+1)+"~":a.key=se.ESC+"[6~";break;case 112:o?a.key=se.ESC+"[1;"+(o+1)+"P":a.key=se.ESC+"OP";break;case 113:o?a.key=se.ESC+"[1;"+(o+1)+"Q":a.key=se.ESC+"OQ";break;case 114:o?a.key=se.ESC+"[1;"+(o+1)+"R":a.key=se.ESC+"OR";break;case 115:o?a.key=se.ESC+"[1;"+(o+1)+"S":a.key=se.ESC+"OS";break;case 116:o?a.key=se.ESC+"[15;"+(o+1)+"~":a.key=se.ESC+"[15~";break;case 117:o?a.key=se.ESC+"[17;"+(o+1)+"~":a.key=se.ESC+"[17~";break;case 118:o?a.key=se.ESC+"[18;"+(o+1)+"~":a.key=se.ESC+"[18~";break;case 119:o?a.key=se.ESC+"[19;"+(o+1)+"~":a.key=se.ESC+"[19~";break;case 120:o?a.key=se.ESC+"[20;"+(o+1)+"~":a.key=se.ESC+"[20~";break;case 121:o?a.key=se.ESC+"[21;"+(o+1)+"~":a.key=se.ESC+"[21~";break;case 122:o?a.key=se.ESC+"[23;"+(o+1)+"~":a.key=se.ESC+"[23~";break;case 123:o?a.key=se.ESC+"[24;"+(o+1)+"~":a.key=se.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?a.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?a.key=se.NUL:e.keyCode>=51&&e.keyCode<=55?a.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?a.key=se.DEL:e.keyCode===219?a.key=se.ESC:e.keyCode===220?a.key=se.FS:e.keyCode===221&&(a.key=se.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let f=(c=R2[e.keyCode])==null?void 0:c[e.shiftKey?1:0];if(f)a.key=se.ESC+f;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,h=String.fromCharCode(p);e.shiftKey&&(h=h.toUpperCase()),a.key=se.ESC+h}else if(e.keyCode===32)a.key=se.ESC+(e.ctrlKey?se.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),a.key=se.ESC+p,a.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(a.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?a.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(a.key=se.US),e.key==="@"&&(a.key=se.NUL));break}return a}var vt=0,B2=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new gu,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new gu,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((a,o)=>this._getKey(a)-this._getKey(o)),t=0,n=0,s=new Array(this._array.length+this._insertedValues.length);for(let a=0;a=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(s[a]=e[t],t++):s[a]=this._array[n++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(vt=this._search(t),vt===-1)||this._getKey(this._array[vt])!==t)return!1;do if(this._array[vt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(vt),!0;while(++vta-o),t=0,n=new Array(this._array.length-e.length),s=0;for(let a=0;a0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(vt=this._search(e),!(vt<0||vt>=this._array.length)&&this._getKey(this._array[vt])===e))do yield this._array[vt];while(++vt=this._array.length)&&this._getKey(this._array[vt])===e))do t(this._array[vt]);while(++vt=t;){let s=t+n>>1,a=this._getKey(this._array[s]);if(a>e)n=s-1;else if(a0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},uf=0,Zv=0,N2=class extends Be{constructor(){super(),this._decorations=new B2(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new he),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new he),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(at(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new L2(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let s=0,a=0;for(let o of this._decorations.getKeyIterator(t))s=o.options.x??0,a=s+(o.options.width??1),e>=s&&e{uf=a.options.x??0,Zv=uf+(a.options.width??1),e>=uf&&e=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let a=s-this._lastRefreshMs,o=this._debounceThresholdMS-a;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Qv=20,vu=class extends Be{constructor(e,t,n,s){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let a=this._coreBrowserService.mainDocument;this._accessibilityContainer=a.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=a.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;othis._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=a.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new O2(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(` -`))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ee(a,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(at(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===` -`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Qv+1&&(this._liveRegion.textContent+=Rf.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,s=n.lines.length.toString();for(let a=e;a<=t;a++){let o=n.lines.get(n.ydisp+a),c=[],f=(o==null?void 0:o.translateToString(!0,void 0,void 0,c))||"",p=(n.ydisp+a+1).toString(),h=this._rowElements[a];h&&(f.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=f,this._rowColumns.set(h,c)),h.setAttribute("aria-posinset",p),h.setAttribute("aria-setsize",s),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],a=n.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(a===o||e.relatedTarget!==s)return;let c,f;if(t===0?(c=n,f=this._rowElements.pop(),this._rowContainer.removeChild(f)):(c=this._rowElements.shift(),f=n,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),f.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let p=this._createAccessibilityTreeNode();this._rowElements.unshift(p),this._rowContainer.insertAdjacentElement("afterbegin",p)}else{let p=this._createAccessibilityTreeNode();this._rowElements.push(p),this._rowContainer.appendChild(p)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var f;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:s,offset:((f=s.textContent)==null?void 0:f.length)??0}),!this._rowContainer.contains(n.node))return;let a=({node:p,offset:h})=>{let g=p instanceof Text?p.parentNode:p,_=parseInt(g==null?void 0:g.getAttribute("aria-posinset"),10)-1;if(isNaN(_))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(g);if(!b)return console.warn("columns is null. Race condition?"),null;let y=h=this._terminal.cols&&(++_,y=0),{row:_,column:y}},o=a(t),c=a(n);if(!(!o||!c)){if(o.row>c.row||o.row===c.row&&o.column>=c.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(c.row-o.row)*this._terminal.cols-o.column+c.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;te;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e{var o;es(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(o=this._activeProviderReplies)==null||o.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Ee(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ee(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ee(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ee(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let s=0;s{o==null||o.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[o,c]of this._linkProviderService.linkProviders.entries())t?(a=this._activeProviderReplies)!=null&&a.get(o)&&(n=this._checkLinkProviderResult(o,e,n)):c.provideLinks(e.y,f=>{var h,g;if(this._isMouseOut)return;let p=f==null?void 0:f.map(_=>({link:_}));(h=this._activeProviderReplies)==null||h.set(o,p),n=this._checkLinkProviderResult(o,e,n),((g=this._activeProviderReplies)==null?void 0:g.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;se?this._bufferService.cols:c.link.range.end.x;for(let h=f;h<=p;h++){if(n.has(h)){a.splice(o--,1);break}n.add(h)}}}}_checkLinkProviderResult(e,t,n){var o;if(!this._activeProviderReplies)return n;let s=this._activeProviderReplies.get(e),a=!1;for(let c=0;cthis._linkAtPosition(f.link,t));c&&(n=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let c=0;cthis._linkAtPosition(p.link,t));if(f){n=!0,this._handleNewLink(f);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&j2(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,es(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.pointerCursor},set:n=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.underline},set:n=>{var s,a,o;(s=this._currentLink)!=null&&s.state&&((o=(a=this._currentLink)==null?void 0:a.state)==null?void 0:o.decorations.underline)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let s=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,a=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=a&&(this._clearCurrentLink(s,a),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,s=this._bufferService.buffer.ydisp,a=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(a)}_linkLeave(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,a=t.y*this._bufferService.cols+t.x;return n<=a&&a<=s}_positionFromMouseEvent(e,t,n){let s=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,s,a){return{x1:e,y1:t,x2:n,y2:s,cols:this._bufferService.cols,fg:a}}};hd=mt([pe(1,kd),pe(2,Fn),pe(3,ui),pe(4,fb)],hd);function j2(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var H2=class extends D2{constructor(e={}){super(e),this._linkifier=this._register(new Js),this.browser=Mb,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Js),this._onCursorMove=this._register(new he),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new he),this.onKey=this._onKey.event,this._onRender=this._register(new he),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new he),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new he),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new he),this.onBell=this._onBell.event,this._onFocus=this._register(new he),this._onBlur=this._register(new he),this._onA11yCharEmitter=this._register(new he),this._onA11yTabEmitter=this._register(new he),this._onWillOpen=this._register(new he),this._setup(),this._decorationService=this._instantiationService.createInstance(N2),this._instantiationService.setService(ka,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(TC),this._instantiationService.setService(fb,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Bf)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Jt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Jt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Jt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Jt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(at(()=>{var t,n;this._customKeyEventHandler=void 0,(n=(t=this.element)==null?void 0:t.parentNode)==null||n.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,s="";switch(t.index){case 256:n="foreground",s="10";break;case 257:n="background",s="11";break;case 258:n="cursor",s="12";break;default:n="ansi",s="4;"+t.index}switch(t.type){case 0:let a=nt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${se.ESC}]${s};${w2(a)}${Db.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=kt.toColor(...t.color));else{let o=n;this._themeService.modifyColors(c=>c[o]=kt.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(vu,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(se.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(se.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,a=t.getWidth(n),o=this._renderService.dimensions.css.cell.width*a,c=this.buffer.y*this._renderService.dimensions.css.cell.height,f=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=f+"px",this.textarea.style.top=c+"px",this.textarea.style.width=o+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ee(this.element,"copy",t=>{this.hasSelection()&&Fx(t,this._selectionService)}));let e=t=>qx(t,this.textarea,this.coreService,this.optionsService);this._register(Ee(this.textarea,"paste",e)),this._register(Ee(this.element,"paste",e)),Bb?this._register(Ee(this.element,"mousedown",t=>{t.button===2&&ov(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ee(this.element,"contextmenu",t=>{ov(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Nd&&this._register(Ee(this.element,"auxclick",t=>{t.button===1&&nb(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ee(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ee(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ee(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ee(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ee(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ee(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ee(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var a;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((a=this.element)==null?void 0:a.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Ee(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Df.get()),zb||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(kC,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(In,this._coreBrowserService),this._register(Ee(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Ee(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Jf,this._document,this._helperContainer),this._instantiationService.setService(Cu,this._charSizeService),this._themeService=this._instantiationService.createInstance(nd),this._instantiationService.setService(tl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(mu),this._instantiationService.setService(hb,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(td,this.rows,this.screenElement)),this._instantiationService.setService(Fn,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Gf,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(ed),this._instantiationService.setService(kd,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(hd,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Xf,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(id,this.element,this.screenElement,s)),this._instantiationService.setService(Zx,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register(Jt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance($f,this.screenElement)),this._register(Ee(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(vu,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(pu,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(pu,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Qf,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(o){var h,g,_,b,y;let c=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!c)return!1;let f,p;switch(o.overrideType||o.type){case"mousemove":p=32,o.buttons===void 0?(f=3,o.button!==void 0&&(f=o.button<3?o.button:3)):f=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":p=0,f=o.button<3?o.button:3;break;case"mousedown":p=1,f=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let x=o.deltaY;if(x===0||e.coreMouseService.consumeWheelEvent(o,(b=(_=(g=(h=e._renderService)==null?void 0:h.dimensions)==null?void 0:g.device)==null?void 0:_.cell)==null?void 0:b.height,(y=e._coreBrowserService)==null?void 0:y.dpr)===0)return!1;p=x<0?0:1,f=4;break;default:return!1}return p===void 0||f===void 0||f>4?!1:e.coreMouseService.triggerMouseEvent({col:c.col,row:c.row,x:c.x,y:c.y,button:f,action:p,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:o=>(n(o),o.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(o)),wheel:o=>(n(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&n(o)},mousemove:o=>{o.buttons||n(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?s.mousemove||(t.addEventListener("mousemove",a.mousemove),s.mousemove=a.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),o&16?s.wheel||(t.addEventListener("wheel",a.wheel,{passive:!1}),s.wheel=a.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),o&2?s.mouseup||(s.mouseup=a.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),o&4?s.mousedrag||(s.mousedrag=a.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ee(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return n(o),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(o)})),this._register(Ee(t,"wheel",o=>{var c,f,p,h,g;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,(h=(p=(f=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:f.device)==null?void 0:p.cell)==null?void 0:h.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return this.cancel(o,!0);let _=se.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(_,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var n;(n=this._renderService)==null||n.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){ib(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var n;(n=this._selectionService)==null||n.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=M2(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let s=this.rows-1;return this.scrollLines(n.type===2?-s:s),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===se.ETX||n.key===se.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(P2(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var n;(n=this._charSizeService)==null||n.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Ki)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Jv=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new I2(t)}getNullCell(){return new Ki}},F2=class extends Be{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new he),this.onBufferChange=this._onBufferChange.event,this._normal=new Jv(this._core.buffers.normal,"normal"),this._alternate=new Jv(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},q2=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,s)=>t(n,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},W2=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},Y2=["cols","rows"],an=0,V2=class extends Be{constructor(e){super(),this._core=this._register(new H2(e)),this._addonManager=this._register(new U2),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],n=(s,a)=>{this._checkReadonlyOptions(s),this._core.options[s]=a};for(let s in this._core.options){let a={get:t.bind(this,s),set:n.bind(this,s)};Object.defineProperty(this._publicOptions,s,a)}}_checkReadonlyOptions(e){if(Y2.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new q2(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new W2(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new F2(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r +`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Nd&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s||!t?!1:this._areCoordsInSelection(t,n,s)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,t],n,s)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){var a,o;let n=(o=(a=this._linkifier.currentLink)==null?void 0:a.link)==null?void 0:o.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=Dv(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Bd(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-nf),nf),t/=nf,t/Math.abs(t)+Math.round(t*(VC-1)))}shouldForceSelection(e){return _u?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),KC)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(_u&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&tthis._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let s=0;t>=s;s++){let a=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:a>1&&t!==s&&(n+=a-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let a=this._bufferService.buffer,o=a.lines.get(e[1]);if(!o)return;let c=a.translateBufferLineToString(e[1],!1),f=this._convertViewportColToCharacterIndex(o,e[0]),p=f,h=e[0]-f,g=0,_=0,b=0,y=0;if(c.charAt(f)===" "){for(;f>0&&c.charAt(f-1)===" ";)f--;for(;p1&&(y+=G-1,p+=G-1);L>0&&f>0&&!this._isCharWordSeparator(o.loadCell(L-1,this._workCell));){o.loadCell(L-1,this._workCell);let I=this._workCell.getChars().length;this._workCell.getWidth()===0?(g++,L--):I>1&&(b+=I-1,f-=I-1),f--,L--}for(;M1&&(y+=I-1,p+=I-1),p++,M++}}p++;let x=f+h-g+b,k=Math.min(this._bufferService.cols,p-f+g+_-b-y);if(!(!t&&c.slice(f,p).trim()==="")){if(n&&x===0&&o.getCodePoint(0)!==32){let L=a.lines.get(e[1]-1);if(L&&o.isWrapped&&L.getCodePoint(this._bufferService.cols-1)!==32){let M=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(M){let G=this._bufferService.cols-M.start;x-=G,k+=G}}}if(s&&x+k===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let L=a.lines.get(e[1]+1);if(L!=null&&L.isWrapped&&L.getCodePoint(0)!==32){let M=this._getWordAt([0,e[1]+1],!1,!1,!0);M&&(k+=M.length)}}return{start:x,length:k}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Dv(n,this._bufferService.cols)}};id=gt([pe(3,ci),pe(4,is),pe(5,kd),pe(6,hi),pe(7,Un),pe(8,Pn)],id);var Rv=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Mv=class{constructor(){this._color=new Rv,this._css=new Rv}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Mt=Object.freeze((()=>{let e=[ft.toColor("#2e3436"),ft.toColor("#cc0000"),ft.toColor("#4e9a06"),ft.toColor("#c4a000"),ft.toColor("#3465a4"),ft.toColor("#75507b"),ft.toColor("#06989a"),ft.toColor("#d3d7cf"),ft.toColor("#555753"),ft.toColor("#ef2929"),ft.toColor("#8ae234"),ft.toColor("#fce94f"),ft.toColor("#729fcf"),ft.toColor("#ad7fa8"),ft.toColor("#34e2e2"),ft.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],a=t[n/6%6|0],o=t[n%6];e.push({css:Dt.toCss(s,a,o),rgba:Dt.toRgba(s,a,o)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:Dt.toCss(s,s,s),rgba:Dt.toRgba(s,s,s)})}return e})()),$r=ft.toColor("#ffffff"),ua=ft.toColor("#000000"),Bv=ft.toColor("#ffffff"),Nv=ua,Jl={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},ZC=$r,nd=class extends Ne{constructor(e){super(),this._optionsService=e,this._contrastCache=new Mv,this._halfContrastCache=new Mv,this._onChangeColors=this._register(new he),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:$r,background:ua,cursor:Bv,cursorAccent:Nv,selectionForeground:void 0,selectionBackgroundTransparent:Jl,selectionBackgroundOpaque:ot.blend(ua,Jl),selectionInactiveBackgroundTransparent:Jl,selectionInactiveBackgroundOpaque:ot.blend(ua,Jl),scrollbarSliderBackground:ot.opacity($r,.2),scrollbarSliderHoverBackground:ot.opacity($r,.4),scrollbarSliderActiveBackground:ot.opacity($r,.5),overviewRulerBorder:$r,ansi:Mt.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=Ze(e.foreground,$r),t.background=Ze(e.background,ua),t.cursor=ot.blend(t.background,Ze(e.cursor,Bv)),t.cursorAccent=ot.blend(t.background,Ze(e.cursorAccent,Nv)),t.selectionBackgroundTransparent=Ze(e.selectionBackground,Jl),t.selectionBackgroundOpaque=ot.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Ze(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ot.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Ze(e.selectionForeground,Ev):void 0,t.selectionForeground===Ev&&(t.selectionForeground=void 0),ot.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ot.opacity(t.selectionBackgroundTransparent,.3)),ot.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ot.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Ze(e.scrollbarSliderBackground,ot.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Ze(e.scrollbarSliderHoverBackground,ot.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Ze(e.scrollbarSliderActiveBackground,ot.opacity(t.foreground,.5)),t.overviewRulerBorder=Ze(e.overviewRulerBorder,ZC),t.ansi=Mt.slice(),t.ansi[0]=Ze(e.black,Mt[0]),t.ansi[1]=Ze(e.red,Mt[1]),t.ansi[2]=Ze(e.green,Mt[2]),t.ansi[3]=Ze(e.yellow,Mt[3]),t.ansi[4]=Ze(e.blue,Mt[4]),t.ansi[5]=Ze(e.magenta,Mt[5]),t.ansi[6]=Ze(e.cyan,Mt[6]),t.ansi[7]=Ze(e.white,Mt[7]),t.ansi[8]=Ze(e.brightBlack,Mt[8]),t.ansi[9]=Ze(e.brightRed,Mt[9]),t.ansi[10]=Ze(e.brightGreen,Mt[10]),t.ansi[11]=Ze(e.brightYellow,Mt[11]),t.ansi[12]=Ze(e.brightBlue,Mt[12]),t.ansi[13]=Ze(e.brightMagenta,Mt[13]),t.ansi[14]=Ze(e.brightCyan,Mt[14]),t.ansi[15]=Ze(e.brightWhite,Mt[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;so.index-c.index),s=[];for(let o of n){let c=this._services.get(o.id);if(!c)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);s.push(c)}let a=n.length>0?n[0].index:t.length;if(t.length!==a)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${a+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},e2={trace:0,debug:1,info:2,warn:3,error:4,off:5},t2="xterm.js: ",rd=class extends Ne{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=e2[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;s--)this._array[this._getCyclicIndex(s+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;sthis._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let a=t-1;a>=0;a--)this.set(e+a+n,this.get(e+a));let s=e+t+n-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*Be+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Be+0]=t|2097152|n[2]<<22):this._data[t*Be+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Be+0]>>22}hasWidth(t){return this._data[t*Be+0]&12582912}getFg(t){return this._data[t*Be+1]}getBg(t){return this._data[t*Be+2]}hasContent(t){return this._data[t*Be+0]&4194303}getCodePoint(t){let n=this._data[t*Be+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Be+0]&2097152}getString(t){let n=this._data[t*Be+0];return n&2097152?this._combined[t]:n&2097151?br(n&2097151):""}isProtected(t){return this._data[t*Be+2]&536870912}loadCell(t,n){return eu=t*Be,n.content=this._data[eu+0],n.fg=this._data[eu+1],n.bg=this._data[eu+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*Be+0]=n.content,this._data[t*Be+1]=n.fg,this._data[t*Be+2]=n.bg}setCellFromCodepoint(t,n,s,a){a.bg&268435456&&(this._extendedAttrs[t]=a.extended),this._data[t*Be+0]=n|s<<22,this._data[t*Be+1]=a.fg,this._data[t*Be+2]=a.bg}addCodepointToCell(t,n,s){let a=this._data[t*Be+0];a&2097152?this._combined[t]+=br(n):a&2097151?(this._combined[t]=br(a&2097151)+br(n),a&=-2097152,a|=2097152):a=n|1<<22,s&&(a&=-12582913,a|=s<<22),this._data[t*Be+0]=a}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n=0;--o)this.setCell(t+n+o,this.loadCell(t+o,a));for(let o=0;othis.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let a=new Uint32Array(s);a.set(this._data),this._data=a}for(let a=this.length;a=t&&delete this._combined[f]}let o=Object.keys(this._extendedAttrs);for(let c=0;c=t&&delete this._extendedAttrs[f]}}return this.length=t,s*4*rf=0;--t)if(this._data[t*Be+0]&4194303)return t+(this._data[t*Be+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Be+0]&4194303||this._data[t*Be+2]&50331648)return t+(this._data[t*Be+0]>>22);return 0}copyCellsFrom(t,n,s,a,o){let c=t._data;if(o)for(let p=a-1;p>=0;p--){for(let h=0;h=n&&(this._combined[h-n+s]=t._combined[h])}}translateToString(t,n,s,a){n=n??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),a&&(a.length=0);let o="";for(;n>22||1}return a&&a.push(n),o}};function i2(e,t,n,s,a,o){let c=[];for(let f=0;f=f&&s0&&(L>_||g[L].getTrimmedLength()===0);L--)k++;k>0&&(c.push(f+g.length-k),c.push(k)),f+=g.length-1}return c}function n2(e,t){let n=[],s=0,a=t[s],o=0;for(let c=0;cya(e,h,t)).reduce((p,h)=>p+h),o=0,c=0,f=0;for(;fp&&(o-=p,c++);let h=e[c].getWidth(o-1)===2;h&&o--;let g=h?n-1:n;s.push(g),f+=g}return s}function ya(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,a=e[t+1].getWidth(0)===2;return s&&a?n-1:n}var Ub=class Ib{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Ib._nextId++,this._onDispose=this.register(new he),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Jr(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Ub._nextId=1;var l2=Ub,Lt={},Gr=Lt.B;Lt[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Lt.A={"#":"£"};Lt.B=void 0;Lt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Lt.C=Lt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Lt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Lt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Lt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Lt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Lt.E=Lt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Lt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Lt.H=Lt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Lt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var zv=4294967295,Ov=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=At.clone(),this.savedCharset=Gr,this.markers=[],this._nullCell=Xi.fromCharData([0,rb,1,0]),this._whitespaceCell=Xi.fromCharData([0,xr,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new gu,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Lv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new du),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new du),this._whitespaceCell}getBlankLine(e,t){return new ca(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&ezv?zv:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=At);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Lv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(At),s=0,a=this._getCorrectBufferLength(t);if(a>this.lines.maxLength&&(this.lines.maxLength=a),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new ca(e,n)));else for(let c=this._rows;c>t;c--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(a0&&(this.lines.trimStart(c),this.ybase=Math.max(this.ybase-c,0),this.ydisp=Math.max(this.ydisp-c,0),this.savedY=Math.max(this.savedY-c,0)),this.lines.maxLength=a}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let o=0;o.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=i2(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(At),n);if(s.length>0){let a=n2(this.lines,s);r2(this.lines,a.layout),this._reflowLargerAdjustViewport(e,t,a.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(At),a=n;for(;a-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;c--){let f=this.lines.get(c);if(!f||!f.isWrapped&&f.getTrimmedLength()<=e)continue;let p=[f];for(;f.isWrapped&&c>0;)f=this.lines.get(--c),p.unshift(f);if(!n){let I=this.ybase+this.y;if(I>=c&&I0&&(a.push({start:c+p.length+o,newLines:y}),o+=y.length),p.push(...y);let x=g.length-1,k=g[x];k===0&&(x--,k=g[x]);let L=p.length-_-1,M=h;for(;L>=0;){let I=Math.min(M,k);if(p[x]===void 0)break;if(p[x].copyCellsFrom(p[L],M-I,k-I,I,!0),k-=I,k===0&&(x--,k=g[x]),M-=I,M===0){L--;let Z=Math.max(L,0);M=ya(p,Z,this._cols)}}for(let I=0;I0;)this.ybase===0?this.y0){let c=[],f=[];for(let k=0;k=0;k--)if(_&&_.start>h+b){for(let L=_.newLines.length-1;L>=0;L--)this.lines.set(k--,_.newLines[L]);k++,c.push({index:h+1,amount:_.newLines.length}),b+=_.newLines.length,_=a[++g]}else this.lines.set(k,f[h--]);let y=0;for(let k=c.length-1;k>=0;k--)c[k].index+=y,this.lines.onInsertEmitter.fire(c[k]),y+=c[k].amount;let x=Math.max(0,p+o-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(e,t,n=0,s){let a=this.lines.get(e);return a?a.translateToString(t,n,s):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+10;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.linen.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},a2=class extends Ne{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new he),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new Ov(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Ov(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},Fb=2,qb=1,sd=class extends Ne{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new he),this.onResize=this._onResize.event,this._onScroll=this._register(new he),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Fb),this.rows=Math.max(e.rawOptions.rows||0,qb),this.buffers=this._register(new a2(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=n.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let a=n.ybase+n.scrollTop,o=n.ybase+n.scrollBottom;if(n.scrollTop===0){let c=n.lines.isFull;o===n.lines.length-1?c?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(o+1,0,s.clone()),c?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let c=o-a+1;n.lines.shiftElements(a+1,c-1,-1),n.lines.set(o,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),s!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};sd=gt([pe(0,hi)],sd);var Ws={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:_u,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},o2=["normal","bold","100","200","300","400","500","600","700","800","900"],u2=class extends Ne{constructor(e){super(),this._onOptionChange=this._register(new he),this.onOptionChange=this._onOptionChange.event;let t={...Ws};for(let n in e)if(n in t)try{let s=e[n];t[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ct(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in Ws))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in Ws))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Ws[e]),!c2(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Ws[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=o2.includes(t)?t:Ws[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function c2(e){return e==="block"||e==="underline"||e==="bar"}function ha(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let s in e)n[s]=t<=1?e[s]:e[s]&&ha(e[s],t-1);return n}var jv=Object.freeze({insertMode:!1}),Hv=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),ld=class extends Ne{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new he),this.onData=this._onData.event,this._onUserInput=this._register(new he),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new he),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new he),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=ha(jv),this.decPrivateModes=ha(Hv)}reset(){this.modes=ha(jv),this.decPrivateModes=ha(Hv)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};ld=gt([pe(0,ci),pe(1,ub),pe(2,hi)],ld);var Pv={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function sf(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var lf=String.fromCharCode,Uv={DEFAULT:e=>{let t=[sf(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${lf(t[0])}${lf(t[1])}${lf(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${sf(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${sf(e,!0)};${e.x};${e.y}${t}`}},ad=class extends Ne{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new he),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Pv))this.addProtocol(s,Pv[s]);for(let s of Object.keys(Uv))this.addEncoding(s,Uv[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let s=t/n,a=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(a/=s+0,Math.abs(e.deltaY)<50&&(a*=.3),this._wheelPartialScroll+=a,a=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(a*=this._bufferService.rows),a}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};ad=gt([pe(0,ci),pe(1,is),pe(2,hi)],ad);var af=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],h2=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Bt;function f2(e,t){let n=0,s=t.length-1,a;if(et[s][1])return!1;for(;s>=n;)if(a=n+s>>1,e>t[a][1])n=a+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let a=Zr.extractWidth(t);a===0?s=!1:a>n&&(n=a)}return Zr.createPropertyValue(0,n,s)}},Zr=class cu{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new he,this.onChange=this._onChange.event;let t=new d2;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,s=!1){return(t&16777215)<<3|(n&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,s=0,a=t.length;for(let o=0;o=a)return n+this.wcwidth(c);let h=t.charCodeAt(o);56320<=h&&h<=57343?c=(c-55296)*1024+h-56320+65536:n+=this.wcwidth(h)}let f=this.charProperties(c,s),p=cu.extractWidth(f);cu.extractShouldJoin(f)&&(p-=cu.extractWidth(s)),n+=p,s=f}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},p2=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Iv(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var ea=2147483647,m2=256,Wb=class od{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>m2)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new od;if(!t.length)return n;for(let s=Array.isArray(t[0])?1:0;s>8,a=this._subParamsIdx[n]&255;a-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,a))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>ea?ea:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>ea?ea:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let t={};for(let n=0;n>8,a=this._subParamsIdx[n]&255;a-s>0&&(t[n]=this._subParams.slice(s,a))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,a=s[n-1];s[n-1]=~a?Math.min(a*10+t,ea):t}},ta=[],_2=class{constructor(){this._state=0,this._active=ta,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ta}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=ta,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ta,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",wu(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=ta,this._id=-1,this._state=0}}},Ri=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=wu(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},ia=[],g2=class{constructor(){this._handlers=Object.create(null),this._active=ia,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ia}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=ia,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||ia,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",wu(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=ia,this._ident=0}},fa=new Wb;fa.addParam(0);var Fv=class{constructor(e){this._handler=e,this._data="",this._params=fa,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():fa,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=wu(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=fa,this._data="",this._hitLimit=!1,n));return this._params=fa,this._data="",this._hitLimit=!1,t}},v2=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let a=0;ap),n=(f,p)=>t.slice(f,p),s=n(32,127),a=n(0,24);a.push(25),a.push.apply(a,n(28,32));let o=n(0,14),c;e.setDefault(1,0),e.addMany(s,0,2,0);for(c in o)e.addMany([24,26,153,154],c,3,0),e.addMany(n(128,144),c,3,0),e.addMany(n(144,152),c,3,0),e.add(156,c,0,0),e.add(27,c,11,1),e.add(157,c,4,8),e.addMany([152,158,159],c,0,7),e.add(155,c,11,3),e.add(144,c,11,9);return e.addMany(a,0,3,0),e.addMany(a,1,3,1),e.add(127,1,0,1),e.addMany(a,8,0,8),e.addMany(a,3,3,3),e.add(127,3,0,3),e.addMany(a,4,3,4),e.add(127,4,0,4),e.addMany(a,6,3,6),e.addMany(a,5,3,5),e.add(127,5,0,5),e.addMany(a,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(a,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(a,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(a,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(a,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(a,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(a,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Vi,0,2,0),e.add(Vi,8,5,8),e.add(Vi,6,0,6),e.add(Vi,11,0,11),e.add(Vi,13,13,13),e})(),b2=class extends Ne{constructor(e=y2){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Wb,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(ct(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new _2),this._dcsParser=this._register(new g2),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let a=0;ao||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=s,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];return s.push(t),{dispose:()=>{let a=s.indexOf(t);a!==-1&&s.splice(a,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];return s.push(t),{dispose:()=>{let a=s.indexOf(t);a!==-1&&s.splice(a,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,s,a){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=a}parse(e,t,n){let s=0,a=0,o=0,c;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let f=this._parseStack.handlers,p=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&p>-1){for(;p>=0&&(c=f[p](this._params),c!==!0);p--)if(c instanceof Promise)return this._parseStack.handlerPos=p,c}this._parseStack.handlers=[];break;case 4:if(n===!1&&p>-1){for(;p>=0&&(c=f[p](),c!==!0);p--)if(c instanceof Promise)return this._parseStack.handlerPos=p,c}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],c=this._dcsParser.unhook(s!==24&&s!==26,n),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],c=this._oscParser.end(s!==24&&s!==26,n),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let f=o;f>4){case 2:for(let b=f+1;;++b){if(b>=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=t||(s=e[b])<32||s>126&&s=0&&(c=p[h](this._params),c!==!0);h--)if(c instanceof Promise)return this._preserveStack(3,p,h,a,f),c;h<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++f47&&s<60);f--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let g=this._escHandlers[this._collect<<8|s],_=g?g.length-1:-1;for(;_>=0&&(c=g[_](),c!==!0);_--)if(c instanceof Promise)return this._preserveStack(4,g,_,a,f),c;_<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let b=f+1;;++b)if(b>=t||(s=e[b])===24||s===26||s===27||s>127&&s=t||(s=e[b])<32||s>127&&s>4:o>>8}return s}}function of(e,t){let n=e.toString(16),s=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function w2(e,t=16){let[n,s,a]=e;return`rgb:${of(n,t)}/${of(s,t)}/${of(a,t)}`}var C2={"(":0,")":1,"*":2,"+":3,"-":1,".":2},vr=131072,Wv=10;function Yv(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Vv=5e3,Kv=0,k2=class extends Ne{constructor(e,t,n,s,a,o,c,f,p=new b2){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=a,this._oscLinkService=o,this._coreMouseService=c,this._unicodeService=f,this._parser=p,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Wx,this._utf8Decoder=new Yx,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=At.clone(),this._eraseAttrDataInternal=At.clone(),this._onRequestBell=this._register(new he),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new he),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new he),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new he),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new he),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new he),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new he),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new he),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new he),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new he),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new he),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new he),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new he),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new ud(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,g)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:g.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,g,_)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:g,data:_})}),this._parser.setDcsHandlerFallback((h,g,_)=>{g==="HOOK"&&(_=_.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:g,payload:_})}),this._parser.setPrintHandler((h,g,_)=>this.print(h,g,_)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler(re.BEL,()=>this.bell()),this._parser.setExecuteHandler(re.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(re.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(re.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(re.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(re.BS,()=>this.backspace()),this._parser.setExecuteHandler(re.HT,()=>this.tab()),this._parser.setExecuteHandler(re.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(re.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ou.IND,()=>this.index()),this._parser.setExecuteHandler(ou.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ou.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ri(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new Ri(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new Ri(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new Ri(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new Ri(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new Ri(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new Ri(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new Ri(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new Ri(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new Ri(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new Ri(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new Ri(h=>this.restoreCursorColor(h))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let h in Lt)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Fv((h,g)=>this.requestStatusString(h,g)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),Vv))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Vv} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,a=this._activeBuffer.y,o=0,c=this._parseStack.paused;if(c){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,a=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>vr&&(o=this._parseStack.position+vr)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(h=>h.charCodeAt(0)):e),this._parseBuffer.lengthvr)for(let h=o;h0&&_.getWidth(this._activeBuffer.x-1)===2&&_.setCellFromCodepoint(this._activeBuffer.x-1,0,1,g);let b=this._parser.precedingJoinState;for(let y=t;yf){if(p){let M=_,G=this._activeBuffer.x-L;for(this._activeBuffer.x=L,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),_=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),L>0&&_ instanceof ca&&_.copyCellsFrom(M,G,0,L,!1);G=0;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,g);continue}if(h&&(_.insertCells(this._activeBuffer.x,a-L,this._activeBuffer.getNullCell(g)),_.getWidth(f-1)===2&&_.setCellFromCodepoint(f-1,0,1,g)),_.setCellFromCodepoint(this._activeBuffer.x++,s,a,g),a>0)for(;--a;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,g)}this._parser.precedingJoinState=b,this._activeBuffer.x0&&_.getWidth(this._activeBuffer.x)===0&&!_.hasContent(this._activeBuffer.x)&&_.setCellFromCodepoint(this._activeBuffer.x,0,1,g),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>Yv(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Fv(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ri(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,s=!1,a=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),a),s&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&s.getTrimmedLength()););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let a=this._activeBuffer.lines.length-this._bufferService.rows;a>0&&(this._activeBuffer.lines.trimStart(a),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-a,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-a,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y65535?2:1}let p=f;for(let h=1;h0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(re.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(re.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(re.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(re.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(re.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t(k[k.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",k[k.SET=1]="SET",k[k.RESET=2]="RESET",k[k.PERMANENTLY_SET=3]="PERMANENTLY_SET",k[k.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:a,activeEncoding:o}=this._coreMouseService,c=this._coreService,{buffers:f,cols:p}=this._bufferService,{active:h,alt:g}=f,_=this._optionsService.rawOptions,b=(k,L)=>(c.triggerDataEvent(`${re.ESC}[${t?"":"?"}${k};${L}$y`),!0),y=k=>k?1:2,x=e.params[0];return t?x===2?b(x,4):x===4?b(x,y(c.modes.insertMode)):x===12?b(x,3):x===20?b(x,y(_.convertEol)):b(x,0):x===1?b(x,y(s.applicationCursorKeys)):x===3?b(x,_.windowOptions.setWinLines?p===80?2:p===132?1:0:0):x===6?b(x,y(s.origin)):x===7?b(x,y(s.wraparound)):x===8?b(x,3):x===9?b(x,y(a==="X10")):x===12?b(x,y(_.cursorBlink)):x===25?b(x,y(!c.isCursorHidden)):x===45?b(x,y(s.reverseWraparound)):x===66?b(x,y(s.applicationKeypad)):x===67?b(x,4):x===1e3?b(x,y(a==="VT200")):x===1002?b(x,y(a==="DRAG")):x===1003?b(x,y(a==="ANY")):x===1004?b(x,y(s.sendFocus)):x===1005?b(x,4):x===1006?b(x,y(o==="SGR")):x===1015?b(x,4):x===1016?b(x,y(o==="SGR_PIXELS")):x===1048?b(x,1):x===47||x===1047||x===1049?b(x,y(h===g)):x===2004?b(x,y(s.bracketedPasteMode)):x===2026?b(x,y(s.synchronizedOutput)):b(x,0)}_updateAttrColor(e,t,n,s,a){return t===2?(e|=50331648,e&=-16777216,e|=wa.fromColorRGB([n,s,a])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let s=[0,0,-1,0,0,0],a=0,o=0;do{if(s[o+a]=e.params[t+o],e.hasSubParams(t+o)){let c=e.getSubParams(t+o),f=0;do s[1]===5&&(a=1),s[o+f+1+a]=c[f];while(++f=2||s[1]===2&&o+a>=5)break;s[1]&&(a=1)}while(++o+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=At.fg,e.bg=At.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,s=this._curAttrData;for(let a=0;a=30&&n<=37?(s.fg&=-50331904,s.fg|=16777216|n-30):n>=40&&n<=47?(s.bg&=-50331904,s.bg|=16777216|n-40):n>=90&&n<=97?(s.fg&=-50331904,s.fg|=16777216|n-90|8):n>=100&&n<=107?(s.bg&=-50331904,s.bg|=16777216|n-100|8):n===0?this._processSGR0(s):n===1?s.fg|=134217728:n===3?s.bg|=67108864:n===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(a)?e.getSubParams(a)[0]:1,s)):n===5?s.fg|=536870912:n===7?s.fg|=67108864:n===8?s.fg|=1073741824:n===9?s.fg|=2147483648:n===2?s.bg|=134217728:n===21?this._processUnderline(2,s):n===22?(s.fg&=-134217729,s.bg&=-134217729):n===23?s.bg&=-67108865:n===24?(s.fg&=-268435457,this._processUnderline(0,s)):n===25?s.fg&=-536870913:n===27?s.fg&=-67108865:n===28?s.fg&=-1073741825:n===29?s.fg&=2147483647:n===39?(s.fg&=-67108864,s.fg|=At.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=At.bg&16777215):n===38||n===48||n===58?a+=this._extractColor(e,a,s):n===53?s.bg|=1073741824:n===55?s.bg&=-1073741825:n===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):n===100?(s.fg&=-67108864,s.fg|=At.fg&16777215,s.bg&=-67108864,s.bg|=At.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${re.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${re.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${re.ESC}[?${t};${n}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=At.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Yv(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${re.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Wv&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Wv&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let s=n.shift(),a=n.shift();if(/^\d+$/.exec(s)){let o=parseInt(s);if(Xv(o))if(a==="?")t.push({type:0,index:o});else{let c=qv(a);c&&t.push({type:1,index:o,color:c})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),s,a=n.findIndex(o=>o.startsWith("id="));return a!==-1&&(s=n[a].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let s=0;s=this._specialColors.length);++s,++t)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let a=qv(n[s]);a&&this._onColor.fire([{type:1,index:this._specialColors[t],color:a}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let s=0;s=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=At.clone(),this._eraseAttrDataInternal=At.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Xi;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t(this._coreService.triggerDataEvent(`${re.ESC}${c}${re.ESC}\\`),!0),s=this._bufferService.buffer,a=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[a.cursorStyle]-(a.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},ud=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){ethis.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Kv=e,e=t,t=Kv),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};ud=gt([pe(0,ci)],ud);function Xv(e){return 0<=e&&e<256}var E2=5e7,$v=12,T2=50,A2=class extends Ne{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new he),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>E2)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],a=this._action(s,t);if(a){let c=f=>performance.now()-n>=$v?setTimeout(()=>this._innerWrite(0,f)):this._innerWrite(n,f);a.catch(f=>(queueMicrotask(()=>{throw f}),Promise.resolve(!1))).then(c);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=$v)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>T2&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},cd=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let f=t.addMarker(t.ybase+t.y),p={data:e,id:this._nextId++,lines:[f]};return f.onDispose(()=>this._removeMarkerFromLink(p,f)),this._dataByLinkId.set(p.id,p),p.id}let n=e,s=this._getEntryIdKey(n),a=this._entriesWithId.get(s);if(a)return this.addLineToLink(a.id,t.ybase+t.y),a.id;let o=t.addMarker(t.ybase+t.y),c={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(c,o)),this._entriesWithId.set(c.key,c),this._dataByLinkId.set(c.id,c),c.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};cd=gt([pe(0,ci)],cd);var Gv=!1,D2=class extends Ne{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Qs),this._onBinary=this._register(new he),this.onBinary=this._onBinary.event,this._onData=this._register(new he),this.onData=this._onData.event,this._onLineFeed=this._register(new he),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new he),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new he),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new he),this._instantiationService=new JC,this.optionsService=this._register(new u2(e)),this._instantiationService.setService(hi,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(sd)),this._instantiationService.setService(ci,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(rd)),this._instantiationService.setService(ub,this._logService),this.coreService=this._register(this._instantiationService.createInstance(ld)),this._instantiationService.setService(is,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(ad)),this._instantiationService.setService(ob,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Zr)),this._instantiationService.setService($x,this.unicodeService),this._charsetService=this._instantiationService.createInstance(p2),this._instantiationService.setService(Xx,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(cd),this._instantiationService.setService(cb,this._oscLinkService),this._inputHandler=this._register(new k2(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(ei.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(ei.forward(this._bufferService.onResize,this._onResize)),this._register(ei.forward(this.coreService.onData,this._onData)),this._register(ei.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new A2((t,n)=>this._inputHandler.parse(t,n))),this._register(ei.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new he),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Gv&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Gv=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,Fb),t=Math.max(t,qb),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Iv.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Iv(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ct(()=>{for(let t of e)t.dispose()})}}},R2={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function M2(e,t,n,s){var c;let a={type:0,cancel:!1,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?a.key=re.ESC+"OA":a.key=re.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?a.key=re.ESC+"OD":a.key=re.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?a.key=re.ESC+"OC":a.key=re.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?a.key=re.ESC+"OB":a.key=re.ESC+"[B");break;case 8:a.key=e.ctrlKey?"\b":re.DEL,e.altKey&&(a.key=re.ESC+a.key);break;case 9:if(e.shiftKey){a.key=re.ESC+"[Z";break}a.key=re.HT,a.cancel=!0;break;case 13:a.key=e.altKey?re.ESC+re.CR:re.CR,a.cancel=!0;break;case 27:a.key=re.ESC,e.altKey&&(a.key=re.ESC+re.ESC),a.cancel=!0;break;case 37:if(e.metaKey)break;o?a.key=re.ESC+"[1;"+(o+1)+"D":t?a.key=re.ESC+"OD":a.key=re.ESC+"[D";break;case 39:if(e.metaKey)break;o?a.key=re.ESC+"[1;"+(o+1)+"C":t?a.key=re.ESC+"OC":a.key=re.ESC+"[C";break;case 38:if(e.metaKey)break;o?a.key=re.ESC+"[1;"+(o+1)+"A":t?a.key=re.ESC+"OA":a.key=re.ESC+"[A";break;case 40:if(e.metaKey)break;o?a.key=re.ESC+"[1;"+(o+1)+"B":t?a.key=re.ESC+"OB":a.key=re.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(a.key=re.ESC+"[2~");break;case 46:o?a.key=re.ESC+"[3;"+(o+1)+"~":a.key=re.ESC+"[3~";break;case 36:o?a.key=re.ESC+"[1;"+(o+1)+"H":t?a.key=re.ESC+"OH":a.key=re.ESC+"[H";break;case 35:o?a.key=re.ESC+"[1;"+(o+1)+"F":t?a.key=re.ESC+"OF":a.key=re.ESC+"[F";break;case 33:e.shiftKey?a.type=2:e.ctrlKey?a.key=re.ESC+"[5;"+(o+1)+"~":a.key=re.ESC+"[5~";break;case 34:e.shiftKey?a.type=3:e.ctrlKey?a.key=re.ESC+"[6;"+(o+1)+"~":a.key=re.ESC+"[6~";break;case 112:o?a.key=re.ESC+"[1;"+(o+1)+"P":a.key=re.ESC+"OP";break;case 113:o?a.key=re.ESC+"[1;"+(o+1)+"Q":a.key=re.ESC+"OQ";break;case 114:o?a.key=re.ESC+"[1;"+(o+1)+"R":a.key=re.ESC+"OR";break;case 115:o?a.key=re.ESC+"[1;"+(o+1)+"S":a.key=re.ESC+"OS";break;case 116:o?a.key=re.ESC+"[15;"+(o+1)+"~":a.key=re.ESC+"[15~";break;case 117:o?a.key=re.ESC+"[17;"+(o+1)+"~":a.key=re.ESC+"[17~";break;case 118:o?a.key=re.ESC+"[18;"+(o+1)+"~":a.key=re.ESC+"[18~";break;case 119:o?a.key=re.ESC+"[19;"+(o+1)+"~":a.key=re.ESC+"[19~";break;case 120:o?a.key=re.ESC+"[20;"+(o+1)+"~":a.key=re.ESC+"[20~";break;case 121:o?a.key=re.ESC+"[21;"+(o+1)+"~":a.key=re.ESC+"[21~";break;case 122:o?a.key=re.ESC+"[23;"+(o+1)+"~":a.key=re.ESC+"[23~";break;case 123:o?a.key=re.ESC+"[24;"+(o+1)+"~":a.key=re.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?a.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?a.key=re.NUL:e.keyCode>=51&&e.keyCode<=55?a.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?a.key=re.DEL:e.keyCode===219?a.key=re.ESC:e.keyCode===220?a.key=re.FS:e.keyCode===221&&(a.key=re.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let f=(c=R2[e.keyCode])==null?void 0:c[e.shiftKey?1:0];if(f)a.key=re.ESC+f;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,h=String.fromCharCode(p);e.shiftKey&&(h=h.toUpperCase()),a.key=re.ESC+h}else if(e.keyCode===32)a.key=re.ESC+(e.ctrlKey?re.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),a.key=re.ESC+p,a.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(a.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?a.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(a.key=re.US),e.key==="@"&&(a.key=re.NUL));break}return a}var St=0,B2=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new gu,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new gu,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((a,o)=>this._getKey(a)-this._getKey(o)),t=0,n=0,s=new Array(this._array.length+this._insertedValues.length);for(let a=0;a=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(s[a]=e[t],t++):s[a]=this._array[n++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(St=this._search(t),St===-1)||this._getKey(this._array[St])!==t)return!1;do if(this._array[St]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(St),!0;while(++Sta-o),t=0,n=new Array(this._array.length-e.length),s=0;for(let a=0;a0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(St=this._search(e),!(St<0||St>=this._array.length)&&this._getKey(this._array[St])===e))do yield this._array[St];while(++St=this._array.length)&&this._getKey(this._array[St])===e))do t(this._array[St]);while(++St=t;){let s=t+n>>1,a=this._getKey(this._array[s]);if(a>e)n=s-1;else if(a0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},uf=0,Zv=0,N2=class extends Ne{constructor(){super(),this._decorations=new B2(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new he),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new he),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ct(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new L2(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let s=0,a=0;for(let o of this._decorations.getKeyIterator(t))s=o.options.x??0,a=s+(o.options.width??1),e>=s&&e{uf=a.options.x??0,Zv=uf+(a.options.width??1),e>=uf&&e=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let a=s-this._lastRefreshMs,o=this._debounceThresholdMS-a;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Qv=20,vu=class extends Ne{constructor(e,t,n,s){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let a=this._coreBrowserService.mainDocument;this._accessibilityContainer=a.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=a.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;othis._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=a.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new O2(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(` +`))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(ke(a,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ct(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===` +`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Qv+1&&(this._liveRegion.textContent+=Rf.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,s=n.lines.length.toString();for(let a=e;a<=t;a++){let o=n.lines.get(n.ydisp+a),c=[],f=(o==null?void 0:o.translateToString(!0,void 0,void 0,c))||"",p=(n.ydisp+a+1).toString(),h=this._rowElements[a];h&&(f.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=f,this._rowColumns.set(h,c)),h.setAttribute("aria-posinset",p),h.setAttribute("aria-setsize",s),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],a=n.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(a===o||e.relatedTarget!==s)return;let c,f;if(t===0?(c=n,f=this._rowElements.pop(),this._rowContainer.removeChild(f)):(c=this._rowElements.shift(),f=n,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),f.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let p=this._createAccessibilityTreeNode();this._rowElements.unshift(p),this._rowContainer.insertAdjacentElement("afterbegin",p)}else{let p=this._createAccessibilityTreeNode();this._rowElements.push(p),this._rowContainer.appendChild(p)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var f;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:s,offset:((f=s.textContent)==null?void 0:f.length)??0}),!this._rowContainer.contains(n.node))return;let a=({node:p,offset:h})=>{let g=p instanceof Text?p.parentNode:p,_=parseInt(g==null?void 0:g.getAttribute("aria-posinset"),10)-1;if(isNaN(_))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(g);if(!b)return console.warn("columns is null. Race condition?"),null;let y=h=this._terminal.cols&&(++_,y=0),{row:_,column:y}},o=a(t),c=a(n);if(!(!o||!c)){if(o.row>c.row||o.row===c.row&&o.column>=c.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(c.row-o.row)*this._terminal.cols-o.column+c.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;te;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e{var o;Jr(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(o=this._activeProviderReplies)==null||o.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(ke(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(ke(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(ke(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(ke(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let s=0;s{o==null||o.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[o,c]of this._linkProviderService.linkProviders.entries())t?(a=this._activeProviderReplies)!=null&&a.get(o)&&(n=this._checkLinkProviderResult(o,e,n)):c.provideLinks(e.y,f=>{var h,g;if(this._isMouseOut)return;let p=f==null?void 0:f.map(_=>({link:_}));(h=this._activeProviderReplies)==null||h.set(o,p),n=this._checkLinkProviderResult(o,e,n),((g=this._activeProviderReplies)==null?void 0:g.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;se?this._bufferService.cols:c.link.range.end.x;for(let h=f;h<=p;h++){if(n.has(h)){a.splice(o--,1);break}n.add(h)}}}}_checkLinkProviderResult(e,t,n){var o;if(!this._activeProviderReplies)return n;let s=this._activeProviderReplies.get(e),a=!1;for(let c=0;cthis._linkAtPosition(f.link,t));c&&(n=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let c=0;cthis._linkAtPosition(p.link,t));if(f){n=!0,this._handleNewLink(f);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&j2(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Jr(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.pointerCursor},set:n=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.underline},set:n=>{var s,a,o;(s=this._currentLink)!=null&&s.state&&((o=(a=this._currentLink)==null?void 0:a.state)==null?void 0:o.decorations.underline)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let s=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,a=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=a&&(this._clearCurrentLink(s,a),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,s=this._bufferService.buffer.ydisp,a=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(a)}_linkLeave(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,a=t.y*this._bufferService.cols+t.x;return n<=a&&a<=s}_positionFromMouseEvent(e,t,n){let s=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,s,a){return{x1:e,y1:t,x2:n,y2:s,cols:this._bufferService.cols,fg:a}}};hd=gt([pe(1,kd),pe(2,Un),pe(3,ci),pe(4,fb)],hd);function j2(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var H2=class extends D2{constructor(e={}){super(e),this._linkifier=this._register(new Qs),this.browser=Mb,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Qs),this._onCursorMove=this._register(new he),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new he),this.onKey=this._onKey.event,this._onRender=this._register(new he),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new he),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new he),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new he),this.onBell=this._onBell.event,this._onFocus=this._register(new he),this._onBlur=this._register(new he),this._onA11yCharEmitter=this._register(new he),this._onA11yTabEmitter=this._register(new he),this._onWillOpen=this._register(new he),this._setup(),this._decorationService=this._instantiationService.createInstance(N2),this._instantiationService.setService(Ca,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(TC),this._instantiationService.setService(fb,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Bf)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(ei.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(ei.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(ei.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(ei.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ct(()=>{var t,n;this._customKeyEventHandler=void 0,(n=(t=this.element)==null?void 0:t.parentNode)==null||n.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,s="";switch(t.index){case 256:n="foreground",s="10";break;case 257:n="background",s="11";break;case 258:n="cursor",s="12";break;default:n="ansi",s="4;"+t.index}switch(t.type){case 0:let a=ot.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${re.ESC}]${s};${w2(a)}${Db.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=Dt.toColor(...t.color));else{let o=n;this._themeService.modifyColors(c=>c[o]=Dt.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(vu,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(re.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(re.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,a=t.getWidth(n),o=this._renderService.dimensions.css.cell.width*a,c=this.buffer.y*this._renderService.dimensions.css.cell.height,f=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=f+"px",this.textarea.style.top=c+"px",this.textarea.style.width=o+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(ke(this.element,"copy",t=>{this.hasSelection()&&Fx(t,this._selectionService)}));let e=t=>qx(t,this.textarea,this.coreService,this.optionsService);this._register(ke(this.textarea,"paste",e)),this._register(ke(this.element,"paste",e)),Bb?this._register(ke(this.element,"mousedown",t=>{t.button===2&&ov(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(ke(this.element,"contextmenu",t=>{ov(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Nd&&this._register(ke(this.element,"auxclick",t=>{t.button===1&&nb(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(ke(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(ke(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(ke(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(ke(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(ke(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(ke(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(ke(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var a;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((a=this.element)==null?void 0:a.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(ke(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Df.get()),zb||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(kC,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Pn,this._coreBrowserService),this._register(ke(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(ke(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Jf,this._document,this._helperContainer),this._instantiationService.setService(Cu,this._charSizeService),this._themeService=this._instantiationService.createInstance(nd),this._instantiationService.setService(el,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(mu),this._instantiationService.setService(hb,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(td,this.rows,this.screenElement)),this._instantiationService.setService(Un,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Gf,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(ed),this._instantiationService.setService(kd,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(hd,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Xf,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(id,this.element,this.screenElement,s)),this._instantiationService.setService(Zx,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register(ei.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance($f,this.screenElement)),this._register(ke(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(vu,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(pu,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(pu,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Qf,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(o){var h,g,_,b,y;let c=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!c)return!1;let f,p;switch(o.overrideType||o.type){case"mousemove":p=32,o.buttons===void 0?(f=3,o.button!==void 0&&(f=o.button<3?o.button:3)):f=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":p=0,f=o.button<3?o.button:3;break;case"mousedown":p=1,f=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let x=o.deltaY;if(x===0||e.coreMouseService.consumeWheelEvent(o,(b=(_=(g=(h=e._renderService)==null?void 0:h.dimensions)==null?void 0:g.device)==null?void 0:_.cell)==null?void 0:b.height,(y=e._coreBrowserService)==null?void 0:y.dpr)===0)return!1;p=x<0?0:1,f=4;break;default:return!1}return p===void 0||f===void 0||f>4?!1:e.coreMouseService.triggerMouseEvent({col:c.col,row:c.row,x:c.x,y:c.y,button:f,action:p,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:o=>(n(o),o.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(o)),wheel:o=>(n(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&n(o)},mousemove:o=>{o.buttons||n(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?s.mousemove||(t.addEventListener("mousemove",a.mousemove),s.mousemove=a.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),o&16?s.wheel||(t.addEventListener("wheel",a.wheel,{passive:!1}),s.wheel=a.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),o&2?s.mouseup||(s.mouseup=a.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),o&4?s.mousedrag||(s.mousedrag=a.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(ke(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return n(o),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(o)})),this._register(ke(t,"wheel",o=>{var c,f,p,h,g;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,(h=(p=(f=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:f.device)==null?void 0:p.cell)==null?void 0:h.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return this.cancel(o,!0);let _=re.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(_,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var n;(n=this._renderService)==null||n.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){ib(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var n;(n=this._selectionService)==null||n.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=M2(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let s=this.rows-1;return this.scrollLines(n.type===2?-s:s),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===re.ETX||n.key===re.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(P2(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var n;(n=this._charSizeService)==null||n.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Xi)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Jv=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new I2(t)}getNullCell(){return new Xi}},F2=class extends Ne{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new he),this.onBufferChange=this._onBufferChange.event,this._normal=new Jv(this._core.buffers.normal,"normal"),this._alternate=new Jv(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},q2=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,s)=>t(n,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},W2=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},Y2=["cols","rows"],an=0,V2=class extends Ne{constructor(e){super(),this._core=this._register(new H2(e)),this._addonManager=this._register(new U2),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],n=(s,a)=>{this._checkReadonlyOptions(s),this._core.options[s]=a};for(let s in this._core.options){let a={get:t.bind(this,s),set:n.bind(this,s)};Object.defineProperty(this._publicOptions,s,a)}}_checkReadonlyOptions(e){if(Y2.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new q2(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new W2(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new F2(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Df.get()},set promptLabel(e){Df.set(e)},get tooMuchOutput(){return Rf.get()},set tooMuchOutput(e){Rf.set(e)}}}_verifyIntegers(...e){for(an of e)if(an===1/0||isNaN(an)||an%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(an of e)if(an&&(an===1/0||isNaN(an)||an%1!==0||an<0))throw new Error("This API only accepts positive integers")}};/** * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. * @license MIT @@ -94,37 +94,37 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t * Fabrice Bellard's javascript vt100 for jslinux: * http://bellard.org/jslinux/ * Copyright (c) 2011 Fabrice Bellard - */var Ut=0,It=0,Ft=0,pt=0,ii;(e=>{function t(a,o,c,f){return f!==void 0?`#${Kr(a)}${Kr(o)}${Kr(c)}${Kr(f)}`:`#${Kr(a)}${Kr(o)}${Kr(c)}`}e.toCss=t;function n(a,o,c,f=255){return(a<<24|o<<16|c<<8|f)>>>0}e.toRgba=n;function s(a,o,c,f){return{css:e.toCss(a,o,c,f),rgba:e.toRgba(a,o,c,f)}}e.toColor=s})(ii||(ii={}));var G2;(e=>{function t(p,h){if(pt=(h.rgba&255)/255,pt===1)return{css:h.css,rgba:h.rgba};let g=h.rgba>>24&255,_=h.rgba>>16&255,b=h.rgba>>8&255,y=p.rgba>>24&255,x=p.rgba>>16&255,k=p.rgba>>8&255;Ut=y+Math.round((g-y)*pt),It=x+Math.round((_-x)*pt),Ft=k+Math.round((b-k)*pt);let L=ii.toCss(Ut,It,Ft),M=ii.toRgba(Ut,It,Ft);return{css:L,rgba:M}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,h,g){let _=hu.ensureContrastRatio(p.rgba,h.rgba,g);if(_)return ii.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function a(p){let h=(p.rgba|255)>>>0;return[Ut,It,Ft]=hu.toChannels(h),{css:ii.toCss(Ut,It,Ft),rgba:h}}e.opaque=a;function o(p,h){return pt=Math.round(h*255),[Ut,It,Ft]=hu.toChannels(p.rgba),{css:ii.toCss(Ut,It,Ft,pt),rgba:ii.toRgba(Ut,It,Ft,pt)}}e.opacity=o;function c(p,h){return pt=p.rgba&255,o(p,pt*h/255)}e.multiplyOpacity=c;function f(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=f})(G2||(G2={}));var Zt;(e=>{let t,n;try{let a=document.createElement("canvas");a.width=1,a.height=1;let o=a.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return Ut=parseInt(a.slice(1,2).repeat(2),16),It=parseInt(a.slice(2,3).repeat(2),16),Ft=parseInt(a.slice(3,4).repeat(2),16),ii.toColor(Ut,It,Ft);case 5:return Ut=parseInt(a.slice(1,2).repeat(2),16),It=parseInt(a.slice(2,3).repeat(2),16),Ft=parseInt(a.slice(3,4).repeat(2),16),pt=parseInt(a.slice(4,5).repeat(2),16),ii.toColor(Ut,It,Ft,pt);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let o=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Ut=parseInt(o[1]),It=parseInt(o[2]),Ft=parseInt(o[3]),pt=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),ii.toColor(Ut,It,Ft,pt);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ut,It,Ft,pt]=t.getImageData(0,0,1,1).data,pt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ii.toRgba(Ut,It,Ft,pt),css:a}}e.toColor=s})(Zt||(Zt={}));var ai;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,a,o){let c=s/255,f=a/255,p=o/255,h=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),_=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return h*.2126+g*.7152+_*.0722}e.relativeLuminance2=n})(ai||(ai={}));var hu;(e=>{function t(c,f){if(pt=(f&255)/255,pt===1)return f;let p=f>>24&255,h=f>>16&255,g=f>>8&255,_=c>>24&255,b=c>>16&255,y=c>>8&255;return Ut=_+Math.round((p-_)*pt),It=b+Math.round((h-b)*pt),Ft=y+Math.round((g-y)*pt),ii.toRgba(Ut,It,Ft)}e.blend=t;function n(c,f,p){let h=ai.relativeLuminance(c>>8),g=ai.relativeLuminance(f>>8);if(Hn(h,g)>8));if(x>8));return x>L?y:k}return y}let _=a(c,f,p),b=Hn(h,ai.relativeLuminance(_>>8));if(b>8));return b>x?_:y}return _}}e.ensureContrastRatio=n;function s(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=Hn(ai.relativeLuminance2(b,y,x),ai.relativeLuminance2(h,g,_));for(;k0||y>0||x>0);)b-=Math.max(0,Math.ceil(b*.1)),y-=Math.max(0,Math.ceil(y*.1)),x-=Math.max(0,Math.ceil(x*.1)),k=Hn(ai.relativeLuminance2(b,y,x),ai.relativeLuminance2(h,g,_));return(b<<24|y<<16|x<<8|255)>>>0}e.reduceLuminance=s;function a(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=Hn(ai.relativeLuminance2(b,y,x),ai.relativeLuminance2(h,g,_));for(;k>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(hu||(hu={}));function Kr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Hn(e,t){return e{let e=[Zt.toColor("#2e3436"),Zt.toColor("#cc0000"),Zt.toColor("#4e9a06"),Zt.toColor("#c4a000"),Zt.toColor("#3465a4"),Zt.toColor("#75507b"),Zt.toColor("#06989a"),Zt.toColor("#d3d7cf"),Zt.toColor("#555753"),Zt.toColor("#ef2929"),Zt.toColor("#8ae234"),Zt.toColor("#fce94f"),Zt.toColor("#729fcf"),Zt.toColor("#ad7fa8"),Zt.toColor("#34e2e2"),Zt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],a=t[n/6%6|0],o=t[n%6];e.push({css:ii.toCss(s,a,o),rgba:ii.toRgba(s,a,o)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:ii.toCss(s,s,s),rgba:ii.toRgba(s,s,s)})}return e})());function ey(e,t,n){return Math.max(t,Math.min(e,n))}function Q2(e){switch(e){case"&":return"&";case"<":return"<"}return e}var Yb=class{constructor(e){this._buffer=e}serialize(e,t){let n=this._buffer.getNullCell(),s=this._buffer.getNullCell(),a=n,o=e.start.y,c=e.end.y,f=e.start.x,p=e.end.x;this._beforeSerialize(c-o,o,c);for(let h=o;h<=c;h++){let g=this._buffer.getLine(h);if(g){let _=h===e.start.y?f:0,b=h===e.end.y?p:g.length;for(let y=_;y0&&!Pn(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let n="";if(!t){e-this._firstRow>=this._terminal.rows&&((s=this._buffer.getLine(this._cursorStyleRow))==null||s.getCell(this._cursorStyleCol,this._backgroundCell));let a=this._buffer.getLine(e),o=this._buffer.getLine(e+1);if(!o.isWrapped)n=`\r -`,this._lastCursorRow=e+1,this._lastCursorCol=0;else{n="";let c=a.getCell(a.length-1,this._thisRowLastChar),f=a.getCell(a.length-2,this._thisRowLastSecondChar),p=o.getCell(0,this._nextRowFirstChar),h=p.getWidth()>1,g=!1;(p.getChars()&&h?this._nullCellCount<=1:this._nullCellCount<=0)&&((c.getChars()||c.getWidth()===0)&&Pn(c,p)&&(g=!0),h&&(f.getChars()||f.getWidth()===0)&&Pn(c,p)&&Pn(f,p)&&(g=!0)),g||(n="-".repeat(this._nullCellCount+1),n+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(n+="\x1B[A",n+=`\x1B[${a.length-this._nullCellCount}C`,n+=`\x1B[${this._nullCellCount}X`,n+=`\x1B[${a.length-this._nullCellCount}D`,n+="\x1B[B"),this._lastContentCursorRow=e+1,this._lastContentCursorCol=0,this._lastCursorRow=e+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=n,this._currentRow="",this._nullCellCount=0}_diffStyle(e,t){let n=[],s=!Vb(e,t),a=!Pn(e,t),o=!Kb(e,t);if(s||a||o)if(e.isAttributeDefault())t.isAttributeDefault()||n.push(0);else{if(s){let c=e.getFgColor();e.isFgRGB()?n.push(38,2,c>>>16&255,c>>>8&255,c&255):e.isFgPalette()?c>=16?n.push(38,5,c):n.push(c&8?90+(c&7):30+(c&7)):n.push(39)}if(a){let c=e.getBgColor();e.isBgRGB()?n.push(48,2,c>>>16&255,c>>>8&255,c&255):e.isBgPalette()?c>=16?n.push(48,5,c):n.push(c&8?100+(c&7):40+(c&7)):n.push(49)}o&&(e.isInverse()!==t.isInverse()&&n.push(e.isInverse()?7:27),e.isBold()!==t.isBold()&&n.push(e.isBold()?1:22),e.isUnderline()!==t.isUnderline()&&n.push(e.isUnderline()?4:24),e.isOverline()!==t.isOverline()&&n.push(e.isOverline()?53:55),e.isBlink()!==t.isBlink()&&n.push(e.isBlink()?5:25),e.isInvisible()!==t.isInvisible()&&n.push(e.isInvisible()?8:28),e.isItalic()!==t.isItalic()&&n.push(e.isItalic()?3:23),e.isDim()!==t.isDim()&&n.push(e.isDim()?2:22),e.isStrikethrough()!==t.isStrikethrough()&&n.push(e.isStrikethrough()?9:29))}return n}_nextCell(e,t,n,s){if(e.getWidth()===0)return;let a=e.getChars()==="",o=this._diffStyle(e,this._cursorStyle);if(a?!Pn(this._cursorStyle,e):o.length>0){this._nullCellCount>0&&(Pn(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=s,this._currentRow+=`\x1B[${o.join(";")}m`;let c=this._buffer.getLine(n);c!==void 0&&(c.getCell(s,this._cursorStyle),this._cursorStyleRow=n,this._cursorStyleCol=s)}a?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(Pn(this._cursorStyle,this._backgroundCell)?this._currentRow+=`\x1B[${this._nullCellCount}C`:(this._currentRow+=`\x1B[${this._nullCellCount}X`,this._currentRow+=`\x1B[${this._nullCellCount}C`),this._nullCellCount=0),this._currentRow+=e.getChars(),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=s+e.getWidth())}_serializeString(e){let t=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(t=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let n="";for(let o=0;o{h>0?n+=`\x1B[${h}C`:h<0&&(n+=`\x1B[${-h}D`)};f&&((h=>{h>0?n+=`\x1B[${h}B`:h<0&&(n+=`\x1B[${-h}A`)})(o-this._lastCursorRow),p(c-this._lastCursorCol))}let s=this._terminal._core._inputHandler._curAttrData,a=this._diffStyle(s,this._cursorStyle);return a.length>0&&(n+=`\x1B[${a.join(";")}m`),n}},ek=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,n){let s=t.length,a=n===void 0?s:ey(n+e.rows,0,s);return this._serializeBufferByRange(e,t,{start:s-a,end:s-1},!1)}_serializeBufferByRange(e,t,n,s){return new J2(t,e).serialize({start:{x:0,y:typeof n.start=="number"?n.start:n.start.line},end:{x:e.cols,y:typeof n.end=="number"?n.end:n.end.line}},s)}_serializeBufferAsHTML(e,t){var f;let n=e.buffer.active,s=new tk(n,e,t),a=t.onlySelection??!1,o=t.range;if(o)return s.serialize({start:{x:o.startCol,y:(o.startLine,o.startLine)},end:{x:e.cols,y:(o.endLine,o.endLine)}});if(!a){let p=n.length,h=t.scrollback,g=h===void 0?p:ey(h+e.rows,0,p);return s.serialize({start:{x:0,y:p-g},end:{x:e.cols,y:p-1}})}let c=(f=this._terminal)==null?void 0:f.getSelectionPosition();return c!==void 0?s.serialize({start:{x:c.start.x,y:c.start.y},end:{x:c.end.x,y:c.end.y}}):""}_serializeModes(e){let t="",n=e.modes;if(n.applicationCursorKeysMode&&(t+="\x1B[?1h"),n.applicationKeypadMode&&(t+="\x1B[?66h"),n.bracketedPasteMode&&(t+="\x1B[?2004h"),n.insertMode&&(t+="\x1B[4h"),n.originMode&&(t+="\x1B[?6h"),n.reverseWraparoundMode&&(t+="\x1B[?45h"),n.sendFocusMode&&(t+="\x1B[?1004h"),n.wraparoundMode===!1&&(t+="\x1B[?7l"),n.mouseTrackingMode!=="none")switch(n.mouseTrackingMode){case"x10":t+="\x1B[?9h";break;case"vt200":t+="\x1B[?1000h";break;case"drag":t+="\x1B[?1002h";break;case"any":t+="\x1B[?1003h";break}return t}serialize(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let t=e!=null&&e.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,e.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,e==null?void 0:e.scrollback);if(!(e!=null&&e.excludeAltBuffer)&&this._terminal.buffer.active.type==="alternate"){let n=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);t+=`\x1B[?1049h\x1B[H${n}`}return e!=null&&e.excludeModes||(t+=this._serializeModes(this._terminal)),t}serializeAsHTML(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,e||{})}dispose(){}},tk=class extends Yb{constructor(e,t,n){super(e),this._terminal=t,this._options=n,this._currentRow="",this._htmlContent="",t._core._themeService?this._ansiColors=t._core._themeService.colors.ansi:this._ansiColors=Z2}_padStart(e,t,n){return t=t>>0,n=n??" ",e.length>t?e:(t-=e.length,t>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}_beforeSerialize(e,t,n){var c,f;this._htmlContent+="
";let s="#000000",a="#ffffff";(this._options.includeGlobalBackground??!1)&&(s=((c=this._terminal.options.theme)==null?void 0:c.foreground)??"#ffffff",a=((f=this._terminal.options.theme)==null?void 0:f.background)??"#000000");let o=[];o.push("color: "+s+";"),o.push("background-color: "+a+";"),o.push("font-family: "+this._terminal.options.fontFamily+";"),o.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="
"}_afterSerialize(){this._htmlContent+="
",this._htmlContent+="
"}_rowEnd(e,t){this._htmlContent+="
"+this._currentRow+"
",this._currentRow=""}_getHexColor(e,t){let n=t?e.getFgColor():e.getBgColor();if(t?e.isFgRGB():e.isBgRGB())return"#"+[n>>16&255,n>>8&255,n&255].map(s=>this._padStart(s.toString(16),2,"0")).join("");if(t?e.isFgPalette():e.isBgPalette())return this._ansiColors[n].css}_diffStyle(e,t){let n=[],s=!Vb(e,t),a=!Pn(e,t),o=!Kb(e,t);if(s||a||o){let c=this._getHexColor(e,!0);c&&n.push("color: "+c+";");let f=this._getHexColor(e,!1);return f&&n.push("background-color: "+f+";"),e.isInverse()&&n.push("color: #000000; background-color: #BFBFBF;"),e.isBold()&&n.push("font-weight: bold;"),e.isUnderline()&&e.isOverline()?n.push("text-decoration: overline underline;"):e.isUnderline()?n.push("text-decoration: underline;"):e.isOverline()&&n.push("text-decoration: overline;"),e.isBlink()&&n.push("text-decoration: blink;"),e.isInvisible()&&n.push("visibility: hidden;"),e.isItalic()&&n.push("font-style: italic;"),e.isDim()&&n.push("opacity: 0.5;"),e.isStrikethrough()&&n.push("text-decoration: line-through;"),n}}_nextCell(e,t,n,s){if(e.getWidth()===0)return;let a=e.getChars()==="",o=this._diffStyle(e,t);o&&(this._currentRow+=o.length===0?"
":""),a?this._currentRow+=" ":this._currentRow+=Q2(e.getChars())}_serializeString(){return this._htmlContent}};const ik={background:"#F0EBE1",foreground:"#2C1810",cursor:"#8B4513",cursorAccent:"#F0EBE1",selectionBackground:"#D4C5B0",selectionForeground:"#2C1810",black:"#2C1810",red:"#A63D40",green:"#4A7A4A",yellow:"#8B6914",blue:"#4A6FA5",magenta:"#7B4B8A",cyan:"#3D7A7A",white:"#E6DDD0",brightBlack:"#8B7355",brightRed:"#B85C5C",brightGreen:"#5A8A5A",brightYellow:"#A07D1C",brightBlue:"#5A82BA",brightMagenta:"#8E5D9F",brightCyan:"#5A8F8F",brightWhite:"#4A3728"},nk="plotlink-terminal",rk=1,Cr="scrollback",ty=10*1024*1024;function Ld(){return new Promise((e,t)=>{const n=indexedDB.open(nk,rk);n.onupgradeneeded=()=>{const s=n.result;s.objectStoreNames.contains(Cr)||s.createObjectStore(Cr)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function ra(e,t){const n=t.length>ty?t.slice(-ty):t,s=await Ld();return new Promise((a,o)=>{const c=s.transaction(Cr,"readwrite");c.objectStore(Cr).put(n,e),c.oncomplete=()=>{s.close(),a()},c.onerror=()=>{s.close(),o(c.error)}})}async function sk(e){const t=await Ld();return new Promise((n,s)=>{const o=t.transaction(Cr,"readonly").objectStore(Cr).get(e);o.onsuccess=()=>{t.close(),n(o.result??null)},o.onerror=()=>{t.close(),s(o.error)}})}async function iy(e){const t=await Ld();return new Promise((n,s)=>{const a=t.transaction(Cr,"readwrite");a.objectStore(Cr).delete(e),a.oncomplete=()=>{t.close(),n()},a.onerror=()=>{t.close(),s(a.error)}})}const Bt=new Map;function lk({token:e,storyName:t,authFetch:n,onSelectStory:s,onDestroySession:a,onArchiveStory:o,confirmedStories:c,renameRef:f}){const p=G.useRef(null),h=G.useRef(n),[g,_]=G.useState([]),[b,y]=G.useState(new Set),[x,k]=G.useState(null),[L,M]=G.useState(null),Z=G.useRef(()=>{});G.useEffect(()=>{h.current=n},[n]);const I=G.useCallback(B=>{var R;const{width:A}=B.container.getBoundingClientRect();if(!(A<50))try{B.fit.fit(),((R=B.ws)==null?void 0:R.readyState)===WebSocket.OPEN&&B.ws.send(JSON.stringify({type:"resize",cols:B.term.cols,rows:B.term.rows}))}catch{}},[]),Q=G.useCallback(B=>{for(const[A,R]of Bt)R.container.style.display=A===B?"block":"none";if(B){const A=Bt.get(B);A&&setTimeout(()=>I(A),50)}},[I]),W=G.useCallback((B,A,R)=>{const T=window.location.protocol==="https:"?"wss:":"ws:",j=new WebSocket(`${T}//${window.location.host}/ws/terminal?story=${encodeURIComponent(B)}&token=${e}&resume=${R}`);j.onopen=()=>{A.connected=!0,A._retried=!1,y(H=>{const ae=new Set(H);return ae.delete(B),ae}),j.send(JSON.stringify({type:"resize",cols:A.term.cols,rows:A.term.rows}))},j.onmessage=H=>{A.term.write(H.data)},j.onclose=H=>{if(A.connected=!1,A.ws===j){A.ws=null;try{const ae=A.serialize.serialize();ra(B,ae).catch(()=>{})}catch{}if(H.code===4e3&&!A._retried){A._retried=!0,A.term.write(`\r + */var Ft=0,qt=0,Wt=0,_t=0,ni;(e=>{function t(a,o,c,f){return f!==void 0?`#${Vr(a)}${Vr(o)}${Vr(c)}${Vr(f)}`:`#${Vr(a)}${Vr(o)}${Vr(c)}`}e.toCss=t;function n(a,o,c,f=255){return(a<<24|o<<16|c<<8|f)>>>0}e.toRgba=n;function s(a,o,c,f){return{css:e.toCss(a,o,c,f),rgba:e.toRgba(a,o,c,f)}}e.toColor=s})(ni||(ni={}));var G2;(e=>{function t(p,h){if(_t=(h.rgba&255)/255,_t===1)return{css:h.css,rgba:h.rgba};let g=h.rgba>>24&255,_=h.rgba>>16&255,b=h.rgba>>8&255,y=p.rgba>>24&255,x=p.rgba>>16&255,k=p.rgba>>8&255;Ft=y+Math.round((g-y)*_t),qt=x+Math.round((_-x)*_t),Wt=k+Math.round((b-k)*_t);let L=ni.toCss(Ft,qt,Wt),M=ni.toRgba(Ft,qt,Wt);return{css:L,rgba:M}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,h,g){let _=hu.ensureContrastRatio(p.rgba,h.rgba,g);if(_)return ni.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function a(p){let h=(p.rgba|255)>>>0;return[Ft,qt,Wt]=hu.toChannels(h),{css:ni.toCss(Ft,qt,Wt),rgba:h}}e.opaque=a;function o(p,h){return _t=Math.round(h*255),[Ft,qt,Wt]=hu.toChannels(p.rgba),{css:ni.toCss(Ft,qt,Wt,_t),rgba:ni.toRgba(Ft,qt,Wt,_t)}}e.opacity=o;function c(p,h){return _t=p.rgba&255,o(p,_t*h/255)}e.multiplyOpacity=c;function f(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=f})(G2||(G2={}));var Qt;(e=>{let t,n;try{let a=document.createElement("canvas");a.width=1,a.height=1;let o=a.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return Ft=parseInt(a.slice(1,2).repeat(2),16),qt=parseInt(a.slice(2,3).repeat(2),16),Wt=parseInt(a.slice(3,4).repeat(2),16),ni.toColor(Ft,qt,Wt);case 5:return Ft=parseInt(a.slice(1,2).repeat(2),16),qt=parseInt(a.slice(2,3).repeat(2),16),Wt=parseInt(a.slice(3,4).repeat(2),16),_t=parseInt(a.slice(4,5).repeat(2),16),ni.toColor(Ft,qt,Wt,_t);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let o=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Ft=parseInt(o[1]),qt=parseInt(o[2]),Wt=parseInt(o[3]),_t=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),ni.toColor(Ft,qt,Wt,_t);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ft,qt,Wt,_t]=t.getImageData(0,0,1,1).data,_t!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ni.toRgba(Ft,qt,Wt,_t),css:a}}e.toColor=s})(Qt||(Qt={}));var oi;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,a,o){let c=s/255,f=a/255,p=o/255,h=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),_=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return h*.2126+g*.7152+_*.0722}e.relativeLuminance2=n})(oi||(oi={}));var hu;(e=>{function t(c,f){if(_t=(f&255)/255,_t===1)return f;let p=f>>24&255,h=f>>16&255,g=f>>8&255,_=c>>24&255,b=c>>16&255,y=c>>8&255;return Ft=_+Math.round((p-_)*_t),qt=b+Math.round((h-b)*_t),Wt=y+Math.round((g-y)*_t),ni.toRgba(Ft,qt,Wt)}e.blend=t;function n(c,f,p){let h=oi.relativeLuminance(c>>8),g=oi.relativeLuminance(f>>8);if(On(h,g)>8));if(x>8));return x>L?y:k}return y}let _=a(c,f,p),b=On(h,oi.relativeLuminance(_>>8));if(b>8));return b>x?_:y}return _}}e.ensureContrastRatio=n;function s(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=On(oi.relativeLuminance2(b,y,x),oi.relativeLuminance2(h,g,_));for(;k0||y>0||x>0);)b-=Math.max(0,Math.ceil(b*.1)),y-=Math.max(0,Math.ceil(y*.1)),x-=Math.max(0,Math.ceil(x*.1)),k=On(oi.relativeLuminance2(b,y,x),oi.relativeLuminance2(h,g,_));return(b<<24|y<<16|x<<8|255)>>>0}e.reduceLuminance=s;function a(c,f,p){let h=c>>24&255,g=c>>16&255,_=c>>8&255,b=f>>24&255,y=f>>16&255,x=f>>8&255,k=On(oi.relativeLuminance2(b,y,x),oi.relativeLuminance2(h,g,_));for(;k>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(hu||(hu={}));function Vr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function On(e,t){return e{let e=[Qt.toColor("#2e3436"),Qt.toColor("#cc0000"),Qt.toColor("#4e9a06"),Qt.toColor("#c4a000"),Qt.toColor("#3465a4"),Qt.toColor("#75507b"),Qt.toColor("#06989a"),Qt.toColor("#d3d7cf"),Qt.toColor("#555753"),Qt.toColor("#ef2929"),Qt.toColor("#8ae234"),Qt.toColor("#fce94f"),Qt.toColor("#729fcf"),Qt.toColor("#ad7fa8"),Qt.toColor("#34e2e2"),Qt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],a=t[n/6%6|0],o=t[n%6];e.push({css:ni.toCss(s,a,o),rgba:ni.toRgba(s,a,o)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:ni.toCss(s,s,s),rgba:ni.toRgba(s,s,s)})}return e})());function ey(e,t,n){return Math.max(t,Math.min(e,n))}function Q2(e){switch(e){case"&":return"&";case"<":return"<"}return e}var Yb=class{constructor(e){this._buffer=e}serialize(e,t){let n=this._buffer.getNullCell(),s=this._buffer.getNullCell(),a=n,o=e.start.y,c=e.end.y,f=e.start.x,p=e.end.x;this._beforeSerialize(c-o,o,c);for(let h=o;h<=c;h++){let g=this._buffer.getLine(h);if(g){let _=h===e.start.y?f:0,b=h===e.end.y?p:g.length;for(let y=_;y0&&!jn(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let n="";if(!t){e-this._firstRow>=this._terminal.rows&&((s=this._buffer.getLine(this._cursorStyleRow))==null||s.getCell(this._cursorStyleCol,this._backgroundCell));let a=this._buffer.getLine(e),o=this._buffer.getLine(e+1);if(!o.isWrapped)n=`\r +`,this._lastCursorRow=e+1,this._lastCursorCol=0;else{n="";let c=a.getCell(a.length-1,this._thisRowLastChar),f=a.getCell(a.length-2,this._thisRowLastSecondChar),p=o.getCell(0,this._nextRowFirstChar),h=p.getWidth()>1,g=!1;(p.getChars()&&h?this._nullCellCount<=1:this._nullCellCount<=0)&&((c.getChars()||c.getWidth()===0)&&jn(c,p)&&(g=!0),h&&(f.getChars()||f.getWidth()===0)&&jn(c,p)&&jn(f,p)&&(g=!0)),g||(n="-".repeat(this._nullCellCount+1),n+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(n+="\x1B[A",n+=`\x1B[${a.length-this._nullCellCount}C`,n+=`\x1B[${this._nullCellCount}X`,n+=`\x1B[${a.length-this._nullCellCount}D`,n+="\x1B[B"),this._lastContentCursorRow=e+1,this._lastContentCursorCol=0,this._lastCursorRow=e+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=n,this._currentRow="",this._nullCellCount=0}_diffStyle(e,t){let n=[],s=!Vb(e,t),a=!jn(e,t),o=!Kb(e,t);if(s||a||o)if(e.isAttributeDefault())t.isAttributeDefault()||n.push(0);else{if(s){let c=e.getFgColor();e.isFgRGB()?n.push(38,2,c>>>16&255,c>>>8&255,c&255):e.isFgPalette()?c>=16?n.push(38,5,c):n.push(c&8?90+(c&7):30+(c&7)):n.push(39)}if(a){let c=e.getBgColor();e.isBgRGB()?n.push(48,2,c>>>16&255,c>>>8&255,c&255):e.isBgPalette()?c>=16?n.push(48,5,c):n.push(c&8?100+(c&7):40+(c&7)):n.push(49)}o&&(e.isInverse()!==t.isInverse()&&n.push(e.isInverse()?7:27),e.isBold()!==t.isBold()&&n.push(e.isBold()?1:22),e.isUnderline()!==t.isUnderline()&&n.push(e.isUnderline()?4:24),e.isOverline()!==t.isOverline()&&n.push(e.isOverline()?53:55),e.isBlink()!==t.isBlink()&&n.push(e.isBlink()?5:25),e.isInvisible()!==t.isInvisible()&&n.push(e.isInvisible()?8:28),e.isItalic()!==t.isItalic()&&n.push(e.isItalic()?3:23),e.isDim()!==t.isDim()&&n.push(e.isDim()?2:22),e.isStrikethrough()!==t.isStrikethrough()&&n.push(e.isStrikethrough()?9:29))}return n}_nextCell(e,t,n,s){if(e.getWidth()===0)return;let a=e.getChars()==="",o=this._diffStyle(e,this._cursorStyle);if(a?!jn(this._cursorStyle,e):o.length>0){this._nullCellCount>0&&(jn(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=s,this._currentRow+=`\x1B[${o.join(";")}m`;let c=this._buffer.getLine(n);c!==void 0&&(c.getCell(s,this._cursorStyle),this._cursorStyleRow=n,this._cursorStyleCol=s)}a?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(jn(this._cursorStyle,this._backgroundCell)?this._currentRow+=`\x1B[${this._nullCellCount}C`:(this._currentRow+=`\x1B[${this._nullCellCount}X`,this._currentRow+=`\x1B[${this._nullCellCount}C`),this._nullCellCount=0),this._currentRow+=e.getChars(),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=s+e.getWidth())}_serializeString(e){let t=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(t=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let n="";for(let o=0;o{h>0?n+=`\x1B[${h}C`:h<0&&(n+=`\x1B[${-h}D`)};f&&((h=>{h>0?n+=`\x1B[${h}B`:h<0&&(n+=`\x1B[${-h}A`)})(o-this._lastCursorRow),p(c-this._lastCursorCol))}let s=this._terminal._core._inputHandler._curAttrData,a=this._diffStyle(s,this._cursorStyle);return a.length>0&&(n+=`\x1B[${a.join(";")}m`),n}},ek=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,n){let s=t.length,a=n===void 0?s:ey(n+e.rows,0,s);return this._serializeBufferByRange(e,t,{start:s-a,end:s-1},!1)}_serializeBufferByRange(e,t,n,s){return new J2(t,e).serialize({start:{x:0,y:typeof n.start=="number"?n.start:n.start.line},end:{x:e.cols,y:typeof n.end=="number"?n.end:n.end.line}},s)}_serializeBufferAsHTML(e,t){var f;let n=e.buffer.active,s=new tk(n,e,t),a=t.onlySelection??!1,o=t.range;if(o)return s.serialize({start:{x:o.startCol,y:(o.startLine,o.startLine)},end:{x:e.cols,y:(o.endLine,o.endLine)}});if(!a){let p=n.length,h=t.scrollback,g=h===void 0?p:ey(h+e.rows,0,p);return s.serialize({start:{x:0,y:p-g},end:{x:e.cols,y:p-1}})}let c=(f=this._terminal)==null?void 0:f.getSelectionPosition();return c!==void 0?s.serialize({start:{x:c.start.x,y:c.start.y},end:{x:c.end.x,y:c.end.y}}):""}_serializeModes(e){let t="",n=e.modes;if(n.applicationCursorKeysMode&&(t+="\x1B[?1h"),n.applicationKeypadMode&&(t+="\x1B[?66h"),n.bracketedPasteMode&&(t+="\x1B[?2004h"),n.insertMode&&(t+="\x1B[4h"),n.originMode&&(t+="\x1B[?6h"),n.reverseWraparoundMode&&(t+="\x1B[?45h"),n.sendFocusMode&&(t+="\x1B[?1004h"),n.wraparoundMode===!1&&(t+="\x1B[?7l"),n.mouseTrackingMode!=="none")switch(n.mouseTrackingMode){case"x10":t+="\x1B[?9h";break;case"vt200":t+="\x1B[?1000h";break;case"drag":t+="\x1B[?1002h";break;case"any":t+="\x1B[?1003h";break}return t}serialize(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let t=e!=null&&e.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,e.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,e==null?void 0:e.scrollback);if(!(e!=null&&e.excludeAltBuffer)&&this._terminal.buffer.active.type==="alternate"){let n=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);t+=`\x1B[?1049h\x1B[H${n}`}return e!=null&&e.excludeModes||(t+=this._serializeModes(this._terminal)),t}serializeAsHTML(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,e||{})}dispose(){}},tk=class extends Yb{constructor(e,t,n){super(e),this._terminal=t,this._options=n,this._currentRow="",this._htmlContent="",t._core._themeService?this._ansiColors=t._core._themeService.colors.ansi:this._ansiColors=Z2}_padStart(e,t,n){return t=t>>0,n=n??" ",e.length>t?e:(t-=e.length,t>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}_beforeSerialize(e,t,n){var c,f;this._htmlContent+="
";let s="#000000",a="#ffffff";(this._options.includeGlobalBackground??!1)&&(s=((c=this._terminal.options.theme)==null?void 0:c.foreground)??"#ffffff",a=((f=this._terminal.options.theme)==null?void 0:f.background)??"#000000");let o=[];o.push("color: "+s+";"),o.push("background-color: "+a+";"),o.push("font-family: "+this._terminal.options.fontFamily+";"),o.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="
"}_afterSerialize(){this._htmlContent+="
",this._htmlContent+="
"}_rowEnd(e,t){this._htmlContent+="
"+this._currentRow+"
",this._currentRow=""}_getHexColor(e,t){let n=t?e.getFgColor():e.getBgColor();if(t?e.isFgRGB():e.isBgRGB())return"#"+[n>>16&255,n>>8&255,n&255].map(s=>this._padStart(s.toString(16),2,"0")).join("");if(t?e.isFgPalette():e.isBgPalette())return this._ansiColors[n].css}_diffStyle(e,t){let n=[],s=!Vb(e,t),a=!jn(e,t),o=!Kb(e,t);if(s||a||o){let c=this._getHexColor(e,!0);c&&n.push("color: "+c+";");let f=this._getHexColor(e,!1);return f&&n.push("background-color: "+f+";"),e.isInverse()&&n.push("color: #000000; background-color: #BFBFBF;"),e.isBold()&&n.push("font-weight: bold;"),e.isUnderline()&&e.isOverline()?n.push("text-decoration: overline underline;"):e.isUnderline()?n.push("text-decoration: underline;"):e.isOverline()&&n.push("text-decoration: overline;"),e.isBlink()&&n.push("text-decoration: blink;"),e.isInvisible()&&n.push("visibility: hidden;"),e.isItalic()&&n.push("font-style: italic;"),e.isDim()&&n.push("opacity: 0.5;"),e.isStrikethrough()&&n.push("text-decoration: line-through;"),n}}_nextCell(e,t,n,s){if(e.getWidth()===0)return;let a=e.getChars()==="",o=this._diffStyle(e,t);o&&(this._currentRow+=o.length===0?"
":""),a?this._currentRow+=" ":this._currentRow+=Q2(e.getChars())}_serializeString(){return this._htmlContent}};const ik={background:"#F0EBE1",foreground:"#2C1810",cursor:"#8B4513",cursorAccent:"#F0EBE1",selectionBackground:"#D4C5B0",selectionForeground:"#2C1810",black:"#2C1810",red:"#A63D40",green:"#4A7A4A",yellow:"#8B6914",blue:"#4A6FA5",magenta:"#7B4B8A",cyan:"#3D7A7A",white:"#E6DDD0",brightBlack:"#8B7355",brightRed:"#B85C5C",brightGreen:"#5A8A5A",brightYellow:"#A07D1C",brightBlue:"#5A82BA",brightMagenta:"#8E5D9F",brightCyan:"#5A8F8F",brightWhite:"#4A3728"},nk="plotlink-terminal",rk=1,Cr="scrollback",ty=10*1024*1024;function Ld(){return new Promise((e,t)=>{const n=indexedDB.open(nk,rk);n.onupgradeneeded=()=>{const s=n.result;s.objectStoreNames.contains(Cr)||s.createObjectStore(Cr)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function na(e,t){const n=t.length>ty?t.slice(-ty):t,s=await Ld();return new Promise((a,o)=>{const c=s.transaction(Cr,"readwrite");c.objectStore(Cr).put(n,e),c.oncomplete=()=>{s.close(),a()},c.onerror=()=>{s.close(),o(c.error)}})}async function sk(e){const t=await Ld();return new Promise((n,s)=>{const o=t.transaction(Cr,"readonly").objectStore(Cr).get(e);o.onsuccess=()=>{t.close(),n(o.result??null)},o.onerror=()=>{t.close(),s(o.error)}})}async function iy(e){const t=await Ld();return new Promise((n,s)=>{const a=t.transaction(Cr,"readwrite");a.objectStore(Cr).delete(e),a.oncomplete=()=>{t.close(),n()},a.onerror=()=>{t.close(),s(a.error)}})}const Nt=new Map;function lk({token:e,storyName:t,authFetch:n,onSelectStory:s,onDestroySession:a,onArchiveStory:o,confirmedStories:c,renameRef:f}){const p=$.useRef(null),h=$.useRef(n),[g,_]=$.useState([]),[b,y]=$.useState(new Set),[x,k]=$.useState(null),[L,M]=$.useState(null),G=$.useRef(()=>{});$.useEffect(()=>{h.current=n},[n]);const I=$.useCallback(B=>{var R;const{width:A}=B.container.getBoundingClientRect();if(!(A<50))try{B.fit.fit(),((R=B.ws)==null?void 0:R.readyState)===WebSocket.OPEN&&B.ws.send(JSON.stringify({type:"resize",cols:B.term.cols,rows:B.term.rows}))}catch{}},[]),Z=$.useCallback(B=>{for(const[A,R]of Nt)R.container.style.display=A===B?"block":"none";if(B){const A=Nt.get(B);A&&setTimeout(()=>I(A),50)}},[I]),W=$.useCallback((B,A,R)=>{const T=window.location.protocol==="https:"?"wss:":"ws:",j=new WebSocket(`${T}//${window.location.host}/ws/terminal?story=${encodeURIComponent(B)}&token=${e}&resume=${R}`);j.onopen=()=>{A.connected=!0,A._retried=!1,y(H=>{const ae=new Set(H);return ae.delete(B),ae}),j.send(JSON.stringify({type:"resize",cols:A.term.cols,rows:A.term.rows}))},j.onmessage=H=>{A.term.write(H.data)},j.onclose=H=>{if(A.connected=!1,A.ws===j){A.ws=null;try{const ae=A.serialize.serialize();na(B,ae).catch(()=>{})}catch{}if(H.code===4e3&&!A._retried){A._retried=!0,A.term.write(`\r \x1B[33m[Resume failed — starting fresh session...]\x1B[0m\r -`),Z.current(B,A,!1);return}y(ae=>new Set(ae).add(B))}},A.term.onData(H=>{j.readyState===WebSocket.OPEN&&j.send(H)}),A.ws=j},[e]);G.useEffect(()=>{Z.current=W},[W]);const O=G.useCallback(async(B,A)=>{if(!p.current||Bt.has(B))return;const{resume:R=!1,autoConnect:T=!0}=A??{},j=document.createElement("div");j.style.width="100%",j.style.height="100%",j.style.display="none",j.style.paddingLeft="10px",j.style.boxSizing="border-box",p.current.appendChild(j);const H=new V2({cols:80,scrollback:5e3,fontSize:13,fontFamily:'"Geist Mono", ui-monospace, monospace',lineHeight:1.05,letterSpacing:0,cursorBlink:!0,cursorStyle:"block",theme:ik,allowTransparency:!1,drawBoldTextInBrightColors:!1,minimumContrastRatio:7}),ae=new $2,E=new ek;H.loadAddon(ae),H.loadAddon(E),H.open(j);const D={term:H,fit:ae,serialize:E,ws:null,container:j,observer:null,connected:!1},K=new ResizeObserver(()=>{var J;const{width:C}=j.getBoundingClientRect();if(!(C<50))try{ae.fit(),((J=D.ws)==null?void 0:J.readyState)===WebSocket.OPEN&&D.ws.send(JSON.stringify({type:"resize",cols:H.cols,rows:H.rows}))}catch{}});K.observe(j),D.observer=K,Bt.set(B,D),_(C=>[...C,B]);try{const C=await sk(B);C&&H.write(C)}catch{}T?W(B,D,R):y(C=>new Set(C).add(B)),setTimeout(()=>I(D),50)},[W,I]),ie=G.useCallback(async(B,A)=>{const R=Bt.get(B);R&&(R.ws&&(R.ws.close(),R.ws=null),A||(await h.current(`/api/terminal/${encodeURIComponent(B)}`,{method:"DELETE"}).catch(()=>{}),R.term.clear()),W(B,R,A))},[W]),ue=G.useCallback(B=>{const A=Bt.get(B);if(A){try{const R=A.serialize.serialize();ra(B,R).catch(()=>{})}catch{}A.observer.disconnect(),A.ws&&A.ws.close(),A.term.dispose(),A.container.remove(),Bt.delete(B),_(R=>R.filter(T=>T!==B)),y(R=>{const T=new Set(R);return T.delete(B),T}),n(`/api/terminal/${encodeURIComponent(B)}`,{method:"DELETE"}).catch(()=>{}),a==null||a(B)}},[n,a]),me=G.useCallback(B=>{var R;const A=Bt.get(B);A&&(((R=A.ws)==null?void 0:R.readyState)===WebSocket.OPEN&&A.ws.send(`exit -`),iy(B).catch(()=>{}),A.observer.disconnect(),A.ws&&A.ws.close(),A.term.dispose(),A.container.remove(),Bt.delete(B),_(T=>T.filter(j=>j!==B)),y(T=>{const j=new Set(T);return j.delete(B),j}),n(`/api/terminal/${encodeURIComponent(B)}/discard`,{method:"DELETE"}).catch(()=>{}),a==null||a(B))},[n,a]),U=G.useCallback(async(B,A)=>{const R=Bt.get(B);if(!R||Bt.has(A)||!(await h.current("/api/terminal/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldName:B,newName:A})})).ok)return!1;Bt.delete(B),Bt.set(A,R);try{const j=R.serialize.serialize();await iy(B),await ra(A,j)}catch{}return _(j=>j.map(H=>H===B?A:H)),y(j=>{if(!j.has(B))return j;const H=new Set(j);return H.delete(B),H.add(A),H}),!0},[]);G.useEffect(()=>(f&&(f.current=U),()=>{f&&(f.current=null)}),[f,U]),G.useEffect(()=>{t&&(Bt.has(t)?Q(t):h.current(`/api/terminal/session/${encodeURIComponent(t)}`).then(B=>B.ok?B.json():null).then(B=>{if(!Bt.has(t)){const A=(B==null?void 0:B.sessionId)&&!(B!=null&&B.running);O(t,{autoConnect:!A}),Q(t)}}).catch(()=>{Bt.has(t)||(O(t),Q(t))}))},[t,O,Q]),G.useEffect(()=>{const B=setInterval(()=>{for(const[A,R]of Bt)if(R.connected)try{const T=R.serialize.serialize();ra(A,T).catch(()=>{})}catch{}},3e4);return()=>clearInterval(B)},[]),G.useEffect(()=>()=>{for(const[B,A]of Bt){try{const R=A.serialize.serialize();ra(B,R).catch(()=>{})}catch{}A.observer.disconnect(),A.ws&&A.ws.close(),A.term.dispose(),A.container.remove(),h.current(`/api/terminal/${encodeURIComponent(B)}`,{method:"DELETE"}).catch(()=>{})}Bt.clear()},[]);const le=t?b.has(t):!1,V=g.length===0;return S.jsxs("div",{className:"h-full flex flex-col",children:[!V&&S.jsxs("div",{className:"px-2 py-1 border-b border-border flex items-center gap-1 overflow-x-auto",children:[g.map(B=>S.jsxs("div",{onClick:()=>s==null?void 0:s(B),className:`flex items-center gap-1 px-2 py-0.5 rounded text-xs font-mono cursor-pointer ${B===t?"bg-accent/10 text-accent":"text-muted hover:text-foreground"}`,children:[S.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${b.has(B)?"bg-amber-500":B===t?"bg-green-600":"bg-muted/50"}`}),S.jsx("span",{className:`truncate max-w-[120px] ${B.startsWith("_new_")?"italic":""}`,children:B.startsWith("_new_")?"Untitled":B}),S.jsx("button",{onClick:A=>{A.stopPropagation(),B.startsWith("_new_")?k(B):ue(B)},className:"ml-0.5 text-muted hover:text-error text-[10px] leading-none",title:"Close terminal",children:"×"})]},B)),t!=null&&t.startsWith("_new_")?S.jsx("button",{onClick:()=>k(t),className:"ml-auto px-2 py-0.5 text-xs text-error hover:bg-surface rounded flex items-center gap-1 flex-shrink-0",children:"Cancel ×"}):t&&o&&(c!=null&&c.has(t))?S.jsx("button",{onClick:()=>M(t),className:"ml-auto px-2 py-0.5 text-xs text-muted hover:text-foreground hover:bg-surface rounded flex items-center gap-1 flex-shrink-0",children:"Archive"}):null]}),S.jsxs("div",{className:"relative flex-1 min-h-0",children:[S.jsx("div",{ref:p,className:"h-full"}),V&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-muted",children:S.jsxs("div",{className:"text-center",children:[S.jsx("p",{className:"text-lg font-serif",children:"Select a story on the left menu"}),S.jsx("p",{className:"text-sm mt-1",children:"to start an AI Writer session"})]})}),x&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[S.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Discard this session?"}),S.jsx("p",{className:"text-xs text-muted",children:"This session will be lost — your AI hasn't created a story structure yet."}),S.jsxs("div",{className:"flex items-center justify-center gap-2",children:[S.jsx("button",{onClick:()=>k(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),S.jsx("button",{onClick:()=>{const B=x;k(null),me(B)},className:"px-4 py-1.5 bg-error text-white text-sm rounded hover:opacity-80",children:"Discard"})]})]})}),L&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[S.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Archive this story?"}),S.jsx("p",{className:"text-xs text-muted",children:"You can restore it later from the Archives view."}),S.jsxs("div",{className:"flex items-center justify-center gap-2",children:[S.jsx("button",{onClick:()=>M(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),S.jsx("button",{onClick:async()=>{const B=L;M(null);try{(await h.current("/api/stories/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B})})).ok&&(ue(B),o==null||o(B))}catch{}},className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Archive"})]})]})}),le&&t&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3",children:[S.jsx("p",{className:"text-sm font-serif text-foreground",children:"Terminal disconnected"}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("button",{onClick:()=>ie(t,!0),className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Resume Session"}),S.jsx("button",{onClick:()=>ie(t,!1),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Start Fresh"})]}),S.jsx("p",{className:"text-xs text-muted",children:"Resume continues your previous Claude conversation"})]})})]})]})}function ak(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const ok=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,uk=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ck={};function ny(e,t){return(ck.jsx?uk:ok).test(e)}const hk=/[ \t\n\f\r]/g;function fk(e){return typeof e=="object"?e.type==="text"?ry(e.value):!1:ry(e)}function ry(e){return e.replace(hk,"")===""}class Aa{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}}Aa.prototype.normal={};Aa.prototype.property={};Aa.prototype.space=void 0;function Xb(e,t){const n={},s={};for(const a of e)Object.assign(n,a.property),Object.assign(s,a.normal);return new Aa(n,s,t)}function fd(e){return e.toLowerCase()}class Si{constructor(t,n){this.attribute=n,this.property=t}}Si.prototype.attribute="";Si.prototype.booleanish=!1;Si.prototype.boolean=!1;Si.prototype.commaOrSpaceSeparated=!1;Si.prototype.commaSeparated=!1;Si.prototype.defined=!1;Si.prototype.mustUseProperty=!1;Si.prototype.number=!1;Si.prototype.overloadedBoolean=!1;Si.prototype.property="";Si.prototype.spaceSeparated=!1;Si.prototype.space=void 0;let dk=0;const Re=rs(),wt=rs(),dd=rs(),oe=rs(),Je=rs(),Qs=rs(),Mi=rs();function rs(){return 2**++dk}const pd=Object.freeze(Object.defineProperty({__proto__:null,boolean:Re,booleanish:wt,commaOrSpaceSeparated:Mi,commaSeparated:Qs,number:oe,overloadedBoolean:dd,spaceSeparated:Je},Symbol.toStringTag,{value:"Module"})),cf=Object.keys(pd);class zd extends Si{constructor(t,n,s,a){let o=-1;if(super(t,n),sy(this,"space",a),typeof s=="number")for(;++o4&&n.slice(0,4)==="data"&&vk.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(ly,Sk);s="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!ly.test(o)){let c=o.replace(gk,bk);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=zd}return new a(s,t)}function bk(e){return"-"+e.toLowerCase()}function Sk(e){return e.charAt(1).toUpperCase()}const xk=Xb([$b,pk,Qb,Jb,eS],"html"),Od=Xb([$b,mk,Qb,Jb,eS],"svg");function wk(e){return e.join(" ").trim()}var Vs={},hf,ay;function Ck(){if(ay)return hf;ay=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,f=/^\s+|\s+$/g,p=` -`,h="/",g="*",_="",b="comment",y="declaration";function x(L,M){if(typeof L!="string")throw new TypeError("First argument must be a string");if(!L)return[];M=M||{};var Z=1,I=1;function Q(A){var R=A.match(t);R&&(Z+=R.length);var T=A.lastIndexOf(p);I=~T?A.length-T:I+A.length}function W(){var A={line:Z,column:I};return function(R){return R.position=new O(A),me(),R}}function O(A){this.start=A,this.end={line:Z,column:I},this.source=M.source}O.prototype.content=L;function ie(A){var R=new Error(M.source+":"+Z+":"+I+": "+A);if(R.reason=A,R.filename=M.source,R.line=Z,R.column=I,R.source=L,!M.silent)throw R}function ue(A){var R=A.exec(L);if(R){var T=R[0];return Q(T),L=L.slice(T.length),R}}function me(){ue(n)}function U(A){var R;for(A=A||[];R=le();)R!==!1&&A.push(R);return A}function le(){var A=W();if(!(h!=L.charAt(0)||g!=L.charAt(1))){for(var R=2;_!=L.charAt(R)&&(g!=L.charAt(R)||h!=L.charAt(R+1));)++R;if(R+=2,_===L.charAt(R-1))return ie("End of comment missing");var T=L.slice(2,R-2);return I+=2,Q(T),L=L.slice(R),I+=2,A({type:b,comment:T})}}function V(){var A=W(),R=ue(s);if(R){if(le(),!ue(a))return ie("property missing ':'");var T=ue(o),j=A({type:y,property:k(R[0].replace(e,_)),value:T?k(T[0].replace(e,_)):_});return ue(c),j}}function B(){var A=[];U(A);for(var R;R=V();)R!==!1&&(A.push(R),U(A));return A}return me(),B()}function k(L){return L?L.replace(f,_):_}return hf=x,hf}var oy;function kk(){if(oy)return Vs;oy=1;var e=Vs&&Vs.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Vs,"__esModule",{value:!0}),Vs.default=n;const t=e(Ck());function n(s,a){let o=null;if(!s||typeof s!="string")return o;const c=(0,t.default)(s),f=typeof a=="function";return c.forEach(p=>{if(p.type!=="declaration")return;const{property:h,value:g}=p;f?a(h,g,p):g&&(o=o||{},o[h]=g)}),o}return Vs}var sa={},uy;function Ek(){if(uy)return sa;uy=1,Object.defineProperty(sa,"__esModule",{value:!0}),sa.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(h){return!h||n.test(h)||e.test(h)},c=function(h,g){return g.toUpperCase()},f=function(h,g){return"".concat(g,"-")},p=function(h,g){return g===void 0&&(g={}),o(h)?h:(h=h.toLowerCase(),g.reactCompat?h=h.replace(a,f):h=h.replace(s,f),h.replace(t,c))};return sa.camelCase=p,sa}var la,cy;function Tk(){if(cy)return la;cy=1;var e=la&&la.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(kk()),n=Ek();function s(a,o){var c={};return!a||typeof a!="string"||(0,t.default)(a,function(f,p){f&&p&&(c[(0,n.camelCase)(f,o)]=p)}),c}return s.default=s,la=s,la}var Ak=Tk();const Dk=xu(Ak),tS=iS("end"),jd=iS("start");function iS(e){return t;function t(n){const s=n&&n.position&&n.position[e]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function nS(e){const t=jd(e),n=tS(e);if(t&&n)return{start:t,end:n}}function ma(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?hy(e.position):"start"in e||"end"in e?hy(e):"line"in e||"column"in e?md(e):""}function md(e){return fy(e&&e.line)+":"+fy(e&&e.column)}function hy(e){return md(e&&e.start)+"-"+md(e&&e.end)}function fy(e){return e&&typeof e=="number"?e:1}class ri extends Error{constructor(t,n,s){super(),typeof n=="string"&&(s=n,n=void 0);let a="",o={},c=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?a=t:!o.cause&&t&&(c=!0,a=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof s=="string"){const p=s.indexOf(":");p===-1?o.ruleId=s:(o.source=s.slice(0,p),o.ruleId=s.slice(p+1))}if(!o.place&&o.ancestors&&o.ancestors){const p=o.ancestors[o.ancestors.length-1];p&&(o.place=p.position)}const f=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=f?f.line:void 0,this.name=ma(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=c&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ri.prototype.file="";ri.prototype.name="";ri.prototype.reason="";ri.prototype.message="";ri.prototype.stack="";ri.prototype.column=void 0;ri.prototype.line=void 0;ri.prototype.ancestors=void 0;ri.prototype.cause=void 0;ri.prototype.fatal=void 0;ri.prototype.place=void 0;ri.prototype.ruleId=void 0;ri.prototype.source=void 0;const Hd={}.hasOwnProperty,Rk=new Map,Mk=/[A-Z]/g,Bk=new Set(["table","tbody","thead","tfoot","tr"]),Nk=new Set(["td","th"]),rS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Lk(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let s;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=Fk(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");s=Ik(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Od:xk,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=sS(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function sS(e,t,n){if(t.type==="element")return zk(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Ok(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Hk(e,t,n);if(t.type==="mdxjsEsm")return jk(e,t);if(t.type==="root")return Pk(e,t,n);if(t.type==="text")return Uk(e,t)}function zk(e,t,n){const s=e.schema;let a=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(a=Od,e.schema=a),e.ancestors.push(t);const o=aS(e,t.tagName,!1),c=qk(e,t);let f=Ud(e,t);return Bk.has(t.tagName)&&(f=f.filter(function(p){return typeof p=="string"?!fk(p):!0})),lS(e,c,o,t),Pd(c,f),e.ancestors.pop(),e.schema=s,e.create(t,o,c,n)}function Ok(e,t){if(t.data&&t.data.estree&&e.evaluater){const s=t.data.estree.body[0];return s.type,e.evaluater.evaluateExpression(s.expression)}Sa(e,t.position)}function jk(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Sa(e,t.position)}function Hk(e,t,n){const s=e.schema;let a=s;t.name==="svg"&&s.space==="html"&&(a=Od,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:aS(e,t.name,!0),c=Wk(e,t),f=Ud(e,t);return lS(e,c,o,t),Pd(c,f),e.ancestors.pop(),e.schema=s,e.create(t,o,c,n)}function Pk(e,t,n){const s={};return Pd(s,Ud(e,t)),e.create(t,e.Fragment,s,n)}function Uk(e,t){return t.value}function lS(e,t,n,s){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=s)}function Pd(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Ik(e,t,n){return s;function s(a,o,c,f){const h=Array.isArray(c.children)?n:t;return f?h(o,c,f):h(o,c)}}function Fk(e,t){return n;function n(s,a,o,c){const f=Array.isArray(o.children),p=jd(s);return t(a,o,c,f,{columnNumber:p?p.column-1:void 0,fileName:e,lineNumber:p?p.line:void 0},void 0)}}function qk(e,t){const n={};let s,a;for(a in t.properties)if(a!=="children"&&Hd.call(t.properties,a)){const o=Yk(e,a,t.properties[a]);if(o){const[c,f]=o;e.tableCellAlignToStyle&&c==="align"&&typeof f=="string"&&Nk.has(t.tagName)?s=f:n[c]=f}}if(s){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return n}function Wk(e,t){const n={};for(const s of t.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&e.evaluater){const o=s.data.estree.body[0];o.type;const c=o.expression;c.type;const f=c.properties[0];f.type,Object.assign(n,e.evaluater.evaluateExpression(f.argument))}else Sa(e,t.position);else{const a=s.name;let o;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&e.evaluater){const f=s.value.data.estree.body[0];f.type,o=e.evaluater.evaluateExpression(f.expression)}else Sa(e,t.position);else o=s.value===null?!0:s.value;n[a]=o}return n}function Ud(e,t){const n=[];let s=-1;const a=e.passKeys?new Map:Rk;for(;++sa?0:a+t:t=t>a?a:t,n=n>0?n:0,s.length<1e4)c=Array.from(s),c.unshift(t,n),e.splice(...c);else for(n&&e.splice(t,n);o0?(Bi(e,e.length,0,t),e):t}const my={}.hasOwnProperty;function uS(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ji(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const oi=kr(/[A-Za-z]/),ni=kr(/[\dA-Za-z]/),eE=kr(/[#-'*+\--9=?A-Z^-~]/);function yu(e){return e!==null&&(e<32||e===127)}const _d=kr(/\d/),tE=kr(/[\dA-Fa-f]/),iE=kr(/[!-/:-@[-`{-~]/);function be(e){return e!==null&&e<-2}function Qe(e){return e!==null&&(e<0||e===32)}function Oe(e){return e===-2||e===-1||e===32}const Tu=kr(new RegExp("\\p{P}|\\p{S}","u")),is=kr(/\s/);function kr(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function rl(e){const t=[];let n=-1,s=0,a=0;for(;++n55295&&o<57344){const f=e.charCodeAt(n+1);o<56320&&f>56319&&f<57344?(c=String.fromCharCode(o,f),a=1):c="�"}else c=String.fromCharCode(o);c&&(t.push(e.slice(s,n),encodeURIComponent(c)),s=n+a+1,c=""),a&&(n+=a,a=0)}return t.join("")+e.slice(s)}function Ue(e,t,n,s){const a=s?s-1:Number.POSITIVE_INFINITY;let o=0;return c;function c(p){return Oe(p)?(e.enter(n),f(p)):t(p)}function f(p){return Oe(p)&&o++c))return;const ie=t.events.length;let ue=ie,me,U;for(;ue--;)if(t.events[ue][0]==="exit"&&t.events[ue][1].type==="chunkFlow"){if(me){U=t.events[ue][1].end;break}me=!0}for(M(s),O=ie;OI;){const W=n[Q];t.containerState=W[1],W[0].exit.call(t,e)}n.length=I}function Z(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function aE(e,t,n){return Ue(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function el(e){if(e===null||Qe(e)||is(e))return 1;if(Tu(e))return 2}function Au(e,t,n){const s=[];let a=-1;for(;++a1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const _={...e[s][1].end},b={...e[n][1].start};gy(_,-p),gy(b,p),c={type:p>1?"strongSequence":"emphasisSequence",start:_,end:{...e[s][1].end}},f={type:p>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:b},o={type:p>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[n][1].start}},a={type:p>1?"strong":"emphasis",start:{...c.start},end:{...f.end}},e[s][1].end={...c.start},e[n][1].start={...f.end},h=[],e[s][1].end.offset-e[s][1].start.offset&&(h=Vi(h,[["enter",e[s][1],t],["exit",e[s][1],t]])),h=Vi(h,[["enter",a,t],["enter",c,t],["exit",c,t],["enter",o,t]]),h=Vi(h,Au(t.parser.constructs.insideSpan.null,e.slice(s+1,n),t)),h=Vi(h,[["exit",o,t],["enter",f,t],["exit",f,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(g=2,h=Vi(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):g=0,Bi(e,s-1,n-s+3,h),n=s+h.length-g-2;break}}for(n=-1;++n0&&Oe(O)?Ue(e,Z,"linePrefix",o+1)(O):Z(O)}function Z(O){return O===null||be(O)?e.check(vy,k,Q)(O):(e.enter("codeFlowValue"),I(O))}function I(O){return O===null||be(O)?(e.exit("codeFlowValue"),Z(O)):(e.consume(O),I)}function Q(O){return e.exit("codeFenced"),t(O)}function W(O,ie,ue){let me=0;return U;function U(R){return O.enter("lineEnding"),O.consume(R),O.exit("lineEnding"),le}function le(R){return O.enter("codeFencedFence"),Oe(R)?Ue(O,V,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):V(R)}function V(R){return R===f?(O.enter("codeFencedFenceSequence"),B(R)):ue(R)}function B(R){return R===f?(me++,O.consume(R),B):me>=c?(O.exit("codeFencedFenceSequence"),Oe(R)?Ue(O,A,"whitespace")(R):A(R)):ue(R)}function A(R){return R===null||be(R)?(O.exit("codeFencedFence"),ie(R)):ue(R)}}}function yE(e,t,n){const s=this;return a;function a(c){return c===null?n(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o)}function o(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}const df={name:"codeIndented",tokenize:SE},bE={partial:!0,tokenize:xE};function SE(e,t,n){const s=this;return a;function a(h){return e.enter("codeIndented"),Ue(e,o,"linePrefix",5)(h)}function o(h){const g=s.events[s.events.length-1];return g&&g[1].type==="linePrefix"&&g[2].sliceSerialize(g[1],!0).length>=4?c(h):n(h)}function c(h){return h===null?p(h):be(h)?e.attempt(bE,c,p)(h):(e.enter("codeFlowValue"),f(h))}function f(h){return h===null||be(h)?(e.exit("codeFlowValue"),c(h)):(e.consume(h),f)}function p(h){return e.exit("codeIndented"),t(h)}}function xE(e,t,n){const s=this;return a;function a(c){return s.parser.lazy[s.now().line]?n(c):be(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):Ue(e,o,"linePrefix",5)(c)}function o(c){const f=s.events[s.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?t(c):be(c)?a(c):n(c)}}const wE={name:"codeText",previous:kE,resolve:CE,tokenize:EE};function CE(e){let t=e.length-4,n=3,s,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(s=n;++s=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(t,n,s){const a=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return s&&aa(this.left,s),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),aa(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),aa(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(c):e.interrupt(s.parser.constructs.flow,n,t)(c)}}function mS(e,t,n,s,a,o,c,f,p){const h=p||Number.POSITIVE_INFINITY;let g=0;return _;function _(M){return M===60?(e.enter(s),e.enter(a),e.enter(o),e.consume(M),e.exit(o),b):M===null||M===32||M===41||yu(M)?n(M):(e.enter(s),e.enter(c),e.enter(f),e.enter("chunkString",{contentType:"string"}),k(M))}function b(M){return M===62?(e.enter(o),e.consume(M),e.exit(o),e.exit(a),e.exit(s),t):(e.enter(f),e.enter("chunkString",{contentType:"string"}),y(M))}function y(M){return M===62?(e.exit("chunkString"),e.exit(f),b(M)):M===null||M===60||be(M)?n(M):(e.consume(M),M===92?x:y)}function x(M){return M===60||M===62||M===92?(e.consume(M),y):y(M)}function k(M){return!g&&(M===null||M===41||Qe(M))?(e.exit("chunkString"),e.exit(f),e.exit(c),e.exit(s),t(M)):g999||y===null||y===91||y===93&&!p||y===94&&!f&&"_hiddenFootnoteSupport"in c.parser.constructs?n(y):y===93?(e.exit(o),e.enter(a),e.consume(y),e.exit(a),e.exit(s),t):be(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),g):(e.enter("chunkString",{contentType:"string"}),_(y))}function _(y){return y===null||y===91||y===93||be(y)||f++>999?(e.exit("chunkString"),g(y)):(e.consume(y),p||(p=!Oe(y)),y===92?b:_)}function b(y){return y===91||y===92||y===93?(e.consume(y),f++,_):_(y)}}function gS(e,t,n,s,a,o){let c;return f;function f(b){return b===34||b===39||b===40?(e.enter(s),e.enter(a),e.consume(b),e.exit(a),c=b===40?41:b,p):n(b)}function p(b){return b===c?(e.enter(a),e.consume(b),e.exit(a),e.exit(s),t):(e.enter(o),h(b))}function h(b){return b===c?(e.exit(o),p(c)):b===null?n(b):be(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),Ue(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),g(b))}function g(b){return b===c||b===null||be(b)?(e.exit("chunkString"),h(b)):(e.consume(b),b===92?_:g)}function _(b){return b===c||b===92?(e.consume(b),g):g(b)}}function _a(e,t){let n;return s;function s(a){return be(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,s):Oe(a)?Ue(e,s,n?"linePrefix":"lineSuffix")(a):t(a)}}const LE={name:"definition",tokenize:OE},zE={partial:!0,tokenize:jE};function OE(e,t,n){const s=this;let a;return o;function o(y){return e.enter("definition"),c(y)}function c(y){return _S.call(s,e,f,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function f(y){return a=Ji(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),p):n(y)}function p(y){return Qe(y)?_a(e,h)(y):h(y)}function h(y){return mS(e,g,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function g(y){return e.attempt(zE,_,_)(y)}function _(y){return Oe(y)?Ue(e,b,"whitespace")(y):b(y)}function b(y){return y===null||be(y)?(e.exit("definition"),s.parser.defined.push(a),t(y)):n(y)}}function jE(e,t,n){return s;function s(f){return Qe(f)?_a(e,a)(f):n(f)}function a(f){return gS(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function o(f){return Oe(f)?Ue(e,c,"whitespace")(f):c(f)}function c(f){return f===null||be(f)?t(f):n(f)}}const HE={name:"hardBreakEscape",tokenize:PE};function PE(e,t,n){return s;function s(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return be(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const UE={name:"headingAtx",resolve:IE,tokenize:FE};function IE(e,t){let n=e.length-2,s=3,a,o;return e[s][1].type==="whitespace"&&(s+=2),n-2>s&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(s===n-1||n-4>s&&e[n-2][1].type==="whitespace")&&(n-=s+1===n?2:4),n>s&&(a={type:"atxHeadingText",start:e[s][1].start,end:e[n][1].end},o={type:"chunkText",start:e[s][1].start,end:e[n][1].end,contentType:"text"},Bi(e,s,n-s+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function FE(e,t,n){let s=0;return a;function a(g){return e.enter("atxHeading"),o(g)}function o(g){return e.enter("atxHeadingSequence"),c(g)}function c(g){return g===35&&s++<6?(e.consume(g),c):g===null||Qe(g)?(e.exit("atxHeadingSequence"),f(g)):n(g)}function f(g){return g===35?(e.enter("atxHeadingSequence"),p(g)):g===null||be(g)?(e.exit("atxHeading"),t(g)):Oe(g)?Ue(e,f,"whitespace")(g):(e.enter("atxHeadingText"),h(g))}function p(g){return g===35?(e.consume(g),p):(e.exit("atxHeadingSequence"),f(g))}function h(g){return g===null||g===35||Qe(g)?(e.exit("atxHeadingText"),f(g)):(e.consume(g),h)}}const qE=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],by=["pre","script","style","textarea"],WE={concrete:!0,name:"htmlFlow",resolveTo:KE,tokenize:XE},YE={partial:!0,tokenize:GE},VE={partial:!0,tokenize:$E};function KE(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function XE(e,t,n){const s=this;let a,o,c,f,p;return h;function h(C){return g(C)}function g(C){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(C),_}function _(C){return C===33?(e.consume(C),b):C===47?(e.consume(C),o=!0,k):C===63?(e.consume(C),a=3,s.interrupt?t:E):oi(C)?(e.consume(C),c=String.fromCharCode(C),L):n(C)}function b(C){return C===45?(e.consume(C),a=2,y):C===91?(e.consume(C),a=5,f=0,x):oi(C)?(e.consume(C),a=4,s.interrupt?t:E):n(C)}function y(C){return C===45?(e.consume(C),s.interrupt?t:E):n(C)}function x(C){const J="CDATA[";return C===J.charCodeAt(f++)?(e.consume(C),f===J.length?s.interrupt?t:V:x):n(C)}function k(C){return oi(C)?(e.consume(C),c=String.fromCharCode(C),L):n(C)}function L(C){if(C===null||C===47||C===62||Qe(C)){const J=C===47,fe=c.toLowerCase();return!J&&!o&&by.includes(fe)?(a=1,s.interrupt?t(C):V(C)):qE.includes(c.toLowerCase())?(a=6,J?(e.consume(C),M):s.interrupt?t(C):V(C)):(a=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(C):o?Z(C):I(C))}return C===45||ni(C)?(e.consume(C),c+=String.fromCharCode(C),L):n(C)}function M(C){return C===62?(e.consume(C),s.interrupt?t:V):n(C)}function Z(C){return Oe(C)?(e.consume(C),Z):U(C)}function I(C){return C===47?(e.consume(C),U):C===58||C===95||oi(C)?(e.consume(C),Q):Oe(C)?(e.consume(C),I):U(C)}function Q(C){return C===45||C===46||C===58||C===95||ni(C)?(e.consume(C),Q):W(C)}function W(C){return C===61?(e.consume(C),O):Oe(C)?(e.consume(C),W):I(C)}function O(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(e.consume(C),p=C,ie):Oe(C)?(e.consume(C),O):ue(C)}function ie(C){return C===p?(e.consume(C),p=null,me):C===null||be(C)?n(C):(e.consume(C),ie)}function ue(C){return C===null||C===34||C===39||C===47||C===60||C===61||C===62||C===96||Qe(C)?W(C):(e.consume(C),ue)}function me(C){return C===47||C===62||Oe(C)?I(C):n(C)}function U(C){return C===62?(e.consume(C),le):n(C)}function le(C){return C===null||be(C)?V(C):Oe(C)?(e.consume(C),le):n(C)}function V(C){return C===45&&a===2?(e.consume(C),T):C===60&&a===1?(e.consume(C),j):C===62&&a===4?(e.consume(C),D):C===63&&a===3?(e.consume(C),E):C===93&&a===5?(e.consume(C),ae):be(C)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(YE,K,B)(C)):C===null||be(C)?(e.exit("htmlFlowData"),B(C)):(e.consume(C),V)}function B(C){return e.check(VE,A,K)(C)}function A(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),R}function R(C){return C===null||be(C)?B(C):(e.enter("htmlFlowData"),V(C))}function T(C){return C===45?(e.consume(C),E):V(C)}function j(C){return C===47?(e.consume(C),c="",H):V(C)}function H(C){if(C===62){const J=c.toLowerCase();return by.includes(J)?(e.consume(C),D):V(C)}return oi(C)&&c.length<8?(e.consume(C),c+=String.fromCharCode(C),H):V(C)}function ae(C){return C===93?(e.consume(C),E):V(C)}function E(C){return C===62?(e.consume(C),D):C===45&&a===2?(e.consume(C),E):V(C)}function D(C){return C===null||be(C)?(e.exit("htmlFlowData"),K(C)):(e.consume(C),D)}function K(C){return e.exit("htmlFlow"),t(C)}}function $E(e,t,n){const s=this;return a;function a(c){return be(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):n(c)}function o(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}function GE(e,t,n){return s;function s(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Da,t,n)}}const ZE={name:"htmlText",tokenize:QE};function QE(e,t,n){const s=this;let a,o,c;return f;function f(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),p}function p(E){return E===33?(e.consume(E),h):E===47?(e.consume(E),W):E===63?(e.consume(E),I):oi(E)?(e.consume(E),ue):n(E)}function h(E){return E===45?(e.consume(E),g):E===91?(e.consume(E),o=0,x):oi(E)?(e.consume(E),Z):n(E)}function g(E){return E===45?(e.consume(E),y):n(E)}function _(E){return E===null?n(E):E===45?(e.consume(E),b):be(E)?(c=_,j(E)):(e.consume(E),_)}function b(E){return E===45?(e.consume(E),y):_(E)}function y(E){return E===62?T(E):E===45?b(E):_(E)}function x(E){const D="CDATA[";return E===D.charCodeAt(o++)?(e.consume(E),o===D.length?k:x):n(E)}function k(E){return E===null?n(E):E===93?(e.consume(E),L):be(E)?(c=k,j(E)):(e.consume(E),k)}function L(E){return E===93?(e.consume(E),M):k(E)}function M(E){return E===62?T(E):E===93?(e.consume(E),M):k(E)}function Z(E){return E===null||E===62?T(E):be(E)?(c=Z,j(E)):(e.consume(E),Z)}function I(E){return E===null?n(E):E===63?(e.consume(E),Q):be(E)?(c=I,j(E)):(e.consume(E),I)}function Q(E){return E===62?T(E):I(E)}function W(E){return oi(E)?(e.consume(E),O):n(E)}function O(E){return E===45||ni(E)?(e.consume(E),O):ie(E)}function ie(E){return be(E)?(c=ie,j(E)):Oe(E)?(e.consume(E),ie):T(E)}function ue(E){return E===45||ni(E)?(e.consume(E),ue):E===47||E===62||Qe(E)?me(E):n(E)}function me(E){return E===47?(e.consume(E),T):E===58||E===95||oi(E)?(e.consume(E),U):be(E)?(c=me,j(E)):Oe(E)?(e.consume(E),me):T(E)}function U(E){return E===45||E===46||E===58||E===95||ni(E)?(e.consume(E),U):le(E)}function le(E){return E===61?(e.consume(E),V):be(E)?(c=le,j(E)):Oe(E)?(e.consume(E),le):me(E)}function V(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),a=E,B):be(E)?(c=V,j(E)):Oe(E)?(e.consume(E),V):(e.consume(E),A)}function B(E){return E===a?(e.consume(E),a=void 0,R):E===null?n(E):be(E)?(c=B,j(E)):(e.consume(E),B)}function A(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||Qe(E)?me(E):(e.consume(E),A)}function R(E){return E===47||E===62||Qe(E)?me(E):n(E)}function T(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function j(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),H}function H(E){return Oe(E)?Ue(e,ae,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):ae(E)}function ae(E){return e.enter("htmlTextData"),c(E)}}const qd={name:"labelEnd",resolveAll:i5,resolveTo:n5,tokenize:r5},JE={tokenize:s5},e5={tokenize:l5},t5={tokenize:a5};function i5(e){let t=-1;const n=[];for(;++t=3&&(h===null||be(h))?(e.exit("thematicBreak"),t(h)):n(h)}function p(h){return h===a?(e.consume(h),s++,p):(e.exit("thematicBreakSequence"),Oe(h)?Ue(e,f,"whitespace")(h):f(h))}}const bi={continuation:{tokenize:g5},exit:y5,name:"list",tokenize:_5},p5={partial:!0,tokenize:b5},m5={partial:!0,tokenize:v5};function _5(e,t,n){const s=this,a=s.events[s.events.length-1];let o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,c=0;return f;function f(y){const x=s.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(x==="listUnordered"?!s.containerState.marker||y===s.containerState.marker:_d(y)){if(s.containerState.type||(s.containerState.type=x,e.enter(x,{_container:!0})),x==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(fu,n,h)(y):h(y);if(!s.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),p(y)}return n(y)}function p(y){return _d(y)&&++c<10?(e.consume(y),p):(!s.interrupt||c<2)&&(s.containerState.marker?y===s.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),h(y)):n(y)}function h(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||y,e.check(Da,s.interrupt?n:g,e.attempt(p5,b,_))}function g(y){return s.containerState.initialBlankLine=!0,o++,b(y)}function _(y){return Oe(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),b):n(y)}function b(y){return s.containerState.size=o+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function g5(e,t,n){const s=this;return s.containerState._closeFlow=void 0,e.check(Da,a,o);function a(f){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,Ue(e,t,"listItemIndent",s.containerState.size+1)(f)}function o(f){return s.containerState.furtherBlankLines||!Oe(f)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,c(f)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(m5,t,c)(f))}function c(f){return s.containerState._closeFlow=!0,s.interrupt=void 0,Ue(e,e.attempt(bi,t,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function v5(e,t,n){const s=this;return Ue(e,a,"listItemIndent",s.containerState.size+1);function a(o){const c=s.events[s.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===s.containerState.size?t(o):n(o)}}function y5(e){e.exit(this.containerState.type)}function b5(e,t,n){const s=this;return Ue(e,a,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(o){const c=s.events[s.events.length-1];return!Oe(o)&&c&&c[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const Sy={name:"setextUnderline",resolveTo:S5,tokenize:x5};function S5(e,t){let n=e.length,s,a,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){s=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const c={type:"setextHeading",start:{...e[s][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",o?(e.splice(a,0,["enter",c,t]),e.splice(o+1,0,["exit",e[s][1],t]),e[s][1].end={...e[o][1].end}):e[s][1]=c,e.push(["exit",c,t]),e}function x5(e,t,n){const s=this;let a;return o;function o(h){let g=s.events.length,_;for(;g--;)if(s.events[g][1].type!=="lineEnding"&&s.events[g][1].type!=="linePrefix"&&s.events[g][1].type!=="content"){_=s.events[g][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||_)?(e.enter("setextHeadingLine"),a=h,c(h)):n(h)}function c(h){return e.enter("setextHeadingLineSequence"),f(h)}function f(h){return h===a?(e.consume(h),f):(e.exit("setextHeadingLineSequence"),Oe(h)?Ue(e,p,"lineSuffix")(h):p(h))}function p(h){return h===null||be(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const w5={tokenize:C5};function C5(e){const t=this,n=e.attempt(Da,s,e.attempt(this.parser.constructs.flowInitial,a,Ue(e,e.attempt(this.parser.constructs.flow,a,e.attempt(DE,a)),"linePrefix")));return n;function s(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const k5={resolveAll:yS()},E5=vS("string"),T5=vS("text");function vS(e){return{resolveAll:yS(e==="text"?A5:void 0),tokenize:t};function t(n){const s=this,a=this.parser.constructs[e],o=n.attempt(a,c,f);return c;function c(g){return h(g)?o(g):f(g)}function f(g){if(g===null){n.consume(g);return}return n.enter("data"),n.consume(g),p}function p(g){return h(g)?(n.exit("data"),o(g)):(n.consume(g),p)}function h(g){if(g===null)return!0;const _=a[g];let b=-1;if(_)for(;++b<_.length;){const y=_[b];if(!y.previous||y.previous.call(s,s.previous))return!0}return!1}}}function yS(e){return t;function t(n,s){let a=-1,o;for(;++a<=n.length;)o===void 0?n[a]&&n[a][1].type==="data"&&(o=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==o+2&&(n[o][1].end=n[a-1][1].end,n.splice(o+2,a-o-2),a=o+2),o=void 0);return e?e(n,s):n}}function A5(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const s=e[n-1][1],a=t.sliceStream(s);let o=a.length,c=-1,f=0,p;for(;o--;){const h=a[o];if(typeof h=="string"){for(c=h.length;h.charCodeAt(c-1)===32;)f++,c--;if(c)break;c=-1}else if(h===-2)p=!0,f++;else if(h!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(f=0),f){const h={type:n===e.length||p||f<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?c:s.start._bufferIndex+c,_index:s.start._index+o,line:s.end.line,column:s.end.column-f,offset:s.end.offset-f},end:{...s.end}};s.end={...h.start},s.start.offset===s.end.offset?Object.assign(s,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const D5={42:bi,43:bi,45:bi,48:bi,49:bi,50:bi,51:bi,52:bi,53:bi,54:bi,55:bi,56:bi,57:bi,62:hS},R5={91:LE},M5={[-2]:df,[-1]:df,32:df},B5={35:UE,42:fu,45:[Sy,fu],60:WE,61:Sy,95:fu,96:yy,126:yy},N5={38:dS,92:fS},L5={[-5]:pf,[-4]:pf,[-3]:pf,33:o5,38:dS,42:gd,60:[cE,ZE],91:c5,92:[HE,fS],93:qd,95:gd,96:wE},z5={null:[gd,k5]},O5={null:[42,95]},j5={null:[]},H5=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:O5,contentInitial:R5,disable:j5,document:D5,flow:B5,flowInitial:M5,insideSpan:z5,string:N5,text:L5},Symbol.toStringTag,{value:"Module"}));function P5(e,t,n){let s={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},o=[];let c=[],f=[];const p={attempt:ie(W),check:ie(O),consume:Z,enter:I,exit:Q,interrupt:ie(O,{interrupt:!0})},h={code:null,containerState:{},defineSkip:k,events:[],now:x,parser:e,previous:null,sliceSerialize:b,sliceStream:y,write:_};let g=t.tokenize.call(h,p);return t.resolveAll&&o.push(t),h;function _(le){return c=Vi(c,le),L(),c[c.length-1]!==null?[]:(ue(t,0),h.events=Au(o,h.events,h),h.events)}function b(le,V){return I5(y(le),V)}function y(le){return U5(c,le)}function x(){const{_bufferIndex:le,_index:V,line:B,column:A,offset:R}=s;return{_bufferIndex:le,_index:V,line:B,column:A,offset:R}}function k(le){a[le.line]=le.column,U()}function L(){let le;for(;s._index-1){const f=c[0];typeof f=="string"?c[0]=f.slice(s):c.shift()}o>0&&c.push(e[a].slice(0,o))}return c}function I5(e,t){let n=-1;const s=[];let a;for(;++nnew Set(ae).add(B))}},A.term.onData(H=>{j.readyState===WebSocket.OPEN&&j.send(H)}),A.ws=j},[e]);$.useEffect(()=>{G.current=W},[W]);const O=$.useCallback(async(B,A)=>{if(!p.current||Nt.has(B))return;const{resume:R=!1,autoConnect:T=!0}=A??{},j=document.createElement("div");j.style.width="100%",j.style.height="100%",j.style.display="none",j.style.paddingLeft="10px",j.style.boxSizing="border-box",p.current.appendChild(j);const H=new V2({cols:80,scrollback:5e3,fontSize:13,fontFamily:'"Geist Mono", ui-monospace, monospace',lineHeight:1.05,letterSpacing:0,cursorBlink:!0,cursorStyle:"block",theme:ik,allowTransparency:!1,drawBoldTextInBrightColors:!1,minimumContrastRatio:7}),ae=new $2,E=new ek;H.loadAddon(ae),H.loadAddon(E),H.open(j);const D={term:H,fit:ae,serialize:E,ws:null,container:j,observer:null,connected:!1},K=new ResizeObserver(()=>{var Q;const{width:C}=j.getBoundingClientRect();if(!(C<50))try{ae.fit(),((Q=D.ws)==null?void 0:Q.readyState)===WebSocket.OPEN&&D.ws.send(JSON.stringify({type:"resize",cols:H.cols,rows:H.rows}))}catch{}});K.observe(j),D.observer=K,Nt.set(B,D),_(C=>[...C,B]);try{const C=await sk(B);C&&H.write(C)}catch{}T?W(B,D,R):y(C=>new Set(C).add(B)),setTimeout(()=>I(D),50)},[W,I]),te=$.useCallback(async(B,A)=>{const R=Nt.get(B);R&&(R.ws&&(R.ws.close(),R.ws=null),A||(await h.current(`/api/terminal/${encodeURIComponent(B)}`,{method:"DELETE"}).catch(()=>{}),R.term.clear()),W(B,R,A))},[W]),ue=$.useCallback(B=>{const A=Nt.get(B);if(A){try{const R=A.serialize.serialize();na(B,R).catch(()=>{})}catch{}A.observer.disconnect(),A.ws&&A.ws.close(),A.term.dispose(),A.container.remove(),Nt.delete(B),_(R=>R.filter(T=>T!==B)),y(R=>{const T=new Set(R);return T.delete(B),T}),n(`/api/terminal/${encodeURIComponent(B)}`,{method:"DELETE"}).catch(()=>{}),a==null||a(B)}},[n,a]),_e=$.useCallback(B=>{var R;const A=Nt.get(B);A&&(((R=A.ws)==null?void 0:R.readyState)===WebSocket.OPEN&&A.ws.send(`exit +`),iy(B).catch(()=>{}),A.observer.disconnect(),A.ws&&A.ws.close(),A.term.dispose(),A.container.remove(),Nt.delete(B),_(T=>T.filter(j=>j!==B)),y(T=>{const j=new Set(T);return j.delete(B),j}),n(`/api/terminal/${encodeURIComponent(B)}/discard`,{method:"DELETE"}).catch(()=>{}),a==null||a(B))},[n,a]),U=$.useCallback(async(B,A)=>{const R=Nt.get(B);if(!R||Nt.has(A)||!(await h.current("/api/terminal/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldName:B,newName:A})})).ok)return!1;Nt.delete(B),Nt.set(A,R);try{const j=R.serialize.serialize();await iy(B),await na(A,j)}catch{}return _(j=>j.map(H=>H===B?A:H)),y(j=>{if(!j.has(B))return j;const H=new Set(j);return H.delete(B),H.add(A),H}),!0},[]);$.useEffect(()=>(f&&(f.current=U),()=>{f&&(f.current=null)}),[f,U]),$.useEffect(()=>{t&&(Nt.has(t)?Z(t):h.current(`/api/terminal/session/${encodeURIComponent(t)}`).then(B=>B.ok?B.json():null).then(B=>{if(!Nt.has(t)){const A=(B==null?void 0:B.sessionId)&&!(B!=null&&B.running);O(t,{autoConnect:!A}),Z(t)}}).catch(()=>{Nt.has(t)||(O(t),Z(t))}))},[t,O,Z]),$.useEffect(()=>{const B=setInterval(()=>{for(const[A,R]of Nt)if(R.connected)try{const T=R.serialize.serialize();na(A,T).catch(()=>{})}catch{}},3e4);return()=>clearInterval(B)},[]),$.useEffect(()=>()=>{for(const[B,A]of Nt){try{const R=A.serialize.serialize();na(B,R).catch(()=>{})}catch{}A.observer.disconnect(),A.ws&&A.ws.close(),A.term.dispose(),A.container.remove(),h.current(`/api/terminal/${encodeURIComponent(B)}`,{method:"DELETE"}).catch(()=>{})}Nt.clear()},[]);const se=t?b.has(t):!1,V=g.length===0;return S.jsxs("div",{className:"h-full flex flex-col",children:[!V&&S.jsxs("div",{className:"px-2 py-1 border-b border-border flex items-center gap-1 overflow-x-auto",children:[g.map(B=>S.jsxs("div",{onClick:()=>s==null?void 0:s(B),className:`flex items-center gap-1 px-2 py-0.5 rounded text-xs font-mono cursor-pointer ${B===t?"bg-accent/10 text-accent":"text-muted hover:text-foreground"}`,children:[S.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${b.has(B)?"bg-amber-500":B===t?"bg-green-600":"bg-muted/50"}`}),S.jsx("span",{className:`truncate max-w-[120px] ${B.startsWith("_new_")?"italic":""}`,children:B.startsWith("_new_")?"Untitled":B}),S.jsx("button",{onClick:A=>{A.stopPropagation(),B.startsWith("_new_")?k(B):ue(B)},className:"ml-0.5 text-muted hover:text-error text-[10px] leading-none",title:"Close terminal",children:"×"})]},B)),t!=null&&t.startsWith("_new_")?S.jsx("button",{onClick:()=>k(t),className:"ml-auto px-2 py-0.5 text-xs text-error hover:bg-surface rounded flex items-center gap-1 flex-shrink-0",children:"Cancel ×"}):t&&o&&(c!=null&&c.has(t))?S.jsx("button",{onClick:()=>M(t),className:"ml-auto px-2 py-0.5 text-xs text-muted hover:text-foreground hover:bg-surface rounded flex items-center gap-1 flex-shrink-0",children:"Archive"}):null]}),S.jsxs("div",{className:"relative flex-1 min-h-0",children:[S.jsx("div",{ref:p,className:"h-full"}),V&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-muted",children:S.jsxs("div",{className:"text-center",children:[S.jsx("p",{className:"text-lg font-serif",children:"Select a story on the left menu"}),S.jsx("p",{className:"text-sm mt-1",children:"to start an AI Writer session"})]})}),x&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[S.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Discard this session?"}),S.jsx("p",{className:"text-xs text-muted",children:"This session will be lost — your AI hasn't created a story structure yet."}),S.jsxs("div",{className:"flex items-center justify-center gap-2",children:[S.jsx("button",{onClick:()=>k(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),S.jsx("button",{onClick:()=>{const B=x;k(null),_e(B)},className:"px-4 py-1.5 bg-error text-white text-sm rounded hover:opacity-80",children:"Discard"})]})]})}),L&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[S.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Archive this story?"}),S.jsx("p",{className:"text-xs text-muted",children:"You can restore it later from the Archives view."}),S.jsxs("div",{className:"flex items-center justify-center gap-2",children:[S.jsx("button",{onClick:()=>M(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),S.jsx("button",{onClick:async()=>{const B=L;M(null);try{(await h.current("/api/stories/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B})})).ok&&(ue(B),o==null||o(B))}catch{}},className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Archive"})]})]})}),se&&t&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:S.jsxs("div",{className:"text-center space-y-3",children:[S.jsx("p",{className:"text-sm font-serif text-foreground",children:"Terminal disconnected"}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("button",{onClick:()=>te(t,!0),className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Resume Session"}),S.jsx("button",{onClick:()=>te(t,!1),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Start Fresh"})]}),S.jsx("p",{className:"text-xs text-muted",children:"Resume continues your previous Claude conversation"})]})})]})]})}function ak(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const ok=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,uk=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ck={};function ny(e,t){return(ck.jsx?uk:ok).test(e)}const hk=/[ \t\n\f\r]/g;function fk(e){return typeof e=="object"?e.type==="text"?ry(e.value):!1:ry(e)}function ry(e){return e.replace(hk,"")===""}class Ta{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}}Ta.prototype.normal={};Ta.prototype.property={};Ta.prototype.space=void 0;function Xb(e,t){const n={},s={};for(const a of e)Object.assign(n,a.property),Object.assign(s,a.normal);return new Ta(n,s,t)}function fd(e){return e.toLowerCase()}class Si{constructor(t,n){this.attribute=n,this.property=t}}Si.prototype.attribute="";Si.prototype.booleanish=!1;Si.prototype.boolean=!1;Si.prototype.commaOrSpaceSeparated=!1;Si.prototype.commaSeparated=!1;Si.prototype.defined=!1;Si.prototype.mustUseProperty=!1;Si.prototype.number=!1;Si.prototype.overloadedBoolean=!1;Si.prototype.property="";Si.prototype.spaceSeparated=!1;Si.prototype.space=void 0;let dk=0;const Me=ns(),Tt=ns(),dd=ns(),oe=ns(),rt=ns(),Zs=ns(),Mi=ns();function ns(){return 2**++dk}const pd=Object.freeze(Object.defineProperty({__proto__:null,boolean:Me,booleanish:Tt,commaOrSpaceSeparated:Mi,commaSeparated:Zs,number:oe,overloadedBoolean:dd,spaceSeparated:rt},Symbol.toStringTag,{value:"Module"})),cf=Object.keys(pd);class zd extends Si{constructor(t,n,s,a){let o=-1;if(super(t,n),sy(this,"space",a),typeof s=="number")for(;++o4&&n.slice(0,4)==="data"&&vk.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(ly,Sk);s="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!ly.test(o)){let c=o.replace(gk,bk);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=zd}return new a(s,t)}function bk(e){return"-"+e.toLowerCase()}function Sk(e){return e.charAt(1).toUpperCase()}const xk=Xb([$b,pk,Qb,Jb,eS],"html"),Od=Xb([$b,mk,Qb,Jb,eS],"svg");function wk(e){return e.join(" ").trim()}var Ys={},hf,ay;function Ck(){if(ay)return hf;ay=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,f=/^\s+|\s+$/g,p=` +`,h="/",g="*",_="",b="comment",y="declaration";function x(L,M){if(typeof L!="string")throw new TypeError("First argument must be a string");if(!L)return[];M=M||{};var G=1,I=1;function Z(A){var R=A.match(t);R&&(G+=R.length);var T=A.lastIndexOf(p);I=~T?A.length-T:I+A.length}function W(){var A={line:G,column:I};return function(R){return R.position=new O(A),_e(),R}}function O(A){this.start=A,this.end={line:G,column:I},this.source=M.source}O.prototype.content=L;function te(A){var R=new Error(M.source+":"+G+":"+I+": "+A);if(R.reason=A,R.filename=M.source,R.line=G,R.column=I,R.source=L,!M.silent)throw R}function ue(A){var R=A.exec(L);if(R){var T=R[0];return Z(T),L=L.slice(T.length),R}}function _e(){ue(n)}function U(A){var R;for(A=A||[];R=se();)R!==!1&&A.push(R);return A}function se(){var A=W();if(!(h!=L.charAt(0)||g!=L.charAt(1))){for(var R=2;_!=L.charAt(R)&&(g!=L.charAt(R)||h!=L.charAt(R+1));)++R;if(R+=2,_===L.charAt(R-1))return te("End of comment missing");var T=L.slice(2,R-2);return I+=2,Z(T),L=L.slice(R),I+=2,A({type:b,comment:T})}}function V(){var A=W(),R=ue(s);if(R){if(se(),!ue(a))return te("property missing ':'");var T=ue(o),j=A({type:y,property:k(R[0].replace(e,_)),value:T?k(T[0].replace(e,_)):_});return ue(c),j}}function B(){var A=[];U(A);for(var R;R=V();)R!==!1&&(A.push(R),U(A));return A}return _e(),B()}function k(L){return L?L.replace(f,_):_}return hf=x,hf}var oy;function kk(){if(oy)return Ys;oy=1;var e=Ys&&Ys.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Ys,"__esModule",{value:!0}),Ys.default=n;const t=e(Ck());function n(s,a){let o=null;if(!s||typeof s!="string")return o;const c=(0,t.default)(s),f=typeof a=="function";return c.forEach(p=>{if(p.type!=="declaration")return;const{property:h,value:g}=p;f?a(h,g,p):g&&(o=o||{},o[h]=g)}),o}return Ys}var ra={},uy;function Ek(){if(uy)return ra;uy=1,Object.defineProperty(ra,"__esModule",{value:!0}),ra.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(h){return!h||n.test(h)||e.test(h)},c=function(h,g){return g.toUpperCase()},f=function(h,g){return"".concat(g,"-")},p=function(h,g){return g===void 0&&(g={}),o(h)?h:(h=h.toLowerCase(),g.reactCompat?h=h.replace(a,f):h=h.replace(s,f),h.replace(t,c))};return ra.camelCase=p,ra}var sa,cy;function Tk(){if(cy)return sa;cy=1;var e=sa&&sa.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(kk()),n=Ek();function s(a,o){var c={};return!a||typeof a!="string"||(0,t.default)(a,function(f,p){f&&p&&(c[(0,n.camelCase)(f,o)]=p)}),c}return s.default=s,sa=s,sa}var Ak=Tk();const Dk=xu(Ak),tS=iS("end"),jd=iS("start");function iS(e){return t;function t(n){const s=n&&n.position&&n.position[e]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function nS(e){const t=jd(e),n=tS(e);if(t&&n)return{start:t,end:n}}function pa(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?hy(e.position):"start"in e||"end"in e?hy(e):"line"in e||"column"in e?md(e):""}function md(e){return fy(e&&e.line)+":"+fy(e&&e.column)}function hy(e){return md(e&&e.start)+"-"+md(e&&e.end)}function fy(e){return e&&typeof e=="number"?e:1}class si extends Error{constructor(t,n,s){super(),typeof n=="string"&&(s=n,n=void 0);let a="",o={},c=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?a=t:!o.cause&&t&&(c=!0,a=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof s=="string"){const p=s.indexOf(":");p===-1?o.ruleId=s:(o.source=s.slice(0,p),o.ruleId=s.slice(p+1))}if(!o.place&&o.ancestors&&o.ancestors){const p=o.ancestors[o.ancestors.length-1];p&&(o.place=p.position)}const f=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=f?f.line:void 0,this.name=pa(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=c&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}si.prototype.file="";si.prototype.name="";si.prototype.reason="";si.prototype.message="";si.prototype.stack="";si.prototype.column=void 0;si.prototype.line=void 0;si.prototype.ancestors=void 0;si.prototype.cause=void 0;si.prototype.fatal=void 0;si.prototype.place=void 0;si.prototype.ruleId=void 0;si.prototype.source=void 0;const Hd={}.hasOwnProperty,Rk=new Map,Mk=/[A-Z]/g,Bk=new Set(["table","tbody","thead","tfoot","tr"]),Nk=new Set(["td","th"]),rS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Lk(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let s;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=Fk(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");s=Ik(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Od:xk,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=sS(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function sS(e,t,n){if(t.type==="element")return zk(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Ok(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Hk(e,t,n);if(t.type==="mdxjsEsm")return jk(e,t);if(t.type==="root")return Pk(e,t,n);if(t.type==="text")return Uk(e,t)}function zk(e,t,n){const s=e.schema;let a=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(a=Od,e.schema=a),e.ancestors.push(t);const o=aS(e,t.tagName,!1),c=qk(e,t);let f=Ud(e,t);return Bk.has(t.tagName)&&(f=f.filter(function(p){return typeof p=="string"?!fk(p):!0})),lS(e,c,o,t),Pd(c,f),e.ancestors.pop(),e.schema=s,e.create(t,o,c,n)}function Ok(e,t){if(t.data&&t.data.estree&&e.evaluater){const s=t.data.estree.body[0];return s.type,e.evaluater.evaluateExpression(s.expression)}ba(e,t.position)}function jk(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ba(e,t.position)}function Hk(e,t,n){const s=e.schema;let a=s;t.name==="svg"&&s.space==="html"&&(a=Od,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:aS(e,t.name,!0),c=Wk(e,t),f=Ud(e,t);return lS(e,c,o,t),Pd(c,f),e.ancestors.pop(),e.schema=s,e.create(t,o,c,n)}function Pk(e,t,n){const s={};return Pd(s,Ud(e,t)),e.create(t,e.Fragment,s,n)}function Uk(e,t){return t.value}function lS(e,t,n,s){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=s)}function Pd(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Ik(e,t,n){return s;function s(a,o,c,f){const h=Array.isArray(c.children)?n:t;return f?h(o,c,f):h(o,c)}}function Fk(e,t){return n;function n(s,a,o,c){const f=Array.isArray(o.children),p=jd(s);return t(a,o,c,f,{columnNumber:p?p.column-1:void 0,fileName:e,lineNumber:p?p.line:void 0},void 0)}}function qk(e,t){const n={};let s,a;for(a in t.properties)if(a!=="children"&&Hd.call(t.properties,a)){const o=Yk(e,a,t.properties[a]);if(o){const[c,f]=o;e.tableCellAlignToStyle&&c==="align"&&typeof f=="string"&&Nk.has(t.tagName)?s=f:n[c]=f}}if(s){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return n}function Wk(e,t){const n={};for(const s of t.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&e.evaluater){const o=s.data.estree.body[0];o.type;const c=o.expression;c.type;const f=c.properties[0];f.type,Object.assign(n,e.evaluater.evaluateExpression(f.argument))}else ba(e,t.position);else{const a=s.name;let o;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&e.evaluater){const f=s.value.data.estree.body[0];f.type,o=e.evaluater.evaluateExpression(f.expression)}else ba(e,t.position);else o=s.value===null?!0:s.value;n[a]=o}return n}function Ud(e,t){const n=[];let s=-1;const a=e.passKeys?new Map:Rk;for(;++sa?0:a+t:t=t>a?a:t,n=n>0?n:0,s.length<1e4)c=Array.from(s),c.unshift(t,n),e.splice(...c);else for(n&&e.splice(t,n);o0?(Bi(e,e.length,0,t),e):t}const my={}.hasOwnProperty;function uS(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function en(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ui=kr(/[A-Za-z]/),ri=kr(/[\dA-Za-z]/),eE=kr(/[#-'*+\--9=?A-Z^-~]/);function yu(e){return e!==null&&(e<32||e===127)}const _d=kr(/\d/),tE=kr(/[\dA-Fa-f]/),iE=kr(/[!-/:-@[-`{-~]/);function Se(e){return e!==null&&e<-2}function it(e){return e!==null&&(e<0||e===32)}function je(e){return e===-2||e===-1||e===32}const Tu=kr(new RegExp("\\p{P}|\\p{S}","u")),ts=kr(/\s/);function kr(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function nl(e){const t=[];let n=-1,s=0,a=0;for(;++n55295&&o<57344){const f=e.charCodeAt(n+1);o<56320&&f>56319&&f<57344?(c=String.fromCharCode(o,f),a=1):c="�"}else c=String.fromCharCode(o);c&&(t.push(e.slice(s,n),encodeURIComponent(c)),s=n+a+1,c=""),a&&(n+=a,a=0)}return t.join("")+e.slice(s)}function Ie(e,t,n,s){const a=s?s-1:Number.POSITIVE_INFINITY;let o=0;return c;function c(p){return je(p)?(e.enter(n),f(p)):t(p)}function f(p){return je(p)&&o++c))return;const te=t.events.length;let ue=te,_e,U;for(;ue--;)if(t.events[ue][0]==="exit"&&t.events[ue][1].type==="chunkFlow"){if(_e){U=t.events[ue][1].end;break}_e=!0}for(M(s),O=te;OI;){const W=n[Z];t.containerState=W[1],W[0].exit.call(t,e)}n.length=I}function G(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function aE(e,t,n){return Ie(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Js(e){if(e===null||it(e)||ts(e))return 1;if(Tu(e))return 2}function Au(e,t,n){const s=[];let a=-1;for(;++a1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const _={...e[s][1].end},b={...e[n][1].start};gy(_,-p),gy(b,p),c={type:p>1?"strongSequence":"emphasisSequence",start:_,end:{...e[s][1].end}},f={type:p>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:b},o={type:p>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[n][1].start}},a={type:p>1?"strong":"emphasis",start:{...c.start},end:{...f.end}},e[s][1].end={...c.start},e[n][1].start={...f.end},h=[],e[s][1].end.offset-e[s][1].start.offset&&(h=Ki(h,[["enter",e[s][1],t],["exit",e[s][1],t]])),h=Ki(h,[["enter",a,t],["enter",c,t],["exit",c,t],["enter",o,t]]),h=Ki(h,Au(t.parser.constructs.insideSpan.null,e.slice(s+1,n),t)),h=Ki(h,[["exit",o,t],["enter",f,t],["exit",f,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(g=2,h=Ki(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):g=0,Bi(e,s-1,n-s+3,h),n=s+h.length-g-2;break}}for(n=-1;++n0&&je(O)?Ie(e,G,"linePrefix",o+1)(O):G(O)}function G(O){return O===null||Se(O)?e.check(vy,k,Z)(O):(e.enter("codeFlowValue"),I(O))}function I(O){return O===null||Se(O)?(e.exit("codeFlowValue"),G(O)):(e.consume(O),I)}function Z(O){return e.exit("codeFenced"),t(O)}function W(O,te,ue){let _e=0;return U;function U(R){return O.enter("lineEnding"),O.consume(R),O.exit("lineEnding"),se}function se(R){return O.enter("codeFencedFence"),je(R)?Ie(O,V,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):V(R)}function V(R){return R===f?(O.enter("codeFencedFenceSequence"),B(R)):ue(R)}function B(R){return R===f?(_e++,O.consume(R),B):_e>=c?(O.exit("codeFencedFenceSequence"),je(R)?Ie(O,A,"whitespace")(R):A(R)):ue(R)}function A(R){return R===null||Se(R)?(O.exit("codeFencedFence"),te(R)):ue(R)}}}function yE(e,t,n){const s=this;return a;function a(c){return c===null?n(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o)}function o(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}const df={name:"codeIndented",tokenize:SE},bE={partial:!0,tokenize:xE};function SE(e,t,n){const s=this;return a;function a(h){return e.enter("codeIndented"),Ie(e,o,"linePrefix",5)(h)}function o(h){const g=s.events[s.events.length-1];return g&&g[1].type==="linePrefix"&&g[2].sliceSerialize(g[1],!0).length>=4?c(h):n(h)}function c(h){return h===null?p(h):Se(h)?e.attempt(bE,c,p)(h):(e.enter("codeFlowValue"),f(h))}function f(h){return h===null||Se(h)?(e.exit("codeFlowValue"),c(h)):(e.consume(h),f)}function p(h){return e.exit("codeIndented"),t(h)}}function xE(e,t,n){const s=this;return a;function a(c){return s.parser.lazy[s.now().line]?n(c):Se(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):Ie(e,o,"linePrefix",5)(c)}function o(c){const f=s.events[s.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?t(c):Se(c)?a(c):n(c)}}const wE={name:"codeText",previous:kE,resolve:CE,tokenize:EE};function CE(e){let t=e.length-4,n=3,s,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(s=n;++s=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(t,n,s){const a=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return s&&la(this.left,s),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),la(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),la(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(c):e.interrupt(s.parser.constructs.flow,n,t)(c)}}function mS(e,t,n,s,a,o,c,f,p){const h=p||Number.POSITIVE_INFINITY;let g=0;return _;function _(M){return M===60?(e.enter(s),e.enter(a),e.enter(o),e.consume(M),e.exit(o),b):M===null||M===32||M===41||yu(M)?n(M):(e.enter(s),e.enter(c),e.enter(f),e.enter("chunkString",{contentType:"string"}),k(M))}function b(M){return M===62?(e.enter(o),e.consume(M),e.exit(o),e.exit(a),e.exit(s),t):(e.enter(f),e.enter("chunkString",{contentType:"string"}),y(M))}function y(M){return M===62?(e.exit("chunkString"),e.exit(f),b(M)):M===null||M===60||Se(M)?n(M):(e.consume(M),M===92?x:y)}function x(M){return M===60||M===62||M===92?(e.consume(M),y):y(M)}function k(M){return!g&&(M===null||M===41||it(M))?(e.exit("chunkString"),e.exit(f),e.exit(c),e.exit(s),t(M)):g999||y===null||y===91||y===93&&!p||y===94&&!f&&"_hiddenFootnoteSupport"in c.parser.constructs?n(y):y===93?(e.exit(o),e.enter(a),e.consume(y),e.exit(a),e.exit(s),t):Se(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),g):(e.enter("chunkString",{contentType:"string"}),_(y))}function _(y){return y===null||y===91||y===93||Se(y)||f++>999?(e.exit("chunkString"),g(y)):(e.consume(y),p||(p=!je(y)),y===92?b:_)}function b(y){return y===91||y===92||y===93?(e.consume(y),f++,_):_(y)}}function gS(e,t,n,s,a,o){let c;return f;function f(b){return b===34||b===39||b===40?(e.enter(s),e.enter(a),e.consume(b),e.exit(a),c=b===40?41:b,p):n(b)}function p(b){return b===c?(e.enter(a),e.consume(b),e.exit(a),e.exit(s),t):(e.enter(o),h(b))}function h(b){return b===c?(e.exit(o),p(c)):b===null?n(b):Se(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),Ie(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),g(b))}function g(b){return b===c||b===null||Se(b)?(e.exit("chunkString"),h(b)):(e.consume(b),b===92?_:g)}function _(b){return b===c||b===92?(e.consume(b),g):g(b)}}function ma(e,t){let n;return s;function s(a){return Se(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,s):je(a)?Ie(e,s,n?"linePrefix":"lineSuffix")(a):t(a)}}const LE={name:"definition",tokenize:OE},zE={partial:!0,tokenize:jE};function OE(e,t,n){const s=this;let a;return o;function o(y){return e.enter("definition"),c(y)}function c(y){return _S.call(s,e,f,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function f(y){return a=en(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),p):n(y)}function p(y){return it(y)?ma(e,h)(y):h(y)}function h(y){return mS(e,g,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function g(y){return e.attempt(zE,_,_)(y)}function _(y){return je(y)?Ie(e,b,"whitespace")(y):b(y)}function b(y){return y===null||Se(y)?(e.exit("definition"),s.parser.defined.push(a),t(y)):n(y)}}function jE(e,t,n){return s;function s(f){return it(f)?ma(e,a)(f):n(f)}function a(f){return gS(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function o(f){return je(f)?Ie(e,c,"whitespace")(f):c(f)}function c(f){return f===null||Se(f)?t(f):n(f)}}const HE={name:"hardBreakEscape",tokenize:PE};function PE(e,t,n){return s;function s(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return Se(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const UE={name:"headingAtx",resolve:IE,tokenize:FE};function IE(e,t){let n=e.length-2,s=3,a,o;return e[s][1].type==="whitespace"&&(s+=2),n-2>s&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(s===n-1||n-4>s&&e[n-2][1].type==="whitespace")&&(n-=s+1===n?2:4),n>s&&(a={type:"atxHeadingText",start:e[s][1].start,end:e[n][1].end},o={type:"chunkText",start:e[s][1].start,end:e[n][1].end,contentType:"text"},Bi(e,s,n-s+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function FE(e,t,n){let s=0;return a;function a(g){return e.enter("atxHeading"),o(g)}function o(g){return e.enter("atxHeadingSequence"),c(g)}function c(g){return g===35&&s++<6?(e.consume(g),c):g===null||it(g)?(e.exit("atxHeadingSequence"),f(g)):n(g)}function f(g){return g===35?(e.enter("atxHeadingSequence"),p(g)):g===null||Se(g)?(e.exit("atxHeading"),t(g)):je(g)?Ie(e,f,"whitespace")(g):(e.enter("atxHeadingText"),h(g))}function p(g){return g===35?(e.consume(g),p):(e.exit("atxHeadingSequence"),f(g))}function h(g){return g===null||g===35||it(g)?(e.exit("atxHeadingText"),f(g)):(e.consume(g),h)}}const qE=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],by=["pre","script","style","textarea"],WE={concrete:!0,name:"htmlFlow",resolveTo:KE,tokenize:XE},YE={partial:!0,tokenize:GE},VE={partial:!0,tokenize:$E};function KE(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function XE(e,t,n){const s=this;let a,o,c,f,p;return h;function h(C){return g(C)}function g(C){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(C),_}function _(C){return C===33?(e.consume(C),b):C===47?(e.consume(C),o=!0,k):C===63?(e.consume(C),a=3,s.interrupt?t:E):ui(C)?(e.consume(C),c=String.fromCharCode(C),L):n(C)}function b(C){return C===45?(e.consume(C),a=2,y):C===91?(e.consume(C),a=5,f=0,x):ui(C)?(e.consume(C),a=4,s.interrupt?t:E):n(C)}function y(C){return C===45?(e.consume(C),s.interrupt?t:E):n(C)}function x(C){const Q="CDATA[";return C===Q.charCodeAt(f++)?(e.consume(C),f===Q.length?s.interrupt?t:V:x):n(C)}function k(C){return ui(C)?(e.consume(C),c=String.fromCharCode(C),L):n(C)}function L(C){if(C===null||C===47||C===62||it(C)){const Q=C===47,fe=c.toLowerCase();return!Q&&!o&&by.includes(fe)?(a=1,s.interrupt?t(C):V(C)):qE.includes(c.toLowerCase())?(a=6,Q?(e.consume(C),M):s.interrupt?t(C):V(C)):(a=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(C):o?G(C):I(C))}return C===45||ri(C)?(e.consume(C),c+=String.fromCharCode(C),L):n(C)}function M(C){return C===62?(e.consume(C),s.interrupt?t:V):n(C)}function G(C){return je(C)?(e.consume(C),G):U(C)}function I(C){return C===47?(e.consume(C),U):C===58||C===95||ui(C)?(e.consume(C),Z):je(C)?(e.consume(C),I):U(C)}function Z(C){return C===45||C===46||C===58||C===95||ri(C)?(e.consume(C),Z):W(C)}function W(C){return C===61?(e.consume(C),O):je(C)?(e.consume(C),W):I(C)}function O(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(e.consume(C),p=C,te):je(C)?(e.consume(C),O):ue(C)}function te(C){return C===p?(e.consume(C),p=null,_e):C===null||Se(C)?n(C):(e.consume(C),te)}function ue(C){return C===null||C===34||C===39||C===47||C===60||C===61||C===62||C===96||it(C)?W(C):(e.consume(C),ue)}function _e(C){return C===47||C===62||je(C)?I(C):n(C)}function U(C){return C===62?(e.consume(C),se):n(C)}function se(C){return C===null||Se(C)?V(C):je(C)?(e.consume(C),se):n(C)}function V(C){return C===45&&a===2?(e.consume(C),T):C===60&&a===1?(e.consume(C),j):C===62&&a===4?(e.consume(C),D):C===63&&a===3?(e.consume(C),E):C===93&&a===5?(e.consume(C),ae):Se(C)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(YE,K,B)(C)):C===null||Se(C)?(e.exit("htmlFlowData"),B(C)):(e.consume(C),V)}function B(C){return e.check(VE,A,K)(C)}function A(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),R}function R(C){return C===null||Se(C)?B(C):(e.enter("htmlFlowData"),V(C))}function T(C){return C===45?(e.consume(C),E):V(C)}function j(C){return C===47?(e.consume(C),c="",H):V(C)}function H(C){if(C===62){const Q=c.toLowerCase();return by.includes(Q)?(e.consume(C),D):V(C)}return ui(C)&&c.length<8?(e.consume(C),c+=String.fromCharCode(C),H):V(C)}function ae(C){return C===93?(e.consume(C),E):V(C)}function E(C){return C===62?(e.consume(C),D):C===45&&a===2?(e.consume(C),E):V(C)}function D(C){return C===null||Se(C)?(e.exit("htmlFlowData"),K(C)):(e.consume(C),D)}function K(C){return e.exit("htmlFlow"),t(C)}}function $E(e,t,n){const s=this;return a;function a(c){return Se(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):n(c)}function o(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}function GE(e,t,n){return s;function s(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Aa,t,n)}}const ZE={name:"htmlText",tokenize:QE};function QE(e,t,n){const s=this;let a,o,c;return f;function f(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),p}function p(E){return E===33?(e.consume(E),h):E===47?(e.consume(E),W):E===63?(e.consume(E),I):ui(E)?(e.consume(E),ue):n(E)}function h(E){return E===45?(e.consume(E),g):E===91?(e.consume(E),o=0,x):ui(E)?(e.consume(E),G):n(E)}function g(E){return E===45?(e.consume(E),y):n(E)}function _(E){return E===null?n(E):E===45?(e.consume(E),b):Se(E)?(c=_,j(E)):(e.consume(E),_)}function b(E){return E===45?(e.consume(E),y):_(E)}function y(E){return E===62?T(E):E===45?b(E):_(E)}function x(E){const D="CDATA[";return E===D.charCodeAt(o++)?(e.consume(E),o===D.length?k:x):n(E)}function k(E){return E===null?n(E):E===93?(e.consume(E),L):Se(E)?(c=k,j(E)):(e.consume(E),k)}function L(E){return E===93?(e.consume(E),M):k(E)}function M(E){return E===62?T(E):E===93?(e.consume(E),M):k(E)}function G(E){return E===null||E===62?T(E):Se(E)?(c=G,j(E)):(e.consume(E),G)}function I(E){return E===null?n(E):E===63?(e.consume(E),Z):Se(E)?(c=I,j(E)):(e.consume(E),I)}function Z(E){return E===62?T(E):I(E)}function W(E){return ui(E)?(e.consume(E),O):n(E)}function O(E){return E===45||ri(E)?(e.consume(E),O):te(E)}function te(E){return Se(E)?(c=te,j(E)):je(E)?(e.consume(E),te):T(E)}function ue(E){return E===45||ri(E)?(e.consume(E),ue):E===47||E===62||it(E)?_e(E):n(E)}function _e(E){return E===47?(e.consume(E),T):E===58||E===95||ui(E)?(e.consume(E),U):Se(E)?(c=_e,j(E)):je(E)?(e.consume(E),_e):T(E)}function U(E){return E===45||E===46||E===58||E===95||ri(E)?(e.consume(E),U):se(E)}function se(E){return E===61?(e.consume(E),V):Se(E)?(c=se,j(E)):je(E)?(e.consume(E),se):_e(E)}function V(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),a=E,B):Se(E)?(c=V,j(E)):je(E)?(e.consume(E),V):(e.consume(E),A)}function B(E){return E===a?(e.consume(E),a=void 0,R):E===null?n(E):Se(E)?(c=B,j(E)):(e.consume(E),B)}function A(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||it(E)?_e(E):(e.consume(E),A)}function R(E){return E===47||E===62||it(E)?_e(E):n(E)}function T(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function j(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),H}function H(E){return je(E)?Ie(e,ae,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):ae(E)}function ae(E){return e.enter("htmlTextData"),c(E)}}const qd={name:"labelEnd",resolveAll:i5,resolveTo:n5,tokenize:r5},JE={tokenize:s5},e5={tokenize:l5},t5={tokenize:a5};function i5(e){let t=-1;const n=[];for(;++t=3&&(h===null||Se(h))?(e.exit("thematicBreak"),t(h)):n(h)}function p(h){return h===a?(e.consume(h),s++,p):(e.exit("thematicBreakSequence"),je(h)?Ie(e,f,"whitespace")(h):f(h))}}const bi={continuation:{tokenize:g5},exit:y5,name:"list",tokenize:_5},p5={partial:!0,tokenize:b5},m5={partial:!0,tokenize:v5};function _5(e,t,n){const s=this,a=s.events[s.events.length-1];let o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,c=0;return f;function f(y){const x=s.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(x==="listUnordered"?!s.containerState.marker||y===s.containerState.marker:_d(y)){if(s.containerState.type||(s.containerState.type=x,e.enter(x,{_container:!0})),x==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(fu,n,h)(y):h(y);if(!s.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),p(y)}return n(y)}function p(y){return _d(y)&&++c<10?(e.consume(y),p):(!s.interrupt||c<2)&&(s.containerState.marker?y===s.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),h(y)):n(y)}function h(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||y,e.check(Aa,s.interrupt?n:g,e.attempt(p5,b,_))}function g(y){return s.containerState.initialBlankLine=!0,o++,b(y)}function _(y){return je(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),b):n(y)}function b(y){return s.containerState.size=o+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function g5(e,t,n){const s=this;return s.containerState._closeFlow=void 0,e.check(Aa,a,o);function a(f){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,Ie(e,t,"listItemIndent",s.containerState.size+1)(f)}function o(f){return s.containerState.furtherBlankLines||!je(f)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,c(f)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(m5,t,c)(f))}function c(f){return s.containerState._closeFlow=!0,s.interrupt=void 0,Ie(e,e.attempt(bi,t,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function v5(e,t,n){const s=this;return Ie(e,a,"listItemIndent",s.containerState.size+1);function a(o){const c=s.events[s.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===s.containerState.size?t(o):n(o)}}function y5(e){e.exit(this.containerState.type)}function b5(e,t,n){const s=this;return Ie(e,a,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(o){const c=s.events[s.events.length-1];return!je(o)&&c&&c[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const Sy={name:"setextUnderline",resolveTo:S5,tokenize:x5};function S5(e,t){let n=e.length,s,a,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){s=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const c={type:"setextHeading",start:{...e[s][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",o?(e.splice(a,0,["enter",c,t]),e.splice(o+1,0,["exit",e[s][1],t]),e[s][1].end={...e[o][1].end}):e[s][1]=c,e.push(["exit",c,t]),e}function x5(e,t,n){const s=this;let a;return o;function o(h){let g=s.events.length,_;for(;g--;)if(s.events[g][1].type!=="lineEnding"&&s.events[g][1].type!=="linePrefix"&&s.events[g][1].type!=="content"){_=s.events[g][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||_)?(e.enter("setextHeadingLine"),a=h,c(h)):n(h)}function c(h){return e.enter("setextHeadingLineSequence"),f(h)}function f(h){return h===a?(e.consume(h),f):(e.exit("setextHeadingLineSequence"),je(h)?Ie(e,p,"lineSuffix")(h):p(h))}function p(h){return h===null||Se(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const w5={tokenize:C5};function C5(e){const t=this,n=e.attempt(Aa,s,e.attempt(this.parser.constructs.flowInitial,a,Ie(e,e.attempt(this.parser.constructs.flow,a,e.attempt(DE,a)),"linePrefix")));return n;function s(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const k5={resolveAll:yS()},E5=vS("string"),T5=vS("text");function vS(e){return{resolveAll:yS(e==="text"?A5:void 0),tokenize:t};function t(n){const s=this,a=this.parser.constructs[e],o=n.attempt(a,c,f);return c;function c(g){return h(g)?o(g):f(g)}function f(g){if(g===null){n.consume(g);return}return n.enter("data"),n.consume(g),p}function p(g){return h(g)?(n.exit("data"),o(g)):(n.consume(g),p)}function h(g){if(g===null)return!0;const _=a[g];let b=-1;if(_)for(;++b<_.length;){const y=_[b];if(!y.previous||y.previous.call(s,s.previous))return!0}return!1}}}function yS(e){return t;function t(n,s){let a=-1,o;for(;++a<=n.length;)o===void 0?n[a]&&n[a][1].type==="data"&&(o=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==o+2&&(n[o][1].end=n[a-1][1].end,n.splice(o+2,a-o-2),a=o+2),o=void 0);return e?e(n,s):n}}function A5(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const s=e[n-1][1],a=t.sliceStream(s);let o=a.length,c=-1,f=0,p;for(;o--;){const h=a[o];if(typeof h=="string"){for(c=h.length;h.charCodeAt(c-1)===32;)f++,c--;if(c)break;c=-1}else if(h===-2)p=!0,f++;else if(h!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(f=0),f){const h={type:n===e.length||p||f<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?c:s.start._bufferIndex+c,_index:s.start._index+o,line:s.end.line,column:s.end.column-f,offset:s.end.offset-f},end:{...s.end}};s.end={...h.start},s.start.offset===s.end.offset?Object.assign(s,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const D5={42:bi,43:bi,45:bi,48:bi,49:bi,50:bi,51:bi,52:bi,53:bi,54:bi,55:bi,56:bi,57:bi,62:hS},R5={91:LE},M5={[-2]:df,[-1]:df,32:df},B5={35:UE,42:fu,45:[Sy,fu],60:WE,61:Sy,95:fu,96:yy,126:yy},N5={38:dS,92:fS},L5={[-5]:pf,[-4]:pf,[-3]:pf,33:o5,38:dS,42:gd,60:[cE,ZE],91:c5,92:[HE,fS],93:qd,95:gd,96:wE},z5={null:[gd,k5]},O5={null:[42,95]},j5={null:[]},H5=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:O5,contentInitial:R5,disable:j5,document:D5,flow:B5,flowInitial:M5,insideSpan:z5,string:N5,text:L5},Symbol.toStringTag,{value:"Module"}));function P5(e,t,n){let s={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},o=[];let c=[],f=[];const p={attempt:te(W),check:te(O),consume:G,enter:I,exit:Z,interrupt:te(O,{interrupt:!0})},h={code:null,containerState:{},defineSkip:k,events:[],now:x,parser:e,previous:null,sliceSerialize:b,sliceStream:y,write:_};let g=t.tokenize.call(h,p);return t.resolveAll&&o.push(t),h;function _(se){return c=Ki(c,se),L(),c[c.length-1]!==null?[]:(ue(t,0),h.events=Au(o,h.events,h),h.events)}function b(se,V){return I5(y(se),V)}function y(se){return U5(c,se)}function x(){const{_bufferIndex:se,_index:V,line:B,column:A,offset:R}=s;return{_bufferIndex:se,_index:V,line:B,column:A,offset:R}}function k(se){a[se.line]=se.column,U()}function L(){let se;for(;s._index-1){const f=c[0];typeof f=="string"?c[0]=f.slice(s):c.shift()}o>0&&c.push(e[a].slice(0,o))}return c}function I5(e,t){let n=-1;const s=[];let a;for(;++n0){const st=ce.tokenStack[ce.tokenStack.length-1];(st[1]||wy).call(ce,void 0,st[0])}for(X.position={start:yr(te.length>0?te[0][1].start:{line:1,column:1,offset:0}),end:yr(te.length>0?te[te.length-2][1].end:{line:1,column:1,offset:0})},Ce=-1;++Ce0){const Te=be.tokenStack[be.tokenStack.length-1];(Te[1]||wy).call(be,void 0,Te[0])}for(ce.position={start:yr(ee.length>0?ee[0][1].start:{line:1,column:1,offset:0}),end:yr(ee.length>0?ee[ee.length-2][1].end:{line:1,column:1,offset:0})},me=-1;++me0&&(s.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:s,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function tT(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function iT(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nT(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),a=rl(s.toLowerCase()),o=e.footnoteOrder.indexOf(s);let c,f=e.footnoteCounts.get(s);f===void 0?(f=0,e.footnoteOrder.push(s),c=e.footnoteOrder.length):c=o+1,f+=1,e.footnoteCounts.set(s,f);const p={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(f>1?"-"+f:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};e.patch(t,p);const h={type:"element",tagName:"sup",properties:{},children:[p]};return e.patch(t,h),e.applyData(t,h)}function rT(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function sT(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function xS(e,t){const n=t.referenceType;let s="]";if(n==="collapsed"?s+="[]":n==="full"&&(s+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+s}];const a=e.all(t),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const c=a[a.length-1];return c&&c.type==="text"?c.value+=s:a.push({type:"text",value:s}),a}function lT(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return xS(e,t);const a={src:rl(s.url||""),alt:t.alt};s.title!==null&&s.title!==void 0&&(a.title=s.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)}function aT(e,t){const n={src:rl(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,s),e.applyData(t,s)}function oT(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const s={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,s),e.applyData(t,s)}function uT(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return xS(e,t);const a={href:rl(s.url||"")};s.title!==null&&s.title!==void 0&&(a.title=s.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function cT(e,t){const n={href:rl(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function hT(e,t,n){const s=e.all(t),a=n?fT(n):wS(t),o={},c=[];if(typeof t.checked=="boolean"){const g=s[0];let _;g&&g.type==="element"&&g.tagName==="p"?_=g:(_={type:"element",tagName:"p",properties:{},children:[]},s.unshift(_)),_.children.length>0&&_.children.unshift({type:"text",value:" "}),_.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let f=-1;for(;++f0&&(s.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:s,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function tT(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function iT(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nT(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),a=nl(s.toLowerCase()),o=e.footnoteOrder.indexOf(s);let c,f=e.footnoteCounts.get(s);f===void 0?(f=0,e.footnoteOrder.push(s),c=e.footnoteOrder.length):c=o+1,f+=1,e.footnoteCounts.set(s,f);const p={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(f>1?"-"+f:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};e.patch(t,p);const h={type:"element",tagName:"sup",properties:{},children:[p]};return e.patch(t,h),e.applyData(t,h)}function rT(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function sT(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function xS(e,t){const n=t.referenceType;let s="]";if(n==="collapsed"?s+="[]":n==="full"&&(s+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+s}];const a=e.all(t),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const c=a[a.length-1];return c&&c.type==="text"?c.value+=s:a.push({type:"text",value:s}),a}function lT(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return xS(e,t);const a={src:nl(s.url||""),alt:t.alt};s.title!==null&&s.title!==void 0&&(a.title=s.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)}function aT(e,t){const n={src:nl(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,s),e.applyData(t,s)}function oT(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const s={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,s),e.applyData(t,s)}function uT(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return xS(e,t);const a={href:nl(s.url||"")};s.title!==null&&s.title!==void 0&&(a.title=s.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function cT(e,t){const n={href:nl(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function hT(e,t,n){const s=e.all(t),a=n?fT(n):wS(t),o={},c=[];if(typeof t.checked=="boolean"){const g=s[0];let _;g&&g.type==="element"&&g.tagName==="p"?_=g:(_={type:"element",tagName:"p",properties:{},children:[]},s.unshift(_)),_.children.length>0&&_.children.unshift({type:"text",value:" "}),_.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let f=-1;for(;++f1}function dT(e,t){const n={},s=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++a0){const c={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},f=jd(t.children[1]),p=tS(t.children[t.children.length-1]);f&&p&&(c.position={start:f,end:p}),a.push(c)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,o),e.applyData(t,o)}function vT(e,t,n){const s=n?n.children:void 0,o=(s?s.indexOf(t):1)===0?"th":"td",c=n&&n.type==="table"?n.align:void 0,f=c?c.length:t.children.length;let p=-1;const h=[];for(;++p0,!0),s[0]),a=s.index+s[0].length,s=n.exec(t);return o.push(Ey(t.slice(a),a>0,!1)),o.join("")}function Ey(e,t,n){let s=0,a=e.length;if(t){let o=e.codePointAt(s);for(;o===Cy||o===ky;)s++,o=e.codePointAt(s)}if(n){let o=e.codePointAt(a-1);for(;o===Cy||o===ky;)a--,o=e.codePointAt(a-1)}return a>s?e.slice(s,a):""}function ST(e,t){const n={type:"text",value:bT(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function xT(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const wT={blockquote:Q5,break:J5,code:eT,delete:tT,emphasis:iT,footnoteReference:nT,heading:rT,html:sT,imageReference:lT,image:aT,inlineCode:oT,linkReference:uT,link:cT,listItem:hT,list:dT,paragraph:pT,root:mT,strong:_T,table:gT,tableCell:yT,tableRow:vT,text:ST,thematicBreak:xT,toml:tu,yaml:tu,definition:tu,footnoteDefinition:tu};function tu(){}const CS=-1,Du=0,ga=1,bu=2,Wd=3,Yd=4,Vd=5,Kd=6,kS=7,ES=8,Ty=typeof self=="object"?self:globalThis,CT=(e,t)=>{const n=(a,o)=>(e.set(o,a),a),s=a=>{if(e.has(a))return e.get(a);const[o,c]=t[a];switch(o){case Du:case CS:return n(c,a);case ga:{const f=n([],a);for(const p of c)f.push(s(p));return f}case bu:{const f=n({},a);for(const[p,h]of c)f[s(p)]=s(h);return f}case Wd:return n(new Date(c),a);case Yd:{const{source:f,flags:p}=c;return n(new RegExp(f,p),a)}case Vd:{const f=n(new Map,a);for(const[p,h]of c)f.set(s(p),s(h));return f}case Kd:{const f=n(new Set,a);for(const p of c)f.add(s(p));return f}case kS:{const{name:f,message:p}=c;return n(new Ty[f](p),a)}case ES:return n(BigInt(c),a);case"BigInt":return n(Object(BigInt(c)),a);case"ArrayBuffer":return n(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:f}=new Uint8Array(c);return n(new DataView(f),c)}}return n(new Ty[o](c),a)};return s},Ay=e=>CT(new Map,e)(0),Ks="",{toString:kT}={},{keys:ET}=Object,oa=e=>{const t=typeof e;if(t!=="object"||!e)return[Du,t];const n=kT.call(e).slice(8,-1);switch(n){case"Array":return[ga,Ks];case"Object":return[bu,Ks];case"Date":return[Wd,Ks];case"RegExp":return[Yd,Ks];case"Map":return[Vd,Ks];case"Set":return[Kd,Ks];case"DataView":return[ga,n]}return n.includes("Array")?[ga,n]:n.includes("Error")?[kS,n]:[bu,n]},iu=([e,t])=>e===Du&&(t==="function"||t==="symbol"),TT=(e,t,n,s)=>{const a=(c,f)=>{const p=s.push(c)-1;return n.set(f,p),p},o=c=>{if(n.has(c))return n.get(c);let[f,p]=oa(c);switch(f){case Du:{let g=c;switch(p){case"bigint":f=ES,g=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+p);g=null;break;case"undefined":return a([CS],c)}return a([f,g],c)}case ga:{if(p){let b=c;return p==="DataView"?b=new Uint8Array(c.buffer):p==="ArrayBuffer"&&(b=new Uint8Array(c)),a([p,[...b]],c)}const g=[],_=a([f,g],c);for(const b of c)g.push(o(b));return _}case bu:{if(p)switch(p){case"BigInt":return a([p,c.toString()],c);case"Boolean":case"Number":case"String":return a([p,c.valueOf()],c)}if(t&&"toJSON"in c)return o(c.toJSON());const g=[],_=a([f,g],c);for(const b of ET(c))(e||!iu(oa(c[b])))&&g.push([o(b),o(c[b])]);return _}case Wd:return a([f,c.toISOString()],c);case Yd:{const{source:g,flags:_}=c;return a([f,{source:g,flags:_}],c)}case Vd:{const g=[],_=a([f,g],c);for(const[b,y]of c)(e||!(iu(oa(b))||iu(oa(y))))&&g.push([o(b),o(y)]);return _}case Kd:{const g=[],_=a([f,g],c);for(const b of c)(e||!iu(oa(b)))&&g.push(o(b));return _}}const{message:h}=c;return a([f,{name:p,message:h}],c)};return o},Dy=(e,{json:t,lossy:n}={})=>{const s=[];return TT(!(t||n),!!t,new Map,s)(e),s},xa=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Ay(Dy(e,t)):structuredClone(e):(e,t)=>Ay(Dy(e,t));function AT(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function DT(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function RT(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||AT,s=e.options.footnoteBackLabel||DT,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",c=e.options.footnoteLabelProperties||{className:["sr-only"]},f=[];let p=-1;for(;++p0&&x.push({type:"text",value:" "});let Z=typeof n=="string"?n:n(p,y);typeof Z=="string"&&(Z={type:"text",value:Z}),x.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+b+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof s=="string"?s:s(p,y),className:["data-footnote-backref"]},children:Array.isArray(Z)?Z:[Z]})}const L=g[g.length-1];if(L&&L.type==="element"&&L.tagName==="p"){const Z=L.children[L.children.length-1];Z&&Z.type==="text"?Z.value+=" ":L.children.push({type:"text",value:" "}),L.children.push(...x)}else g.push(...x);const M={type:"element",tagName:"li",properties:{id:t+"fn-"+b},children:e.wrap(g,!0)};e.patch(h,M),f.push(M)}if(f.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...xa(c),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:` +`});const h={type:"element",tagName:"li",properties:o,children:c};return e.patch(t,h),e.applyData(t,h)}function fT(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let s=-1;for(;!t&&++s1}function dT(e,t){const n={},s=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++a0){const c={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},f=jd(t.children[1]),p=tS(t.children[t.children.length-1]);f&&p&&(c.position={start:f,end:p}),a.push(c)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,o),e.applyData(t,o)}function vT(e,t,n){const s=n?n.children:void 0,o=(s?s.indexOf(t):1)===0?"th":"td",c=n&&n.type==="table"?n.align:void 0,f=c?c.length:t.children.length;let p=-1;const h=[];for(;++p0,!0),s[0]),a=s.index+s[0].length,s=n.exec(t);return o.push(Ey(t.slice(a),a>0,!1)),o.join("")}function Ey(e,t,n){let s=0,a=e.length;if(t){let o=e.codePointAt(s);for(;o===Cy||o===ky;)s++,o=e.codePointAt(s)}if(n){let o=e.codePointAt(a-1);for(;o===Cy||o===ky;)a--,o=e.codePointAt(a-1)}return a>s?e.slice(s,a):""}function ST(e,t){const n={type:"text",value:bT(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function xT(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const wT={blockquote:Q5,break:J5,code:eT,delete:tT,emphasis:iT,footnoteReference:nT,heading:rT,html:sT,imageReference:lT,image:aT,inlineCode:oT,linkReference:uT,link:cT,listItem:hT,list:dT,paragraph:pT,root:mT,strong:_T,table:gT,tableCell:yT,tableRow:vT,text:ST,thematicBreak:xT,toml:tu,yaml:tu,definition:tu,footnoteDefinition:tu};function tu(){}const CS=-1,Du=0,_a=1,bu=2,Wd=3,Yd=4,Vd=5,Kd=6,kS=7,ES=8,Ty=typeof self=="object"?self:globalThis,CT=(e,t)=>{const n=(a,o)=>(e.set(o,a),a),s=a=>{if(e.has(a))return e.get(a);const[o,c]=t[a];switch(o){case Du:case CS:return n(c,a);case _a:{const f=n([],a);for(const p of c)f.push(s(p));return f}case bu:{const f=n({},a);for(const[p,h]of c)f[s(p)]=s(h);return f}case Wd:return n(new Date(c),a);case Yd:{const{source:f,flags:p}=c;return n(new RegExp(f,p),a)}case Vd:{const f=n(new Map,a);for(const[p,h]of c)f.set(s(p),s(h));return f}case Kd:{const f=n(new Set,a);for(const p of c)f.add(s(p));return f}case kS:{const{name:f,message:p}=c;return n(new Ty[f](p),a)}case ES:return n(BigInt(c),a);case"BigInt":return n(Object(BigInt(c)),a);case"ArrayBuffer":return n(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:f}=new Uint8Array(c);return n(new DataView(f),c)}}return n(new Ty[o](c),a)};return s},Ay=e=>CT(new Map,e)(0),Vs="",{toString:kT}={},{keys:ET}=Object,aa=e=>{const t=typeof e;if(t!=="object"||!e)return[Du,t];const n=kT.call(e).slice(8,-1);switch(n){case"Array":return[_a,Vs];case"Object":return[bu,Vs];case"Date":return[Wd,Vs];case"RegExp":return[Yd,Vs];case"Map":return[Vd,Vs];case"Set":return[Kd,Vs];case"DataView":return[_a,n]}return n.includes("Array")?[_a,n]:n.includes("Error")?[kS,n]:[bu,n]},iu=([e,t])=>e===Du&&(t==="function"||t==="symbol"),TT=(e,t,n,s)=>{const a=(c,f)=>{const p=s.push(c)-1;return n.set(f,p),p},o=c=>{if(n.has(c))return n.get(c);let[f,p]=aa(c);switch(f){case Du:{let g=c;switch(p){case"bigint":f=ES,g=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+p);g=null;break;case"undefined":return a([CS],c)}return a([f,g],c)}case _a:{if(p){let b=c;return p==="DataView"?b=new Uint8Array(c.buffer):p==="ArrayBuffer"&&(b=new Uint8Array(c)),a([p,[...b]],c)}const g=[],_=a([f,g],c);for(const b of c)g.push(o(b));return _}case bu:{if(p)switch(p){case"BigInt":return a([p,c.toString()],c);case"Boolean":case"Number":case"String":return a([p,c.valueOf()],c)}if(t&&"toJSON"in c)return o(c.toJSON());const g=[],_=a([f,g],c);for(const b of ET(c))(e||!iu(aa(c[b])))&&g.push([o(b),o(c[b])]);return _}case Wd:return a([f,c.toISOString()],c);case Yd:{const{source:g,flags:_}=c;return a([f,{source:g,flags:_}],c)}case Vd:{const g=[],_=a([f,g],c);for(const[b,y]of c)(e||!(iu(aa(b))||iu(aa(y))))&&g.push([o(b),o(y)]);return _}case Kd:{const g=[],_=a([f,g],c);for(const b of c)(e||!iu(aa(b)))&&g.push(o(b));return _}}const{message:h}=c;return a([f,{name:p,message:h}],c)};return o},Dy=(e,{json:t,lossy:n}={})=>{const s=[];return TT(!(t||n),!!t,new Map,s)(e),s},Sa=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Ay(Dy(e,t)):structuredClone(e):(e,t)=>Ay(Dy(e,t));function AT(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function DT(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function RT(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||AT,s=e.options.footnoteBackLabel||DT,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",c=e.options.footnoteLabelProperties||{className:["sr-only"]},f=[];let p=-1;for(;++p0&&x.push({type:"text",value:" "});let G=typeof n=="string"?n:n(p,y);typeof G=="string"&&(G={type:"text",value:G}),x.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+b+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof s=="string"?s:s(p,y),className:["data-footnote-backref"]},children:Array.isArray(G)?G:[G]})}const L=g[g.length-1];if(L&&L.type==="element"&&L.tagName==="p"){const G=L.children[L.children.length-1];G&&G.type==="text"?G.value+=" ":L.children.push({type:"text",value:" "}),L.children.push(...x)}else g.push(...x);const M={type:"element",tagName:"li",properties:{id:t+"fn-"+b},children:e.wrap(g,!0)};e.patch(h,M),f.push(M)}if(f.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Sa(c),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:` `},{type:"element",tagName:"ol",properties:{},children:e.wrap(f,!0)},{type:"text",value:` -`}]}}const Ru=(function(e){if(e==null)return LT;if(typeof e=="function")return Mu(e);if(typeof e=="object")return Array.isArray(e)?MT(e):BT(e);if(typeof e=="string")return NT(e);throw new Error("Expected function, string, or object as test")});function MT(e){const t=[];let n=-1;for(;++n":""))+")"})}return b;function b(){let y=TS,x,k,L;if((!t||o(p,h,g[g.length-1]||void 0))&&(y=HT(n(p,g)),y[0]===vd))return y;if("children"in p&&p.children){const M=p;if(M.children&&y[0]!==jT)for(k=(s?M.children.length:-1)+c,L=g.concat(M);k>-1&&k":""))+")"})}return b;function b(){let y=TS,x,k,L;if((!t||o(p,h,g[g.length-1]||void 0))&&(y=HT(n(p,g)),y[0]===vd))return y;if("children"in p&&p.children){const M=p;if(M.children&&y[0]!==jT)for(k=(s?M.children.length:-1)+c,L=g.concat(M);k>-1&&k0&&n.push({type:"text",value:` `}),n}function Ry(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function My(e,t){const n=UT(e,t),s=n.one(e,void 0),a=RT(n),o=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return a&&o.children.push({type:"text",value:` -`},a),o}function YT(e,t){return e&&"run"in e?async function(n,s){const a=My(n,{file:s,...t});await e.run(a,s)}:function(n,s){return My(n,{file:s,...e||t})}}function By(e){if(e)throw e}var mf,Ny;function VT(){if(Ny)return mf;Ny=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},o=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var g=e.call(h,"constructor"),_=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!g&&!_)return!1;var b;for(b in h);return typeof b>"u"||e.call(h,b)},c=function(h,g){n&&g.name==="__proto__"?n(h,g.name,{enumerable:!0,configurable:!0,value:g.newValue,writable:!0}):h[g.name]=g.newValue},f=function(h,g){if(g==="__proto__")if(e.call(h,g)){if(s)return s(h,g).value}else return;return h[g]};return mf=function p(){var h,g,_,b,y,x,k=arguments[0],L=1,M=arguments.length,Z=!1;for(typeof k=="boolean"&&(Z=k,k=arguments[1]||{},L=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});Lc.length;let p;f&&c.push(a);try{p=e.apply(this,c)}catch(h){const g=h;if(f&&n)throw g;return a(g)}f||(p&&p.then&&typeof p.then=="function"?p.then(o,a):p instanceof Error?a(p):o(p))}function a(c,...f){n||(n=!0,t(c,...f))}function o(c){a(null,c)}}const un={basename:GT,dirname:ZT,extname:QT,join:JT,sep:"/"};function GT(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Ra(e);let n=0,s=-1,a=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else s<0&&(o=!0,s=a+1);return s<0?"":e.slice(n,s)}if(t===e)return"";let c=-1,f=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else c<0&&(o=!0,c=a+1),f>-1&&(e.codePointAt(a)===t.codePointAt(f--)?f<0&&(s=a):(f=-1,s=c));return n===s?s=c:s<0&&(s=e.length),e.slice(n,s)}function ZT(e){if(Ra(e),e.length===0)return".";let t=-1,n=e.length,s;for(;--n;)if(e.codePointAt(n)===47){if(s){t=n;break}}else s||(s=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function QT(e){Ra(e);let t=e.length,n=-1,s=0,a=-1,o=0,c;for(;t--;){const f=e.codePointAt(t);if(f===47){if(c){s=t+1;break}continue}n<0&&(c=!0,n=t+1),f===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||n<0||o===0||o===1&&a===n-1&&a===s+1?"":e.slice(a,n)}function JT(...e){let t=-1,n;for(;++t0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function t3(e,t){let n="",s=0,a=-1,o=0,c=-1,f,p;for(;++c<=e.length;){if(c2){if(p=n.lastIndexOf("/"),p!==n.length-1){p<0?(n="",s=0):(n=n.slice(0,p),s=n.length-1-n.lastIndexOf("/")),a=c,o=0;continue}}else if(n.length>0){n="",s=0,a=c,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",s=2)}else n.length>0?n+="/"+e.slice(a+1,c):n=e.slice(a+1,c),s=c-a-1;a=c,o=0}else f===46&&o>-1?o++:o=-1}return n}function Ra(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const i3={cwd:n3};function n3(){return"/"}function Sd(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function r3(e){if(typeof e=="string")e=new URL(e);else if(!Sd(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return s3(e)}function s3(e){if(e.hostname!==""){const s=new TypeError('File URL host must be "localhost" or empty on darwin');throw s.code="ERR_INVALID_FILE_URL_HOST",s}const t=e.pathname;let n=-1;for(;++n0){let[y,...x]=g;const k=s[b][1];bd(k)&&bd(y)&&(y=_f(!0,k,y)),s[b]=[h,y,...x]}}}}const u3=new $d().freeze();function bf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Sf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function xf(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function zy(e){if(!bd(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Oy(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function nu(e){return c3(e)?e:new DS(e)}function c3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function h3(e){return typeof e=="string"||f3(e)}function f3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const d3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",jy=[],Hy={allowDangerousHtml:!0},p3=/^(https?|ircs?|mailto|xmpp)$/i,m3=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function _3(e){const t=g3(e),n=v3(e);return y3(t.runSync(t.parse(n),n),e)}function g3(e){const t=e.rehypePlugins||jy,n=e.remarkPlugins||jy,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Hy}:Hy;return u3().use(Z5).use(n).use(YT,s).use(t)}function v3(e){const t=e.children||"",n=new DS;return typeof t=="string"&&(n.value=t),n}function y3(e,t){const n=t.allowedElements,s=t.allowElement,a=t.components,o=t.disallowedElements,c=t.skipHtml,f=t.unwrapDisallowed,p=t.urlTransform||b3;for(const g of m3)Object.hasOwn(t,g.from)&&(""+g.from+(g.to?"use `"+g.to+"` instead":"remove it")+d3+g.id,void 0);return Xd(e,h),Lk(e,{Fragment:S.Fragment,components:a,ignoreInvalidStyle:!0,jsx:S.jsx,jsxs:S.jsxs,passKeys:!0,passNode:!0});function h(g,_,b){if(g.type==="raw"&&b&&typeof _=="number")return c?b.children.splice(_,1):b.children[_]={type:"text",value:g.value},_;if(g.type==="element"){let y;for(y in ff)if(Object.hasOwn(ff,y)&&Object.hasOwn(g.properties,y)){const x=g.properties[y],k=ff[y];(k===null||k.includes(g.tagName))&&(g.properties[y]=p(String(x||""),y,g))}}if(g.type==="element"){let y=n?!n.includes(g.tagName):o?o.includes(g.tagName):!1;if(!y&&s&&typeof _=="number"&&(y=!s(g,_,b)),y&&b&&typeof _=="number")return f&&g.children?b.children.splice(_,1,...g.children):b.children.splice(_,1),_}}}function b3(e){const t=e.indexOf(":"),n=e.indexOf("?"),s=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||s!==-1&&t>s||p3.test(e.slice(0,t))?e:""}function S3(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function RS(e,t,n){const a=Ru((n||{}).ignore||[]),o=x3(t);let c=-1;for(;++c0?{type:"text",value:O}:void 0),O===!1?b.lastIndex=Q+1:(x!==Q&&Z.push({type:"text",value:h.value.slice(x,Q)}),Array.isArray(O)?Z.push(...O):O&&Z.push(O),x=Q+I[0].length,M=!0),!b.global)break;I=b.exec(h.value)}return M?(x?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],s=n.indexOf(")");const a=Py(e,"(");let o=Py(e,")");for(;s!==-1&&a>o;)e+=n.slice(0,s+1),n=n.slice(s+1),s=n.indexOf(")"),o++;return[e,n]}function MS(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||is(n)||Tu(n))&&(!t||n!==47)}BS.peek=X3;function U3(){this.buffer()}function I3(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function F3(){this.buffer()}function q3(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function W3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ji(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Y3(e){this.exit(e)}function V3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ji(this.sliceSerialize(e)).toLowerCase(),n.label=t}function K3(e){this.exit(e)}function X3(){return"["}function BS(e,t,n,s){const a=n.createTracker(s);let o=a.move("[^");const c=n.enter("footnoteReference"),f=n.enter("reference");return o+=a.move(n.safe(n.associationId(e),{after:"]",before:o})),f(),c(),o+=a.move("]"),o}function $3(){return{enter:{gfmFootnoteCallString:U3,gfmFootnoteCall:I3,gfmFootnoteDefinitionLabelString:F3,gfmFootnoteDefinition:q3},exit:{gfmFootnoteCallString:W3,gfmFootnoteCall:Y3,gfmFootnoteDefinitionLabelString:V3,gfmFootnoteDefinition:K3}}}function G3(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:BS},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(s,a,o,c){const f=o.createTracker(c);let p=f.move("[^");const h=o.enter("footnoteDefinition"),g=o.enter("label");return p+=f.move(o.safe(o.associationId(s),{before:p,after:"]"})),g(),p+=f.move("]:"),s.children&&s.children.length>0&&(f.shift(4),p+=f.move((t?` -`:" ")+o.indentLines(o.containerFlow(s,f.current()),t?NS:Z3))),h(),p}}function Z3(e,t,n){return t===0?e:NS(e,t,n)}function NS(e,t,n){return(n?"":" ")+e}const Q3=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];LS.peek=nA;function J3(){return{canContainEols:["delete"],enter:{strikethrough:tA},exit:{strikethrough:iA}}}function eA(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Q3}],handlers:{delete:LS}}}function tA(e){this.enter({type:"delete",children:[]},e)}function iA(e){this.exit(e)}function LS(e,t,n,s){const a=n.createTracker(s),o=n.enter("strikethrough");let c=a.move("~~");return c+=n.containerPhrasing(e,{...a.current(),before:c,after:"~"}),c+=a.move("~~"),o(),c}function nA(){return"~"}function rA(e){return e.length}function sA(e,t){const n=t||{},s=(n.align||[]).concat(),a=n.stringLength||rA,o=[],c=[],f=[],p=[];let h=0,g=-1;for(;++gh&&(h=e[g].length);++Mp[M])&&(p[M]=I)}k.push(Z)}c[g]=k,f[g]=L}let _=-1;if(typeof s=="object"&&"length"in s)for(;++_p[_]&&(p[_]=Z),y[_]=Z),b[_]=I}c.splice(1,0,b),f.splice(1,0,y),g=-1;const x=[];for(;++g"u"||e.call(h,b)},c=function(h,g){n&&g.name==="__proto__"?n(h,g.name,{enumerable:!0,configurable:!0,value:g.newValue,writable:!0}):h[g.name]=g.newValue},f=function(h,g){if(g==="__proto__")if(e.call(h,g)){if(s)return s(h,g).value}else return;return h[g]};return mf=function p(){var h,g,_,b,y,x,k=arguments[0],L=1,M=arguments.length,G=!1;for(typeof k=="boolean"&&(G=k,k=arguments[1]||{},L=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});Lc.length;let p;f&&c.push(a);try{p=e.apply(this,c)}catch(h){const g=h;if(f&&n)throw g;return a(g)}f||(p&&p.then&&typeof p.then=="function"?p.then(o,a):p instanceof Error?a(p):o(p))}function a(c,...f){n||(n=!0,t(c,...f))}function o(c){a(null,c)}}const un={basename:GT,dirname:ZT,extname:QT,join:JT,sep:"/"};function GT(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Da(e);let n=0,s=-1,a=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else s<0&&(o=!0,s=a+1);return s<0?"":e.slice(n,s)}if(t===e)return"";let c=-1,f=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else c<0&&(o=!0,c=a+1),f>-1&&(e.codePointAt(a)===t.codePointAt(f--)?f<0&&(s=a):(f=-1,s=c));return n===s?s=c:s<0&&(s=e.length),e.slice(n,s)}function ZT(e){if(Da(e),e.length===0)return".";let t=-1,n=e.length,s;for(;--n;)if(e.codePointAt(n)===47){if(s){t=n;break}}else s||(s=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function QT(e){Da(e);let t=e.length,n=-1,s=0,a=-1,o=0,c;for(;t--;){const f=e.codePointAt(t);if(f===47){if(c){s=t+1;break}continue}n<0&&(c=!0,n=t+1),f===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||n<0||o===0||o===1&&a===n-1&&a===s+1?"":e.slice(a,n)}function JT(...e){let t=-1,n;for(;++t0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function t3(e,t){let n="",s=0,a=-1,o=0,c=-1,f,p;for(;++c<=e.length;){if(c2){if(p=n.lastIndexOf("/"),p!==n.length-1){p<0?(n="",s=0):(n=n.slice(0,p),s=n.length-1-n.lastIndexOf("/")),a=c,o=0;continue}}else if(n.length>0){n="",s=0,a=c,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",s=2)}else n.length>0?n+="/"+e.slice(a+1,c):n=e.slice(a+1,c),s=c-a-1;a=c,o=0}else f===46&&o>-1?o++:o=-1}return n}function Da(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const i3={cwd:n3};function n3(){return"/"}function Sd(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function r3(e){if(typeof e=="string")e=new URL(e);else if(!Sd(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return s3(e)}function s3(e){if(e.hostname!==""){const s=new TypeError('File URL host must be "localhost" or empty on darwin');throw s.code="ERR_INVALID_FILE_URL_HOST",s}const t=e.pathname;let n=-1;for(;++n0){let[y,...x]=g;const k=s[b][1];bd(k)&&bd(y)&&(y=_f(!0,k,y)),s[b]=[h,y,...x]}}}}const u3=new $d().freeze();function bf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Sf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function xf(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function zy(e){if(!bd(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Oy(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function nu(e){return c3(e)?e:new DS(e)}function c3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function h3(e){return typeof e=="string"||f3(e)}function f3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const d3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",jy=[],Hy={allowDangerousHtml:!0},p3=/^(https?|ircs?|mailto|xmpp)$/i,m3=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function _3(e){const t=g3(e),n=v3(e);return y3(t.runSync(t.parse(n),n),e)}function g3(e){const t=e.rehypePlugins||jy,n=e.remarkPlugins||jy,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Hy}:Hy;return u3().use(Z5).use(n).use(YT,s).use(t)}function v3(e){const t=e.children||"",n=new DS;return typeof t=="string"&&(n.value=t),n}function y3(e,t){const n=t.allowedElements,s=t.allowElement,a=t.components,o=t.disallowedElements,c=t.skipHtml,f=t.unwrapDisallowed,p=t.urlTransform||b3;for(const g of m3)Object.hasOwn(t,g.from)&&(""+g.from+(g.to?"use `"+g.to+"` instead":"remove it")+d3+g.id,void 0);return Xd(e,h),Lk(e,{Fragment:S.Fragment,components:a,ignoreInvalidStyle:!0,jsx:S.jsx,jsxs:S.jsxs,passKeys:!0,passNode:!0});function h(g,_,b){if(g.type==="raw"&&b&&typeof _=="number")return c?b.children.splice(_,1):b.children[_]={type:"text",value:g.value},_;if(g.type==="element"){let y;for(y in ff)if(Object.hasOwn(ff,y)&&Object.hasOwn(g.properties,y)){const x=g.properties[y],k=ff[y];(k===null||k.includes(g.tagName))&&(g.properties[y]=p(String(x||""),y,g))}}if(g.type==="element"){let y=n?!n.includes(g.tagName):o?o.includes(g.tagName):!1;if(!y&&s&&typeof _=="number"&&(y=!s(g,_,b)),y&&b&&typeof _=="number")return f&&g.children?b.children.splice(_,1,...g.children):b.children.splice(_,1),_}}}function b3(e){const t=e.indexOf(":"),n=e.indexOf("?"),s=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||s!==-1&&t>s||p3.test(e.slice(0,t))?e:""}function S3(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function RS(e,t,n){const a=Ru((n||{}).ignore||[]),o=x3(t);let c=-1;for(;++c0?{type:"text",value:O}:void 0),O===!1?b.lastIndex=Z+1:(x!==Z&&G.push({type:"text",value:h.value.slice(x,Z)}),Array.isArray(O)?G.push(...O):O&&G.push(O),x=Z+I[0].length,M=!0),!b.global)break;I=b.exec(h.value)}return M?(x?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],s=n.indexOf(")");const a=Py(e,"(");let o=Py(e,")");for(;s!==-1&&a>o;)e+=n.slice(0,s+1),n=n.slice(s+1),s=n.indexOf(")"),o++;return[e,n]}function MS(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||ts(n)||Tu(n))&&(!t||n!==47)}BS.peek=X3;function U3(){this.buffer()}function I3(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function F3(){this.buffer()}function q3(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function W3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=en(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Y3(e){this.exit(e)}function V3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=en(this.sliceSerialize(e)).toLowerCase(),n.label=t}function K3(e){this.exit(e)}function X3(){return"["}function BS(e,t,n,s){const a=n.createTracker(s);let o=a.move("[^");const c=n.enter("footnoteReference"),f=n.enter("reference");return o+=a.move(n.safe(n.associationId(e),{after:"]",before:o})),f(),c(),o+=a.move("]"),o}function $3(){return{enter:{gfmFootnoteCallString:U3,gfmFootnoteCall:I3,gfmFootnoteDefinitionLabelString:F3,gfmFootnoteDefinition:q3},exit:{gfmFootnoteCallString:W3,gfmFootnoteCall:Y3,gfmFootnoteDefinitionLabelString:V3,gfmFootnoteDefinition:K3}}}function G3(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:BS},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(s,a,o,c){const f=o.createTracker(c);let p=f.move("[^");const h=o.enter("footnoteDefinition"),g=o.enter("label");return p+=f.move(o.safe(o.associationId(s),{before:p,after:"]"})),g(),p+=f.move("]:"),s.children&&s.children.length>0&&(f.shift(4),p+=f.move((t?` +`:" ")+o.indentLines(o.containerFlow(s,f.current()),t?NS:Z3))),h(),p}}function Z3(e,t,n){return t===0?e:NS(e,t,n)}function NS(e,t,n){return(n?"":" ")+e}const Q3=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];LS.peek=nA;function J3(){return{canContainEols:["delete"],enter:{strikethrough:tA},exit:{strikethrough:iA}}}function eA(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Q3}],handlers:{delete:LS}}}function tA(e){this.enter({type:"delete",children:[]},e)}function iA(e){this.exit(e)}function LS(e,t,n,s){const a=n.createTracker(s),o=n.enter("strikethrough");let c=a.move("~~");return c+=n.containerPhrasing(e,{...a.current(),before:c,after:"~"}),c+=a.move("~~"),o(),c}function nA(){return"~"}function rA(e){return e.length}function sA(e,t){const n=t||{},s=(n.align||[]).concat(),a=n.stringLength||rA,o=[],c=[],f=[],p=[];let h=0,g=-1;for(;++gh&&(h=e[g].length);++Mp[M])&&(p[M]=I)}k.push(G)}c[g]=k,f[g]=L}let _=-1;if(typeof s=="object"&&"length"in s)for(;++_p[_]&&(p[_]=G),y[_]=G),b[_]=I}c.splice(1,0,b),f.splice(1,0,y),g=-1;const x=[];for(;++g "),o.shift(2);const c=n.indentLines(n.containerFlow(e,o.current()),oA);return a(),c}function oA(e,t,n){return">"+(n?"":" ")+e}function uA(e,t){return Iy(e,t.inConstruct,!0)&&!Iy(e,t.notInConstruct,!1)}function Iy(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let s=-1;for(;++sc&&(c=o):o=1,a=s+t.length,s=n.indexOf(t,a);return c}function hA(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function fA(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function dA(e,t,n,s){const a=fA(n),o=e.value||"",c=a==="`"?"GraveAccent":"Tilde";if(hA(e,n)){const _=n.enter("codeIndented"),b=n.indentLines(o,pA);return _(),b}const f=n.createTracker(s),p=a.repeat(Math.max(cA(o,a)+1,3)),h=n.enter("codeFenced");let g=f.move(p);if(e.lang){const _=n.enter(`codeFencedLang${c}`);g+=f.move(n.safe(e.lang,{before:g,after:" ",encode:["`"],...f.current()})),_()}if(e.lang&&e.meta){const _=n.enter(`codeFencedMeta${c}`);g+=f.move(" "),g+=f.move(n.safe(e.meta,{before:g,after:` `,encode:["`"],...f.current()})),_()}return g+=f.move(` `),o&&(g+=f.move(o+` `)),g+=f.move(p),h(),g}function pA(e,t,n){return(n?"":" ")+e}function Gd(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function mA(e,t,n,s){const a=Gd(n),o=a==='"'?"Quote":"Apostrophe",c=n.enter("definition");let f=n.enter("label");const p=n.createTracker(s);let h=p.move("[");return h+=p.move(n.safe(n.associationId(e),{before:h,after:"]",...p.current()})),h+=p.move("]: "),f(),!e.url||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(n.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(f=n.enter("destinationRaw"),h+=p.move(n.safe(e.url,{before:h,after:e.title?" ":` -`,...p.current()}))),f(),e.title&&(f=n.enter(`title${o}`),h+=p.move(" "+a),h+=p.move(n.safe(e.title,{before:h,after:a,...p.current()})),h+=p.move(a),f()),c(),h}function _A(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function wa(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Su(e,t,n){const s=el(e),a=el(t);return s===void 0?a===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:s===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}zS.peek=gA;function zS(e,t,n,s){const a=_A(n),o=n.enter("emphasis"),c=n.createTracker(s),f=c.move(a);let p=c.move(n.containerPhrasing(e,{after:a,before:f,...c.current()}));const h=p.charCodeAt(0),g=Su(s.before.charCodeAt(s.before.length-1),h,a);g.inside&&(p=wa(h)+p.slice(1));const _=p.charCodeAt(p.length-1),b=Su(s.after.charCodeAt(0),_,a);b.inside&&(p=p.slice(0,-1)+wa(_));const y=c.move(a);return o(),n.attentionEncodeSurroundingInfo={after:b.outside,before:g.outside},f+p+y}function gA(e,t,n){return n.options.emphasis||"*"}function vA(e,t){let n=!1;return Xd(e,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return n=!0,vd}),!!((!e.depth||e.depth<3)&&Id(e)&&(t.options.setext||n))}function yA(e,t,n,s){const a=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(s);if(vA(e,n)){const g=n.enter("headingSetext"),_=n.enter("phrasing"),b=n.containerPhrasing(e,{...o.current(),before:` +`,...p.current()}))),f(),e.title&&(f=n.enter(`title${o}`),h+=p.move(" "+a),h+=p.move(n.safe(e.title,{before:h,after:a,...p.current()})),h+=p.move(a),f()),c(),h}function _A(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function xa(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Su(e,t,n){const s=Js(e),a=Js(t);return s===void 0?a===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:s===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}zS.peek=gA;function zS(e,t,n,s){const a=_A(n),o=n.enter("emphasis"),c=n.createTracker(s),f=c.move(a);let p=c.move(n.containerPhrasing(e,{after:a,before:f,...c.current()}));const h=p.charCodeAt(0),g=Su(s.before.charCodeAt(s.before.length-1),h,a);g.inside&&(p=xa(h)+p.slice(1));const _=p.charCodeAt(p.length-1),b=Su(s.after.charCodeAt(0),_,a);b.inside&&(p=p.slice(0,-1)+xa(_));const y=c.move(a);return o(),n.attentionEncodeSurroundingInfo={after:b.outside,before:g.outside},f+p+y}function gA(e,t,n){return n.options.emphasis||"*"}function vA(e,t){let n=!1;return Xd(e,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return n=!0,vd}),!!((!e.depth||e.depth<3)&&Id(e)&&(t.options.setext||n))}function yA(e,t,n,s){const a=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(s);if(vA(e,n)){const g=n.enter("headingSetext"),_=n.enter("phrasing"),b=n.containerPhrasing(e,{...o.current(),before:` `,after:` `});return _(),g(),b+` `+(a===1?"=":"-").repeat(b.length-(Math.max(b.lastIndexOf("\r"),b.lastIndexOf(` `))+1))}const c="#".repeat(a),f=n.enter("headingAtx"),p=n.enter("phrasing");o.move(c+" ");let h=n.containerPhrasing(e,{before:"# ",after:` -`,...o.current()});return/^[\t ]/.test(h)&&(h=wa(h.charCodeAt(0))+h.slice(1)),h=h?c+" "+h:c,n.options.closeAtx&&(h+=" "+c),p(),f(),h}OS.peek=bA;function OS(e){return e.value||""}function bA(){return"<"}jS.peek=SA;function jS(e,t,n,s){const a=Gd(n),o=a==='"'?"Quote":"Apostrophe",c=n.enter("image");let f=n.enter("label");const p=n.createTracker(s);let h=p.move("![");return h+=p.move(n.safe(e.alt,{before:h,after:"]",...p.current()})),h+=p.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(n.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(f=n.enter("destinationRaw"),h+=p.move(n.safe(e.url,{before:h,after:e.title?" ":")",...p.current()}))),f(),e.title&&(f=n.enter(`title${o}`),h+=p.move(" "+a),h+=p.move(n.safe(e.title,{before:h,after:a,...p.current()})),h+=p.move(a),f()),h+=p.move(")"),c(),h}function SA(){return"!"}HS.peek=xA;function HS(e,t,n,s){const a=e.referenceType,o=n.enter("imageReference");let c=n.enter("label");const f=n.createTracker(s);let p=f.move("![");const h=n.safe(e.alt,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),c();const g=n.stack;n.stack=[],c=n.enter("reference");const _=n.safe(n.associationId(e),{before:p,after:"]",...f.current()});return c(),n.stack=g,o(),a==="full"||!h||h!==_?p+=f.move(_+"]"):a==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function xA(){return"!"}PS.peek=wA;function PS(e,t,n){let s=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(s);)a+="`";for(/[^ \r\n]/.test(s)&&(/^[ \r\n]/.test(s)&&/[ \r\n]$/.test(s)||/^`|`$/.test(s))&&(s=" "+s+" ");++o\u007F]/.test(e.url))}IS.peek=CA;function IS(e,t,n,s){const a=Gd(n),o=a==='"'?"Quote":"Apostrophe",c=n.createTracker(s);let f,p;if(US(e,n)){const g=n.stack;n.stack=[],f=n.enter("autolink");let _=c.move("<");return _+=c.move(n.containerPhrasing(e,{before:_,after:">",...c.current()})),_+=c.move(">"),f(),n.stack=g,_}f=n.enter("link"),p=n.enter("label");let h=c.move("[");return h+=c.move(n.containerPhrasing(e,{before:h,after:"](",...c.current()})),h+=c.move("]("),p(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(p=n.enter("destinationLiteral"),h+=c.move("<"),h+=c.move(n.safe(e.url,{before:h,after:">",...c.current()})),h+=c.move(">")):(p=n.enter("destinationRaw"),h+=c.move(n.safe(e.url,{before:h,after:e.title?" ":")",...c.current()}))),p(),e.title&&(p=n.enter(`title${o}`),h+=c.move(" "+a),h+=c.move(n.safe(e.title,{before:h,after:a,...c.current()})),h+=c.move(a),p()),h+=c.move(")"),f(),h}function CA(e,t,n){return US(e,n)?"<":"["}FS.peek=kA;function FS(e,t,n,s){const a=e.referenceType,o=n.enter("linkReference");let c=n.enter("label");const f=n.createTracker(s);let p=f.move("[");const h=n.containerPhrasing(e,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),c();const g=n.stack;n.stack=[],c=n.enter("reference");const _=n.safe(n.associationId(e),{before:p,after:"]",...f.current()});return c(),n.stack=g,o(),a==="full"||!h||h!==_?p+=f.move(_+"]"):a==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function kA(){return"["}function Zd(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function EA(e){const t=Zd(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function TA(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function qS(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function AA(e,t,n,s){const a=n.enter("list"),o=n.bulletCurrent;let c=e.ordered?TA(n):Zd(n);const f=e.ordered?c==="."?")":".":EA(n);let p=t&&n.bulletLastUsed?c===n.bulletLastUsed:!1;if(!e.ordered){const g=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&g&&(!g.children||!g.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(p=!0),qS(n)===c&&g){let _=-1;for(;++_-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let c=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(c=Math.ceil(c/4)*4);const f=n.createTracker(s);f.move(o+" ".repeat(c-o.length)),f.shift(c);const p=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,f.current()),g);return p(),h;function g(_,b,y){return b?(y?"":" ".repeat(c))+_:(y?o:o+" ".repeat(c-o.length))+_}}function MA(e,t,n,s){const a=n.enter("paragraph"),o=n.enter("phrasing"),c=n.containerPhrasing(e,s);return o(),a(),c}const BA=Ru(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function NA(e,t,n,s){return(e.children.some(function(c){return BA(c)})?n.containerPhrasing:n.containerFlow).call(n,e,s)}function LA(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}WS.peek=zA;function WS(e,t,n,s){const a=LA(n),o=n.enter("strong"),c=n.createTracker(s),f=c.move(a+a);let p=c.move(n.containerPhrasing(e,{after:a,before:f,...c.current()}));const h=p.charCodeAt(0),g=Su(s.before.charCodeAt(s.before.length-1),h,a);g.inside&&(p=wa(h)+p.slice(1));const _=p.charCodeAt(p.length-1),b=Su(s.after.charCodeAt(0),_,a);b.inside&&(p=p.slice(0,-1)+wa(_));const y=c.move(a+a);return o(),n.attentionEncodeSurroundingInfo={after:b.outside,before:g.outside},f+p+y}function zA(e,t,n){return n.options.strong||"*"}function OA(e,t,n,s){return n.safe(e.value,s)}function jA(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function HA(e,t,n){const s=(qS(n)+(n.options.ruleSpaces?" ":"")).repeat(jA(n));return n.options.ruleSpaces?s.slice(0,-1):s}const YS={blockquote:aA,break:Fy,code:dA,definition:mA,emphasis:zS,hardBreak:Fy,heading:yA,html:OS,image:jS,imageReference:HS,inlineCode:PS,link:IS,linkReference:FS,list:AA,listItem:RA,paragraph:MA,root:NA,strong:WS,text:OA,thematicBreak:HA};function PA(){return{enter:{table:UA,tableData:qy,tableHeader:qy,tableRow:FA},exit:{codeText:qA,table:IA,tableData:Ef,tableHeader:Ef,tableRow:Ef}}}function UA(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function IA(e){this.exit(e),this.data.inTable=void 0}function FA(e){this.enter({type:"tableRow",children:[]},e)}function Ef(e){this.exit(e)}function qy(e){this.enter({type:"tableCell",children:[]},e)}function qA(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,WA));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function WA(e,t){return t==="|"?t:e}function YA(e){const t=e||{},n=t.tableCellPadding,s=t.tablePipeAlign,a=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` -`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:b,table:c,tableCell:p,tableRow:f}};function c(y,x,k,L){return h(g(y,k,L),y.align)}function f(y,x,k,L){const M=_(y,k,L),Z=h([M]);return Z.slice(0,Z.indexOf(` -`))}function p(y,x,k,L){const M=k.enter("tableCell"),Z=k.enter("phrasing"),I=k.containerPhrasing(y,{...L,before:o,after:o});return Z(),M(),I}function h(y,x){return sA(y,{align:x,alignDelimiters:s,padding:n,stringLength:a})}function g(y,x,k){const L=y.children;let M=-1;const Z=[],I=x.enter("table");for(;++M0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const uD={tokenize:gD,partial:!0};function cD(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:pD,continuation:{tokenize:mD},exit:_D}},text:{91:{name:"gfmFootnoteCall",tokenize:dD},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:hD,resolveTo:fD}}}}function hD(e,t,n){const s=this;let a=s.events.length;const o=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let c;for(;a--;){const p=s.events[a][1];if(p.type==="labelImage"){c=p;break}if(p.type==="gfmFootnoteCall"||p.type==="labelLink"||p.type==="label"||p.type==="image"||p.type==="link")break}return f;function f(p){if(!c||!c._balanced)return n(p);const h=Ji(s.sliceSerialize({start:c.end,end:s.now()}));return h.codePointAt(0)!==94||!o.includes(h.slice(1))?n(p):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),t(p))}}function fD(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const s={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},f=[e[n+1],e[n+2],["enter",s,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",c,t],["exit",c,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",s,t]];return e.splice(n,e.length-n+1,...f),e}function dD(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o=0,c;return f;function f(_){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(_),e.exit("gfmFootnoteCallLabelMarker"),p}function p(_){return _!==94?n(_):(e.enter("gfmFootnoteCallMarker"),e.consume(_),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(_){if(o>999||_===93&&!c||_===null||_===91||Qe(_))return n(_);if(_===93){e.exit("chunkString");const b=e.exit("gfmFootnoteCallString");return a.includes(Ji(s.sliceSerialize(b)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(_),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(_)}return Qe(_)||(c=!0),o++,e.consume(_),_===92?g:h}function g(_){return _===91||_===92||_===93?(e.consume(_),o++,h):h(_)}}function pD(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o,c=0,f;return p;function p(x){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(x){return x===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",g):n(x)}function g(x){if(c>999||x===93&&!f||x===null||x===91||Qe(x))return n(x);if(x===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return o=Ji(s.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),b}return Qe(x)||(f=!0),c++,e.consume(x),x===92?_:g}function _(x){return x===91||x===92||x===93?(e.consume(x),c++,g):g(x)}function b(x){return x===58?(e.enter("definitionMarker"),e.consume(x),e.exit("definitionMarker"),a.includes(o)||a.push(o),Ue(e,y,"gfmFootnoteDefinitionWhitespace")):n(x)}function y(x){return t(x)}}function mD(e,t,n){return e.check(Da,t,e.attempt(uD,t,n))}function _D(e){e.exit("gfmFootnoteDefinition")}function gD(e,t,n){const s=this;return Ue(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const c=s.events[s.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?t(o):n(o)}}function vD(e){let n=(e||{}).singleTilde;const s={name:"strikethrough",tokenize:o,resolveAll:a};return n==null&&(n=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function a(c,f){let p=-1;for(;++p1?p(x):(c.consume(x),_++,y);if(_<2&&!n)return p(x);const L=c.exit("strikethroughSequenceTemporary"),M=el(x);return L._open=!M||M===2&&!!k,L._close=!k||k===2&&!!M,f(x)}}}class yD{constructor(){this.map=[]}add(t,n,s){bD(this,t,n,s)}consume(t){if(this.map.sort(function(o,c){return o[0]-c[0]}),this.map.length===0)return;let n=this.map.length;const s=[];for(;n>0;)n-=1,s.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];s.push(t.slice()),t.length=0;let a=s.pop();for(;a;){for(const o of a)t.push(o);a=s.pop()}this.map.length=0}}function bD(e,t,n,s){let a=0;if(!(n===0&&s.length===0)){for(;a-1;){const A=s.events[le][1].type;if(A==="lineEnding"||A==="linePrefix")le--;else break}const V=le>-1?s.events[le][1].type:null,B=V==="tableHead"||V==="tableRow"?O:p;return B===O&&s.parser.lazy[s.now().line]?n(U):B(U)}function p(U){return e.enter("tableHead"),e.enter("tableRow"),h(U)}function h(U){return U===124||(c=!0,o+=1),g(U)}function g(U){return U===null?n(U):be(U)?o>1?(o=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(U),e.exit("lineEnding"),y):n(U):Oe(U)?Ue(e,g,"whitespace")(U):(o+=1,c&&(c=!1,a+=1),U===124?(e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),c=!0,g):(e.enter("data"),_(U)))}function _(U){return U===null||U===124||Qe(U)?(e.exit("data"),g(U)):(e.consume(U),U===92?b:_)}function b(U){return U===92||U===124?(e.consume(U),_):_(U)}function y(U){return s.interrupt=!1,s.parser.lazy[s.now().line]?n(U):(e.enter("tableDelimiterRow"),c=!1,Oe(U)?Ue(e,x,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(U):x(U))}function x(U){return U===45||U===58?L(U):U===124?(c=!0,e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),k):W(U)}function k(U){return Oe(U)?Ue(e,L,"whitespace")(U):L(U)}function L(U){return U===58?(o+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(U),e.exit("tableDelimiterMarker"),M):U===45?(o+=1,M(U)):U===null||be(U)?Q(U):W(U)}function M(U){return U===45?(e.enter("tableDelimiterFiller"),Z(U)):W(U)}function Z(U){return U===45?(e.consume(U),Z):U===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(U),e.exit("tableDelimiterMarker"),I):(e.exit("tableDelimiterFiller"),I(U))}function I(U){return Oe(U)?Ue(e,Q,"whitespace")(U):Q(U)}function Q(U){return U===124?x(U):U===null||be(U)?!c||a!==o?W(U):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(U)):W(U)}function W(U){return n(U)}function O(U){return e.enter("tableRow"),ie(U)}function ie(U){return U===124?(e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),ie):U===null||be(U)?(e.exit("tableRow"),t(U)):Oe(U)?Ue(e,ie,"whitespace")(U):(e.enter("data"),ue(U))}function ue(U){return U===null||U===124||Qe(U)?(e.exit("data"),ie(U)):(e.consume(U),U===92?me:ue)}function me(U){return U===92||U===124?(e.consume(U),ue):ue(U)}}function CD(e,t){let n=-1,s=!0,a=0,o=[0,0,0,0],c=[0,0,0,0],f=!1,p=0,h,g,_;const b=new yD;for(;++nn[2]+1){const x=n[2]+1,k=n[3]-n[2]-1;e.add(x,k,[])}}e.add(n[3]+1,0,[["exit",_,t]])}return a!==void 0&&(o.end=Object.assign({},Gs(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function Yy(e,t,n,s,a){const o=[],c=Gs(t.events,n);a&&(a.end=Object.assign({},c),o.push(["exit",a,t])),s.end=Object.assign({},c),o.push(["exit",s,t]),e.add(n+1,0,o)}function Gs(e,t){const n=e[t],s=n[0]==="enter"?"start":"end";return n[1][s]}const kD={name:"tasklistCheck",tokenize:TD};function ED(){return{text:{91:kD}}}function TD(e,t,n){const s=this;return a;function a(p){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?n(p):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),o)}function o(p){return Qe(p)?(e.enter("taskListCheckValueUnchecked"),e.consume(p),e.exit("taskListCheckValueUnchecked"),c):p===88||p===120?(e.enter("taskListCheckValueChecked"),e.consume(p),e.exit("taskListCheckValueChecked"),c):n(p)}function c(p){return p===93?(e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):n(p)}function f(p){return be(p)?t(p):Oe(p)?e.check({tokenize:AD},t,n)(p):n(p)}}function AD(e,t,n){return Ue(e,s,"whitespace");function s(a){return a===null?n(a):t(a)}}function DD(e){return uS([eD(),cD(),vD(e),xD(),ED()])}const RD={};function MD(e){const t=this,n=e||RD,s=t.data(),a=s.micromarkExtensions||(s.micromarkExtensions=[]),o=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),c=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);a.push(DD(n)),o.push(GA()),c.push(ZA(n))}const $r=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],Vy={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...$r,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...$r],h2:[["className","sr-only"]],img:[...$r,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...$r,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...$r],table:[...$r],ul:[...$r,["className","contains-task-list"]],"*":["abbr","accept","acceptCharset","accessKey","action","align","alt","axis","border","cellPadding","cellSpacing","char","charOff","charSet","checked","clear","colSpan","color","cols","compact","coords","dateTime","dir","encType","frame","hSpace","headers","height","hrefLang","htmlFor","id","isMap","itemProp","label","lang","maxLength","media","method","multiple","name","noHref","noShade","noWrap","open","prompt","readOnly","rev","rowSpan","rows","rules","scope","selected","shape","size","span","start","summary","tabIndex","title","useMap","vAlign","value","width"]},clobber:["ariaDescribedBy","ariaLabelledBy","id","name"],clobberPrefix:"user-content-",protocols:{cite:["http","https"],href:["http","https","irc","ircs","mailto","xmpp"],longDesc:["http","https"],src:["http","https"]},required:{input:{disabled:!0,type:"checkbox"}},strip:["script"],tagNames:["a","b","blockquote","br","code","dd","del","details","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","i","img","input","ins","kbd","li","ol","p","picture","pre","q","rp","rt","ruby","s","samp","section","source","span","strike","strong","sub","summary","sup","table","tbody","td","tfoot","th","thead","tr","tt","ul","var"]},Sr={}.hasOwnProperty;function BD(e,t){let n={type:"root",children:[]};const s={schema:t?{...Vy,...t}:Vy,stack:[]},a=e0(s,e);return a&&(Array.isArray(a)?a.length===1?n=a[0]:n.children=a:n=a),n}function e0(e,t){if(t&&typeof t=="object"){const n=t;switch(typeof n.type=="string"?n.type:""){case"comment":return ND(e,n);case"doctype":return LD(e,n);case"element":return zD(e,n);case"root":return OD(e,n);case"text":return jD(e,n)}}}function ND(e,t){if(e.schema.allowComments){const n=typeof t.value=="string"?t.value:"",s=n.indexOf("-->"),o={type:"comment",value:s<0?n:n.slice(0,s)};return Ma(o,t),o}}function LD(e,t){if(e.schema.allowDoctypes){const n={type:"doctype"};return Ma(n,t),n}}function zD(e,t){const n=typeof t.tagName=="string"?t.tagName:"";e.stack.push(n);const s=t0(e,t.children),a=HD(e,t.properties);e.stack.pop();let o=!1;if(n&&n!=="*"&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(o=!0,e.schema.ancestors&&Sr.call(e.schema.ancestors,n))){const f=e.schema.ancestors[n];let p=-1;for(o=!1;++p1){let a=!1,o=0;for(;++o-1&&o>p||c>-1&&o>c||f>-1&&o>f)return!0;let h=-1;for(;++h4&&t.slice(0,4).toLowerCase()==="data")return n}function ID(e){return function(t){return BD(t,e)}}const Xs=["Romance","Fantasy","Science Fiction","Mystery","Thriller","Horror","Adventure","Historical Fiction","Contemporary Lit","Humor","Poetry","Non-Fiction","Fanfiction","Short Story","Paranormal","Werewolf","LGBTQ+","New Adult","Teen Fiction","Diverse Lit","Others"],$s=["English","Chinese","Korean","Japanese","Spanish","French","Hindi","Arabic","Portuguese","Russian","Others"];function FD({storyName:e,fileName:t,authFetch:n,onPublish:s,publishingFile:a,walletAddress:o}){const[c,f]=G.useState(null),[p,h]=G.useState(!1),[g,_]=G.useState("preview"),[b,y]=G.useState(""),[x,k]=G.useState(!1),[L,M]=G.useState(!1),[Z,I]=G.useState(!1),[Q,W]=G.useState(null),[O,ie]=G.useState(Xs[0]),[ue,me]=G.useState($s[0]),[U,le]=G.useState(!1),V=G.useRef(null),B=G.useRef(!1),[A,R]=G.useState(!1),[T,j]=G.useState(Xs[0]),[H,ae]=G.useState($s[0]),[E,D]=G.useState(!1),[K,C]=G.useState(null),[J,fe]=G.useState(null),[de,xe]=G.useState(!1),[Ne,ke]=G.useState(null),[rt,et]=G.useState(!1),ct=G.useRef(null),we=G.useRef(null),Et=G.useCallback(async()=>{if(!e||!t){f(null);return}const X=`${e}/${t}`,ce=we.current!==X;ce&&(we.current=X);try{const _e=await n(`/api/stories/${e}/${t}`);if(_e.ok){const Ce=await _e.json();f(Ce),(ce||!B.current)&&(y(Ce.content??""),ce&&(M(!1),B.current=!1))}}catch{}},[e,t,n]);G.useEffect(()=>{h(!0),Et().finally(()=>h(!1))},[Et]),G.useEffect(()=>{if(!e||!t||g==="edit"&&L)return;const X=setInterval(Et,3e3);return()=>clearInterval(X)},[e,t,Et,g,L]),G.useEffect(()=>{if(!e)return;let X=!1;return n(`/api/stories/${e}/structure.md`).then(ce=>ce.ok?ce.json():null).then(ce=>{if(X||!(ce!=null&&ce.content))return;const _e=ce.content.match(/\*{0,2}genre\*{0,2}[:\s]+(.+)/i);if(_e){const st=_e[1].replace(/\*+/g,"").trim(),Yt=Xs.find(Tt=>Tt.toLowerCase()===st.toLowerCase());Yt&&ie(Yt)}const Ce=ce.content.match(/\*{0,2}language\*{0,2}[:\s]+(.+)/i);if(Ce){const st=Ce[1].replace(/\*+/g,"").trim(),Yt=$s.find(Tt=>Tt.toLowerCase()===st.toLowerCase());Yt&&me(Yt)}}).catch(()=>{}),()=>{X=!0}},[e,n]);const en=G.useCallback(async()=>{if(!(!e||!t)){k(!0);try{(await n(`/api/stories/${e}/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:b})})).ok&&(M(!1),B.current=!1,f(ce=>ce&&{...ce,content:b}))}catch{}k(!1)}},[e,t,n,b]),Wn=G.useCallback(X=>{var _e;const ce=(_e=X.target.files)==null?void 0:_e[0];if(ce){if(ce.size>500*1024){ke("Image exceeds 500KB limit");return}if(!ce.type.startsWith("image/")){ke("File must be an image");return}C(ce),fe(URL.createObjectURL(ce)),ke(null)}},[]),ss=G.useCallback(async()=>{if(c!=null&&c.storylineId){xe(!0),ke(null),et(!1);try{let X;if(K){const _e=new FormData;_e.append("file",K);const Ce=await n("/api/publish/upload-cover",{method:"POST",body:_e});if(!Ce.ok){const Yt=await Ce.json();throw new Error(Yt.error||"Cover upload failed")}X=(await Ce.json()).cid}const ce=await n("/api/publish/update-storyline",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storylineId:c.storylineId,...X!==void 0&&{coverCid:X},genre:T,language:H,isNsfw:E})});if(!ce.ok){const _e=await ce.json();throw new Error(_e.error||"Update failed")}et(!0),C(null),setTimeout(()=>et(!1),3e3)}catch(X){ke(X instanceof Error?X.message:"Update failed")}finally{xe(!1)}}},[c==null?void 0:c.storylineId,K,T,H,E,n]);G.useEffect(()=>{R(!1),C(null),fe(null),ke(null),et(!1)},[e,t]),G.useEffect(()=>{if(!A||!(c!=null&&c.storylineId))return;const X="https://plotlink.xyz";let ce=!1;return fetch(`${X}/api/storyline/${c.storylineId}`).then(_e=>_e.ok?_e.json():null).then(_e=>{if(!(ce||!_e)){if(_e.genre){const Ce=Xs.find(st=>st.toLowerCase()===_e.genre.toLowerCase());Ce&&j(Ce)}if(_e.language){const Ce=$s.find(st=>st.toLowerCase()===_e.language.toLowerCase());Ce&&ae(Ce)}_e.isNsfw!==void 0&&D(!!_e.isNsfw)}}).catch(()=>{}),()=>{ce=!0}},[A,c==null?void 0:c.storylineId]),G.useEffect(()=>{if(g!=="edit")return;const X=ce=>{(ce.metaKey||ce.ctrlKey)&&ce.key==="s"&&(ce.preventDefault(),en())};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[g,en]),G.useEffect(()=>{if((c==null?void 0:c.status)!=="published-not-indexed"||!c.publishedAt)return;const X=new Date(c.publishedAt).getTime(),ce=300*1e3,_e=()=>{const st=Math.max(0,ce-(Date.now()-X));W(st)};_e();const Ce=setInterval(_e,1e3);return()=>clearInterval(Ce)},[c==null?void 0:c.status,c==null?void 0:c.publishedAt]);const Er=Q!==null&&Q<=0,pn=Q!==null&&Q>0?`${Math.floor(Q/6e4)}:${String(Math.floor(Q%6e4/1e3)).padStart(2,"0")}`:null;if(!e||!t)return S.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:S.jsxs("div",{className:"text-center",children:[S.jsx("p",{className:"text-lg font-serif",children:"Select a file to preview"}),S.jsx("p",{className:"text-sm mt-1",children:"Click a story file in the sidebar"})]})});if(p&&!c)return S.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:"Loading..."});const mn=(g==="edit"?b:(c==null?void 0:c.content)??"").length,_n=t==="genesis.md",gn=t?/^plot-\d+\.md$/.test(t):!1,Wt=(c==null?void 0:c.status)==="published"||(c==null?void 0:c.status)==="published-not-indexed",vn=_n||gn?1e4:null,te=!Wt&&vn!==null&&mn>vn;return S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"border-b border-border",children:[S.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[S.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono text-muted",children:[S.jsxs("span",{children:[e,"/",t]}),(c==null?void 0:c.status)==="published"&&S.jsx("span",{className:"text-green-700 font-medium",children:"Published"}),(c==null?void 0:c.status)==="published-not-indexed"&&S.jsx("span",{className:"text-amber-700 font-medium",title:c.indexError,children:"Published (not indexed)"}),(c==null?void 0:c.status)==="pending"&&S.jsx("span",{className:"text-amber-700 font-medium",children:"Pending"})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsxs("span",{className:`text-xs font-mono ${te?"text-error font-medium":"text-muted"}`,children:[mn.toLocaleString(),vn!==null?`/${vn.toLocaleString()}`:" chars"]}),te&&S.jsxs("span",{className:"text-error text-xs font-medium",children:[(mn-vn).toLocaleString()," over limit"]})]})]}),S.jsxs("div",{className:"flex px-3 gap-1",children:[S.jsx("button",{onClick:()=>_("preview"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${g==="preview"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:"Preview"}),S.jsxs("button",{onClick:()=>_("edit"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${g==="edit"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:["Edit",L&&S.jsx("span",{className:"ml-1 text-amber-600",children:"*"})]})]})]}),g==="preview"?S.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-6 py-4",style:{background:"var(--paper-bg)"},children:c!=null&&c.content?S.jsx("div",{className:"prose max-w-none",children:S.jsx(_3,{remarkPlugins:[T3,MD],rehypePlugins:[ID],children:c.content})}):S.jsx("p",{className:"text-muted italic",children:"No content"})}):S.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",style:{background:"var(--paper-bg)"},children:[S.jsx("textarea",{ref:V,value:b,onChange:X=>{y(X.target.value),M(!0),B.current=!0},className:"flex-1 min-h-0 w-full resize-none px-4 py-3 text-sm leading-relaxed focus:outline-none",style:{fontFamily:'"Geist Mono", ui-monospace, monospace',background:"var(--paper-bg)",color:"var(--text)"},spellCheck:!1}),S.jsxs("div",{className:"px-3 py-1.5 border-t border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs text-muted",children:L?"Unsaved changes":"No changes"}),S.jsx("button",{onClick:en,disabled:!L||x,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:x?"Saving...":"Save"})]})]}),S.jsx("div",{className:"px-3 py-2 border-t border-border flex items-center justify-between",children:t==="structure.md"?S.jsx("p",{className:"text-muted text-xs italic",children:"This is your story outline — not publishable. Ask AI to write the genesis next."}):(c==null?void 0:c.status)==="published-not-indexed"?S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[S.jsx("span",{className:"text-amber-700",children:"Published on-chain but not indexed on PlotLink"}),!Er&&S.jsx("button",{onClick:async()=>{if(!(!e||!t||!c.txHash)){I(!0);try{(await(await n("/api/publish/retry-index",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:e,fileName:t,txHash:c.txHash,content:c.content,storylineId:c.storylineId})})).json()).ok&&(await n(`/api/stories/${e}/${t}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:c.txHash,storylineId:c.storylineId,contentCid:"",gasCost:""})}),Et())}catch{}I(!1)}},disabled:Z,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:Z?"Retrying...":`Retry Index${pn?` (${pn})`:""}`}),gn&&S.jsx("button",{onClick:()=>e&&t&&(s==null?void 0:s(e,t,O,ue,U)),disabled:!!a,className:"px-3 py-1 border border-border text-xs rounded hover:bg-surface disabled:opacity-50",children:a===t?"Publishing...":"Retry Publish"}),c.txHash&&S.jsx("a",{href:`https://basescan.org/tx/${c.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"})]}),S.jsx("p",{className:"text-muted text-xs",children:Er?gn?"Index window expired. Use Retry Publish to create a new on-chain tx.":"Index window expired. Contact support or re-publish manually.":gn?"Try Retry Index first (available for 5 min after publish). If that fails, Retry Publish creates a new on-chain tx.":"Retry Index is available for 5 min after publish."}),c.indexError&&S.jsx("p",{className:"text-error text-xs",children:c.indexError})]}):(c==null?void 0:c.status)==="published"?S.jsxs("div",{className:"flex flex-col gap-2",children:[S.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[S.jsx("span",{className:"text-green-700",children:"Published"}),c.storylineId&&S.jsx("a",{href:(()=>{var _e;const X=`https://plotlink.xyz/story/${c.storylineId}`;if(!gn)return X;const ce=c.plotIndex!=null&&c.plotIndex>0?c.plotIndex:parseInt(((_e=t==null?void 0:t.match(/^plot-(\d+)\.md$/))==null?void 0:_e[1])??"1");return`${X}/${ce}`})(),target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"}),c.txHash&&S.jsx("a",{href:`https://basescan.org/tx/${c.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"}),_n&&o&&c.storylineId&&(!c.authorAddress||c.authorAddress.toLowerCase()===o.toLowerCase())&&S.jsx("button",{onClick:()=>R(X=>!X),className:"px-2 py-0.5 border border-border text-xs rounded hover:bg-surface",children:A?"Close Edit":"Edit Story"})]}),A&&_n&&c.storylineId&&S.jsxs("div",{className:"border border-border rounded p-3 flex flex-col gap-3 bg-surface",children:[S.jsxs("div",{className:"flex flex-col gap-1.5",children:[S.jsx("span",{className:"text-xs font-medium text-foreground",children:"Cover Image"}),S.jsxs("div",{className:"flex items-start gap-3",children:[J&&S.jsxs("div",{className:"relative",children:[S.jsx("img",{src:J,alt:"Cover preview",className:"w-16 h-24 object-cover rounded border border-border"}),S.jsx("button",{onClick:()=>{C(null),fe(null),ct.current&&(ct.current.value="")},className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-error text-white rounded-full text-xs flex items-center justify-center",children:"x"})]}),S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsx("input",{ref:ct,type:"file",accept:"image/webp,image/jpeg,image/png",onChange:Wn,className:"text-xs"}),S.jsx("span",{className:"text-xs text-muted",children:"WebP/JPEG, max 500KB, 600x900px recommended"})]})]})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("select",{value:T,onChange:X=>j(X.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:Xs.map(X=>S.jsx("option",{value:X,children:X},X))}),S.jsx("select",{value:H,onChange:X=>ae(X.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:$s.map(X=>S.jsx("option",{value:X,children:X},X))})]}),S.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[S.jsx("input",{type:"checkbox",checked:E,onChange:X=>D(X.target.checked),className:"rounded border-border"}),"This story contains adult content (18+)"]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("button",{onClick:ss,disabled:de,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:de?"Saving...":"Save Changes"}),rt&&S.jsx("span",{className:"text-green-700 text-xs",children:"Updated!"}),Ne&&S.jsx("span",{className:"text-error text-xs",children:Ne})]})]})]}):S.jsxs("div",{className:"flex flex-col gap-2",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[_n&&S.jsxs(S.Fragment,{children:[S.jsx("select",{value:O,onChange:X=>ie(X.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:Xs.map(X=>S.jsx("option",{value:X,children:X},X))}),S.jsx("select",{value:ue,onChange:X=>me(X.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:$s.map(X=>S.jsx("option",{value:X,children:X},X))})]}),S.jsx("button",{onClick:()=>e&&t&&(s==null?void 0:s(e,t,O,ue,U)),disabled:!!a||te,className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:a===t?"Publishing...":"Publish to PlotLink"}),te&&S.jsx("span",{className:"text-error text-xs",children:"Reduce content to publish"})]}),_n&&S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[S.jsx("input",{type:"checkbox",checked:U,onChange:X=>le(X.target.checked),className:"rounded border-border"}),"This story contains adult content (18+)"]}),U&&S.jsx("span",{className:"text-xs text-amber-600",children:"Adult content will be hidden from the default browse view."})]})]})})]})}const n0="plotlink-panel-ratio",qD=.6,$y=300,Tf=224,Af=6;function WD(){try{const e=localStorage.getItem(n0);if(e){const t=parseFloat(e);if(t>0&&t<1)return t}}catch{}return qD}function Gy(e,t){if(t<=0)return e;const n=$y/t,s=1-$y/t;return n>=s?.5:Math.min(s,Math.max(n,e))}function YD({token:e,authFetch:t}){const[n,s]=G.useState(null),[a,o]=G.useState(null),[c,f]=G.useState(null),[p,h]=G.useState(""),[g,_]=G.useState(null),[b,y]=G.useState(WD),[x,k]=G.useState([]),L=G.useRef(new Set),M=G.useRef(null),Z=G.useRef(null),I=G.useRef(!1);G.useEffect(()=>{t("/api/wallet").then(A=>A.ok?A.json():null).then(A=>{A!=null&&A.address&&_(A.address)}).catch(()=>{})},[t]),G.useEffect(()=>{try{localStorage.setItem(n0,String(b))}catch{}},[b]),G.useEffect(()=>{const A=()=>{if(!Z.current)return;const R=Z.current.getBoundingClientRect().width-Tf-Af;y(T=>Gy(T,R))};return window.addEventListener("resize",A),A(),()=>window.removeEventListener("resize",A)},[]);const Q=G.useCallback(()=>{const A=`_new_${Date.now()}`;k(R=>[...R,A]),s(A),o(null)},[]);G.useEffect(()=>{if(x.length===0)return;const A=setInterval(async()=>{try{const R=await t("/api/stories");if(!R.ok)return;const T=await R.json(),j=new Set(T.stories.filter(H=>H.name!=="_example").map(H=>H.name));for(const H of j)if(!L.current.has(H)&&x.length>0){const ae=x[0];let E=!1;M.current&&(E=await M.current(ae,H).catch(()=>!1)),E&&k(D=>D.slice(1)),s(H),o(null)}L.current=j}catch{}},3e3);return()=>clearInterval(A)},[t,x]),G.useEffect(()=>{t("/api/stories").then(A=>{if(A.ok)return A.json()}).then(A=>{A!=null&&A.stories&&(L.current=new Set(A.stories.filter(R=>R.name!=="_example").map(R=>R.name)))}).catch(()=>{})},[t]);const W=G.useCallback((A,R)=>{s(A),o(R)},[]),O=G.useRef(null),ie=G.useCallback(async A=>{var R,T,j,H;O.current=A,s(A),o(null);try{const ae=await t(`/api/stories/${A}`);if(ae.ok&&O.current===A){const D=(await ae.json()).files||[],C=((R=D.map(J=>{var fe;return{file:J.file,num:(fe=J.file.match(/^plot-(\d+)\.md$/))==null?void 0:fe[1]}}).filter(J=>J.num!=null).sort((J,fe)=>parseInt(fe.num)-parseInt(J.num))[0])==null?void 0:R.file)??((T=D.find(J=>J.file==="genesis.md"))==null?void 0:T.file)??((j=D.find(J=>J.file==="structure.md"))==null?void 0:j.file)??((H=D[0])==null?void 0:H.file);C&&O.current===A&&o(C)}}catch{}},[t]),ue=G.useCallback(A=>{A.preventDefault(),I.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";const R=j=>{if(!I.current||!Z.current)return;const H=Z.current.getBoundingClientRect(),ae=H.width-Tf-Af,E=j.clientX-H.left-Tf;y(Gy(E/ae,ae))},T=()=>{I.current=!1,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",R),window.removeEventListener("mouseup",T)};window.addEventListener("mousemove",R),window.addEventListener("mouseup",T)},[]),me=G.useCallback(async(A,R,T,j,H)=>{var ae;f(R),h("Reading file...");try{const E=await t(`/api/stories/${A}/${R}`);if(!E.ok)throw new Error("Failed to read file");const D=await E.json(),K=D.content.match(/^#\s+(.+)$/m),C=K?K[1].slice(0,60):R.replace(".md","");let J;if(R.match(/^plot-\d+\.md$/)){try{const Ne=await t(`/api/stories/${A}`);if(Ne.ok){const rt=(await Ne.json()).files.find(et=>et.file==="genesis.md"&&et.storylineId);J=rt==null?void 0:rt.storylineId}}catch{}if(!J){h("Error: Publish genesis first to create the storyline"),setTimeout(()=>{f(null),h("")},3e3);return}}h("Publishing...");const fe=await t("/api/publish/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:A,fileName:R,title:C,content:D.content,genre:T,language:j,isNsfw:H,storylineId:J})});if(!fe.ok){const Ne=await fe.json();throw new Error(Ne.error||"Publish failed")}const de=(ae=fe.body)==null?void 0:ae.getReader(),xe=new TextDecoder;if(de)for(;;){const{done:Ne,value:ke}=await de.read();if(Ne)break;const et=xe.decode(ke).split(` -`).filter(ct=>ct.startsWith("data: "));for(const ct of et)try{const we=JSON.parse(ct.slice(6));we.step&&h(we.message||we.step),we.step==="done"&&we.txHash&&await t(`/api/stories/${A}/${R}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:we.txHash,storylineId:we.storylineId,plotIndex:we.plotIndex,contentCid:we.contentCid,gasCost:we.gasCost,indexError:we.indexError,authorAddress:g})})}catch{}}h("Published!")}catch(E){const D=E instanceof Error?E.message:"Publish failed";h(`Error: ${D}`)}finally{setTimeout(()=>{f(null),h("")},3e3)}},[t]),U=G.useCallback(A=>{A.startsWith("_new_")&&k(R=>R.filter(T=>T!==A))},[]),[le,V]=G.useState(new Set);G.useEffect(()=>{t("/api/stories").then(R=>R.ok?R.json():null).then(R=>{R!=null&&R.stories&&V(new Set(R.stories.filter(T=>T.hasStructure).map(T=>T.name)))}).catch(()=>{});const A=setInterval(async()=>{try{const R=await t("/api/stories");if(R.ok){const T=await R.json();V(new Set(T.stories.filter(j=>j.hasStructure).map(j=>j.name)))}}catch{}},5e3);return()=>clearInterval(A)},[t]);const B=G.useCallback(A=>{n===A&&(s(null),o(null))},[n]);return S.jsxs("div",{ref:Z,className:"h-[calc(100vh-3.5rem)] flex",children:[S.jsx("div",{className:"w-56 border-r border-border flex-shrink-0",children:S.jsx(jx,{authFetch:t,selectedStory:n,selectedFile:a,onSelectFile:W,onNewStory:Q,untitledSessions:x})}),S.jsx("div",{className:"min-w-0 border-r border-border",style:{flex:`${b} 0 0`},children:S.jsx(lk,{token:e,storyName:n,authFetch:t,onSelectStory:ie,onDestroySession:U,onArchiveStory:B,confirmedStories:le,renameRef:M})}),S.jsx("div",{onMouseDown:ue,className:"flex-shrink-0 flex items-center justify-center hover:bg-border/50 transition-colors",style:{width:Af,cursor:"col-resize",background:"var(--border)"},children:S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}})]})}),S.jsxs("div",{className:"min-w-0 flex flex-col",style:{flex:`${1-b} 0 0`},children:[S.jsx(FD,{storyName:n,fileName:a,authFetch:t,onPublish:me,publishingFile:c,walletAddress:g}),p&&S.jsx("div",{className:"px-3 py-1.5 bg-surface border-t border-border text-xs text-muted",children:p})]})]})}function VD({token:e,onComplete:t}){const[n,s]=G.useState(!1),[a,o]=G.useState(null),[c,f]=G.useState(!1),p=async()=>{s(!0),o(null);try{const h=await fetch("/api/wallet/create",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),g=await h.json();if(!h.ok)throw new Error(g.error||"Wallet creation failed");f(!0)}catch(h){o(h instanceof Error?h.message:"Wallet creation failed")}s(!1)};return G.useEffect(()=>{p()},[]),S.jsxs("div",{className:"mx-auto max-w-sm p-6 text-center",children:[S.jsx("h2",{className:"text-accent mb-1 text-lg font-bold",children:"Wallet Setup"}),S.jsx("p",{className:"text-muted mb-6 text-xs",children:"creating your OWS wallet for on-chain publishing"}),n&&S.jsx("p",{className:"text-accent text-sm",children:"creating wallet..."}),a&&S.jsxs("div",{className:"space-y-4",children:[S.jsx("div",{className:"rounded border border-red-700/30 p-3 text-xs text-red-700",children:a}),S.jsx("button",{onClick:p,className:"border-accent text-accent hover:bg-accent/10 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:"retry"})]}),c&&S.jsxs("div",{className:"space-y-4",children:[S.jsx("div",{className:"text-accent text-2xl",children:"✓"}),S.jsx("p",{className:"text-foreground text-sm font-medium",children:"wallet created"}),S.jsx("button",{onClick:t,className:"border-accent text-accent hover:bg-accent/10 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:"continue"})]})]})}function KD({token:e,onLogout:t}){const[n,s]=G.useState("home"),[a,o]=G.useState(0),c=G.useCallback(async(f,p)=>fetch(f,{...p,headers:{...(p==null?void 0:p.headers)||{},Authorization:`Bearer ${e}`}}),[e]);return G.useEffect(()=>{async function f(){try{if(!(await(await c("/api/wallet")).json()).exists){s("wallet-setup");return}const g=await c("/api/stories");if(g.ok){const _=await g.json();o(_.stories.filter(b=>b.name!=="_example").length)}}catch{}}f()},[e]),S.jsxs("div",{className:"flex h-screen flex-col",children:[S.jsxs("header",{className:"border-border flex h-14 items-center justify-between border-b px-4 flex-shrink-0",children:[S.jsxs("div",{className:"flex items-center gap-3",children:[S.jsx("button",{onClick:()=>{n!=="wallet-setup"&&s("home")},className:"flex items-center gap-2 hover:opacity-80",children:S.jsx("span",{className:"text-accent text-sm font-bold tracking-tight",children:"PlotLink OWS"})}),S.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"writer"})]}),n!=="wallet-setup"&&S.jsxs("nav",{className:"flex items-center gap-4",children:[S.jsx("button",{onClick:()=>s("stories"),className:`text-xs transition-colors ${n==="stories"?"text-accent":"text-muted hover:text-foreground"}`,children:"stories"}),S.jsx("button",{onClick:()=>s("dashboard"),className:`text-xs transition-colors ${n==="dashboard"?"text-accent":"text-muted hover:text-foreground"}`,children:"dashboard"}),S.jsx("button",{onClick:()=>s("settings"),className:`text-xs transition-colors ${n==="settings"?"text-accent":"text-muted hover:text-foreground"}`,children:"settings"}),S.jsx("button",{onClick:t,className:"text-muted hover:text-foreground text-xs transition-colors",children:"logout"})]})]}),S.jsxs("main",{className:"flex-1 min-h-0",children:[n==="home"&&S.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-8",children:[S.jsxs("div",{className:"text-center space-y-2",children:[S.jsx("h1",{className:"text-2xl font-serif text-foreground",children:"Write. Publish. Earn."}),S.jsx("p",{className:"text-muted text-sm",children:"Claude CLI writes stories. You publish them on-chain."})]}),S.jsxs("div",{className:"text-center space-y-3",children:[S.jsx("button",{onClick:()=>s("stories"),className:"bg-accent text-white hover:bg-accent-dim px-6 py-2.5 rounded text-sm font-medium transition-colors",children:"Start Writing"}),a>0&&S.jsxs("p",{className:"text-muted text-xs",children:[a," ",a===1?"story":"stories"," in progress"]})]}),S.jsxs("div",{className:"rounded border border-border p-4 space-y-2 text-xs text-muted",children:[S.jsx("p",{className:"font-medium text-foreground text-sm",children:"How it works"}),S.jsxs("ol",{className:"space-y-1.5 list-decimal list-inside",children:[S.jsxs("li",{children:["Open the ",S.jsx("strong",{children:"Stories"})," tab — Claude CLI launches in the terminal"]}),S.jsx("li",{children:"Tell Claude your story idea — it brainstorms, outlines, and writes"}),S.jsx("li",{children:"Review the live preview as Claude creates files"}),S.jsxs("li",{children:["Click ",S.jsx("strong",{children:"Publish"})," to put your story on-chain"]}),S.jsxs("li",{children:["Earn 5% royalties on every trade at ",S.jsx("a",{href:"https://plotlink.xyz",target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"plotlink.xyz"})]})]})]}),S.jsx("div",{className:"text-center",children:S.jsx("a",{href:"https://github.com/realproject7/plotlink-ows#-wallet-setup",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted hover:text-accent underline transition-colors",children:"Wallet Setup Guide"})}),S.jsx(eb,{token:e})]}),n==="stories"&&S.jsx(YD,{token:e,authFetch:c}),n==="dashboard"&&S.jsx(Lx,{token:e}),n==="wallet-setup"&&S.jsx(VD,{token:e,onComplete:()=>s("home")}),n==="settings"&&S.jsx(Bx,{token:e,onLogout:t})]})]})}function XD(){const[e,t]=G.useState(()=>localStorage.getItem("ows-token")),[n,s]=G.useState(null),[a,o]=G.useState(!0);G.useEffect(()=>{fetch("/api/auth/status").then(h=>h.json()).then(h=>s(h.configured)).catch(()=>s(null))},[]),G.useEffect(()=>{if(!e){o(!1);return}fetch("/api/auth/verify",{headers:{Authorization:`Bearer ${e}`}}).then(h=>{h.ok||(localStorage.removeItem("ows-token"),t(null))}).catch(()=>{localStorage.removeItem("ows-token"),t(null)}).finally(()=>o(!1))},[e]);const c=async h=>{try{const g=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:h})}),_=await g.json();return g.ok?(localStorage.setItem("ows-token",_.token),t(_.token),null):_.error||"Login failed"}catch{return"Cannot connect to server"}},f=async h=>{try{const g=await fetch("/api/auth/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:h})}),_=await g.json();return g.ok?(localStorage.setItem("ows-token",_.token),t(_.token),s(!0),null):_.error||"Setup failed"}catch{return"Cannot connect to server"}},p=()=>{localStorage.removeItem("ows-token"),t(null)};return a||n===null?S.jsx("div",{className:"flex h-screen items-center justify-center",children:S.jsx("span",{className:"text-muted text-sm",children:"connecting..."})}):n?e?S.jsx(KD,{token:e,onLogout:p}):S.jsx(Rx,{onLogin:c}):S.jsx(Mx,{onSetup:f})}Dx.createRoot(document.getElementById("root")).render(S.jsx(Sx.StrictMode,{children:S.jsx(XD,{})})); +`,...o.current()});return/^[\t ]/.test(h)&&(h=xa(h.charCodeAt(0))+h.slice(1)),h=h?c+" "+h:c,n.options.closeAtx&&(h+=" "+c),p(),f(),h}OS.peek=bA;function OS(e){return e.value||""}function bA(){return"<"}jS.peek=SA;function jS(e,t,n,s){const a=Gd(n),o=a==='"'?"Quote":"Apostrophe",c=n.enter("image");let f=n.enter("label");const p=n.createTracker(s);let h=p.move("![");return h+=p.move(n.safe(e.alt,{before:h,after:"]",...p.current()})),h+=p.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(n.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(f=n.enter("destinationRaw"),h+=p.move(n.safe(e.url,{before:h,after:e.title?" ":")",...p.current()}))),f(),e.title&&(f=n.enter(`title${o}`),h+=p.move(" "+a),h+=p.move(n.safe(e.title,{before:h,after:a,...p.current()})),h+=p.move(a),f()),h+=p.move(")"),c(),h}function SA(){return"!"}HS.peek=xA;function HS(e,t,n,s){const a=e.referenceType,o=n.enter("imageReference");let c=n.enter("label");const f=n.createTracker(s);let p=f.move("![");const h=n.safe(e.alt,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),c();const g=n.stack;n.stack=[],c=n.enter("reference");const _=n.safe(n.associationId(e),{before:p,after:"]",...f.current()});return c(),n.stack=g,o(),a==="full"||!h||h!==_?p+=f.move(_+"]"):a==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function xA(){return"!"}PS.peek=wA;function PS(e,t,n){let s=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(s);)a+="`";for(/[^ \r\n]/.test(s)&&(/^[ \r\n]/.test(s)&&/[ \r\n]$/.test(s)||/^`|`$/.test(s))&&(s=" "+s+" ");++o\u007F]/.test(e.url))}IS.peek=CA;function IS(e,t,n,s){const a=Gd(n),o=a==='"'?"Quote":"Apostrophe",c=n.createTracker(s);let f,p;if(US(e,n)){const g=n.stack;n.stack=[],f=n.enter("autolink");let _=c.move("<");return _+=c.move(n.containerPhrasing(e,{before:_,after:">",...c.current()})),_+=c.move(">"),f(),n.stack=g,_}f=n.enter("link"),p=n.enter("label");let h=c.move("[");return h+=c.move(n.containerPhrasing(e,{before:h,after:"](",...c.current()})),h+=c.move("]("),p(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(p=n.enter("destinationLiteral"),h+=c.move("<"),h+=c.move(n.safe(e.url,{before:h,after:">",...c.current()})),h+=c.move(">")):(p=n.enter("destinationRaw"),h+=c.move(n.safe(e.url,{before:h,after:e.title?" ":")",...c.current()}))),p(),e.title&&(p=n.enter(`title${o}`),h+=c.move(" "+a),h+=c.move(n.safe(e.title,{before:h,after:a,...c.current()})),h+=c.move(a),p()),h+=c.move(")"),f(),h}function CA(e,t,n){return US(e,n)?"<":"["}FS.peek=kA;function FS(e,t,n,s){const a=e.referenceType,o=n.enter("linkReference");let c=n.enter("label");const f=n.createTracker(s);let p=f.move("[");const h=n.containerPhrasing(e,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),c();const g=n.stack;n.stack=[],c=n.enter("reference");const _=n.safe(n.associationId(e),{before:p,after:"]",...f.current()});return c(),n.stack=g,o(),a==="full"||!h||h!==_?p+=f.move(_+"]"):a==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function kA(){return"["}function Zd(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function EA(e){const t=Zd(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function TA(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function qS(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function AA(e,t,n,s){const a=n.enter("list"),o=n.bulletCurrent;let c=e.ordered?TA(n):Zd(n);const f=e.ordered?c==="."?")":".":EA(n);let p=t&&n.bulletLastUsed?c===n.bulletLastUsed:!1;if(!e.ordered){const g=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&g&&(!g.children||!g.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(p=!0),qS(n)===c&&g){let _=-1;for(;++_-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let c=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(c=Math.ceil(c/4)*4);const f=n.createTracker(s);f.move(o+" ".repeat(c-o.length)),f.shift(c);const p=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,f.current()),g);return p(),h;function g(_,b,y){return b?(y?"":" ".repeat(c))+_:(y?o:o+" ".repeat(c-o.length))+_}}function MA(e,t,n,s){const a=n.enter("paragraph"),o=n.enter("phrasing"),c=n.containerPhrasing(e,s);return o(),a(),c}const BA=Ru(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function NA(e,t,n,s){return(e.children.some(function(c){return BA(c)})?n.containerPhrasing:n.containerFlow).call(n,e,s)}function LA(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}WS.peek=zA;function WS(e,t,n,s){const a=LA(n),o=n.enter("strong"),c=n.createTracker(s),f=c.move(a+a);let p=c.move(n.containerPhrasing(e,{after:a,before:f,...c.current()}));const h=p.charCodeAt(0),g=Su(s.before.charCodeAt(s.before.length-1),h,a);g.inside&&(p=xa(h)+p.slice(1));const _=p.charCodeAt(p.length-1),b=Su(s.after.charCodeAt(0),_,a);b.inside&&(p=p.slice(0,-1)+xa(_));const y=c.move(a+a);return o(),n.attentionEncodeSurroundingInfo={after:b.outside,before:g.outside},f+p+y}function zA(e,t,n){return n.options.strong||"*"}function OA(e,t,n,s){return n.safe(e.value,s)}function jA(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function HA(e,t,n){const s=(qS(n)+(n.options.ruleSpaces?" ":"")).repeat(jA(n));return n.options.ruleSpaces?s.slice(0,-1):s}const YS={blockquote:aA,break:Fy,code:dA,definition:mA,emphasis:zS,hardBreak:Fy,heading:yA,html:OS,image:jS,imageReference:HS,inlineCode:PS,link:IS,linkReference:FS,list:AA,listItem:RA,paragraph:MA,root:NA,strong:WS,text:OA,thematicBreak:HA};function PA(){return{enter:{table:UA,tableData:qy,tableHeader:qy,tableRow:FA},exit:{codeText:qA,table:IA,tableData:Ef,tableHeader:Ef,tableRow:Ef}}}function UA(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function IA(e){this.exit(e),this.data.inTable=void 0}function FA(e){this.enter({type:"tableRow",children:[]},e)}function Ef(e){this.exit(e)}function qy(e){this.enter({type:"tableCell",children:[]},e)}function qA(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,WA));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function WA(e,t){return t==="|"?t:e}function YA(e){const t=e||{},n=t.tableCellPadding,s=t.tablePipeAlign,a=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` +`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:b,table:c,tableCell:p,tableRow:f}};function c(y,x,k,L){return h(g(y,k,L),y.align)}function f(y,x,k,L){const M=_(y,k,L),G=h([M]);return G.slice(0,G.indexOf(` +`))}function p(y,x,k,L){const M=k.enter("tableCell"),G=k.enter("phrasing"),I=k.containerPhrasing(y,{...L,before:o,after:o});return G(),M(),I}function h(y,x){return sA(y,{align:x,alignDelimiters:s,padding:n,stringLength:a})}function g(y,x,k){const L=y.children;let M=-1;const G=[],I=x.enter("table");for(;++M0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const uD={tokenize:gD,partial:!0};function cD(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:pD,continuation:{tokenize:mD},exit:_D}},text:{91:{name:"gfmFootnoteCall",tokenize:dD},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:hD,resolveTo:fD}}}}function hD(e,t,n){const s=this;let a=s.events.length;const o=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let c;for(;a--;){const p=s.events[a][1];if(p.type==="labelImage"){c=p;break}if(p.type==="gfmFootnoteCall"||p.type==="labelLink"||p.type==="label"||p.type==="image"||p.type==="link")break}return f;function f(p){if(!c||!c._balanced)return n(p);const h=en(s.sliceSerialize({start:c.end,end:s.now()}));return h.codePointAt(0)!==94||!o.includes(h.slice(1))?n(p):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),t(p))}}function fD(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const s={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},f=[e[n+1],e[n+2],["enter",s,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",c,t],["exit",c,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",s,t]];return e.splice(n,e.length-n+1,...f),e}function dD(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o=0,c;return f;function f(_){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(_),e.exit("gfmFootnoteCallLabelMarker"),p}function p(_){return _!==94?n(_):(e.enter("gfmFootnoteCallMarker"),e.consume(_),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(_){if(o>999||_===93&&!c||_===null||_===91||it(_))return n(_);if(_===93){e.exit("chunkString");const b=e.exit("gfmFootnoteCallString");return a.includes(en(s.sliceSerialize(b)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(_),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(_)}return it(_)||(c=!0),o++,e.consume(_),_===92?g:h}function g(_){return _===91||_===92||_===93?(e.consume(_),o++,h):h(_)}}function pD(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o,c=0,f;return p;function p(x){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(x){return x===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",g):n(x)}function g(x){if(c>999||x===93&&!f||x===null||x===91||it(x))return n(x);if(x===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return o=en(s.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),b}return it(x)||(f=!0),c++,e.consume(x),x===92?_:g}function _(x){return x===91||x===92||x===93?(e.consume(x),c++,g):g(x)}function b(x){return x===58?(e.enter("definitionMarker"),e.consume(x),e.exit("definitionMarker"),a.includes(o)||a.push(o),Ie(e,y,"gfmFootnoteDefinitionWhitespace")):n(x)}function y(x){return t(x)}}function mD(e,t,n){return e.check(Aa,t,e.attempt(uD,t,n))}function _D(e){e.exit("gfmFootnoteDefinition")}function gD(e,t,n){const s=this;return Ie(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const c=s.events[s.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?t(o):n(o)}}function vD(e){let n=(e||{}).singleTilde;const s={name:"strikethrough",tokenize:o,resolveAll:a};return n==null&&(n=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function a(c,f){let p=-1;for(;++p1?p(x):(c.consume(x),_++,y);if(_<2&&!n)return p(x);const L=c.exit("strikethroughSequenceTemporary"),M=Js(x);return L._open=!M||M===2&&!!k,L._close=!k||k===2&&!!M,f(x)}}}class yD{constructor(){this.map=[]}add(t,n,s){bD(this,t,n,s)}consume(t){if(this.map.sort(function(o,c){return o[0]-c[0]}),this.map.length===0)return;let n=this.map.length;const s=[];for(;n>0;)n-=1,s.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];s.push(t.slice()),t.length=0;let a=s.pop();for(;a;){for(const o of a)t.push(o);a=s.pop()}this.map.length=0}}function bD(e,t,n,s){let a=0;if(!(n===0&&s.length===0)){for(;a-1;){const A=s.events[se][1].type;if(A==="lineEnding"||A==="linePrefix")se--;else break}const V=se>-1?s.events[se][1].type:null,B=V==="tableHead"||V==="tableRow"?O:p;return B===O&&s.parser.lazy[s.now().line]?n(U):B(U)}function p(U){return e.enter("tableHead"),e.enter("tableRow"),h(U)}function h(U){return U===124||(c=!0,o+=1),g(U)}function g(U){return U===null?n(U):Se(U)?o>1?(o=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(U),e.exit("lineEnding"),y):n(U):je(U)?Ie(e,g,"whitespace")(U):(o+=1,c&&(c=!1,a+=1),U===124?(e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),c=!0,g):(e.enter("data"),_(U)))}function _(U){return U===null||U===124||it(U)?(e.exit("data"),g(U)):(e.consume(U),U===92?b:_)}function b(U){return U===92||U===124?(e.consume(U),_):_(U)}function y(U){return s.interrupt=!1,s.parser.lazy[s.now().line]?n(U):(e.enter("tableDelimiterRow"),c=!1,je(U)?Ie(e,x,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(U):x(U))}function x(U){return U===45||U===58?L(U):U===124?(c=!0,e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),k):W(U)}function k(U){return je(U)?Ie(e,L,"whitespace")(U):L(U)}function L(U){return U===58?(o+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(U),e.exit("tableDelimiterMarker"),M):U===45?(o+=1,M(U)):U===null||Se(U)?Z(U):W(U)}function M(U){return U===45?(e.enter("tableDelimiterFiller"),G(U)):W(U)}function G(U){return U===45?(e.consume(U),G):U===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(U),e.exit("tableDelimiterMarker"),I):(e.exit("tableDelimiterFiller"),I(U))}function I(U){return je(U)?Ie(e,Z,"whitespace")(U):Z(U)}function Z(U){return U===124?x(U):U===null||Se(U)?!c||a!==o?W(U):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(U)):W(U)}function W(U){return n(U)}function O(U){return e.enter("tableRow"),te(U)}function te(U){return U===124?(e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),te):U===null||Se(U)?(e.exit("tableRow"),t(U)):je(U)?Ie(e,te,"whitespace")(U):(e.enter("data"),ue(U))}function ue(U){return U===null||U===124||it(U)?(e.exit("data"),te(U)):(e.consume(U),U===92?_e:ue)}function _e(U){return U===92||U===124?(e.consume(U),ue):ue(U)}}function CD(e,t){let n=-1,s=!0,a=0,o=[0,0,0,0],c=[0,0,0,0],f=!1,p=0,h,g,_;const b=new yD;for(;++nn[2]+1){const x=n[2]+1,k=n[3]-n[2]-1;e.add(x,k,[])}}e.add(n[3]+1,0,[["exit",_,t]])}return a!==void 0&&(o.end=Object.assign({},$s(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function Yy(e,t,n,s,a){const o=[],c=$s(t.events,n);a&&(a.end=Object.assign({},c),o.push(["exit",a,t])),s.end=Object.assign({},c),o.push(["exit",s,t]),e.add(n+1,0,o)}function $s(e,t){const n=e[t],s=n[0]==="enter"?"start":"end";return n[1][s]}const kD={name:"tasklistCheck",tokenize:TD};function ED(){return{text:{91:kD}}}function TD(e,t,n){const s=this;return a;function a(p){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?n(p):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),o)}function o(p){return it(p)?(e.enter("taskListCheckValueUnchecked"),e.consume(p),e.exit("taskListCheckValueUnchecked"),c):p===88||p===120?(e.enter("taskListCheckValueChecked"),e.consume(p),e.exit("taskListCheckValueChecked"),c):n(p)}function c(p){return p===93?(e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):n(p)}function f(p){return Se(p)?t(p):je(p)?e.check({tokenize:AD},t,n)(p):n(p)}}function AD(e,t,n){return Ie(e,s,"whitespace");function s(a){return a===null?n(a):t(a)}}function DD(e){return uS([eD(),cD(),vD(e),xD(),ED()])}const RD={};function MD(e){const t=this,n=e||RD,s=t.data(),a=s.micromarkExtensions||(s.micromarkExtensions=[]),o=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),c=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);a.push(DD(n)),o.push(GA()),c.push(ZA(n))}const Xr=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],Vy={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...Xr,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...Xr],h2:[["className","sr-only"]],img:[...Xr,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...Xr,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...Xr],table:[...Xr],ul:[...Xr,["className","contains-task-list"]],"*":["abbr","accept","acceptCharset","accessKey","action","align","alt","axis","border","cellPadding","cellSpacing","char","charOff","charSet","checked","clear","colSpan","color","cols","compact","coords","dateTime","dir","encType","frame","hSpace","headers","height","hrefLang","htmlFor","id","isMap","itemProp","label","lang","maxLength","media","method","multiple","name","noHref","noShade","noWrap","open","prompt","readOnly","rev","rowSpan","rows","rules","scope","selected","shape","size","span","start","summary","tabIndex","title","useMap","vAlign","value","width"]},clobber:["ariaDescribedBy","ariaLabelledBy","id","name"],clobberPrefix:"user-content-",protocols:{cite:["http","https"],href:["http","https","irc","ircs","mailto","xmpp"],longDesc:["http","https"],src:["http","https"]},required:{input:{disabled:!0,type:"checkbox"}},strip:["script"],tagNames:["a","b","blockquote","br","code","dd","del","details","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","i","img","input","ins","kbd","li","ol","p","picture","pre","q","rp","rt","ruby","s","samp","section","source","span","strike","strong","sub","summary","sup","table","tbody","td","tfoot","th","thead","tr","tt","ul","var"]},Sr={}.hasOwnProperty;function BD(e,t){let n={type:"root",children:[]};const s={schema:t?{...Vy,...t}:Vy,stack:[]},a=e0(s,e);return a&&(Array.isArray(a)?a.length===1?n=a[0]:n.children=a:n=a),n}function e0(e,t){if(t&&typeof t=="object"){const n=t;switch(typeof n.type=="string"?n.type:""){case"comment":return ND(e,n);case"doctype":return LD(e,n);case"element":return zD(e,n);case"root":return OD(e,n);case"text":return jD(e,n)}}}function ND(e,t){if(e.schema.allowComments){const n=typeof t.value=="string"?t.value:"",s=n.indexOf("-->"),o={type:"comment",value:s<0?n:n.slice(0,s)};return Ra(o,t),o}}function LD(e,t){if(e.schema.allowDoctypes){const n={type:"doctype"};return Ra(n,t),n}}function zD(e,t){const n=typeof t.tagName=="string"?t.tagName:"";e.stack.push(n);const s=t0(e,t.children),a=HD(e,t.properties);e.stack.pop();let o=!1;if(n&&n!=="*"&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(o=!0,e.schema.ancestors&&Sr.call(e.schema.ancestors,n))){const f=e.schema.ancestors[n];let p=-1;for(o=!1;++p1){let a=!1,o=0;for(;++o-1&&o>p||c>-1&&o>c||f>-1&&o>f)return!0;let h=-1;for(;++h4&&t.slice(0,4).toLowerCase()==="data")return n}function ID(e){return function(t){return BD(t,e)}}const Ks=["Romance","Fantasy","Science Fiction","Mystery","Thriller","Horror","Adventure","Historical Fiction","Contemporary Lit","Humor","Poetry","Non-Fiction","Fanfiction","Short Story","Paranormal","Werewolf","LGBTQ+","New Adult","Teen Fiction","Diverse Lit","Others"],Xs=["English","Chinese","Korean","Japanese","Spanish","French","Hindi","Arabic","Portuguese","Russian","Others"];function FD({storyName:e,fileName:t,authFetch:n,onPublish:s,publishingFile:a,walletAddress:o}){const[c,f]=$.useState(null),[p,h]=$.useState(!1),[g,_]=$.useState("preview"),[b,y]=$.useState(""),[x,k]=$.useState(!1),[L,M]=$.useState(!1),[G,I]=$.useState(!1),[Z,W]=$.useState(null),[O,te]=$.useState(Ks[0]),[ue,_e]=$.useState(Xs[0]),[U,se]=$.useState(!1),V=$.useRef(null),B=$.useRef(!1),[A,R]=$.useState(!1),[T,j]=$.useState(Ks[0]),[H,ae]=$.useState(Xs[0]),[E,D]=$.useState(!1),[K,C]=$.useState(null),[Q,fe]=$.useState(null),[de,Ce]=$.useState(!1),[Le,Ee]=$.useState(!1),[st,Ye]=$.useState(null),[xt,xe]=$.useState(!1),Vt=$.useRef(null),pn=$.useRef(null),Ni=$.useCallback(async()=>{if(!e||!t){f(null);return}const le=`${e}/${t}`,me=pn.current!==le;me&&(pn.current=le);try{const Te=await n(`/api/stories/${e}/${t}`);if(Te.ok){const Qe=await Te.json();f(Qe),(me||!B.current)&&(y(Qe.content??""),me&&(M(!1),B.current=!1))}}catch{}},[e,t,n]);$.useEffect(()=>{h(!0),Ni().finally(()=>h(!1))},[Ni]),$.useEffect(()=>{if(!e||!t||g==="edit"&&L)return;const le=setInterval(Ni,3e3);return()=>clearInterval(le)},[e,t,Ni,g,L]),$.useEffect(()=>{if(!e)return;let le=!1;return n(`/api/stories/${e}/structure.md`).then(me=>me.ok?me.json():null).then(me=>{if(le||!(me!=null&&me.content))return;const Te=me.content.match(/\*{0,2}genre\*{0,2}[:\s]+(.+)/i);if(Te){const nt=Te[1].replace(/\*+/g,"").trim(),Je=Ks.find(zt=>zt.toLowerCase()===nt.toLowerCase());Je&&te(Je)}const Qe=me.content.match(/\*{0,2}language\*{0,2}[:\s]+(.+)/i);if(Qe){const nt=Qe[1].replace(/\*+/g,"").trim(),Je=Xs.find(zt=>zt.toLowerCase()===nt.toLowerCase());Je&&_e(Je)}}).catch(()=>{}),()=>{le=!0}},[e,n]);const Fn=$.useCallback(async()=>{if(!(!e||!t)){k(!0);try{(await n(`/api/stories/${e}/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:b})})).ok&&(M(!1),B.current=!1,f(me=>me&&{...me,content:b}))}catch{}k(!1)}},[e,t,n,b]),rs=$.useCallback(le=>{var Te;const me=(Te=le.target.files)==null?void 0:Te[0];if(me){if(me.size>500*1024){Ye("Image exceeds 500KB limit");return}if(!me.type.startsWith("image/")){Ye("File must be an image");return}C(me),fe(URL.createObjectURL(me)),Ye(null)}},[]),qn=$.useCallback(async()=>{if(c!=null&&c.storylineId){Ce(!0),Ye(null),xe(!1);try{let le;if(K){const Te=new FormData;Te.append("file",K);const Qe=await n("/api/publish/upload-cover",{method:"POST",body:Te});if(!Qe.ok){const Je=await Qe.json();throw new Error(Je.error||"Cover upload failed")}le=(await Qe.json()).cid}const me=await n("/api/publish/update-storyline",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storylineId:c.storylineId,...le!==void 0&&{coverCid:le},genre:T,language:H,isNsfw:E})});if(!me.ok){const Te=await me.json();throw new Error(Te.error||"Update failed")}xe(!0),C(null),setTimeout(()=>xe(!1),3e3)}catch(le){Ye(le instanceof Error?le.message:"Update failed")}finally{Ce(!1)}}},[c==null?void 0:c.storylineId,K,T,H,E,n]);$.useEffect(()=>{R(!1),C(null),fe(null),Ye(null),xe(!1),Ee(!1)},[e,t]),$.useEffect(()=>{if(!A||!(c!=null&&c.storylineId))return;Ee(!1);const le="https://plotlink.xyz";let me=!1;return fetch(`${le}/api/storyline/${c.storylineId}`).then(Te=>Te.ok?Te.json():null).then(Te=>{if(!me){if(!Te){Ye("Could not load current story metadata");return}if(Te.genre){const Qe=Ks.find(nt=>nt.toLowerCase()===Te.genre.toLowerCase());Qe&&j(Qe)}if(Te.language){const Qe=Xs.find(nt=>nt.toLowerCase()===Te.language.toLowerCase());Qe&&ae(Qe)}Te.isNsfw!==void 0&&D(!!Te.isNsfw),Ee(!0)}}).catch(()=>{me||Ye("Could not load current story metadata")}),()=>{me=!0}},[A,c==null?void 0:c.storylineId]),$.useEffect(()=>{if(g!=="edit")return;const le=me=>{(me.metaKey||me.ctrlKey)&&me.key==="s"&&(me.preventDefault(),Fn())};return window.addEventListener("keydown",le),()=>window.removeEventListener("keydown",le)},[g,Fn]),$.useEffect(()=>{if((c==null?void 0:c.status)!=="published-not-indexed"||!c.publishedAt)return;const le=new Date(c.publishedAt).getTime(),me=300*1e3,Te=()=>{const nt=Math.max(0,me-(Date.now()-le));W(nt)};Te();const Qe=setInterval(Te,1e3);return()=>clearInterval(Qe)},[c==null?void 0:c.status,c==null?void 0:c.publishedAt]);const mn=Z!==null&&Z<=0,Wn=Z!==null&&Z>0?`${Math.floor(Z/6e4)}:${String(Math.floor(Z%6e4/1e3)).padStart(2,"0")}`:null;if(!e||!t)return S.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:S.jsxs("div",{className:"text-center",children:[S.jsx("p",{className:"text-lg font-serif",children:"Select a file to preview"}),S.jsx("p",{className:"text-sm mt-1",children:"Click a story file in the sidebar"})]})});if(p&&!c)return S.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:"Loading..."});const Er=(g==="edit"?b:(c==null?void 0:c.content)??"").length,vt=t==="genesis.md",_n=t?/^plot-\d+\.md$/.test(t):!1,ee=(c==null?void 0:c.status)==="published"||(c==null?void 0:c.status)==="published-not-indexed",ce=vt||_n?1e4:null,be=!ee&&ce!==null&&Er>ce;return S.jsxs("div",{className:"h-full flex flex-col",children:[S.jsxs("div",{className:"border-b border-border",children:[S.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[S.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono text-muted",children:[S.jsxs("span",{children:[e,"/",t]}),(c==null?void 0:c.status)==="published"&&S.jsx("span",{className:"text-green-700 font-medium",children:"Published"}),(c==null?void 0:c.status)==="published-not-indexed"&&S.jsx("span",{className:"text-amber-700 font-medium",title:c.indexError,children:"Published (not indexed)"}),(c==null?void 0:c.status)==="pending"&&S.jsx("span",{className:"text-amber-700 font-medium",children:"Pending"})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsxs("span",{className:`text-xs font-mono ${be?"text-error font-medium":"text-muted"}`,children:[Er.toLocaleString(),ce!==null?`/${ce.toLocaleString()}`:" chars"]}),be&&S.jsxs("span",{className:"text-error text-xs font-medium",children:[(Er-ce).toLocaleString()," over limit"]})]})]}),S.jsxs("div",{className:"flex px-3 gap-1",children:[S.jsx("button",{onClick:()=>_("preview"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${g==="preview"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:"Preview"}),S.jsxs("button",{onClick:()=>_("edit"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${g==="edit"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:["Edit",L&&S.jsx("span",{className:"ml-1 text-amber-600",children:"*"})]})]})]}),g==="preview"?S.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-6 py-4",style:{background:"var(--paper-bg)"},children:c!=null&&c.content?S.jsx("div",{className:"prose max-w-none",children:S.jsx(_3,{remarkPlugins:[T3,MD],rehypePlugins:[ID],children:c.content})}):S.jsx("p",{className:"text-muted italic",children:"No content"})}):S.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",style:{background:"var(--paper-bg)"},children:[S.jsx("textarea",{ref:V,value:b,onChange:le=>{y(le.target.value),M(!0),B.current=!0},className:"flex-1 min-h-0 w-full resize-none px-4 py-3 text-sm leading-relaxed focus:outline-none",style:{fontFamily:'"Geist Mono", ui-monospace, monospace',background:"var(--paper-bg)",color:"var(--text)"},spellCheck:!1}),S.jsxs("div",{className:"px-3 py-1.5 border-t border-border flex items-center justify-between",children:[S.jsx("span",{className:"text-xs text-muted",children:L?"Unsaved changes":"No changes"}),S.jsx("button",{onClick:Fn,disabled:!L||x,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:x?"Saving...":"Save"})]})]}),S.jsx("div",{className:"px-3 py-2 border-t border-border flex items-center justify-between",children:t==="structure.md"?S.jsx("p",{className:"text-muted text-xs italic",children:"This is your story outline — not publishable. Ask AI to write the genesis next."}):(c==null?void 0:c.status)==="published-not-indexed"?S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[S.jsx("span",{className:"text-amber-700",children:"Published on-chain but not indexed on PlotLink"}),!mn&&S.jsx("button",{onClick:async()=>{if(!(!e||!t||!c.txHash)){I(!0);try{(await(await n("/api/publish/retry-index",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:e,fileName:t,txHash:c.txHash,content:c.content,storylineId:c.storylineId})})).json()).ok&&(await n(`/api/stories/${e}/${t}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:c.txHash,storylineId:c.storylineId,contentCid:"",gasCost:""})}),Ni())}catch{}I(!1)}},disabled:G,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:G?"Retrying...":`Retry Index${Wn?` (${Wn})`:""}`}),_n&&S.jsx("button",{onClick:()=>e&&t&&(s==null?void 0:s(e,t,O,ue,U)),disabled:!!a,className:"px-3 py-1 border border-border text-xs rounded hover:bg-surface disabled:opacity-50",children:a===t?"Publishing...":"Retry Publish"}),c.txHash&&S.jsx("a",{href:`https://basescan.org/tx/${c.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"})]}),S.jsx("p",{className:"text-muted text-xs",children:mn?_n?"Index window expired. Use Retry Publish to create a new on-chain tx.":"Index window expired. Contact support or re-publish manually.":_n?"Try Retry Index first (available for 5 min after publish). If that fails, Retry Publish creates a new on-chain tx.":"Retry Index is available for 5 min after publish."}),c.indexError&&S.jsx("p",{className:"text-error text-xs",children:c.indexError})]}):(c==null?void 0:c.status)==="published"?S.jsxs("div",{className:"flex flex-col gap-2",children:[S.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[S.jsx("span",{className:"text-green-700",children:"Published"}),c.storylineId&&S.jsx("a",{href:(()=>{var Te;const le=`https://plotlink.xyz/story/${c.storylineId}`;if(!_n)return le;const me=c.plotIndex!=null&&c.plotIndex>0?c.plotIndex:parseInt(((Te=t==null?void 0:t.match(/^plot-(\d+)\.md$/))==null?void 0:Te[1])??"1");return`${le}/${me}`})(),target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"}),c.txHash&&S.jsx("a",{href:`https://basescan.org/tx/${c.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"}),vt&&o&&c.storylineId&&(!c.authorAddress||c.authorAddress.toLowerCase()===o.toLowerCase())&&S.jsx("button",{onClick:()=>R(le=>!le),className:"px-2 py-0.5 border border-border text-xs rounded hover:bg-surface",children:A?"Close Edit":"Edit Story"})]}),A&&vt&&c.storylineId&&S.jsxs("div",{className:"border border-border rounded p-3 flex flex-col gap-3 bg-surface",children:[S.jsxs("div",{className:"flex flex-col gap-1.5",children:[S.jsx("span",{className:"text-xs font-medium text-foreground",children:"Cover Image"}),S.jsxs("div",{className:"flex items-start gap-3",children:[Q&&S.jsxs("div",{className:"relative",children:[S.jsx("img",{src:Q,alt:"Cover preview",className:"w-16 h-24 object-cover rounded border border-border"}),S.jsx("button",{onClick:()=>{C(null),fe(null),Vt.current&&(Vt.current.value="")},className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-error text-white rounded-full text-xs flex items-center justify-center",children:"x"})]}),S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsx("input",{ref:Vt,type:"file",accept:"image/webp,image/jpeg,image/png",onChange:rs,className:"text-xs"}),S.jsx("span",{className:"text-xs text-muted",children:"WebP/JPEG, max 500KB, 600x900px recommended"})]})]})]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("select",{value:T,onChange:le=>j(le.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:Ks.map(le=>S.jsx("option",{value:le,children:le},le))}),S.jsx("select",{value:H,onChange:le=>ae(le.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:Xs.map(le=>S.jsx("option",{value:le,children:le},le))})]}),S.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[S.jsx("input",{type:"checkbox",checked:E,onChange:le=>D(le.target.checked),className:"rounded border-border"}),"This story contains adult content (18+)"]}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("button",{onClick:qn,disabled:de||!Le,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:de?"Saving...":Le?"Save Changes":"Loading..."}),xt&&S.jsx("span",{className:"text-green-700 text-xs",children:"Updated!"}),st&&S.jsx("span",{className:"text-error text-xs",children:st})]})]})]}):S.jsxs("div",{className:"flex flex-col gap-2",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[vt&&S.jsxs(S.Fragment,{children:[S.jsx("select",{value:O,onChange:le=>te(le.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:Ks.map(le=>S.jsx("option",{value:le,children:le},le))}),S.jsx("select",{value:ue,onChange:le=>_e(le.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:Xs.map(le=>S.jsx("option",{value:le,children:le},le))})]}),S.jsx("button",{onClick:()=>e&&t&&(s==null?void 0:s(e,t,O,ue,U)),disabled:!!a||be,className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:a===t?"Publishing...":"Publish to PlotLink"}),be&&S.jsx("span",{className:"text-error text-xs",children:"Reduce content to publish"})]}),vt&&S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[S.jsx("input",{type:"checkbox",checked:U,onChange:le=>se(le.target.checked),className:"rounded border-border"}),"This story contains adult content (18+)"]}),U&&S.jsx("span",{className:"text-xs text-amber-600",children:"Adult content will be hidden from the default browse view."})]})]})})]})}const n0="plotlink-panel-ratio",qD=.6,$y=300,Tf=224,Af=6;function WD(){try{const e=localStorage.getItem(n0);if(e){const t=parseFloat(e);if(t>0&&t<1)return t}}catch{}return qD}function Gy(e,t){if(t<=0)return e;const n=$y/t,s=1-$y/t;return n>=s?.5:Math.min(s,Math.max(n,e))}function YD({token:e,authFetch:t}){const[n,s]=$.useState(null),[a,o]=$.useState(null),[c,f]=$.useState(null),[p,h]=$.useState(""),[g,_]=$.useState(null),[b,y]=$.useState(WD),[x,k]=$.useState([]),L=$.useRef(new Set),M=$.useRef(null),G=$.useRef(null),I=$.useRef(!1);$.useEffect(()=>{t("/api/wallet").then(A=>A.ok?A.json():null).then(A=>{A!=null&&A.address&&_(A.address)}).catch(()=>{})},[t]),$.useEffect(()=>{try{localStorage.setItem(n0,String(b))}catch{}},[b]),$.useEffect(()=>{const A=()=>{if(!G.current)return;const R=G.current.getBoundingClientRect().width-Tf-Af;y(T=>Gy(T,R))};return window.addEventListener("resize",A),A(),()=>window.removeEventListener("resize",A)},[]);const Z=$.useCallback(()=>{const A=`_new_${Date.now()}`;k(R=>[...R,A]),s(A),o(null)},[]);$.useEffect(()=>{if(x.length===0)return;const A=setInterval(async()=>{try{const R=await t("/api/stories");if(!R.ok)return;const T=await R.json(),j=new Set(T.stories.filter(H=>H.name!=="_example").map(H=>H.name));for(const H of j)if(!L.current.has(H)&&x.length>0){const ae=x[0];let E=!1;M.current&&(E=await M.current(ae,H).catch(()=>!1)),E&&k(D=>D.slice(1)),s(H),o(null)}L.current=j}catch{}},3e3);return()=>clearInterval(A)},[t,x]),$.useEffect(()=>{t("/api/stories").then(A=>{if(A.ok)return A.json()}).then(A=>{A!=null&&A.stories&&(L.current=new Set(A.stories.filter(R=>R.name!=="_example").map(R=>R.name)))}).catch(()=>{})},[t]);const W=$.useCallback((A,R)=>{s(A),o(R)},[]),O=$.useRef(null),te=$.useCallback(async A=>{var R,T,j,H;O.current=A,s(A),o(null);try{const ae=await t(`/api/stories/${A}`);if(ae.ok&&O.current===A){const D=(await ae.json()).files||[],C=((R=D.map(Q=>{var fe;return{file:Q.file,num:(fe=Q.file.match(/^plot-(\d+)\.md$/))==null?void 0:fe[1]}}).filter(Q=>Q.num!=null).sort((Q,fe)=>parseInt(fe.num)-parseInt(Q.num))[0])==null?void 0:R.file)??((T=D.find(Q=>Q.file==="genesis.md"))==null?void 0:T.file)??((j=D.find(Q=>Q.file==="structure.md"))==null?void 0:j.file)??((H=D[0])==null?void 0:H.file);C&&O.current===A&&o(C)}}catch{}},[t]),ue=$.useCallback(A=>{A.preventDefault(),I.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";const R=j=>{if(!I.current||!G.current)return;const H=G.current.getBoundingClientRect(),ae=H.width-Tf-Af,E=j.clientX-H.left-Tf;y(Gy(E/ae,ae))},T=()=>{I.current=!1,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",R),window.removeEventListener("mouseup",T)};window.addEventListener("mousemove",R),window.addEventListener("mouseup",T)},[]),_e=$.useCallback(async(A,R,T,j,H)=>{var ae;f(R),h("Reading file...");try{const E=await t(`/api/stories/${A}/${R}`);if(!E.ok)throw new Error("Failed to read file");const D=await E.json(),K=D.content.match(/^#\s+(.+)$/m),C=K?K[1].slice(0,60):R.replace(".md","");let Q;if(R.match(/^plot-\d+\.md$/)){try{const Le=await t(`/api/stories/${A}`);if(Le.ok){const st=(await Le.json()).files.find(Ye=>Ye.file==="genesis.md"&&Ye.storylineId);Q=st==null?void 0:st.storylineId}}catch{}if(!Q){h("Error: Publish genesis first to create the storyline"),setTimeout(()=>{f(null),h("")},3e3);return}}h("Publishing...");const fe=await t("/api/publish/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:A,fileName:R,title:C,content:D.content,genre:T,language:j,isNsfw:H,storylineId:Q})});if(!fe.ok){const Le=await fe.json();throw new Error(Le.error||"Publish failed")}const de=(ae=fe.body)==null?void 0:ae.getReader(),Ce=new TextDecoder;if(de)for(;;){const{done:Le,value:Ee}=await de.read();if(Le)break;const Ye=Ce.decode(Ee).split(` +`).filter(xt=>xt.startsWith("data: "));for(const xt of Ye)try{const xe=JSON.parse(xt.slice(6));xe.step&&h(xe.message||xe.step),xe.step==="done"&&xe.txHash&&await t(`/api/stories/${A}/${R}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:xe.txHash,storylineId:xe.storylineId,plotIndex:xe.plotIndex,contentCid:xe.contentCid,gasCost:xe.gasCost,indexError:xe.indexError,authorAddress:g})})}catch{}}h("Published!")}catch(E){const D=E instanceof Error?E.message:"Publish failed";h(`Error: ${D}`)}finally{setTimeout(()=>{f(null),h("")},3e3)}},[t]),U=$.useCallback(A=>{A.startsWith("_new_")&&k(R=>R.filter(T=>T!==A))},[]),[se,V]=$.useState(new Set);$.useEffect(()=>{t("/api/stories").then(R=>R.ok?R.json():null).then(R=>{R!=null&&R.stories&&V(new Set(R.stories.filter(T=>T.hasStructure).map(T=>T.name)))}).catch(()=>{});const A=setInterval(async()=>{try{const R=await t("/api/stories");if(R.ok){const T=await R.json();V(new Set(T.stories.filter(j=>j.hasStructure).map(j=>j.name)))}}catch{}},5e3);return()=>clearInterval(A)},[t]);const B=$.useCallback(A=>{n===A&&(s(null),o(null))},[n]);return S.jsxs("div",{ref:G,className:"h-[calc(100vh-3.5rem)] flex",children:[S.jsx("div",{className:"w-56 border-r border-border flex-shrink-0",children:S.jsx(jx,{authFetch:t,selectedStory:n,selectedFile:a,onSelectFile:W,onNewStory:Z,untitledSessions:x})}),S.jsx("div",{className:"min-w-0 border-r border-border",style:{flex:`${b} 0 0`},children:S.jsx(lk,{token:e,storyName:n,authFetch:t,onSelectStory:te,onDestroySession:U,onArchiveStory:B,confirmedStories:se,renameRef:M})}),S.jsx("div",{onMouseDown:ue,className:"flex-shrink-0 flex items-center justify-center hover:bg-border/50 transition-colors",style:{width:Af,cursor:"col-resize",background:"var(--border)"},children:S.jsxs("div",{className:"flex flex-col gap-1",children:[S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),S.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}})]})}),S.jsxs("div",{className:"min-w-0 flex flex-col",style:{flex:`${1-b} 0 0`},children:[S.jsx(FD,{storyName:n,fileName:a,authFetch:t,onPublish:_e,publishingFile:c,walletAddress:g}),p&&S.jsx("div",{className:"px-3 py-1.5 bg-surface border-t border-border text-xs text-muted",children:p})]})]})}function VD({token:e,onComplete:t}){const[n,s]=$.useState(!1),[a,o]=$.useState(null),[c,f]=$.useState(!1),p=async()=>{s(!0),o(null);try{const h=await fetch("/api/wallet/create",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),g=await h.json();if(!h.ok)throw new Error(g.error||"Wallet creation failed");f(!0)}catch(h){o(h instanceof Error?h.message:"Wallet creation failed")}s(!1)};return $.useEffect(()=>{p()},[]),S.jsxs("div",{className:"mx-auto max-w-sm p-6 text-center",children:[S.jsx("h2",{className:"text-accent mb-1 text-lg font-bold",children:"Wallet Setup"}),S.jsx("p",{className:"text-muted mb-6 text-xs",children:"creating your OWS wallet for on-chain publishing"}),n&&S.jsx("p",{className:"text-accent text-sm",children:"creating wallet..."}),a&&S.jsxs("div",{className:"space-y-4",children:[S.jsx("div",{className:"rounded border border-red-700/30 p-3 text-xs text-red-700",children:a}),S.jsx("button",{onClick:p,className:"border-accent text-accent hover:bg-accent/10 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:"retry"})]}),c&&S.jsxs("div",{className:"space-y-4",children:[S.jsx("div",{className:"text-accent text-2xl",children:"✓"}),S.jsx("p",{className:"text-foreground text-sm font-medium",children:"wallet created"}),S.jsx("button",{onClick:t,className:"border-accent text-accent hover:bg-accent/10 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:"continue"})]})]})}function KD({token:e,onLogout:t}){const[n,s]=$.useState("home"),[a,o]=$.useState(0),c=$.useCallback(async(f,p)=>fetch(f,{...p,headers:{...(p==null?void 0:p.headers)||{},Authorization:`Bearer ${e}`}}),[e]);return $.useEffect(()=>{async function f(){try{if(!(await(await c("/api/wallet")).json()).exists){s("wallet-setup");return}const g=await c("/api/stories");if(g.ok){const _=await g.json();o(_.stories.filter(b=>b.name!=="_example").length)}}catch{}}f()},[e]),S.jsxs("div",{className:"flex h-screen flex-col",children:[S.jsxs("header",{className:"border-border flex h-14 items-center justify-between border-b px-4 flex-shrink-0",children:[S.jsxs("div",{className:"flex items-center gap-3",children:[S.jsx("button",{onClick:()=>{n!=="wallet-setup"&&s("home")},className:"flex items-center gap-2 hover:opacity-80",children:S.jsx("span",{className:"text-accent text-sm font-bold tracking-tight",children:"PlotLink OWS"})}),S.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"writer"})]}),n!=="wallet-setup"&&S.jsxs("nav",{className:"flex items-center gap-4",children:[S.jsx("button",{onClick:()=>s("stories"),className:`text-xs transition-colors ${n==="stories"?"text-accent":"text-muted hover:text-foreground"}`,children:"stories"}),S.jsx("button",{onClick:()=>s("dashboard"),className:`text-xs transition-colors ${n==="dashboard"?"text-accent":"text-muted hover:text-foreground"}`,children:"dashboard"}),S.jsx("button",{onClick:()=>s("settings"),className:`text-xs transition-colors ${n==="settings"?"text-accent":"text-muted hover:text-foreground"}`,children:"settings"}),S.jsx("button",{onClick:t,className:"text-muted hover:text-foreground text-xs transition-colors",children:"logout"})]})]}),S.jsxs("main",{className:"flex-1 min-h-0",children:[n==="home"&&S.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-8",children:[S.jsxs("div",{className:"text-center space-y-2",children:[S.jsx("h1",{className:"text-2xl font-serif text-foreground",children:"Write. Publish. Earn."}),S.jsx("p",{className:"text-muted text-sm",children:"Claude CLI writes stories. You publish them on-chain."})]}),S.jsxs("div",{className:"text-center space-y-3",children:[S.jsx("button",{onClick:()=>s("stories"),className:"bg-accent text-white hover:bg-accent-dim px-6 py-2.5 rounded text-sm font-medium transition-colors",children:"Start Writing"}),a>0&&S.jsxs("p",{className:"text-muted text-xs",children:[a," ",a===1?"story":"stories"," in progress"]})]}),S.jsxs("div",{className:"rounded border border-border p-4 space-y-2 text-xs text-muted",children:[S.jsx("p",{className:"font-medium text-foreground text-sm",children:"How it works"}),S.jsxs("ol",{className:"space-y-1.5 list-decimal list-inside",children:[S.jsxs("li",{children:["Open the ",S.jsx("strong",{children:"Stories"})," tab — Claude CLI launches in the terminal"]}),S.jsx("li",{children:"Tell Claude your story idea — it brainstorms, outlines, and writes"}),S.jsx("li",{children:"Review the live preview as Claude creates files"}),S.jsxs("li",{children:["Click ",S.jsx("strong",{children:"Publish"})," to put your story on-chain"]}),S.jsxs("li",{children:["Earn 5% royalties on every trade at ",S.jsx("a",{href:"https://plotlink.xyz",target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"plotlink.xyz"})]})]})]}),S.jsx("div",{className:"text-center",children:S.jsx("a",{href:"https://github.com/realproject7/plotlink-ows#-wallet-setup",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted hover:text-accent underline transition-colors",children:"Wallet Setup Guide"})}),S.jsx(eb,{token:e})]}),n==="stories"&&S.jsx(YD,{token:e,authFetch:c}),n==="dashboard"&&S.jsx(Lx,{token:e}),n==="wallet-setup"&&S.jsx(VD,{token:e,onComplete:()=>s("home")}),n==="settings"&&S.jsx(Bx,{token:e,onLogout:t})]})]})}function XD(){const[e,t]=$.useState(()=>localStorage.getItem("ows-token")),[n,s]=$.useState(null),[a,o]=$.useState(!0);$.useEffect(()=>{fetch("/api/auth/status").then(h=>h.json()).then(h=>s(h.configured)).catch(()=>s(null))},[]),$.useEffect(()=>{if(!e){o(!1);return}fetch("/api/auth/verify",{headers:{Authorization:`Bearer ${e}`}}).then(h=>{h.ok||(localStorage.removeItem("ows-token"),t(null))}).catch(()=>{localStorage.removeItem("ows-token"),t(null)}).finally(()=>o(!1))},[e]);const c=async h=>{try{const g=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:h})}),_=await g.json();return g.ok?(localStorage.setItem("ows-token",_.token),t(_.token),null):_.error||"Login failed"}catch{return"Cannot connect to server"}},f=async h=>{try{const g=await fetch("/api/auth/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:h})}),_=await g.json();return g.ok?(localStorage.setItem("ows-token",_.token),t(_.token),s(!0),null):_.error||"Setup failed"}catch{return"Cannot connect to server"}},p=()=>{localStorage.removeItem("ows-token"),t(null)};return a||n===null?S.jsx("div",{className:"flex h-screen items-center justify-center",children:S.jsx("span",{className:"text-muted text-sm",children:"connecting..."})}):n?e?S.jsx(KD,{token:e,onLogout:p}):S.jsx(Rx,{onLogin:c}):S.jsx(Mx,{onSetup:f})}Dx.createRoot(document.getElementById("root")).render(S.jsx(Sx.StrictMode,{children:S.jsx(XD,{})})); diff --git a/app/web/dist/index.html b/app/web/dist/index.html index 4683166..836d25c 100644 --- a/app/web/dist/index.html +++ b/app/web/dist/index.html @@ -7,7 +7,7 @@ - +