From 86e8bf747e97ebafe649eac199c0b708fcecf268 Mon Sep 17 00:00:00 2001 From: Obvious Date: Tue, 20 Oct 2026 16:13:55 +0000 Subject: [PATCH 1/3] feat(csv): extract multiple tables from Markdown blocks with interactive table chooser Co-authored-by: David Boskovic --- app/src/App.tsx | 35 ++- app/src/components/InputPane.tsx | 93 ++++++- app/src/lib/convert.ts | 11 +- app/src/lib/csvTable.ts | 10 +- app/src/lib/markdownTable.ts | 433 +++++++++++++++++++++++-------- 5 files changed, 448 insertions(+), 134 deletions(-) diff --git a/app/src/App.tsx b/app/src/App.tsx index f4c0baa..def8571 100644 --- a/app/src/App.tsx +++ b/app/src/App.tsx @@ -129,6 +129,27 @@ export default function App() { useState(loadRecentHistory); const [projectedInputCsv, setProjectedInputCsv] = useState(null); const [projectedOutputCsv, setProjectedOutputCsv] = useState(null); + const [markdownTableSelection, setMarkdownTableSelection] = useState<{ + forInput: string; + index: number; + }>({ forInput: "", index: 0 }); + const selectedMarkdownTableIndex = + markdownTableSelection.forInput === input + ? markdownTableSelection.index + : 0; + const handleSelectMarkdownTableIndex = useCallback( + (index: number) => { + setMarkdownTableSelection({ forInput: input, index }); + }, + [input] + ); + const effectiveOptions = useMemo( + () => + selectedMarkdownTableIndex > 0 + ? { ...options, markdownTableIndex: selectedMarkdownTableIndex } + : options, + [options, selectedMarkdownTableIndex] + ); // Latest converter state for the conversion-event validity predicate — // fires happen up to 2s after the last edit (or synchronously for a @@ -227,14 +248,14 @@ export default function App() { const permalink = useLegacyPermalink(permalinkPath); const result = useMemo( - () => convertText(direction, conversionInput, options), - [direction, conversionInput, options] + () => convertText(direction, conversionInput, effectiveOptions), + [direction, conversionInput, effectiveOptions] ); // Fire-time validity reads this; assigned after the memo so it always // holds the freshest state (see the tracker's isValid above). converterStateRef.current = { direction, - options, + options: effectiveOptions, input: effectiveInput, resultOk: result.ok, }; @@ -332,11 +353,11 @@ export default function App() { csvToJson && projectedInputCsv !== null && input.trim() !== "" ? projectedInputCsv : input; - const current = convertText(direction, sourceText, options); + const current = convertText(direction, sourceText, effectiveOptions); if (current.ok) setLastValidOutput(current.text); setOutputEdited(false); setEditedOutput(null); - }, [csvToJson, direction, input, options, projectedInputCsv]); + }, [csvToJson, direction, effectiveOptions, input, projectedInputCsv]); const commitInput = useCallback( (value: string) => { @@ -438,7 +459,7 @@ export default function App() { // memoized result lags `input` by the debounce window (1 s for large // files), so using it here could wipe a freshly typed value. if (!inputEmpty) { - const current = convertText(direction, input, options); + const current = convertText(direction, input, effectiveOptions); const nextInput = current.ok ? current.text : input; setInputHistory(createCsvHistory(nextInput)); if (nextInput.trim() !== "") { @@ -772,6 +793,8 @@ export default function App() { onToggleFlatten={() => setOptions((prev) => ({ ...prev, flatten: !prev.flatten })) } + selectedMarkdownTableIndex={selectedMarkdownTableIndex} + onSelectMarkdownTableIndex={handleSelectMarkdownTableIndex} filename={filename} reading={reading} meta={meta} diff --git a/app/src/components/InputPane.tsx b/app/src/components/InputPane.tsx index d4ed960..e3fb887 100644 --- a/app/src/components/InputPane.tsx +++ b/app/src/components/InputPane.tsx @@ -13,7 +13,7 @@ import { resolveJsonFormatToggle, } from "@/lib/convert"; import { parseCsvTable } from "@/lib/csvTable"; -import { detectMarkdownOrCliTable } from "@/lib/markdownTable"; +import { extractTablesFromMarkdownBlock } from "@/lib/markdownTable"; import { cn } from "@/lib/utils"; /** @@ -56,6 +56,8 @@ type InputPaneProps = { onChangeColumnTypes?: (columnTypes: Record) => void; flatten?: boolean; onToggleFlatten?: () => void; + selectedMarkdownTableIndex?: number; + onSelectMarkdownTableIndex?: (index: number) => void; }; function ReadingSpinner() { @@ -184,20 +186,45 @@ export function InputPane({ onChangeColumnTypes, flatten = false, onToggleFlatten, + selectedMarkdownTableIndex, + onSelectMarkdownTableIndex, }: InputPaneProps) { const [rawMode, setRawMode] = useState(false); const [dragOver, setDragOver] = useState(false); + const [localTableSelection, setLocalTableSelection] = useState<{ + forInput: string; + index: number; + }>({ forInput: "", index: 0 }); const dragDepth = useRef(0); const fileInputRef = useRef(null); const inputEmpty = input.trim() === ""; const isCsv = format === "CSV"; - const detectedMarkdownTable = useMemo( + const extractedMarkdownTables = useMemo( () => !isCsv || inputEmpty || delimiter !== undefined - ? null - : detectMarkdownOrCliTable(input), + ? [] + : extractTablesFromMarkdownBlock(input), [isCsv, inputEmpty, input, delimiter] ); + const requestedTableIndex = + selectedMarkdownTableIndex !== undefined + ? selectedMarkdownTableIndex + : localTableSelection.forInput === input + ? localTableSelection.index + : 0; + const activeMarkdownTableIndex = + extractedMarkdownTables.length === 0 + ? 0 + : Math.min( + Math.max(0, requestedTableIndex), + extractedMarkdownTables.length - 1 + ); + const detectedMarkdownTable = + extractedMarkdownTables[activeMarkdownTableIndex] ?? null; + const handleSelectMarkdownTable = (index: number) => { + setLocalTableSelection({ forInput: input, index }); + onSelectMarkdownTableIndex?.(index); + }; const indexedHeaderGroups = useMemo(() => { if (!isCsv || inputEmpty) return []; const sourceCsv = detectedMarkdownTable @@ -429,20 +456,56 @@ export function InputPane({ data-testid="csv-markdown-table-bar" className="flex flex-shrink-0 flex-wrap items-center justify-between gap-1.5 border-b border-border bg-muted/30 px-3.5 py-1.5" > - - {detectedMarkdownTable.kind === "box" - ? "ASCII CLI box table detected:" - : "Markdown pipe table detected:"} - + {extractedMarkdownTables.length >= 2 ? ( +
+ + {`${extractedMarkdownTables.length} tables detected:`} + + {extractedMarkdownTables.map((candidate) => { + const isSelected = + candidate.index === activeMarkdownTableIndex; + const shortTitle = + candidate.title ?? + candidate.headers.slice(0, 2).join(", "); + return ( + + ); + })} +
+ ) : ( + + {detectedMarkdownTable.kind === "box" + ? "ASCII CLI box table detected:" + : "Markdown pipe table detected:"} + + )} ) : null} @@ -482,7 +545,11 @@ export function InputPane({ /> ) : ( ; + /** + * 0-based index of the extracted Markdown/CLI table when input contains + * multiple tables (AC-18 / D17). + */ + markdownTableIndex?: number; }; export type Json2CsvOptions = { @@ -620,7 +625,7 @@ export function csvToJson( const rawInput = csv.startsWith(UTF8_BOM) ? csv.slice(UTF8_BOM.length) : csv; const normalizedTable = options.separator === undefined - ? detectMarkdownOrCliTable(rawInput) + ? detectMarkdownOrCliTable(rawInput, options.markdownTableIndex ?? 0) : null; const input = normalizedTable ? normalizedTable.cleanedCsv : rawInput; try { @@ -710,6 +715,7 @@ export type ConverterOptions = { flatten: boolean; collapseIndexedArrays?: boolean; columnTypes?: Record; + markdownTableIndex?: number; }; export const DEFAULT_OPTIONS: ConverterOptions = { @@ -1066,10 +1072,11 @@ export function convertText( hash: options.hash, collapseIndexedArrays: options.collapseIndexedArrays ?? true, columnTypes: options.columnTypes, + markdownTableIndex: options.markdownTableIndex, }; const normalizedTable = csv2jsonOptions.separator === undefined - ? detectMarkdownOrCliTable(input) + ? detectMarkdownOrCliTable(input, options.markdownTableIndex ?? 0) : null; const effectiveInput = normalizedTable ? normalizedTable.cleanedCsv diff --git a/app/src/lib/csvTable.ts b/app/src/lib/csvTable.ts index 39e1a32..dad40f8 100644 --- a/app/src/lib/csvTable.ts +++ b/app/src/lib/csvTable.ts @@ -102,9 +102,15 @@ function parseField(source: string, start: number, delimiter: string): [string, * CRLF/LF/CR line endings all accepted; a trailing newline does not create * an empty trailing row. */ -export function parseCsvTable(raw: string, forcedDelimiter?: string): CsvTableData { +export function parseCsvTable( + raw: string, + forcedDelimiter?: string, + markdownTableIndex = 0 +): CsvTableData { const mdTable = - forcedDelimiter === undefined ? detectMarkdownOrCliTable(raw) : null; + forcedDelimiter === undefined + ? detectMarkdownOrCliTable(raw, markdownTableIndex) + : null; const effectiveRaw = mdTable ? mdTable.cleanedCsv : raw; const bomStripped = effectiveRaw.startsWith(UTF8_BOM); const text = bomStripped ? effectiveRaw.slice(UTF8_BOM.length) : effectiveRaw; diff --git a/app/src/lib/markdownTable.ts b/app/src/lib/markdownTable.ts index 3f5cf8b..edbf307 100644 --- a/app/src/lib/markdownTable.ts +++ b/app/src/lib/markdownTable.ts @@ -7,8 +7,28 @@ export interface DetectedTablePaste { kind: "markdown" | "box"; } +export interface ExtractedTableCandidate { + index: number; + title: string | null; + label: string; + headers: string[]; + cleanedCsv: string; + rows: number; + cols: number; + kind: "markdown" | "box"; +} + const UTF8_BOM = "\uFEFF"; +/** + * Fast pre-check over the first 64 KB: matches any line that is a Markdown + * alignment separator (`| --- | --- |` or `---|---`), an ASCII box border + * (`+---+---+`), or a `psql` rule (`----+----`). Large regular CSVs without + * table rule lines are rejected in O(1) without splitting lines. + */ +const FAST_RULE_LINE_RE = + /^\s*(?:\|?\s*:?-{2,}:?\s*(?:\|\s*:?-{2,}:?\s*)+\|?|\|\s*:?-{2,}:?\s*\||\+[-=]+(?:\+[-=]+)*\+|[-=]+(?:\+[-=]+)+)\s*$/m; + /** * GitHub / ChatGPT Markdown pipe table alignment separator row: * e.g. `| --- | :---: | ---: |` or `---|---` or `| --- |`. @@ -32,6 +52,26 @@ const PSQL_RULE_LINE_RE = /^\s*[-=]+(?:\+[-=]+)+\s*$/; const CLI_FOOTER_LINE_RE = /^\s*(?:\(\d+\s+rows?\)|\d+\s+rows?\s+in\s+set(?:\s*\([^)]*\))?)\s*$/i; +/** + * Fenced code block delimiter (` ``` `, ` ```sql `, `~~~`). + */ +const CODE_FENCE_LINE_RE = /^\s*(?:`{3,}|~{3,})/; + +/** + * Markdown ATX heading (`# Heading`, `## Section Title ###`). + */ +const ATX_HEADING_LINE_RE = /^\s*#{1,6}\s+(.+?)\s*#*\s*$/; + +/** + * Standalone bold title line (`**Title**`, `**Title:**`, `__Title__`). + */ +const BOLD_TITLE_LINE_RE = /^\s*(?:\*\*([^*]+)\*\*|__([^_]+)__)\s*:?\s*$/; + +/** + * Setext heading underline (`=======` or `-------`). + */ +const SETEXT_UNDERLINE_RE = /^\s*(?:={3,}|-{3,})\s*$/; + function hasUnescapedPipe(line: string): boolean { for (let i = 0; i < line.length; i++) { if (line[i] === "\\" && i + 1 < line.length) { @@ -98,141 +138,312 @@ function parseBoxRow(line: string, framed: boolean): string[] { return body.split("|").map((cell) => cell.trim()); } -/** - * Extract the first `limit` non-empty lines from `text` without splitting the - * entire string — keeps large-CSV non-matches O(1). - */ -function peekFirstNonEmptyLines(text: string, limit: number): string[] { - const result: string[] = []; - const maxScan = Math.min(text.length, 32 * 1024); - let lineStart = 0; - - for (let i = 0; i <= maxScan; i++) { - const atEnd = i === maxScan; - const ch = atEnd ? "\n" : text[i]; - if (ch === "\n" || ch === "\r") { - const line = text.slice(lineStart, i); - if (line.trim().length > 0) { - result.push(line); - if (result.length >= limit) return result; - } - if (ch === "\r" && text[i + 1] === "\n") { - i++; - } - lineStart = i + 1; - } - } - return result; -} - function isBoxRuleOrBorder(line: string): boolean { return BOX_BORDER_LINE_RE.test(line) || PSQL_RULE_LINE_RE.test(line); } +const MAX_TITLE_CHARS = 32; + +function normalizeCandidateTitle(rawTitle: string): string | null { + const cleaned = rawTitle + .replace(/(\*\*|__|`)*/g, "") + .replace(/\s+/g, " ") + .replace(/\s*:\s*$/, "") + .trim(); + if (!cleaned) return null; + return cleaned.length > MAX_TITLE_CHARS + ? `${cleaned.slice(0, MAX_TITLE_CHARS - 1).trimEnd()}…` + : cleaned; +} + +function buildCandidateLabel( + index: number, + title: string | null, + headers: string[] +): string { + if (title) return title; + const preview = headers + .slice(0, 3) + .map((h) => h.trim()) + .filter(Boolean) + .join(", "); + return preview ? `Table ${index + 1} (${preview})` : `Table ${index + 1}`; +} + +function extractHeadingOrBoldTitle( + line: string, + nextLine?: string +): { title: string; consumedNextLine: boolean } | null { + const atxMatch = ATX_HEADING_LINE_RE.exec(line); + if (atxMatch) { + const title = normalizeCandidateTitle(atxMatch[1]); + if (title) return { title, consumedNextLine: false }; + } + + const boldMatch = BOLD_TITLE_LINE_RE.exec(line); + if (boldMatch) { + const title = normalizeCandidateTitle(boldMatch[1] ?? boldMatch[2] ?? ""); + if (title) return { title, consumedNextLine: false }; + } + + if ( + nextLine !== undefined && + SETEXT_UNDERLINE_RE.test(nextLine) && + line.trim().length > 0 && + !hasUnescapedPipe(line) && + !isBoxRuleOrBorder(line) && + !CODE_FENCE_LINE_RE.test(line) + ) { + const title = normalizeCandidateTitle(line); + if (title) return { title, consumedNextLine: true }; + } + + return null; +} + /** - * Detect and normalize GitHub/ChatGPT Markdown pipe tables and `psql`/MySQL - * ASCII box tables into canonical comma-delimited RFC 4180 CSV. + * Scan a pasted Markdown document or CLI transcript and extract every + * contiguous Markdown pipe table and `psql`/MySQL ASCII box table in document + * order, capturing each table's nearest preceding `#` heading or `**bold**` + * title line. * - * Returns `null` for plain CSV, TSV, JSON, or pipe-delimited CSV that lacks a - * Markdown alignment separator row (`|---|---|`) or CLI box border/rule line - * (`+---+---+` / `----+----`). + * Keeps O(1) fast rejection when the first 64 KB contains no Markdown + * alignment separator (`|---|---|`) or CLI box rule (`+---+---+` / `----+----`). */ -export function detectMarkdownOrCliTable( +export function extractTablesFromMarkdownBlock( input: string -): DetectedTablePaste | null { - if (!input) return null; +): ExtractedTableCandidate[] { + if (!input) return []; const raw = input.startsWith(UTF8_BOM) ? input.slice(UTF8_BOM.length) : input; - // Fast O(1) pre-check over the first 3 non-empty lines so large regular CSVs + // Fast O(1) pre-check over the first 64 KB so multi-megabyte regular CSVs // never allocate a full-file line split. - const head = peekFirstNonEmptyLines(raw, 3); - if (head.length < 2) return null; - - const isMarkdownCandidate = - hasUnescapedPipe(head[0]) && - !isBoxRuleOrBorder(head[0]) && - !MD_SEPARATOR_ROW_RE.test(head[0]) && - MD_SEPARATOR_ROW_RE.test(head[1]); - - const isPsqlCandidate = - hasUnescapedPipe(head[0]) && - !isBoxRuleOrBorder(head[0]) && - (PSQL_RULE_LINE_RE.test(head[1]) || BOX_BORDER_LINE_RE.test(head[1])); - - const isBorderedBoxCandidate = - BOX_BORDER_LINE_RE.test(head[0]) && - hasUnescapedPipe(head[1]) && - !isBoxRuleOrBorder(head[1]) && - (head.length < 3 || isBoxRuleOrBorder(head[2]) || hasUnescapedPipe(head[2])); - - if (!isMarkdownCandidate && !isPsqlCandidate && !isBorderedBoxCandidate) { - return null; + const headSlice = raw.slice(0, 64 * 1024); + if (!headSlice.includes("|") || !FAST_RULE_LINE_RE.test(headSlice)) { + return []; } - const nonEmptyLines = raw - .split(/\r?\n/) - .filter((line) => line.trim().length > 0); - if (nonEmptyLines.length < 2) return null; - - // Path A: GitHub / ChatGPT Markdown pipe table - if (isMarkdownCandidate && MD_SEPARATOR_ROW_RE.test(nonEmptyLines[1])) { - const headers = parseMarkdownRow(nonEmptyLines[0]); - if (headers.length === 0 || headers.every((h) => h === "")) return null; - - const dataRows: string[][] = []; - for (let i = 2; i < nonEmptyLines.length; i++) { - const line = nonEmptyLines[i]; - if (MD_SEPARATOR_ROW_RE.test(line)) continue; - if (!hasUnescapedPipe(line)) return null; - dataRows.push(parseMarkdownRow(line)); + const lines = raw.split(/\r?\n/); + const candidates: ExtractedTableCandidate[] = []; + let pendingTitle: string | null = null; + let i = 0; + + while (i < lines.length) { + const line = lines[i]; + const trimmed = line.trim(); + + if (trimmed.length === 0 || CODE_FENCE_LINE_RE.test(line)) { + i++; + continue; } - const cleanedCsv = serializeCsvTable(headers, dataRows, ","); - return { - cleanedCsv, - rows: dataRows.length, - cols: headers.length, - kind: "markdown", - }; - } + // Path 1: Bordered MySQL / ASCII box table starting with `+----+----+` + if (BOX_BORDER_LINE_RE.test(line)) { + let j = i + 1; + let ruleCount = 1; + const contentLines: string[] = []; - // Path B: psql / MySQL ASCII box table - let lineCount = nonEmptyLines.length; - if (lineCount >= 2 && CLI_FOOTER_LINE_RE.test(nonEmptyLines[lineCount - 1])) { - lineCount--; - } + while (j < lines.length) { + const cur = lines[j]; + if (cur.trim().length === 0 || CODE_FENCE_LINE_RE.test(cur)) break; + if (isBoxRuleOrBorder(cur)) { + ruleCount++; + j++; + continue; + } + if (cur.includes("|") && !MD_SEPARATOR_ROW_RE.test(cur)) { + contentLines.push(cur); + j++; + continue; + } + break; + } + + if (j < lines.length && CLI_FOOTER_LINE_RE.test(lines[j])) { + j++; + } + + if (ruleCount >= 2 && contentLines.length >= 1) { + const headers = parseBoxRow(contentLines[0], true); + if (headers.length > 0 && !headers.every((h) => h === "")) { + const dataRows = contentLines + .slice(1) + .map((rowLine) => parseBoxRow(rowLine, true)); + const cleanedCsv = serializeCsvTable(headers, dataRows, ","); + const index = candidates.length; + const title = pendingTitle; + candidates.push({ + index, + title, + label: buildCandidateLabel(index, title, headers), + headers, + cleanedCsv, + rows: dataRows.length, + cols: headers.length, + kind: "box", + }); + pendingTitle = null; + i = j; + continue; + } + } - let sawRuleOrBorder = false; - const contentLines: string[] = []; - for (let i = 0; i < lineCount; i++) { - const line = nonEmptyLines[i]; - if (isBoxRuleOrBorder(line)) { - sawRuleOrBorder = true; + i++; continue; } - if (! line.includes("|")) return null; - contentLines.push(line); - } - if (!sawRuleOrBorder || contentLines.length === 0) return null; + // Path 2: GitHub / ChatGPT Markdown pipe table (`header` + `|---|---|` + rows) + if ( + hasUnescapedPipe(line) && + !isBoxRuleOrBorder(line) && + !MD_SEPARATOR_ROW_RE.test(line) && + !ATX_HEADING_LINE_RE.test(line) && + i + 1 < lines.length && + MD_SEPARATOR_ROW_RE.test(lines[i + 1]) + ) { + const headers = parseMarkdownRow(line); + if (headers.length > 0 && !headers.every((h) => h === "")) { + const dataRows: string[][] = []; + let j = i + 2; + while (j < lines.length) { + const cur = lines[j]; + if ( + cur.trim().length === 0 || + CODE_FENCE_LINE_RE.test(cur) || + isBoxRuleOrBorder(cur) || + ATX_HEADING_LINE_RE.test(cur) + ) { + break; + } + if (MD_SEPARATOR_ROW_RE.test(cur)) { + j++; + continue; + } + if (hasUnescapedPipe(cur)) { + dataRows.push(parseMarkdownRow(cur)); + j++; + continue; + } + break; + } + + const cleanedCsv = serializeCsvTable(headers, dataRows, ","); + const index = candidates.length; + const title = pendingTitle; + candidates.push({ + index, + title, + label: buildCandidateLabel(index, title, headers), + headers, + cleanedCsv, + rows: dataRows.length, + cols: headers.length, + kind: "markdown", + }); + pendingTitle = null; + i = j; + continue; + } + } + + // Path 3: `psql` ASCII box table (`header` + `----+----` rule + rows + optional `(N rows)`) + if ( + hasUnescapedPipe(line) && + !isBoxRuleOrBorder(line) && + !MD_SEPARATOR_ROW_RE.test(line) && + !ATX_HEADING_LINE_RE.test(line) && + i + 1 < lines.length && + isBoxRuleOrBorder(lines[i + 1]) + ) { + const contentLines: string[] = [line]; + let j = i + 2; + while (j < lines.length) { + const cur = lines[j]; + if (cur.trim().length === 0 || CODE_FENCE_LINE_RE.test(cur)) break; + if (CLI_FOOTER_LINE_RE.test(cur)) { + j++; + break; + } + if (isBoxRuleOrBorder(cur)) { + j++; + continue; + } + if (cur.includes("|") && !MD_SEPARATOR_ROW_RE.test(cur)) { + contentLines.push(cur); + j++; + continue; + } + break; + } - const firstContent = contentLines[0].trim(); - const framed = - BOX_BORDER_LINE_RE.test(nonEmptyLines[0]) || - (firstContent.startsWith("|") && firstContent.endsWith("|")); + const firstContent = contentLines[0].trim(); + const framed = + firstContent.startsWith("|") && firstContent.endsWith("|"); + const headers = parseBoxRow(contentLines[0], framed); + if (headers.length > 0 && !headers.every((h) => h === "")) { + const dataRows = contentLines + .slice(1) + .map((rowLine) => parseBoxRow(rowLine, framed)); + const cleanedCsv = serializeCsvTable(headers, dataRows, ","); + const index = candidates.length; + const title = pendingTitle; + candidates.push({ + index, + title, + label: buildCandidateLabel(index, title, headers), + headers, + cleanedCsv, + rows: dataRows.length, + cols: headers.length, + kind: "box", + }); + pendingTitle = null; + i = j; + continue; + } + } - const headers = parseBoxRow(contentLines[0], framed); - if (headers.length === 0 || headers.every((h) => h === "")) return null; + // Non-table line: check if it is a `#` heading or `**bold**` title line + const headingMatch = extractHeadingOrBoldTitle(line, lines[i + 1]); + if (headingMatch) { + pendingTitle = headingMatch.title; + i += headingMatch.consumedNextLine ? 2 : 1; + continue; + } - const dataRows = contentLines - .slice(1) - .map((line) => parseBoxRow(line, framed)); + i++; + } - const cleanedCsv = serializeCsvTable(headers, dataRows, ","); + return candidates; +} + +/** + * Detect and normalize GitHub/ChatGPT Markdown pipe tables and `psql`/MySQL + * ASCII box tables into canonical comma-delimited RFC 4180 CSV. + * + * Supports both standalone tables and Markdown documents containing prose or + * multiple tables (`tableIndex` selects which detected table to return, + * clamped to `[0, candidates.length - 1]`). + * + * Returns `null` for plain CSV, TSV, JSON, or pipe-delimited CSV that lacks a + * Markdown alignment separator row (`|---|---|`) or CLI box border/rule line + * (`+---+---+` / `----+----`). + */ +export function detectMarkdownOrCliTable( + input: string, + tableIndex = 0 +): DetectedTablePaste | null { + const candidates = extractTablesFromMarkdownBlock(input); + if (candidates.length === 0) return null; + const clampedIndex = Math.min( + Math.max(0, Math.trunc(tableIndex) || 0), + candidates.length - 1 + ); + const chosen = candidates[clampedIndex]; return { - cleanedCsv, - rows: dataRows.length, - cols: headers.length, - kind: "box", + cleanedCsv: chosen.cleanedCsv, + rows: chosen.rows, + cols: chosen.cols, + kind: chosen.kind, }; } From 63171dbd6d368f288455b586587920b28855ec27 Mon Sep 17 00:00:00 2001 From: Obvious Date: Tue, 20 Oct 2026 16:13:55 +0000 Subject: [PATCH 2/3] test(csv): cover multi-table Markdown extraction and table switching Co-authored-by: David Boskovic --- app/src/App.test.tsx | 91 +++++++++++++++ app/src/lib/__tests__/convert.test.ts | 49 ++++++++ app/src/lib/markdownTable.test.ts | 160 +++++++++++++++++++++++++- 3 files changed, 299 insertions(+), 1 deletion(-) diff --git a/app/src/App.test.tsx b/app/src/App.test.tsx index f3b301b..c60d1f7 100644 --- a/app/src/App.test.tsx +++ b/app/src/App.test.tsx @@ -1957,6 +1957,97 @@ describe("Markdown & CLI box table paste in CSV → JSON (AC-14 / D13)", () => { await user.click(pill); expect(screen.queryByTestId("csv-clean-markdown-pill")).toBeNull(); }); + + it("extracts all tables from a multi-table Markdown document and switches active table via chooser pills (AC-18 / D17)", async () => { + const user = userEvent.setup(); + render(); + + const multiTableMarkdown = [ + "# Q3 Executive Summary", + "Below are the regional and product breakdowns:", + "", + "## By Region", + "| region | revenue |", + "| :--- | ---: |", + "| NA | 1200 |", + "| EU | 950 |", + "", + "## Top Products", + "| sku | product | units |", + "| :--- | :--- | ---: |", + "| A-1 | Widget | 40 |", + "| B-2 | Gadget | 25 |", + "| C-3 | Gizmo | 15 |", + "", + "Let me know if you need Q4 projections.", + ].join("\n"); + + fireEvent.change(screen.getByTestId("paste-field"), { + target: { value: multiTableMarkdown }, + }); + + await waitFor(() => { + const output = JSON.parse( + screen.getByTestId("output-view").textContent ?? "[]" + ); + expect(output).toEqual([ + { region: "NA", revenue: 1200 }, + { region: "EU", revenue: 950 }, + ]); + }); + + const select0 = screen.getByTestId("csv-markdown-table-select-0"); + const select1 = screen.getByTestId("csv-markdown-table-select-1"); + expect(select0).toHaveAttribute("aria-pressed", "true"); + expect(select0).toHaveTextContent("1. By Region (2×2)"); + expect(select1).toHaveAttribute("aria-pressed", "false"); + expect(select1).toHaveTextContent("2. Top Products (3×3)"); + + const cleanBtn = screen.getByTestId("csv-clean-markdown-pill"); + expect(cleanBtn).toHaveTextContent("Use only this table (2 rows)"); + + // Switch to Table 2 (Top Products) + await user.click(select1); + + expect(select0).toHaveAttribute("aria-pressed", "false"); + expect(select1).toHaveAttribute("aria-pressed", "true"); + expect(screen.getByTestId("csv-clean-markdown-pill")).toHaveTextContent( + "Use only this table (3 rows)" + ); + + const inputTable = screen.getByTestId("input-table"); + expect(within(inputTable).getByText("SKU")).toBeInTheDocument(); + expect(within(inputTable).getByText("PRODUCT")).toBeInTheDocument(); + expect(within(inputTable).getByText("Widget")).toBeInTheDocument(); + + await waitFor(() => { + const output = JSON.parse( + screen.getByTestId("output-view").textContent ?? "[]" + ); + expect(output).toEqual([ + { sku: "A-1", product: "Widget", units: 40 }, + { sku: "B-2", product: "Gadget", units: 25 }, + { sku: "C-3", product: "Gizmo", units: 15 }, + ]); + }); + + // Click "Use only this table" to replace raw input with Table 2's clean CSV + await user.click(screen.getByTestId("csv-clean-markdown-pill")); + expect(screen.queryByTestId("csv-markdown-table-bar")).toBeNull(); + + await user.click(screen.getByTestId("raw-toggle")); + const rawEditor = screen.getByTestId( + "input-editor" + ) as HTMLTextAreaElement; + expect(rawEditor.value).toBe( + "sku,product,units\nA-1,Widget,40\nB-2,Gadget,25\nC-3,Gizmo,15" + ); + + // Undo restores the full multi-table Markdown document + await user.click(screen.getByTestId("csv-undo-button")); + expect(rawEditor.value).toBe(multiTableMarkdown); + expect(screen.getByTestId("csv-markdown-table-bar")).toBeInTheDocument(); + }); }); describe("View-Driven Output: Column Picker & Apply view to output (AC-11 / D10)", () => { diff --git a/app/src/lib/__tests__/convert.test.ts b/app/src/lib/__tests__/convert.test.ts index 7d69733..9ab7a7d 100644 --- a/app/src/lib/__tests__/convert.test.ts +++ b/app/src/lib/__tests__/convert.test.ts @@ -1528,6 +1528,55 @@ describe("Markdown & CLI box table auto-normalization in convertText and csvToJs ]); } }); + + it("converts a single table surrounded by Markdown prose/fences and selects tables via markdownTableIndex in multi-table documents (AC-18 / D17)", () => { + const multiDoc = [ + "# Monthly Summary", + "Here are the two tables from the report:", + "", + "## By Region", + "| region | revenue |", + "| --- | ---: |", + "| NA | 1200 |", + "| EU | 950 |", + "", + "## Server Inventory", + " host | port ", + "----------+------", + " db-main | 5432 ", + " db-read | 5433 ", + " db-cache | 6379 ", + "(3 rows)", + "", + "Generated automatically.", + ].join("\n"); + + const table0 = convertText("csv2json", multiDoc, DEFAULT_OPTIONS); + expect(table0.ok).toBe(true); + if (table0.ok) { + expect(table0.rows).toBe(2); + expect(table0.cols).toBe(2); + expect(JSON.parse(table0.text)).toEqual([ + { region: "NA", revenue: 1200 }, + { region: "EU", revenue: 950 }, + ]); + } + + const table1 = convertText("csv2json", multiDoc, { + ...DEFAULT_OPTIONS, + markdownTableIndex: 1, + }); + expect(table1.ok).toBe(true); + if (table1.ok) { + expect(table1.rows).toBe(3); + expect(table1.cols).toBe(2); + expect(JSON.parse(table1.text)).toEqual([ + { host: "db-main", port: 5432 }, + { host: "db-read", port: 5433 }, + { host: "db-cache", port: 6379 }, + ]); + } + }); }); diff --git a/app/src/lib/markdownTable.test.ts b/app/src/lib/markdownTable.test.ts index 56a1aaa..b076f65 100644 --- a/app/src/lib/markdownTable.test.ts +++ b/app/src/lib/markdownTable.test.ts @@ -1,5 +1,8 @@ import { describe, expect, it } from "vitest"; -import { detectMarkdownOrCliTable } from "./markdownTable"; +import { + detectMarkdownOrCliTable, + extractTablesFromMarkdownBlock, +} from "./markdownTable"; describe("detectMarkdownOrCliTable (AC-14 / D13)", () => { it("detects and normalizes a GitHub / ChatGPT Markdown pipe table with outer pipes and alignment colons", () => { @@ -123,5 +126,160 @@ describe("detectMarkdownOrCliTable (AC-14 / D13)", () => { expect( detectMarkdownOrCliTable("id|album|year\n1|Elephant|2003\n2|De Stijl|2000") ).toBeNull(); + expect( + extractTablesFromMarkdownBlock( + "id|album|year\n1|Elephant|2003\n2|De Stijl|2000" + ) + ).toEqual([]); + }); +}); + +describe("extractTablesFromMarkdownBlock (AC-18 / D17)", () => { + it("extracts a single Markdown table embedded in ChatGPT prose and code fences", () => { + const doc = [ + "Sure! Here is the summary table you requested:", + "", + "### Active Regions", + "", + "```markdown", + "| region | revenue | active |", + "| :--- | ---: | :---: |", + "| NA | 1200 | true |", + "| EU | 950 | true |", + "```", + "", + "Let me know if you would like to filter by quarter.", + ].join("\n"); + + const tables = extractTablesFromMarkdownBlock(doc); + expect(tables).toEqual([ + { + index: 0, + title: "Active Regions", + label: "Active Regions", + headers: ["region", "revenue", "active"], + cleanedCsv: "region,revenue,active\nNA,1200,true\nEU,950,true", + rows: 2, + cols: 3, + kind: "markdown", + }, + ]); + + expect(detectMarkdownOrCliTable(doc)).toEqual({ + cleanedCsv: "region,revenue,active\nNA,1200,true\nEU,950,true", + rows: 2, + cols: 3, + kind: "markdown", + }); + }); + + it("extracts multiple Markdown tables in document order with # headings and **bold** titles", () => { + const doc = [ + "# Q3 Performance Report", + "Overview of regional and product metrics.", + "", + "## By Region", + "Regional breakdown for Q3:", + "", + "| region | revenue |", + "| --- | ---: |", + "| NA | 1200 |", + "| EU | 950 |", + "", + "**Top Products:**", + "| sku | name | units |", + "| --- | --- | ---: |", + "| A-1 | Widget | 40 |", + "| B-2 | Gadget | 25 |", + "| C-3 | Gizmo | 15 |", + "", + "End of report.", + ].join("\n"); + + const tables = extractTablesFromMarkdownBlock(doc); + expect(tables).toHaveLength(2); + expect(tables[0]).toEqual({ + index: 0, + title: "By Region", + label: "By Region", + headers: ["region", "revenue"], + cleanedCsv: "region,revenue\nNA,1200\nEU,950", + rows: 2, + cols: 2, + kind: "markdown", + }); + expect(tables[1]).toEqual({ + index: 1, + title: "Top Products", + label: "Top Products", + headers: ["sku", "name", "units"], + cleanedCsv: + "sku,name,units\nA-1,Widget,40\nB-2,Gadget,25\nC-3,Gizmo,15", + rows: 3, + cols: 3, + kind: "markdown", + }); + + expect(detectMarkdownOrCliTable(doc, 0)?.cleanedCsv).toBe( + "region,revenue\nNA,1200\nEU,950" + ); + expect(detectMarkdownOrCliTable(doc, 1)?.cleanedCsv).toBe( + "sku,name,units\nA-1,Widget,40\nB-2,Gadget,25\nC-3,Gizmo,15" + ); + // Out-of-range tableIndex clamps safely + expect(detectMarkdownOrCliTable(doc, 99)?.cleanedCsv).toBe( + "sku,name,units\nA-1,Widget,40\nB-2,Gadget,25\nC-3,Gizmo,15" + ); + }); + + it("extracts mixed Markdown pipe tables and psql / MySQL ASCII box tables, falling back to Table N (col preview) when untitled", () => { + const doc = [ + "| user_id | handle |", + "| --- | --- |", + "| 1 | ada |", + "", + "Database query result:", + "", + " host | port | primary ", + "-----------+------+---------", + " db-main-1 | 5432 | t ", + " db-read-1 | 5433 | f ", + "(2 rows)", + "", + "+------+-------+", + "| code | count |", + "+------+-------+", + "| 200 | 1420 |", + "+------+-------+", + ].join("\n"); + + const tables = extractTablesFromMarkdownBlock(doc); + expect(tables).toHaveLength(3); + expect(tables[0]).toMatchObject({ + index: 0, + title: null, + label: "Table 1 (user_id, handle)", + rows: 1, + cols: 2, + kind: "markdown", + }); + expect(tables[1]).toMatchObject({ + index: 1, + title: null, + label: "Table 2 (host, port, primary)", + cleanedCsv: "host,port,primary\ndb-main-1,5432,t\ndb-read-1,5433,f", + rows: 2, + cols: 3, + kind: "box", + }); + expect(tables[2]).toMatchObject({ + index: 2, + title: null, + label: "Table 3 (code, count)", + cleanedCsv: "code,count\n200,1420", + rows: 1, + cols: 2, + kind: "box", + }); }); }); From 1a0cc875726b7fdc8303a7f2b728e1c6d939e0e2 Mon Sep 17 00:00:00 2001 From: Obvious Date: Tue, 20 Oct 2026 16:13:55 +0000 Subject: [PATCH 3/3] chore(build): add changelog entry and rebuild app/dist Co-authored-by: David Boskovic --- ...s => data-grid-overlay-editor-pDz6NZm5.js} | 2 +- app/dist/assets/index-8usKNU6j.css | 1 + app/dist/assets/index-BtPygL0s.js | 316 ------------------ app/dist/assets/index-CqiPq7HB.js | 313 +++++++++++++++++ app/dist/assets/index-DfgoDwrH.css | 1 - ...J.js => number-overlay-editor-HYC-Cz64.js} | 2 +- app/dist/index.html | 4 +- app/src/changelog/entries.ts | 8 + 8 files changed, 326 insertions(+), 321 deletions(-) rename app/dist/assets/{data-grid-overlay-editor-C3DdHprK.js => data-grid-overlay-editor-pDz6NZm5.js} (98%) create mode 100644 app/dist/assets/index-8usKNU6j.css delete mode 100644 app/dist/assets/index-BtPygL0s.js create mode 100644 app/dist/assets/index-CqiPq7HB.js delete mode 100644 app/dist/assets/index-DfgoDwrH.css rename app/dist/assets/{number-overlay-editor-B1A_c6JJ.js => number-overlay-editor-HYC-Cz64.js} (99%) diff --git a/app/dist/assets/data-grid-overlay-editor-C3DdHprK.js b/app/dist/assets/data-grid-overlay-editor-pDz6NZm5.js similarity index 98% rename from app/dist/assets/data-grid-overlay-editor-C3DdHprK.js rename to app/dist/assets/data-grid-overlay-editor-pDz6NZm5.js index 5dd950f..b050e2b 100644 --- a/app/dist/assets/data-grid-overlay-editor-C3DdHprK.js +++ b/app/dist/assets/data-grid-overlay-editor-pDz6NZm5.js @@ -1 +1 @@ -import{s as $,r,i as w,a as z,b as J,c as Q,T as U,C as Z,m as ee}from"./index-BtPygL0s.js";const te=()=>t=>t.targetX,re=()=>t=>t.targetY,ne=()=>t=>t.targetWidth,ie=()=>t=>t.targetHeight,se=()=>t=>t.targetY+10,ae=()=>t=>Math.max(0,(t.targetHeight-28)/2),oe=$("div")({name:"DataGridOverlayEditorStyle",class:"gdg-d19meir1",propsAsIs:!1,vars:{"d19meir1-0":[re(),"px"],"d19meir1-1":[te(),"px"],"d19meir1-2":[ne(),"px"],"d19meir1-3":[ie(),"px"],"d19meir1-4":[se(),"px"],"d19meir1-5":[ae(),"px"]}});function de(){const[t,s]=r.useState();return[t??void 0,s]}function le(){const[t,s]=de(),[i,y]=r.useState(0),[m,x]=r.useState(!0);r.useLayoutEffect(()=>{if(t===void 0||!("IntersectionObserver"in window))return;const a=new IntersectionObserver(o=>{o.length!==0&&x(o[0].isIntersecting)},{threshold:1});return a.observe(t),()=>a.disconnect()},[t]),r.useEffect(()=>{if(m||t===void 0)return;let a;const o=()=>{const{right:S}=t.getBoundingClientRect();y(p=>Math.min(p+window.innerWidth-S-10,0)),a=requestAnimationFrame(o)};return a=requestAnimationFrame(o),()=>{a!==void 0&&cancelAnimationFrame(a)}},[t,m]);const O=r.useMemo(()=>({transform:`translateX(${i}px)`}),[i]);return{ref:s,style:O}}const ce=t=>{const{target:s,content:i,onFinishEditing:y,forceEditMode:m,initialValue:x,imageEditorOverride:O,markdownDivCreateNode:a,highlight:o,className:S,theme:p,id:H,cell:v,bloom:c,validateCell:d,getCellRenderer:F,provideEditor:h,isOutsideClick:X}=t,[l,A]=r.useState(m?i:void 0),k=r.useRef(l??i);k.current=l??i;const[E,R]=r.useState(()=>d===void 0?!0:!(w(i)&&(d==null?void 0:d(v,i,k.current))===!1)),f=r.useCallback((e,n)=>{y(E?e:void 0,n)},[E,y]),K=r.useCallback(e=>{if(d!==void 0&&e!==void 0&&w(e)){const n=d(v,e,k.current);n===!1?R(!1):(typeof n=="object"&&(e=n),R(!0))}A(e)},[v,d]),C=r.useRef(!1),g=r.useRef(void 0),W=r.useCallback(()=>{f(l,[0,0]),C.current=!0},[l,f]),Y=r.useCallback((e,n)=>{f(e,n??g.current??[0,0]),C.current=!0},[f]),j=r.useCallback(async e=>{let n=!1;e.key==="Escape"?(e.stopPropagation(),e.preventDefault(),g.current=[0,0]):e.key==="Enter"&&!e.shiftKey?(e.stopPropagation(),e.preventDefault(),g.current=[0,1],n=!0):e.key==="Tab"&&(e.stopPropagation(),e.preventDefault(),g.current=[e.shiftKey?-1:1,0],n=!0),window.setTimeout(()=>{!C.current&&g.current!==void 0&&(f(n?l:void 0,g.current),C.current=!0)},0)},[f,l]),D=l??i,[u,q]=r.useMemo(()=>{var n,G;if(z(i))return[];const e=h==null?void 0:h(i);return e!==void 0?[e,!1]:[(G=(n=F(i))==null?void 0:n.provideEditor)==null?void 0:G.call(n,i),!1]},[i,F,h]),{ref:B,style:L}=le();let P=!0,M,_=!0,b;if(u!==void 0){P=u.disablePadding!==!0,_=u.disableStyling!==!0;const e=J(u);e&&(b=u.styleOverride);const n=e?u.editor:u;M=r.createElement(n,{isHighlighted:o,onChange:K,value:D,initialValue:x,onFinishedEditing:Y,validatedSelection:w(D)?D.selectionRange:void 0,forceEditMode:m,target:s,imageEditorOverride:O,markdownDivCreateNode:a,isValid:E,theme:p})}b={...b,...L};const N=document.getElementById("portal");if(N===null)return console.error('Cannot open Data Grid overlay editor, because portal not found. Please add `
` as the last child of your ``.'),null;let I=_?"gdg-style":"gdg-unstyle";E||(I+=" gdg-invalid"),P&&(I+=" gdg-pad");const T=(c==null?void 0:c[0])??1,V=(c==null?void 0:c[1])??1;return Q.createPortal(r.createElement(U.Provider,{value:p},r.createElement(Z,{style:ee(p),className:S,onClickOutside:W,isOutsideClick:X},r.createElement(oe,{ref:B,id:H,className:I,style:b,as:q===!0?"label":void 0,targetX:s.x-T,targetY:s.y-V,targetWidth:s.width+T*2,targetHeight:s.height+V*2},r.createElement("div",{className:"gdg-clip-region",onKeyDown:j},M)))),N)};export{ce as default}; +import{s as $,r,i as w,a as z,b as J,c as Q,T as U,C as Z,m as ee}from"./index-CqiPq7HB.js";const te=()=>t=>t.targetX,re=()=>t=>t.targetY,ne=()=>t=>t.targetWidth,ie=()=>t=>t.targetHeight,se=()=>t=>t.targetY+10,ae=()=>t=>Math.max(0,(t.targetHeight-28)/2),oe=$("div")({name:"DataGridOverlayEditorStyle",class:"gdg-d19meir1",propsAsIs:!1,vars:{"d19meir1-0":[re(),"px"],"d19meir1-1":[te(),"px"],"d19meir1-2":[ne(),"px"],"d19meir1-3":[ie(),"px"],"d19meir1-4":[se(),"px"],"d19meir1-5":[ae(),"px"]}});function de(){const[t,s]=r.useState();return[t??void 0,s]}function le(){const[t,s]=de(),[i,y]=r.useState(0),[m,x]=r.useState(!0);r.useLayoutEffect(()=>{if(t===void 0||!("IntersectionObserver"in window))return;const a=new IntersectionObserver(o=>{o.length!==0&&x(o[0].isIntersecting)},{threshold:1});return a.observe(t),()=>a.disconnect()},[t]),r.useEffect(()=>{if(m||t===void 0)return;let a;const o=()=>{const{right:S}=t.getBoundingClientRect();y(p=>Math.min(p+window.innerWidth-S-10,0)),a=requestAnimationFrame(o)};return a=requestAnimationFrame(o),()=>{a!==void 0&&cancelAnimationFrame(a)}},[t,m]);const O=r.useMemo(()=>({transform:`translateX(${i}px)`}),[i]);return{ref:s,style:O}}const ce=t=>{const{target:s,content:i,onFinishEditing:y,forceEditMode:m,initialValue:x,imageEditorOverride:O,markdownDivCreateNode:a,highlight:o,className:S,theme:p,id:H,cell:v,bloom:c,validateCell:d,getCellRenderer:F,provideEditor:h,isOutsideClick:X}=t,[l,A]=r.useState(m?i:void 0),k=r.useRef(l??i);k.current=l??i;const[E,R]=r.useState(()=>d===void 0?!0:!(w(i)&&(d==null?void 0:d(v,i,k.current))===!1)),f=r.useCallback((e,n)=>{y(E?e:void 0,n)},[E,y]),K=r.useCallback(e=>{if(d!==void 0&&e!==void 0&&w(e)){const n=d(v,e,k.current);n===!1?R(!1):(typeof n=="object"&&(e=n),R(!0))}A(e)},[v,d]),C=r.useRef(!1),g=r.useRef(void 0),W=r.useCallback(()=>{f(l,[0,0]),C.current=!0},[l,f]),Y=r.useCallback((e,n)=>{f(e,n??g.current??[0,0]),C.current=!0},[f]),j=r.useCallback(async e=>{let n=!1;e.key==="Escape"?(e.stopPropagation(),e.preventDefault(),g.current=[0,0]):e.key==="Enter"&&!e.shiftKey?(e.stopPropagation(),e.preventDefault(),g.current=[0,1],n=!0):e.key==="Tab"&&(e.stopPropagation(),e.preventDefault(),g.current=[e.shiftKey?-1:1,0],n=!0),window.setTimeout(()=>{!C.current&&g.current!==void 0&&(f(n?l:void 0,g.current),C.current=!0)},0)},[f,l]),D=l??i,[u,q]=r.useMemo(()=>{var n,G;if(z(i))return[];const e=h==null?void 0:h(i);return e!==void 0?[e,!1]:[(G=(n=F(i))==null?void 0:n.provideEditor)==null?void 0:G.call(n,i),!1]},[i,F,h]),{ref:B,style:L}=le();let P=!0,M,_=!0,b;if(u!==void 0){P=u.disablePadding!==!0,_=u.disableStyling!==!0;const e=J(u);e&&(b=u.styleOverride);const n=e?u.editor:u;M=r.createElement(n,{isHighlighted:o,onChange:K,value:D,initialValue:x,onFinishedEditing:Y,validatedSelection:w(D)?D.selectionRange:void 0,forceEditMode:m,target:s,imageEditorOverride:O,markdownDivCreateNode:a,isValid:E,theme:p})}b={...b,...L};const N=document.getElementById("portal");if(N===null)return console.error('Cannot open Data Grid overlay editor, because portal not found. Please add `
` as the last child of your ``.'),null;let I=_?"gdg-style":"gdg-unstyle";E||(I+=" gdg-invalid"),P&&(I+=" gdg-pad");const T=(c==null?void 0:c[0])??1,V=(c==null?void 0:c[1])??1;return Q.createPortal(r.createElement(U.Provider,{value:p},r.createElement(Z,{style:ee(p),className:S,onClickOutside:W,isOutsideClick:X},r.createElement(oe,{ref:B,id:H,className:I,style:b,as:q===!0?"label":void 0,targetX:s.x-T,targetY:s.y-V,targetWidth:s.width+T*2,targetHeight:s.height+V*2},r.createElement("div",{className:"gdg-clip-region",onKeyDown:j},M)))),N)};export{ce as default}; diff --git a/app/dist/assets/index-8usKNU6j.css b/app/dist/assets/index-8usKNU6j.css new file mode 100644 index 0000000..3fba30e --- /dev/null +++ b/app/dist/assets/index-8usKNU6j.css @@ -0,0 +1 @@ +/*! tailwindcss v4.3.3 | 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-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial}}}@layer theme{:root,:host{--font-sans:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;--color-amber-100:oklch(96.2% .059 95.617);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-600:oklch(66.6% .179 58.318);--color-amber-700:oklch(55.5% .163 48.998);--color-sky-400:oklch(74.6% .16 232.661);--color-sky-600:oklch(58.8% .158 241.966);--spacing:.25rem;--container-sm:24rem;--container-md:28rem;--container-3xl:48rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--font-weight-medium:500;--font-weight-semibold:600;--tracking-tight:-.025em;--tracking-wide:.025em;--tracking-wider:.05em;--leading-relaxed:1.625;--radius-xl:.75rem;--animate-spin:spin 1s linear infinite;--blur-sm:8px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;--color-background:hsl(var(--background));--color-foreground:hsl(var(--foreground));--color-muted-foreground:hsl(var(--muted-foreground));--breakpoint-fit:98.5rem}}@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;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-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{.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.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}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.inset-3{inset:calc(var(--spacing) * 3)}.inset-x-0{inset-inline:0}.top-0{top:0}.top-1{top:var(--spacing)}.top-1\/2{top:50%}.top-7{top:calc(var(--spacing) * 7)}.top-9{top:calc(var(--spacing) * 9)}.right-0{right:0}.right-1{right:var(--spacing)}.right-1\.5{right:calc(var(--spacing) * 1.5)}.bottom-full{bottom:100%}.left-0{left:0}.left-1\.5{left:calc(var(--spacing) * 1.5)}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-50{z-index:50}.row-0{grid-row:0}.row-10{grid-row:10}.row-59{grid-row:59}.row-60{grid-row:60}.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}}@media (min-width:98.5rem){.container{max-width:98.5rem}}.mx-4{margin-inline:calc(var(--spacing) * 4)}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1\.5{margin-top:calc(var(--spacing) * 1.5)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mb-0\.5{margin-bottom:calc(var(--spacing) * .5)}.mb-1{margin-bottom:var(--spacing)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.ml-1{margin-left:var(--spacing)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-auto{margin-left:auto}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.size-1\.5{width:calc(var(--spacing) * 1.5);height:calc(var(--spacing) * 1.5)}.size-3{width:calc(var(--spacing) * 3);height:calc(var(--spacing) * 3)}.size-3\.5{width:calc(var(--spacing) * 3.5);height:calc(var(--spacing) * 3.5)}.size-4{width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.size-6{width:calc(var(--spacing) * 6);height:calc(var(--spacing) * 6)}.size-8{width:calc(var(--spacing) * 8);height:calc(var(--spacing) * 8)}.size-9{width:calc(var(--spacing) * 9);height:calc(var(--spacing) * 9)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-9{height:calc(var(--spacing) * 9)}.h-14{height:calc(var(--spacing) * 14)}.h-\[18px\]{height:18px}.h-\[var\(--split\)\]{height:var(--split)}.h-svh{height:100svh}.max-h-56{max-height:calc(var(--spacing) * 56)}.max-h-96{max-height:calc(var(--spacing) * 96)}.min-h-0{min-height:0}.min-h-11{min-height:calc(var(--spacing) * 11)}.min-h-12{min-height:calc(var(--spacing) * 12)}.min-h-\[42px\]{min-height:42px}.min-h-svh{min-height:100svh}.w-3{width:calc(var(--spacing) * 3)}.w-4{width:calc(var(--spacing) * 4)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-72{width:calc(var(--spacing) * 72)}.w-80{width:calc(var(--spacing) * 80)}.w-full{width:100%}.w-px{width:1px}.max-w-3xl{max-width:var(--container-3xl)}.max-w-44{max-width:calc(var(--spacing) * 44)}.max-w-64{max-width:calc(var(--spacing) * 64)}.max-w-md{max-width:var(--container-md)}.max-w-sm{max-width:var(--container-sm)}.min-w-0{min-width:0}.min-w-32{min-width:calc(var(--spacing) * 32)}.min-w-44{min-width:calc(var(--spacing) * 44)}.flex-1{flex:1}.flex-none{flex:none}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.grow{flex-grow:1}.translate-x-\[2px\]{--tw-translate-x:2px;translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-x-\[15px\]{--tw-translate-x:15px;translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-spin{animation:var(--animate-spin)}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.cursor-row-resize{cursor:row-resize}.resize{resize:both}.resize-none{resize:none}.appearance-none{-webkit-appearance:none;-moz-appearance:none;appearance:none}.flex-col{flex-direction:column}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-5{gap:calc(var(--spacing) * 5)}.gap-x-2{column-gap:calc(var(--spacing) * 2)}.gap-x-3{column-gap:calc(var(--spacing) * 3)}.gap-x-4{column-gap:calc(var(--spacing) * 4)}.gap-y-1\.5{row-gap:calc(var(--spacing) * 1.5)}.gap-y-2\.5{row-gap:calc(var(--spacing) * 2.5)}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px * var(--tw-divide-y-reverse));border-bottom-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-border>:not(:last-child)){border-color:hsl(var(--border))}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-\[7px\]{border-radius:7px}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-sm{border-radius:calc(var(--radius) - 4px)}.rounded-xl{border-radius:var(--radius-xl)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-border{border-color:hsl(var(--border))}.border-foreground,.border-foreground\/30{border-color:hsl(var(--foreground))}@supports (color:color-mix(in lab,red,red)){.border-foreground\/30{border-color:color-mix(in oklab,hsl(var(--foreground)) 30%,transparent)}}.border-primary,.border-primary\/50{border-color:hsl(var(--primary))}@supports (color:color-mix(in lab,red,red)){.border-primary\/50{border-color:color-mix(in oklab,hsl(var(--primary)) 50%,transparent)}}.border-ring{border-color:hsl(var(--ring))}.bg-amber-100{background-color:var(--color-amber-100)}.bg-background,.bg-background\/80{background-color:hsl(var(--background))}@supports (color:color-mix(in lab,red,red)){.bg-background\/80{background-color:color-mix(in oklab,hsl(var(--background)) 80%,transparent)}}.bg-border{background-color:hsl(var(--border))}.bg-foreground{background-color:hsl(var(--foreground))}.bg-muted,.bg-muted\/20{background-color:hsl(var(--muted))}@supports (color:color-mix(in lab,red,red)){.bg-muted\/20{background-color:color-mix(in oklab,hsl(var(--muted)) 20%,transparent)}}.bg-muted\/30{background-color:hsl(var(--muted))}@supports (color:color-mix(in lab,red,red)){.bg-muted\/30{background-color:color-mix(in oklab,hsl(var(--muted)) 30%,transparent)}}.bg-muted\/40{background-color:hsl(var(--muted))}@supports (color:color-mix(in lab,red,red)){.bg-muted\/40{background-color:color-mix(in oklab,hsl(var(--muted)) 40%,transparent)}}.bg-muted\/50{background-color:hsl(var(--muted))}@supports (color:color-mix(in lab,red,red)){.bg-muted\/50{background-color:color-mix(in oklab,hsl(var(--muted)) 50%,transparent)}}.bg-muted\/60{background-color:hsl(var(--muted))}@supports (color:color-mix(in lab,red,red)){.bg-muted\/60{background-color:color-mix(in oklab,hsl(var(--muted)) 60%,transparent)}}.bg-panel{background-color:hsl(var(--panel))}.bg-primary{background-color:hsl(var(--primary))}.bg-secondary{background-color:hsl(var(--secondary))}.bg-transparent{background-color:#0000}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-1\.5{padding:calc(var(--spacing) * 1.5)}.p-3{padding:calc(var(--spacing) * 3)}.p-6{padding:calc(var(--spacing) * 6)}.px-1{padding-inline:var(--spacing)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-3\.5{padding-inline:calc(var(--spacing) * 3.5)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-5{padding-inline:calc(var(--spacing) * 5)}.py-0{padding-block:0}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-6{padding-block:calc(var(--spacing) * 6)}.py-px{padding-block:1px}.pr-1\.5{padding-right:calc(var(--spacing) * 1.5)}.pr-6{padding-right:calc(var(--spacing) * 6)}.pb-1{padding-bottom:var(--spacing)}.pb-2{padding-bottom:calc(var(--spacing) * 2)}.pb-4{padding-bottom:calc(var(--spacing) * 4)}.pl-2\.5{padding-left:calc(var(--spacing) * 2.5)}.pl-3{padding-left:calc(var(--spacing) * 3)}.pl-6{padding-left:calc(var(--spacing) * 6)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:ui-monospace,SF Mono,SFMono-Regular,Menlo,Consolas,Liberation Mono,monospace}.font-sans{font-family:var(--font-sans)}.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}.text-\[11px\]{font-size:11px}.text-\[12\.5px\]{font-size:12.5px}.text-\[13px\]{font-size:13px}.text-\[15px\]{font-size:15px}.leading-6{--tw-leading:calc(var(--spacing) * 6);line-height:calc(var(--spacing) * 6)}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-\[0\.1em\]{--tw-tracking:.1em;letter-spacing:.1em}.tracking-\[0\.08em\]{--tw-tracking:.08em;letter-spacing:.08em}.tracking-\[0\.14em\]{--tw-tracking:.14em;letter-spacing:.14em}.tracking-\[0\.18em\]{--tw-tracking:.18em;letter-spacing:.18em}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-line{white-space:pre-line}.text-amber-600{color:var(--color-amber-600)}.text-amber-700{color:var(--color-amber-700)}.text-background{color:hsl(var(--background))}.text-destructive{color:hsl(var(--destructive))}.text-foreground{color:hsl(var(--foreground))}.text-muted-foreground,.text-muted-foreground\/60{color:hsl(var(--muted-foreground))}@supports (color:color-mix(in lab,red,red)){.text-muted-foreground\/60{color:color-mix(in oklab,hsl(var(--muted-foreground)) 60%,transparent)}}.text-muted-foreground\/70{color:hsl(var(--muted-foreground))}@supports (color:color-mix(in lab,red,red)){.text-muted-foreground\/70{color:color-mix(in oklab,hsl(var(--muted-foreground)) 70%,transparent)}}.text-panel{color:hsl(var(--panel))}.lowercase{text-transform:lowercase}.uppercase{text-transform:uppercase}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.underline{text-decoration-line:underline}.decoration-border{-webkit-text-decoration-color:hsl(var(--border));text-decoration-color:hsl(var(--border))}.underline-offset-2{text-underline-offset:2px}.accent-foreground{accent-color:hsl(var(--foreground))}.opacity-60{opacity:.6}.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-2xs{--tw-shadow:0 1px var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a), 0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-1{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-foreground\/15{--tw-ring-color:hsl(var(--foreground))}@supports (color:color-mix(in lab,red,red)){.ring-foreground\/15{--tw-ring-color:color-mix(in oklab, hsl(var(--foreground)) 15%, transparent)}}.ring-ring\/50{--tw-ring-color:hsl(var(--ring))}@supports (color:color-mix(in lab,red,red)){.ring-ring\/50{--tw-ring-color:color-mix(in oklab, hsl(var(--ring)) 50%, transparent)}}.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,)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-300{--tw-duration:.3s;transition-duration:.3s}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.placeholder\:text-muted-foreground::placeholder,.placeholder\:text-muted-foreground\/50::placeholder{color:hsl(var(--muted-foreground))}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-muted-foreground\/50::placeholder{color:color-mix(in oklab,hsl(var(--muted-foreground)) 50%,transparent)}}.placeholder\:text-muted-foreground\/60::placeholder{color:hsl(var(--muted-foreground))}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-muted-foreground\/60::placeholder{color:color-mix(in oklab,hsl(var(--muted-foreground)) 60%,transparent)}}.last\:mb-0:last-child{margin-bottom:0}@media (hover:hover){.hover\:border-foreground:hover{border-color:hsl(var(--foreground))}.hover\:border-muted-foreground\/50:hover{border-color:hsl(var(--muted-foreground))}@supports (color:color-mix(in lab,red,red)){.hover\:border-muted-foreground\/50:hover{border-color:color-mix(in oklab,hsl(var(--muted-foreground)) 50%,transparent)}}.hover\:bg-foreground\/90:hover{background-color:hsl(var(--foreground))}@supports (color:color-mix(in lab,red,red)){.hover\:bg-foreground\/90:hover{background-color:color-mix(in oklab,hsl(var(--foreground)) 90%,transparent)}}.hover\:bg-muted:hover,.hover\:bg-muted\/50:hover{background-color:hsl(var(--muted))}@supports (color:color-mix(in lab,red,red)){.hover\:bg-muted\/50:hover{background-color:color-mix(in oklab,hsl(var(--muted)) 50%,transparent)}}.hover\:text-foreground:hover{color:hsl(var(--foreground))}.hover\:decoration-foreground:hover{-webkit-text-decoration-color:hsl(var(--foreground));text-decoration-color:hsl(var(--foreground))}}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\:border-sky-600:focus-visible{border-color:var(--color-sky-600)}.focus-visible\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-3:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-ring\/50:focus-visible{--tw-ring-color:hsl(var(--ring))}@supports (color:color-mix(in lab,red,red)){.focus-visible\:ring-ring\/50:focus-visible{--tw-ring-color:color-mix(in oklab, hsl(var(--ring)) 50%, transparent)}}.focus-visible\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\:outline-offset-1:focus-visible{outline-offset:1px}.focus-visible\:outline-offset-2:focus-visible{outline-offset:2px}.focus-visible\:outline-ring:focus-visible{outline-color:hsl(var(--ring))}.focus-visible\:outline-none:focus-visible{--tw-outline-style:none;outline-style:none}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}@media not all and (min-width:48rem){.max-md\:max-h-\[340px\]{max-height:340px}.max-md\:max-h-\[360px\]{max-height:360px}.max-md\:min-h-\[240px\]{min-height:240px}.max-md\:min-h-\[280px\]{min-height:280px}.max-md\:gap-1{gap:var(--spacing)}.max-md\:gap-2{gap:calc(var(--spacing) * 2)}}@media not all and (min-width:40rem){.max-sm\:static{position:static}.max-sm\:inset-x-2{inset-inline:calc(var(--spacing) * 2)}.max-sm\:top-14{top:calc(var(--spacing) * 14)}.max-sm\:w-auto{width:auto}}@media (min-width:40rem){.sm\:inline{display:inline}.sm\:max-w-64{max-width:calc(var(--spacing) * 64)}.sm\:max-w-none{max-width:none}.sm\:px-2{padding-inline:calc(var(--spacing) * 2)}.sm\:px-4{padding-inline:calc(var(--spacing) * 4)}.sm\:py-1{padding-block:var(--spacing)}.sm\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}}@media (min-width:48rem){.md\:absolute{position:absolute}.md\:inset-auto{inset:auto}.md\:top-0{top:0}.md\:top-1\/2{top:50%}.md\:right-auto{right:auto}.md\:bottom-0{bottom:0}.md\:-left-1\.5{left:calc(var(--spacing) * -1.5)}.md\:left-1\/2{left:50%}.md\:left-\[var\(--split\)\]{left:var(--split)}.md\:block{display:block}.md\:hidden{display:none}.md\:size-5{width:calc(var(--spacing) * 5);height:calc(var(--spacing) * 5)}.md\:size-11{width:calc(var(--spacing) * 11);height:calc(var(--spacing) * 11)}.md\:h-8{height:calc(var(--spacing) * 8)}.md\:h-12{height:calc(var(--spacing) * 12)}.md\:h-auto{height:auto}.md\:h-svh{height:100svh}.md\:min-h-0{min-height:0}.md\:min-h-12{min-height:calc(var(--spacing) * 12)}.md\:w-0{width:0}.md\:w-3{width:calc(var(--spacing) * 3)}.md\:w-\[var\(--split\)\]{width:var(--split)}.md\:-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.md\:-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.md\:cursor-col-resize{cursor:col-resize}.md\:flex-row{flex-direction:row}.md\:gap-1{gap:var(--spacing)}.md\:gap-3{gap:calc(var(--spacing) * 3)}.md\:border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.md\:border-b-0{border-bottom-style:var(--tw-border-style);border-bottom-width:0}.md\:bg-transparent{background-color:#0000}.md\:p-6{padding:calc(var(--spacing) * 6)}.md\:px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.md\:px-4{padding-inline:calc(var(--spacing) * 4)}.md\:px-16{padding-inline:calc(var(--spacing) * 16)}.md\:py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.md\:pr-2\.5{padding-right:calc(var(--spacing) * 2.5)}.md\:pl-3\.5{padding-left:calc(var(--spacing) * 3.5)}.md\:text-\[11px\]{font-size:11px}}@media (min-width:64rem){.lg\:inline{display:inline}.lg\:gap-3{gap:calc(var(--spacing) * 3)}.lg\:gap-x-3{column-gap:calc(var(--spacing) * 3)}.lg\:px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.lg\:pr-3{padding-right:calc(var(--spacing) * 3)}.lg\:pl-5{padding-left:calc(var(--spacing) * 5)}}@media (min-width:80rem){.xl\:block{display:block}.xl\:inline{display:inline}}@media (min-width:98.5rem){.fit\:block{display:block}}.dark\:bg-amber-400\/15:is(.dark *){background-color:#fcbb0026}@supports (color:color-mix(in lab,red,red)){.dark\:bg-amber-400\/15:is(.dark *){background-color:color-mix(in oklab,var(--color-amber-400) 15%,transparent)}}.dark\:text-amber-400:is(.dark *){color:var(--color-amber-400)}.dark\:focus-visible\:border-sky-400:is(.dark *):focus-visible{border-color:var(--color-sky-400)}.\[\&_svg\]\:size-3\.5 svg{width:calc(var(--spacing) * 3.5);height:calc(var(--spacing) * 3.5)}}:root{--panel:0 0% 100%;--background:0 0% 100%;--foreground:240 10% 3.9%;--muted:240 4.8% 95.9%;--muted-foreground:240 3.8% 46.1%;--border:240 5.9% 90%;--primary:240 5.9% 10%;--primary-foreground:0 0% 98%;--secondary:240 4.8% 95.9%;--secondary-foreground:240 5.9% 10%;--accent:240 4.8% 95.9%;--accent-foreground:240 5.9% 10%;--destructive:0 84.2% 60.2%;--destructive-foreground:0 0% 98%;--ring:240 5% 64.9%;--radius:.625rem}.dark{--background:240 10% 3.9%;--panel:240 6% 7%;--foreground:0 0% 98%;--muted:240 3.7% 15.9%;--muted-foreground:240 5% 64.9%;--border:240 3.7% 15.9%;--primary:0 0% 98%;--primary-foreground:240 5.9% 10%;--secondary:240 3.7% 15.9%;--secondary-foreground:0 0% 98%;--destructive:0 62.8% 30.6%;--destructive-foreground:0 0% 98%;--ring:240 4.9% 83.9%}body{background-color:var(--color-background);color:var(--color-foreground)}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-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-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}.gdg-mnuv029{word-break:break-word;-webkit-touch-callout:default;padding-top:6px}.gdg-mnuv029>*{margin:0}.gdg-mnuv029 *:last-child{margin-bottom:0}.gdg-mnuv029 p img{width:100%}.gdg-d19meir1{position:absolute;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;overflow:hidden;box-sizing:border-box;--overlay-top:var(--d19meir1-0);left:var(--d19meir1-1);top:var(--d19meir1-0);min-width:var(--d19meir1-2);min-height:var(--d19meir1-3);width:-webkit-max-content;width:-moz-max-content;width:max-content;max-width:400px;max-height:calc(100vh - var(--d19meir1-4));font-family:var(--gdg-font-family);font-size:var(--gdg-editor-font-size);text-align:start}@-webkit-keyframes glide_fade_in-gdg-d19meir1{0%{opacity:0%}to{opacity:100%}}@keyframes glide_fade_in-gdg-d19meir1{0%{opacity:0%}to{opacity:100%}}.gdg-d19meir1.gdg-style{border-radius:2px;background-color:var(--gdg-bg-cell);box-shadow:0 0 0 1px var(--gdg-accent-color),0 0 1px #3e415666,0 6px 12px #3e415626;-webkit-animation:glide_fade_in-gdg-d19meir1 60ms 1;animation:glide_fade_in-gdg-d19meir1 60ms 1}.gdg-d19meir1.gdg-pad{padding:var(--d19meir1-5) 8.5px 3px}.gdg-d19meir1 .gdg-clip-region{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;overflow-y:auto;overflow-x:hidden;border-radius:2px;-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1}.gdg-d19meir1 .gdg-clip-region .gdg-growing-entry{height:100%}.gdg-d19meir1 .gdg-clip-region input.gdg-input{width:100%;border:none;border-width:0;outline:none}.gdg-d19meir1 .gdg-clip-region textarea.gdg-input{border:none;border-width:0;outline:none}.gdg-b1ygi5by{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;margin-top:auto;margin-bottom:auto}.gdg-b1ygi5by .boe-bubble{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;border-radius:var(--gdg-rounding-radius,10px);padding:0 8px;height:20px;background-color:var(--gdg-bg-bubble);color:var(--gdg-text-dark);margin:2px}.gdg-b1ygi5by textarea{position:absolute;top:0;left:0;width:0px;height:0px;opacity:0}.gdg-n15fjm3e{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;margin:6px 0 3px;color:var(--gdg-text-dark)}.gdg-n15fjm3e>input{font-size:var(--gdg-editor-font-size);padding:0;font-family:var(--gdg-font-family);color:var(--gdg-text-dark);background-color:var(--gdg-bg-cell)}.gdg-d4zsq0x{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap}.gdg-d4zsq0x .doe-bubble{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:0 8px;height:24px;background-color:var(--gdg-bg-cell);color:var(--gdg-text-dark);margin:2px;border-radius:var(--gdg-rounding-radius,6px);box-shadow:0 0 1px #3e415666,0 1px 3px #3e415666}.gdg-d4zsq0x .doe-bubble img{height:16px;object-fit:contain;margin-right:4px}.gdg-d4zsq0x textarea{position:absolute;top:0;left:0;width:0px;height:0px;opacity:0}.gdg-i2iowwq{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;height:100%}.gdg-i2iowwq .gdg-centering-container{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;height:100%}.gdg-i2iowwq .gdg-centering-container img,.gdg-i2iowwq .gdg-centering-container canvas{max-height:calc(100vh - var(--overlay-top) - 20px);object-fit:contain;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.gdg-i2iowwq .gdg-centering-container canvas{max-width:380px}.gdg-i2iowwq .gdg-edit-icon{position:absolute;top:12px;right:0;width:48px;height:48px;color:var(--gdg-accent-color);cursor:pointer;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.gdg-i2iowwq .gdg-edit-icon>*{width:24px;height:24px}.gdg-i2iowwq textarea{position:absolute;top:0;left:0;width:0px;height:0px;opacity:0}.gdg-u1rrojo{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;min-height:21px}.gdg-u1rrojo .gdg-link-area{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;-webkit-flex-shrink:1;-ms-flex-negative:1;flex-shrink:1;cursor:pointer;margin-right:8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--gdg-link-color);-webkit-text-decoration:underline!important;text-decoration:underline!important}.gdg-u1rrojo .gdg-edit-icon{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;width:32px;color:var(--gdg-accent-color);cursor:pointer;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.gdg-u1rrojo .gdg-edit-icon>*{width:24px;height:24px}.gdg-u1rrojo textarea{position:absolute;top:0;left:0;width:0px;height:0px;opacity:0}.gdg-m1pnx84e{min-width:var(--m1pnx84e-0);width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:flex-start;-webkit-box-align:flex-start;-ms-flex-align:flex-start;align-items:flex-start;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;position:relative;color:var(--gdg-text-dark)}.gdg-m1pnx84e .gdg-g1y0xocz{-webkit-flex-shrink:1;-ms-flex-negative:1;flex-shrink:1;min-width:0}.gdg-m1pnx84e .gdg-spacer{-webkit-flex:1;-ms-flex:1;flex:1}.gdg-m1pnx84e .gdg-edit-icon{position:relative;cursor:pointer;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:var(--gdg-accent-color);padding:0;height:24px;width:24px;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;-webkit-transition:all "0.125s ease";transition:all "0.125s ease";border-radius:6px}.gdg-m1pnx84e .gdg-edit-icon>*{width:16px;height:16px}.gdg-m1pnx84e .gdg-edit-hover:hover{background-color:var(--gdg-accent-light);-webkit-transition:background-color .15s;transition:background-color .15s}.gdg-m1pnx84e .gdg-checkmark-hover:hover{color:#fff;background-color:var(--gdg-accent-color)}.gdg-m1pnx84e .gdg-md-edit-textarea{position:relative;top:0;left:0;width:0px;height:0px;margin-top:25px;opacity:0;padding:0}.gdg-m1pnx84e .gdg-ml-6{margin-left:6px}.gdg-s1dgczr6 .dvn-scroller{overflow:var(--s1dgczr6-0);-webkit-transform:translate3d(0,0,0);-ms-transform:translate3d(0,0,0);transform:translateZ(0)}.gdg-s1dgczr6 .dvn-hidden{visibility:hidden}.gdg-s1dgczr6 .dvn-scroll-inner{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;pointer-events:none}.gdg-s1dgczr6 .dvn-scroll-inner>*{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0}.gdg-s1dgczr6 .dvn-scroll-inner .dvn-spacer{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1}.gdg-s1dgczr6 .dvn-scroll-inner .dvn-stack{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column}.gdg-s1dgczr6 .dvn-underlay>*{position:absolute;left:0;top:0}.gdg-s1dgczr6 canvas{outline:none}.gdg-s1dgczr6 canvas *{height:0}.gdg-izpuzkl{position:absolute;left:0;right:0;top:0;bottom:0;width:100%;height:100%;border-radius:0;resize:none;white-space:pre-wrap;min-width:100%;overflow:hidden;border:0;background-color:transparent;font-size:var(--gdg-editor-font-size);line-height:16px;font-family:var(--gdg-font-family);-webkit-text-fill-color:var(--gdg-text-dark);color:var(--gdg-text-dark);padding:0;margin:0}.gdg-izpuzkl::-webkit-input-placeholder{color:var(--gdg-text-light)}.gdg-izpuzkl::-moz-placeholder{color:var(--gdg-text-light)}.gdg-izpuzkl:-ms-input-placeholder{color:var(--gdg-text-light)}.gdg-izpuzkl::placeholder{color:var(--gdg-text-light)}.gdg-invalid .gdg-izpuzkl{-webkit-text-decoration:underline;text-decoration:underline;-webkit-text-decoration-color:#d60606;text-decoration-color:#d60606}.gdg-s69h75o{visibility:hidden;white-space:pre-wrap;word-wrap:break-word;width:-webkit-max-content;width:-moz-max-content;width:max-content;max-width:100%;min-width:100%;font-size:var(--gdg-editor-font-size);line-height:16px;font-family:var(--gdg-font-family);color:var(--gdg-text-dark);padding:0 0 2px;margin:0}.gdg-g1y0xocz{position:relative;margin-top:6px}.gdg-seveqep{position:absolute;top:4px;right:20px;background-color:var(--gdg-bg-cell);color:var(--gdg-text-dark);padding:8px;border:1px solid var(--gdg-border-color);border-radius:6px;font-size:var(--gdg-editor-font-size);-webkit-animation:gdg-search-fadein-gdg-seveqep .15s forwards;animation:gdg-search-fadein-gdg-seveqep .15s forwards}.gdg-seveqep.out{-webkit-animation:gdg-search-fadeout-gdg-seveqep .15s forwards;animation:gdg-search-fadeout-gdg-seveqep .15s forwards}.gdg-seveqep .gdg-search-bar-inner{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.gdg-seveqep .gdg-search-status{padding-top:4px;font-size:11px}.gdg-seveqep .gdg-search-progress{position:absolute;height:4px;left:0;bottom:0;background-color:var(--gdg-text-light)}.gdg-seveqep input{width:220px;color:var(--gdg-textDark);background-color:var(--gdg-bg-cell);border:none;border-width:0;outline:none}.gdg-seveqep button{width:24px;height:24px;padding:0;border:none;outline:none;background:none;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;cursor:pointer;color:var(--gdg-text-medium)}.gdg-seveqep button:hover{color:var(--gdg-text-dark)}.gdg-seveqep button .button-icon{width:16px;height:16px}.gdg-seveqep button:disabled{opacity:.4;pointer-events:none}@-webkit-keyframes gdg-search-fadeout-gdg-seveqep{0%{-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translate(0)}to{-webkit-transform:translateX(400px);-ms-transform:translateX(400px);transform:translate(400px)}}@keyframes gdg-search-fadeout-gdg-seveqep{0%{-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translate(0)}to{-webkit-transform:translateX(400px);-ms-transform:translateX(400px);transform:translate(400px)}}@-webkit-keyframes gdg-search-fadein-gdg-seveqep{0%{-webkit-transform:translateX(400px);-ms-transform:translateX(400px);transform:translate(400px)}to{-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translate(0)}}@keyframes gdg-search-fadein-gdg-seveqep{0%{-webkit-transform:translateX(400px);-ms-transform:translateX(400px);transform:translate(400px)}to{-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translate(0)}}.gdg-wmyidgi{position:relative;min-width:10px;min-height:10px;max-width:100%;max-height:100%;width:var(--wmyidgi-0);height:var(--wmyidgi-1);overflow:hidden;overflow:clip;direction:ltr}.gdg-wmyidgi>:first-child{position:absolute;left:0;top:0;width:100%;height:100%}.gdg-r17m35ur{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;border:none;outline:none;background-color:var(--gdg-bg-header-has-focus);border-radius:9px;padding:0 8px;box-shadow:0 0 0 1px var(--gdg-border-color);color:var(--gdg-text-group-header);min-height:var(--r17m35ur-0);font:var(--gdg-header-font-style) var(--gdg-font-family)}.gdg-c1tqibwd{padding:0 8px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;background-color:var(--gdg-bg-header)} diff --git a/app/dist/assets/index-BtPygL0s.js b/app/dist/assets/index-BtPygL0s.js deleted file mode 100644 index 0a6e9e4..0000000 --- a/app/dist/assets/index-BtPygL0s.js +++ /dev/null @@ -1,316 +0,0 @@ -var rO=Object.defineProperty;var iO=(t,e,n)=>e in t?rO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var St=(t,e,n)=>iO(t,typeof e!="symbol"?e+"":e,n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var So=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Qi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var oC={exports:{}},up={},lC={exports:{}},Mt={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Zc=Symbol.for("react.element"),sO=Symbol.for("react.portal"),oO=Symbol.for("react.fragment"),lO=Symbol.for("react.strict_mode"),aO=Symbol.for("react.profiler"),uO=Symbol.for("react.provider"),cO=Symbol.for("react.context"),fO=Symbol.for("react.forward_ref"),dO=Symbol.for("react.suspense"),hO=Symbol.for("react.memo"),pO=Symbol.for("react.lazy"),o1=Symbol.iterator;function gO(t){return t===null||typeof t!="object"?null:(t=o1&&t[o1]||t["@@iterator"],typeof t=="function"?t:null)}var aC={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},uC=Object.assign,cC={};function nu(t,e,n){this.props=t,this.context=e,this.refs=cC,this.updater=n||aC}nu.prototype.isReactComponent={};nu.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};nu.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function fC(){}fC.prototype=nu.prototype;function Uy(t,e,n){this.props=t,this.context=e,this.refs=cC,this.updater=n||aC}var Ky=Uy.prototype=new fC;Ky.constructor=Uy;uC(Ky,nu.prototype);Ky.isPureReactComponent=!0;var l1=Array.isArray,dC=Object.prototype.hasOwnProperty,Xy={current:null},hC={key:!0,ref:!0,__self:!0,__source:!0};function pC(t,e,n){var r,i={},s=null,o=null;if(e!=null)for(r in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)dC.call(e,r)&&!hC.hasOwnProperty(r)&&(i[r]=e[r]);var l=arguments.length-2;if(l===1)i.children=n;else if(1>>1,$=j[I];if(0>>1;Ii(W,M))de<$&&0>i(le,W)?(j[I]=le,j[de]=M,I=de):(j[I]=W,j[Y]=M,I=Y);else if(de<$&&0>i(le,M))j[I]=le,j[de]=M,I=de;else break e}}return G}function i(j,G){var M=j.sortIndex-G.sortIndex;return M!==0?M:j.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var a=[],u=[],c=1,f=null,d=3,h=!1,p=!1,g=!1,b=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(j){for(var G=n(u);G!==null;){if(G.callback===null)r(u);else if(G.startTime<=j)r(u),G.sortIndex=G.expirationTime,e(a,G);else break;G=n(u)}}function k(j){if(g=!1,w(j),!p)if(n(a)!==null)p=!0,ie(x);else{var G=n(u);G!==null&&V(k,G.startTime-j)}}function x(j,G){p=!1,g&&(g=!1,m(A),A=-1),h=!0;var M=d;try{for(w(G),f=n(a);f!==null&&(!(f.expirationTime>G)||j&&!_());){var I=f.callback;if(typeof I=="function"){f.callback=null,d=f.priorityLevel;var $=I(f.expirationTime<=G);G=t.unstable_now(),typeof $=="function"?f.callback=$:f===n(a)&&r(a),w(G)}else r(a);f=n(a)}if(f!==null)var B=!0;else{var Y=n(u);Y!==null&&V(k,Y.startTime-G),B=!1}return B}finally{f=null,d=M,h=!1}}var C=!1,T=null,A=-1,R=5,P=-1;function _(){return!(t.unstable_now()-Pj||125I?(j.sortIndex=M,e(u,j),n(a)===null&&j===n(u)&&(g?(m(A),A=-1):g=!0,V(k,M-I))):(j.sortIndex=$,e(a,j),p||h||(p=!0,ie(x))),j},t.unstable_shouldYield=_,t.unstable_wrapCallback=function(j){var G=d;return function(){var M=d;d=G;try{return j.apply(this,arguments)}finally{d=M}}}})(wC);vC.exports=wC;var EO=vC.exports;/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var AO=y,ti=EO;function fe(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),zm=Object.prototype.hasOwnProperty,MO=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,u1={},c1={};function RO(t){return zm.call(c1,t)?!0:zm.call(u1,t)?!1:MO.test(t)?c1[t]=!0:(u1[t]=!0,!1)}function OO(t,e,n,r){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function PO(t,e,n,r){if(e===null||typeof e>"u"||OO(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Mr(t,e,n,r,i,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}var ir={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){ir[t]=new Mr(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];ir[e]=new Mr(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){ir[t]=new Mr(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){ir[t]=new Mr(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){ir[t]=new Mr(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){ir[t]=new Mr(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){ir[t]=new Mr(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){ir[t]=new Mr(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){ir[t]=new Mr(t,5,!1,t.toLowerCase(),null,!1,!1)});var qy=/[\-:]([a-z])/g;function Yy(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(qy,Yy);ir[e]=new Mr(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(qy,Yy);ir[e]=new Mr(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(qy,Yy);ir[e]=new Mr(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){ir[t]=new Mr(t,1,!1,t.toLowerCase(),null,!1,!1)});ir.xlinkHref=new Mr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){ir[t]=new Mr(t,1,!1,t.toLowerCase(),null,!0,!0)});function Jy(t,e,n,r){var i=ir.hasOwnProperty(e)?ir[e]:null;(i!==null?i.type!==0:r||!(2l||i[o]!==s[l]){var a=` -`+i[o].replace(" at new "," at ");return t.displayName&&a.includes("")&&(a=a.replace("",t.displayName)),a}while(1<=o&&0<=l);break}}}finally{yg=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Xu(t):""}function IO(t){switch(t.tag){case 5:return Xu(t.type);case 16:return Xu("Lazy");case 13:return Xu("Suspense");case 19:return Xu("SuspenseList");case 0:case 2:case 15:return t=vg(t.type,!1),t;case 11:return t=vg(t.type.render,!1),t;case 1:return t=vg(t.type,!0),t;default:return""}}function Wm(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case aa:return"Fragment";case la:return"Portal";case Bm:return"Profiler";case Qy:return"StrictMode";case jm:return"Suspense";case Hm:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case kC:return(t.displayName||"Context")+".Consumer";case xC:return(t._context.displayName||"Context")+".Provider";case Zy:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case ev:return e=t.displayName||null,e!==null?e:Wm(t.type)||"Memo";case go:e=t._payload,t=t._init;try{return Wm(t(e))}catch{}}return null}function NO(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Wm(e);case 8:return e===Qy?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function $o(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function CC(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function _O(t){var e=CC(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,s=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Ff(t){t._valueTracker||(t._valueTracker=_O(t))}function TC(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=CC(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function th(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Vm(t,e){var n=e.checked;return xn({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function d1(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=$o(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function EC(t,e){e=e.checked,e!=null&&Jy(t,"checked",e,!1)}function Um(t,e){EC(t,e);var n=$o(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Km(t,e.type,n):e.hasOwnProperty("defaultValue")&&Km(t,e.type,$o(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function h1(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Km(t,e,n){(e!=="number"||th(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var Gu=Array.isArray;function Ta(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=zf.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function Ec(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var tc={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},DO=["Webkit","ms","Moz","O"];Object.keys(tc).forEach(function(t){DO.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),tc[e]=tc[t]})});function OC(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||tc.hasOwnProperty(t)&&tc[t]?(""+e).trim():e+"px"}function PC(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=OC(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,i):t[n]=i}}var LO=xn({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function qm(t,e){if(e){if(LO[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(fe(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(fe(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(fe(61))}if(e.style!=null&&typeof e.style!="object")throw Error(fe(62))}}function Ym(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Jm=null;function tv(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Qm=null,Ea=null,Aa=null;function m1(t){if(t=nf(t)){if(typeof Qm!="function")throw Error(fe(280));var e=t.stateNode;e&&(e=pp(e),Qm(t.stateNode,t.type,e))}}function IC(t){Ea?Aa?Aa.push(t):Aa=[t]:Ea=t}function NC(){if(Ea){var t=Ea,e=Aa;if(Aa=Ea=null,m1(t),e)for(t=0;t>>=0,t===0?32:31-(XO(t)/GO|0)|0}var Bf=64,jf=4194304;function qu(t){switch(t&-t){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: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 t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function sh(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,s=t.pingedLanes,o=n&268435455;if(o!==0){var l=o&~i;l!==0?r=qu(l):(s&=o,s!==0&&(r=qu(s)))}else o=n&~i,o!==0?r=qu(o):s!==0&&(r=qu(s));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if(r&4&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0n;n++)e.push(t);return e}function ef(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Gi(e),t[e]=n}function QO(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=rc),T1=" ",E1=!1;function ZC(t,e){switch(t){case"keyup":return EP.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function e2(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var ua=!1;function MP(t,e){switch(t){case"compositionend":return e2(e);case"keypress":return e.which!==32?null:(E1=!0,T1);case"textInput":return t=e.data,t===T1&&E1?null:t;default:return null}}function RP(t,e){if(ua)return t==="compositionend"||!uv&&ZC(t,e)?(t=JC(),Dd=ov=Co=null,ua=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=O1(n)}}function i2(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?i2(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function s2(){for(var t=window,e=th();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=th(t.document)}return e}function cv(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function FP(t){var e=s2(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&i2(n.ownerDocument.documentElement,n)){if(r!==null&&cv(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!t.extend&&s>r&&(i=r,r=s,s=i),i=P1(n,s);var o=P1(n,r);i&&o&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),s>r?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,ca=null,i0=null,sc=null,s0=!1;function I1(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;s0||ca==null||ca!==th(r)||(r=ca,"selectionStart"in r&&cv(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),sc&&Ic(sc,r)||(sc=r,r=ah(i0,"onSelect"),0ha||(t.current=f0[ha],f0[ha]=null,ha--)}function cn(t,e){ha++,f0[ha]=t.current,t.current=e}var Fo={},mr=Uo(Fo),Lr=Uo(!1),Tl=Fo;function Fa(t,e){var n=t.type.contextTypes;if(!n)return Fo;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=e[s];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function $r(t){return t=t.childContextTypes,t!=null}function ch(){pn(Lr),pn(mr)}function z1(t,e,n){if(mr.current!==Fo)throw Error(fe(168));cn(mr,e),cn(Lr,n)}function p2(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(fe(108,NO(t)||"Unknown",i));return xn({},n,r)}function fh(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Fo,Tl=mr.current,cn(mr,t),cn(Lr,Lr.current),!0}function B1(t,e,n){var r=t.stateNode;if(!r)throw Error(fe(169));n?(t=p2(t,e,Tl),r.__reactInternalMemoizedMergedChildContext=t,pn(Lr),pn(mr),cn(mr,t)):pn(Lr),cn(Lr,n)}var _s=null,gp=!1,Ig=!1;function g2(t){_s===null?_s=[t]:_s.push(t)}function YP(t){gp=!0,g2(t)}function Ko(){if(!Ig&&_s!==null){Ig=!0;var t=0,e=Xt;try{var n=_s;for(Xt=1;t>=o,i-=o,zs=1<<32-Gi(e)+i|n<A?(R=T,T=null):R=T.sibling;var P=d(m,T,w[A],k);if(P===null){T===null&&(T=R);break}t&&T&&P.alternate===null&&e(m,T),v=s(P,v,A),C===null?x=P:C.sibling=P,C=P,T=R}if(A===w.length)return n(m,T),yn&&al(m,A),x;if(T===null){for(;AA?(R=T,T=null):R=T.sibling;var _=d(m,T,P.value,k);if(_===null){T===null&&(T=R);break}t&&T&&_.alternate===null&&e(m,T),v=s(_,v,A),C===null?x=_:C.sibling=_,C=_,T=R}if(P.done)return n(m,T),yn&&al(m,A),x;if(T===null){for(;!P.done;A++,P=w.next())P=f(m,P.value,k),P!==null&&(v=s(P,v,A),C===null?x=P:C.sibling=P,C=P);return yn&&al(m,A),x}for(T=r(m,T);!P.done;A++,P=w.next())P=h(T,m,A,P.value,k),P!==null&&(t&&P.alternate!==null&&T.delete(P.key===null?A:P.key),v=s(P,v,A),C===null?x=P:C.sibling=P,C=P);return t&&T.forEach(function(O){return e(m,O)}),yn&&al(m,A),x}function b(m,v,w,k){if(typeof w=="object"&&w!==null&&w.type===aa&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case $f:e:{for(var x=w.key,C=v;C!==null;){if(C.key===x){if(x=w.type,x===aa){if(C.tag===7){n(m,C.sibling),v=i(C,w.props.children),v.return=m,m=v;break e}}else if(C.elementType===x||typeof x=="object"&&x!==null&&x.$$typeof===go&&W1(x)===C.type){n(m,C.sibling),v=i(C,w.props),v.ref=Ou(m,C,w),v.return=m,m=v;break e}n(m,C);break}else e(m,C);C=C.sibling}w.type===aa?(v=kl(w.props.children,m.mode,k,w.key),v.return=m,m=v):(k=Wd(w.type,w.key,w.props,null,m.mode,k),k.ref=Ou(m,v,w),k.return=m,m=k)}return o(m);case la:e:{for(C=w.key;v!==null;){if(v.key===C)if(v.tag===4&&v.stateNode.containerInfo===w.containerInfo&&v.stateNode.implementation===w.implementation){n(m,v.sibling),v=i(v,w.children||[]),v.return=m,m=v;break e}else{n(m,v);break}else e(m,v);v=v.sibling}v=Bg(w,m.mode,k),v.return=m,m=v}return o(m);case go:return C=w._init,b(m,v,C(w._payload),k)}if(Gu(w))return p(m,v,w,k);if(Tu(w))return g(m,v,w,k);Gf(m,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,v!==null&&v.tag===6?(n(m,v.sibling),v=i(v,w),v.return=m,m=v):(n(m,v),v=zg(w,m.mode,k),v.return=m,m=v),o(m)):n(m,v)}return b}var Ba=w2(!0),b2=w2(!1),ph=Uo(null),gh=null,ma=null,pv=null;function gv(){pv=ma=gh=null}function mv(t){var e=ph.current;pn(ph),t._currentValue=e}function p0(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function Ra(t,e){gh=t,pv=ma=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(_r=!0),t.firstContext=null)}function bi(t){var e=t._currentValue;if(pv!==t)if(t={context:t,memoizedValue:e,next:null},ma===null){if(gh===null)throw Error(fe(308));ma=t,gh.dependencies={lanes:0,firstContext:t}}else ma=ma.next=t;return e}var yl=null;function yv(t){yl===null?yl=[t]:yl.push(t)}function x2(t,e,n,r){var i=e.interleaved;return i===null?(n.next=n,yv(e)):(n.next=i.next,i.next=n),e.interleaved=n,Ks(t,r)}function Ks(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var mo=!1;function vv(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function k2(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Hs(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function Io(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,Dt&2){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,Ks(t,n)}return i=r.interleaved,i===null?(e.next=e,yv(r)):(e.next=i.next,i.next=e),r.interleaved=e,Ks(t,n)}function $d(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,rv(t,n)}}function V1(t,e){var n=t.updateQueue,r=t.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?i=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?i=s=e:s=s.next=e}else i=s=e;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function mh(t,e,n,r){var i=t.updateQueue;mo=!1;var s=i.firstBaseUpdate,o=i.lastBaseUpdate,l=i.shared.pending;if(l!==null){i.shared.pending=null;var a=l,u=a.next;a.next=null,o===null?s=u:o.next=u,o=a;var c=t.alternate;c!==null&&(c=c.updateQueue,l=c.lastBaseUpdate,l!==o&&(l===null?c.firstBaseUpdate=u:l.next=u,c.lastBaseUpdate=a))}if(s!==null){var f=i.baseState;o=0,c=u=a=null,l=s;do{var d=l.lane,h=l.eventTime;if((r&d)===d){c!==null&&(c=c.next={eventTime:h,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var p=t,g=l;switch(d=e,h=n,g.tag){case 1:if(p=g.payload,typeof p=="function"){f=p.call(h,f,d);break e}f=p;break e;case 3:p.flags=p.flags&-65537|128;case 0:if(p=g.payload,d=typeof p=="function"?p.call(h,f,d):p,d==null)break e;f=xn({},f,d);break e;case 2:mo=!0}}l.callback!==null&&l.lane!==0&&(t.flags|=64,d=i.effects,d===null?i.effects=[l]:d.push(l))}else h={eventTime:h,lane:d,tag:l.tag,payload:l.payload,callback:l.callback,next:null},c===null?(u=c=h,a=f):c=c.next=h,o|=d;if(l=l.next,l===null){if(l=i.shared.pending,l===null)break;d=l,l=d.next,d.next=null,i.lastBaseUpdate=d,i.shared.pending=null}}while(!0);if(c===null&&(a=f),i.baseState=a,i.firstBaseUpdate=u,i.lastBaseUpdate=c,e=i.shared.interleaved,e!==null){i=e;do o|=i.lane,i=i.next;while(i!==e)}else s===null&&(i.shared.lanes=0);Ml|=o,t.lanes=o,t.memoizedState=f}}function U1(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;en?n:4,t(!0);var r=_g.transition;_g.transition={};try{t(!1),e()}finally{Xt=n,_g.transition=r}}function z2(){return xi().memoizedState}function eI(t,e,n){var r=_o(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},B2(t))j2(e,n);else if(n=x2(t,e,n,r),n!==null){var i=Cr();qi(n,t,r,i),H2(n,e,r)}}function tI(t,e,n){var r=_o(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(B2(t))j2(e,i);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,l=s(o,n);if(i.hasEagerState=!0,i.eagerState=l,Yi(l,o)){var a=e.interleaved;a===null?(i.next=i,yv(e)):(i.next=a.next,a.next=i),e.interleaved=i;return}}catch{}finally{}n=x2(t,e,i,r),n!==null&&(i=Cr(),qi(n,t,r,i),H2(n,e,r))}}function B2(t){var e=t.alternate;return t===bn||e!==null&&e===bn}function j2(t,e){oc=vh=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function H2(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,rv(t,n)}}var wh={readContext:bi,useCallback:ur,useContext:ur,useEffect:ur,useImperativeHandle:ur,useInsertionEffect:ur,useLayoutEffect:ur,useMemo:ur,useReducer:ur,useRef:ur,useState:ur,useDebugValue:ur,useDeferredValue:ur,useTransition:ur,useMutableSource:ur,useSyncExternalStore:ur,useId:ur,unstable_isNewReconciler:!1},nI={readContext:bi,useCallback:function(t,e){return ds().memoizedState=[t,e===void 0?null:e],t},useContext:bi,useEffect:X1,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,zd(4194308,4,_2.bind(null,e,t),n)},useLayoutEffect:function(t,e){return zd(4194308,4,t,e)},useInsertionEffect:function(t,e){return zd(4,2,t,e)},useMemo:function(t,e){var n=ds();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=ds();return e=n!==void 0?n(e):e,r.memoizedState=r.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},r.queue=t,t=t.dispatch=eI.bind(null,bn,t),[r.memoizedState,t]},useRef:function(t){var e=ds();return t={current:t},e.memoizedState=t},useState:K1,useDebugValue:Ev,useDeferredValue:function(t){return ds().memoizedState=t},useTransition:function(){var t=K1(!1),e=t[0];return t=ZP.bind(null,t[1]),ds().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=bn,i=ds();if(yn){if(n===void 0)throw Error(fe(407));n=n()}else{if(n=e(),qn===null)throw Error(fe(349));Al&30||E2(r,e,n)}i.memoizedState=n;var s={value:n,getSnapshot:e};return i.queue=s,X1(M2.bind(null,r,s,t),[t]),r.flags|=2048,Bc(9,A2.bind(null,r,s,n,e),void 0,null),n},useId:function(){var t=ds(),e=qn.identifierPrefix;if(yn){var n=Bs,r=zs;n=(r&~(1<<32-Gi(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=Fc++,0<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=o.createElement(n,{is:r.is}):(t=o.createElement(n),n==="select"&&(o=t,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):t=o.createElementNS(t,n),t[hs]=e,t[Dc]=r,Q2(t,e,!1,!1),e.stateNode=t;e:{switch(o=Ym(n,r),n){case"dialog":dn("cancel",t),dn("close",t),i=r;break;case"iframe":case"object":case"embed":dn("load",t),i=r;break;case"video":case"audio":for(i=0;iWa&&(e.flags|=128,r=!0,Pu(s,!1),e.lanes=4194304)}else{if(!r)if(t=yh(o),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),Pu(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!yn)return cr(e),null}else 2*_n()-s.renderingStartTime>Wa&&n!==1073741824&&(e.flags|=128,r=!0,Pu(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(n=s.last,n!==null?n.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=_n(),e.sibling=null,n=wn.current,cn(wn,r?n&1|2:n&1),e):(cr(e),null);case 22:case 23:return Iv(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Xr&1073741824&&(cr(e),e.subtreeFlags&6&&(e.flags|=8192)):cr(e),null;case 24:return null;case 25:return null}throw Error(fe(156,e.tag))}function cI(t,e){switch(dv(e),e.tag){case 1:return $r(e.type)&&ch(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return ja(),pn(Lr),pn(mr),xv(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return bv(e),null;case 13:if(pn(wn),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(fe(340));za()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return pn(wn),null;case 4:return ja(),null;case 10:return mv(e.type._context),null;case 22:case 23:return Iv(),null;case 24:return null;default:return null}}var Yf=!1,pr=!1,fI=typeof WeakSet=="function"?WeakSet:Set,De=null;function ya(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Cn(t,e,r)}else n.current=null}function S0(t,e,n){try{n()}catch(r){Cn(t,e,r)}}var ib=!1;function dI(t,e){if(o0=oh,t=s2(),cv(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,l=-1,a=-1,u=0,c=0,f=t,d=null;t:for(;;){for(var h;f!==n||i!==0&&f.nodeType!==3||(l=o+i),f!==s||r!==0&&f.nodeType!==3||(a=o+r),f.nodeType===3&&(o+=f.nodeValue.length),(h=f.firstChild)!==null;)d=f,f=h;for(;;){if(f===t)break t;if(d===n&&++u===i&&(l=o),d===s&&++c===r&&(a=o),(h=f.nextSibling)!==null)break;f=d,d=f.parentNode}f=h}n=l===-1||a===-1?null:{start:l,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(l0={focusedElem:t,selectionRange:n},oh=!1,De=e;De!==null;)if(e=De,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,De=t;else for(;De!==null;){e=De;try{var p=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(p!==null){var g=p.memoizedProps,b=p.memoizedState,m=e.stateNode,v=m.getSnapshotBeforeUpdate(e.elementType===e.type?g:Fi(e.type,g),b);m.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var w=e.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(fe(163))}}catch(k){Cn(e,e.return,k)}if(t=e.sibling,t!==null){t.return=e.return,De=t;break}De=e.return}return p=ib,ib=!1,p}function lc(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var s=i.destroy;i.destroy=void 0,s!==void 0&&S0(e,n,s)}i=i.next}while(i!==r)}}function vp(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function C0(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function tT(t){var e=t.alternate;e!==null&&(t.alternate=null,tT(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[hs],delete e[Dc],delete e[c0],delete e[GP],delete e[qP])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function nT(t){return t.tag===5||t.tag===3||t.tag===4}function sb(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||nT(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function T0(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=uh));else if(r!==4&&(t=t.child,t!==null))for(T0(t,e,n),t=t.sibling;t!==null;)T0(t,e,n),t=t.sibling}function E0(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(E0(t,e,n),t=t.sibling;t!==null;)E0(t,e,n),t=t.sibling}var Zn=null,zi=!1;function so(t,e,n){for(n=n.child;n!==null;)rT(t,e,n),n=n.sibling}function rT(t,e,n){if(ks&&typeof ks.onCommitFiberUnmount=="function")try{ks.onCommitFiberUnmount(cp,n)}catch{}switch(n.tag){case 5:pr||ya(n,e);case 6:var r=Zn,i=zi;Zn=null,so(t,e,n),Zn=r,zi=i,Zn!==null&&(zi?(t=Zn,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):Zn.removeChild(n.stateNode));break;case 18:Zn!==null&&(zi?(t=Zn,n=n.stateNode,t.nodeType===8?Pg(t.parentNode,n):t.nodeType===1&&Pg(t,n),Oc(t)):Pg(Zn,n.stateNode));break;case 4:r=Zn,i=zi,Zn=n.stateNode.containerInfo,zi=!0,so(t,e,n),Zn=r,zi=i;break;case 0:case 11:case 14:case 15:if(!pr&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&S0(n,e,o),i=i.next}while(i!==r)}so(t,e,n);break;case 1:if(!pr&&(ya(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Cn(n,e,l)}so(t,e,n);break;case 21:so(t,e,n);break;case 22:n.mode&1?(pr=(r=pr)||n.memoizedState!==null,so(t,e,n),pr=r):so(t,e,n);break;default:so(t,e,n)}}function ob(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new fI),e.forEach(function(r){var i=xI.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Di(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=_n()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*pI(r/1960))-r,10t?16:t,To===null)var r=!1;else{if(t=To,To=null,kh=0,Dt&6)throw Error(fe(331));var i=Dt;for(Dt|=4,De=t.current;De!==null;){var s=De,o=s.child;if(De.flags&16){var l=s.deletions;if(l!==null){for(var a=0;a_n()-Ov?xl(t,0):Rv|=n),Fr(t,e)}function fT(t,e){e===0&&(t.mode&1?(e=jf,jf<<=1,!(jf&130023424)&&(jf=4194304)):e=1);var n=Cr();t=Ks(t,e),t!==null&&(ef(t,e,n),Fr(t,n))}function bI(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),fT(t,n)}function xI(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,i=t.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(fe(314))}r!==null&&r.delete(e),fT(t,n)}var dT;dT=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Lr.current)_r=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return _r=!1,aI(t,e,n);_r=!!(t.flags&131072)}else _r=!1,yn&&e.flags&1048576&&m2(e,hh,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;Bd(t,e),t=e.pendingProps;var i=Fa(e,mr.current);Ra(e,n),i=Sv(null,e,r,t,i,n);var s=Cv();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,$r(r)?(s=!0,fh(e)):s=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,vv(e),i.updater=yp,e.stateNode=i,i._reactInternals=e,m0(e,r,t,n),e=w0(null,e,r,!0,s,n)):(e.tag=0,yn&&s&&fv(e),kr(null,e,i,n),e=e.child),e;case 16:r=e.elementType;e:{switch(Bd(t,e),t=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=SI(r),t=Fi(r,t),i){case 0:e=v0(null,e,r,t,n);break e;case 1:e=tb(null,e,r,t,n);break e;case 11:e=Z1(null,e,r,t,n);break e;case 14:e=eb(null,e,r,Fi(r.type,t),n);break e}throw Error(fe(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Fi(r,i),v0(t,e,r,i,n);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Fi(r,i),tb(t,e,r,i,n);case 3:e:{if(q2(e),t===null)throw Error(fe(387));r=e.pendingProps,s=e.memoizedState,i=s.element,k2(t,e),mh(e,r,null,n);var o=e.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){i=Ha(Error(fe(423)),e),e=nb(t,e,r,n,i);break e}else if(r!==i){i=Ha(Error(fe(424)),e),e=nb(t,e,r,n,i);break e}else for(Zr=Po(e.stateNode.containerInfo.firstChild),ei=e,yn=!0,Bi=null,n=b2(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(za(),r===i){e=Xs(t,e,n);break e}kr(t,e,r,n)}e=e.child}return e;case 5:return S2(e),t===null&&h0(e),r=e.type,i=e.pendingProps,s=t!==null?t.memoizedProps:null,o=i.children,a0(r,i)?o=null:s!==null&&a0(r,s)&&(e.flags|=32),G2(t,e),kr(t,e,o,n),e.child;case 6:return t===null&&h0(e),null;case 13:return Y2(t,e,n);case 4:return wv(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Ba(e,null,r,n):kr(t,e,r,n),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Fi(r,i),Z1(t,e,r,i,n);case 7:return kr(t,e,e.pendingProps,n),e.child;case 8:return kr(t,e,e.pendingProps.children,n),e.child;case 12:return kr(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,s=e.memoizedProps,o=i.value,cn(ph,r._currentValue),r._currentValue=o,s!==null)if(Yi(s.value,o)){if(s.children===i.children&&!Lr.current){e=Xs(t,e,n);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var l=s.dependencies;if(l!==null){o=s.child;for(var a=l.firstContext;a!==null;){if(a.context===r){if(s.tag===1){a=Hs(-1,n&-n),a.tag=2;var u=s.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?a.next=a:(a.next=c.next,c.next=a),u.pending=a}}s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),p0(s.return,n,e),l.lanes|=n;break}a=a.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(fe(341));o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),p0(o,n,e),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===e){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}kr(t,e,i.children,n),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,Ra(e,n),i=bi(i),r=r(i),e.flags|=1,kr(t,e,r,n),e.child;case 14:return r=e.type,i=Fi(r,e.pendingProps),i=Fi(r.type,i),eb(t,e,r,i,n);case 15:return K2(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Fi(r,i),Bd(t,e),e.tag=1,$r(r)?(t=!0,fh(e)):t=!1,Ra(e,n),W2(e,r,i),m0(e,r,i,n),w0(null,e,r,!0,t,n);case 19:return J2(t,e,n);case 22:return X2(t,e,n)}throw Error(fe(156,e.tag))};function hT(t,e){return BC(t,e)}function kI(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function di(t,e,n,r){return new kI(t,e,n,r)}function _v(t){return t=t.prototype,!(!t||!t.isReactComponent)}function SI(t){if(typeof t=="function")return _v(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Zy)return 11;if(t===ev)return 14}return 2}function Do(t,e){var n=t.alternate;return n===null?(n=di(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function Wd(t,e,n,r,i,s){var o=2;if(r=t,typeof t=="function")_v(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case aa:return kl(n.children,i,s,e);case Qy:o=8,i|=8;break;case Bm:return t=di(12,n,e,i|2),t.elementType=Bm,t.lanes=s,t;case jm:return t=di(13,n,e,i),t.elementType=jm,t.lanes=s,t;case Hm:return t=di(19,n,e,i),t.elementType=Hm,t.lanes=s,t;case SC:return bp(n,i,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case xC:o=10;break e;case kC:o=9;break e;case Zy:o=11;break e;case ev:o=14;break e;case go:o=16,r=null;break e}throw Error(fe(130,t==null?t:typeof t,""))}return e=di(o,n,e,i),e.elementType=t,e.type=r,e.lanes=s,e}function kl(t,e,n,r){return t=di(7,t,r,e),t.lanes=n,t}function bp(t,e,n,r){return t=di(22,t,r,e),t.elementType=SC,t.lanes=n,t.stateNode={isHidden:!1},t}function zg(t,e,n){return t=di(6,t,null,e),t.lanes=n,t}function Bg(t,e,n){return e=di(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function CI(t,e,n,r,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=bg(0),this.expirationTimes=bg(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=bg(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Dv(t,e,n,r,i,s,o,l,a){return t=new CI(t,e,n,l,a),e===1?(e=1,s===!0&&(e|=8)):e=0,s=di(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},vv(s),t}function TI(t,e,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(yT)}catch(t){console.error(t)}}yT(),yC.exports=ni;var OI=yC.exports,vT,pb=OI;vT=pb.createRoot,pb.hydrateRoot;function wT(){return""}function PI(){return/^G-[A-Z0-9]+$/.test(wT())}function II(){const t=window.gtag;typeof t=="function"&&PI()&&t("config",wT(),{send_page_view:!1})}function NI(){var t,e;(t=window.gtag)==null||t.call(window,"event","page_view",{page_path:window.location.pathname,page_location:window.location.href}),(e=window.plausible)==null||e.call(window,"pageview")}function _I(){var t,e;(t=window.gtag)==null||t.call(window,"event","permalink_view"),(e=window.plausible)==null||e.call(window,"Permalink View")}function DI(){var t,e;(t=window.gtag)==null||t.call(window,"event","changelog_open"),(e=window.plausible)==null||e.call(window,"Changelog Open")}function LI(t){var e,n;(e=window.gtag)==null||e.call(window,"event","changelog_vote",{...t}),(n=window.plausible)==null||n.call(window,"Changelog Vote",{props:{...t}})}function $I(t){return t.charAt(0).toUpperCase()+t.slice(1)}function Tp(t,e){var n,r;(n=window.gtag)==null||n.call(window,"event",t,{...e}),(r=window.plausible)==null||r.call(window,$I(t),{props:{...e}})}function FI(t){Tp("input",t)}function zI(t){Tp("conversion",t)}function tl(t){const e={via:t.via,format:t.format,...t.pane!==void 0?{pane:t.pane}:{},...t.direction!==void 0?{direction:t.direction}:{}};Tp("export",e)}function BI(t){Tp("feedback",t)}function jI(t){return new TextEncoder().encode(t).length}function HI(t){return t<10*1024?"<10KB":t<100*1024?"10-100KB":t<1024*1024?"100KB-1MB":">1MB"}function WI(t){let e=2166136261;for(let n=0;n>>0).toString(36)}function VI(t={}){const e=t.settleMs??2e3,n=t.minWindowMs??2e3,r=t.now??(()=>Date.now()),i=t.isValid??(()=>!0);let s=null,o,l=null,a=0,u=null,c=0;function f(h){if(h.text.trim()==="")return!1;const p=jI(h.text),g=HI(p),b=i(h.direction,h.text),m=`${h.direction}:${h.input}:${p}:${WI(h.text)}`,v=r();return m!==l&&(a===0||v-a>=n)&&(l=m,a=v,FI({direction:h.direction,input:h.input,size:g,valid:b})),!b||m===u||c!==0&&v-c{o=void 0,s&&f(s)},e)}return{edit(h,p){s={direction:h,input:"paste",text:p},d()},discrete(h,p,g){s={direction:h,input:p,text:g},d(),f(s)},cancel(){s=null,l=null,u=null,o&&(clearTimeout(o),o=void 0)}}}/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const bT=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const UI=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const KI=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const gb=t=>{const e=KI(t);return e.charAt(0).toUpperCase()+e.slice(1)};/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */var jg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const XI=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1},GI=y.createContext({}),qI=()=>y.useContext(GI),YI=y.forwardRef(({color:t,size:e,strokeWidth:n,absoluteStrokeWidth:r,className:i="",children:s,iconNode:o,...l},a)=>{const{size:u=24,strokeWidth:c=2,absoluteStrokeWidth:f=!1,color:d="currentColor",className:h=""}=qI()??{},p=r??f?Number(n??c)*24/Number(e??u):n??c;return y.createElement("svg",{ref:a,...jg,width:e??u??jg.width,height:e??u??jg.height,stroke:t??d,strokeWidth:p,className:bT("lucide",h,i),...!s&&!XI(l)&&{"aria-hidden":"true"},...l},[...o.map(([g,b])=>y.createElement(g,b)),...Array.isArray(s)?s:[s]])});/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Mn=(t,e)=>{const n=y.forwardRef(({className:r,...i},s)=>y.createElement(YI,{ref:s,iconNode:e,className:bT(`lucide-${UI(gb(t))}`,`lucide-${t}`,r),...i}));return n.displayName=gb(t),n};/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const JI=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],QI=Mn("arrow-left-right",JI);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ZI=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],mb=Mn("braces",ZI);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const eN=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],tN=Mn("chevron-down",eN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const nN=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]],rN=Mn("clipboard",nN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const iN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],sN=Mn("clock",iN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const oN=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],lN=Mn("columns-3",oN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const aN=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],zv=Mn("copy",aN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const uN=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],xT=Mn("download",uN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const cN=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]],kT=Mn("file-up",cN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const fN=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],dN=Mn("moon",fN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const hN=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],pN=Mn("redo-2",hN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const gN=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],mN=Mn("rotate-ccw-clock",gN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const yN=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],yb=Mn("rotate-ccw",yN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const vN=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],wN=Mn("search",vN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const bN=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],xN=Mn("sparkles",bN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const kN=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],SN=Mn("sun",kN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const CN=[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]],TN=Mn("table",CN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const EN=[["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}],["path",{d:"M17 14V2",key:"8ymqnk"}]],AN=Mn("thumbs-down",EN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const MN=[["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}],["path",{d:"M7 10v12",key:"1qc93n"}]],RN=Mn("thumbs-up",MN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ON=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Th=Mn("trash",ON);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const PN=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],IN=Mn("undo-2",PN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const NN=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Eh=Mn("x",NN);function ST(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e{const e=$N(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{const l=o.split(Bv);return l[0]===""&&l.length!==1&&l.shift(),CT(l,e)||LN(o)},getConflictingClassGroupIds:(o,l)=>{const a=n[o]||[];return l&&r[o]?[...a,...r[o]]:a}}},CT=(t,e)=>{var o;if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),i=r?CT(t.slice(1),r):void 0;if(i)return i;if(e.validators.length===0)return;const s=t.join(Bv);return(o=e.validators.find(({validator:l})=>l(s)))==null?void 0:o.classGroupId},vb=/^\[(.+)\]$/,LN=t=>{if(vb.test(t)){const e=vb.exec(t)[1],n=e==null?void 0:e.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},$N=t=>{const{theme:e,prefix:n}=t,r={nextPart:new Map,validators:[]};return zN(Object.entries(t.classGroups),n).forEach(([s,o])=>{P0(o,r,s,e)}),r},P0=(t,e,n,r)=>{t.forEach(i=>{if(typeof i=="string"){const s=i===""?e:wb(e,i);s.classGroupId=n;return}if(typeof i=="function"){if(FN(i)){P0(i(r),e,n,r);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([s,o])=>{P0(o,wb(e,s),n,r)})})},wb=(t,e)=>{let n=t;return e.split(Bv).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},FN=t=>t.isThemeGetter,zN=(t,e)=>e?t.map(([n,r])=>{const i=r.map(s=>typeof s=="string"?e+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,l])=>[e+o,l])):s);return[n,i]}):t,BN=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,r=new Map;const i=(s,o)=>{n.set(s,o),e++,e>t&&(e=0,r=n,n=new Map)};return{get(s){let o=n.get(s);if(o!==void 0)return o;if((o=r.get(s))!==void 0)return i(s,o),o},set(s,o){n.has(s)?n.set(s,o):i(s,o)}}},TT="!",jN=t=>{const{separator:e,experimentalParseClassName:n}=t,r=e.length===1,i=e[0],s=e.length,o=l=>{const a=[];let u=0,c=0,f;for(let b=0;bc?f-c:void 0;return{modifiers:a,hasImportantModifier:h,baseClassName:p,maybePostfixModifierPosition:g}};return n?l=>n({className:l,parseClassName:o}):o},HN=t=>{if(t.length<=1)return t;const e=[];let n=[];return t.forEach(r=>{r[0]==="["?(e.push(...n.sort(),r),n=[]):n.push(r)}),e.push(...n.sort()),e},WN=t=>({cache:BN(t.cacheSize),parseClassName:jN(t),...DN(t)}),VN=/\s+/,UN=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=e,s=[],o=t.trim().split(VN);let l="";for(let a=o.length-1;a>=0;a-=1){const u=o[a],{modifiers:c,hasImportantModifier:f,baseClassName:d,maybePostfixModifierPosition:h}=n(u);let p=!!h,g=r(p?d.substring(0,h):d);if(!g){if(!p){l=u+(l.length>0?" "+l:l);continue}if(g=r(d),!g){l=u+(l.length>0?" "+l:l);continue}p=!1}const b=HN(c).join(":"),m=f?b+TT:b,v=m+g;if(s.includes(v))continue;s.push(v);const w=i(g,p);for(let k=0;k0?" "+l:l)}return l};function KN(){let t=0,e,n,r="";for(;t{if(typeof t=="string")return t;let e,n="";for(let r=0;rf(c),t());return n=WN(u),r=n.cache.get,i=n.cache.set,s=l,l(a)}function l(a){const u=r(a);if(u)return u;const c=UN(a,n);return i(a,c),c}return function(){return s(KN.apply(null,arguments))}}const fn=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},AT=/^\[(?:([a-z-]+):)?(.+)\]$/i,GN=/^\d+\/\d+$/,qN=new Set(["px","full","screen"]),YN=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,JN=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,QN=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ZN=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,e_=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ps=t=>Pa(t)||qN.has(t)||GN.test(t),oo=t=>su(t,"length",a_),Pa=t=>!!t&&!Number.isNaN(Number(t)),Hg=t=>su(t,"number",Pa),Nu=t=>!!t&&Number.isInteger(Number(t)),t_=t=>t.endsWith("%")&&Pa(t.slice(0,-1)),bt=t=>AT.test(t),lo=t=>YN.test(t),n_=new Set(["length","size","percentage"]),r_=t=>su(t,n_,MT),i_=t=>su(t,"position",MT),s_=new Set(["image","url"]),o_=t=>su(t,s_,c_),l_=t=>su(t,"",u_),_u=()=>!0,su=(t,e,n)=>{const r=AT.exec(t);return r?r[1]?typeof e=="string"?r[1]===e:e.has(r[1]):n(r[2]):!1},a_=t=>JN.test(t)&&!QN.test(t),MT=()=>!1,u_=t=>ZN.test(t),c_=t=>e_.test(t),f_=()=>{const t=fn("colors"),e=fn("spacing"),n=fn("blur"),r=fn("brightness"),i=fn("borderColor"),s=fn("borderRadius"),o=fn("borderSpacing"),l=fn("borderWidth"),a=fn("contrast"),u=fn("grayscale"),c=fn("hueRotate"),f=fn("invert"),d=fn("gap"),h=fn("gradientColorStops"),p=fn("gradientColorStopPositions"),g=fn("inset"),b=fn("margin"),m=fn("opacity"),v=fn("padding"),w=fn("saturate"),k=fn("scale"),x=fn("sepia"),C=fn("skew"),T=fn("space"),A=fn("translate"),R=()=>["auto","contain","none"],P=()=>["auto","hidden","clip","visible","scroll"],_=()=>["auto",bt,e],O=()=>[bt,e],D=()=>["",Ps,oo],N=()=>["auto",Pa,bt],ne=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ie=()=>["solid","dashed","dotted","double","none"],V=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],j=()=>["start","end","center","between","around","evenly","stretch"],G=()=>["","0",bt],M=()=>["auto","avoid","all","avoid-page","page","left","right","column"],I=()=>[Pa,bt];return{cacheSize:500,separator:":",theme:{colors:[_u],spacing:[Ps,oo],blur:["none","",lo,bt],brightness:I(),borderColor:[t],borderRadius:["none","","full",lo,bt],borderSpacing:O(),borderWidth:D(),contrast:I(),grayscale:G(),hueRotate:I(),invert:G(),gap:O(),gradientColorStops:[t],gradientColorStopPositions:[t_,oo],inset:_(),margin:_(),opacity:I(),padding:O(),saturate:I(),scale:I(),sepia:G(),skew:I(),space:O(),translate:O()},classGroups:{aspect:[{aspect:["auto","square","video",bt]}],container:["container"],columns:[{columns:[lo]}],"break-after":[{"break-after":M()}],"break-before":[{"break-before":M()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...ne(),bt]}],overflow:[{overflow:P()}],"overflow-x":[{"overflow-x":P()}],"overflow-y":[{"overflow-y":P()}],overscroll:[{overscroll:R()}],"overscroll-x":[{"overscroll-x":R()}],"overscroll-y":[{"overscroll-y":R()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[g]}],"inset-x":[{"inset-x":[g]}],"inset-y":[{"inset-y":[g]}],start:[{start:[g]}],end:[{end:[g]}],top:[{top:[g]}],right:[{right:[g]}],bottom:[{bottom:[g]}],left:[{left:[g]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Nu,bt]}],basis:[{basis:_()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",bt]}],grow:[{grow:G()}],shrink:[{shrink:G()}],order:[{order:["first","last","none",Nu,bt]}],"grid-cols":[{"grid-cols":[_u]}],"col-start-end":[{col:["auto",{span:["full",Nu,bt]},bt]}],"col-start":[{"col-start":N()}],"col-end":[{"col-end":N()}],"grid-rows":[{"grid-rows":[_u]}],"row-start-end":[{row:["auto",{span:[Nu,bt]},bt]}],"row-start":[{"row-start":N()}],"row-end":[{"row-end":N()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",bt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",bt]}],gap:[{gap:[d]}],"gap-x":[{"gap-x":[d]}],"gap-y":[{"gap-y":[d]}],"justify-content":[{justify:["normal",...j()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...j(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...j(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[v]}],px:[{px:[v]}],py:[{py:[v]}],ps:[{ps:[v]}],pe:[{pe:[v]}],pt:[{pt:[v]}],pr:[{pr:[v]}],pb:[{pb:[v]}],pl:[{pl:[v]}],m:[{m:[b]}],mx:[{mx:[b]}],my:[{my:[b]}],ms:[{ms:[b]}],me:[{me:[b]}],mt:[{mt:[b]}],mr:[{mr:[b]}],mb:[{mb:[b]}],ml:[{ml:[b]}],"space-x":[{"space-x":[T]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[T]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",bt,e]}],"min-w":[{"min-w":[bt,e,"min","max","fit"]}],"max-w":[{"max-w":[bt,e,"none","full","min","max","fit","prose",{screen:[lo]},lo]}],h:[{h:[bt,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[bt,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[bt,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[bt,e,"auto","min","max","fit"]}],"font-size":[{text:["base",lo,oo]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Hg]}],"font-family":[{font:[_u]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",bt]}],"line-clamp":[{"line-clamp":["none",Pa,Hg]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Ps,bt]}],"list-image":[{"list-image":["none",bt]}],"list-style-type":[{list:["none","disc","decimal",bt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[m]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[m]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ie(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Ps,oo]}],"underline-offset":[{"underline-offset":["auto",Ps,bt]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:O()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",bt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",bt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[m]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...ne(),i_]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",r_]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},o_]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[p]}],"gradient-via-pos":[{via:[p]}],"gradient-to-pos":[{to:[p]}],"gradient-from":[{from:[h]}],"gradient-via":[{via:[h]}],"gradient-to":[{to:[h]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[m]}],"border-style":[{border:[...ie(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[m]}],"divide-style":[{divide:ie()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...ie()]}],"outline-offset":[{"outline-offset":[Ps,bt]}],"outline-w":[{outline:[Ps,oo]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:D()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[m]}],"ring-offset-w":[{"ring-offset":[Ps,oo]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",lo,l_]}],"shadow-color":[{shadow:[_u]}],opacity:[{opacity:[m]}],"mix-blend":[{"mix-blend":[...V(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":V()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[a]}],"drop-shadow":[{"drop-shadow":["","none",lo,bt]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[c]}],invert:[{invert:[f]}],saturate:[{saturate:[w]}],sepia:[{sepia:[x]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[a]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[c]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[m]}],"backdrop-saturate":[{"backdrop-saturate":[w]}],"backdrop-sepia":[{"backdrop-sepia":[x]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",bt]}],duration:[{duration:I()}],ease:[{ease:["linear","in","out","in-out",bt]}],delay:[{delay:I()}],animate:[{animate:["none","spin","ping","pulse","bounce",bt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[k]}],"scale-x":[{"scale-x":[k]}],"scale-y":[{"scale-y":[k]}],rotate:[{rotate:[Nu,bt]}],"translate-x":[{"translate-x":[A]}],"translate-y":[{"translate-y":[A]}],"skew-x":[{"skew-x":[C]}],"skew-y":[{"skew-y":[C]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",bt]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",bt]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":O()}],"scroll-mx":[{"scroll-mx":O()}],"scroll-my":[{"scroll-my":O()}],"scroll-ms":[{"scroll-ms":O()}],"scroll-me":[{"scroll-me":O()}],"scroll-mt":[{"scroll-mt":O()}],"scroll-mr":[{"scroll-mr":O()}],"scroll-mb":[{"scroll-mb":O()}],"scroll-ml":[{"scroll-ml":O()}],"scroll-p":[{"scroll-p":O()}],"scroll-px":[{"scroll-px":O()}],"scroll-py":[{"scroll-py":O()}],"scroll-ps":[{"scroll-ps":O()}],"scroll-pe":[{"scroll-pe":O()}],"scroll-pt":[{"scroll-pt":O()}],"scroll-pr":[{"scroll-pr":O()}],"scroll-pb":[{"scroll-pb":O()}],"scroll-pl":[{"scroll-pl":O()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",bt]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[Ps,oo,Hg]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},d_=XN(f_);function Gn(...t){return d_(_N(t))}function Wg(t){return t==="csv2json"?"CSV → JSON":"JSON → CSV"}function h_({flipped:t}){return E.jsx(QI,{size:18,strokeWidth:2,"aria-hidden":"true",className:Gn("transition-transform duration-300",t&&"rotate-180")})}function p_({direction:t,onFlip:e}){return E.jsxs("button",{type:"button","data-testid":"divider-switch",onClick:e,onMouseDown:n=>n.stopPropagation(),onDoubleClick:n=>n.stopPropagation(),title:`Switch direction (currently ${Wg(t)})`,"aria-label":`Switch conversion direction (currently ${Wg(t)})`,className:"flex h-9 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-full border border-border bg-background px-3 text-xs font-medium text-muted-foreground shadow-sm transition-colors hover:border-muted-foreground/50 hover:text-foreground md:h-8 md:gap-1 md:px-2.5 md:text-[11px]",children:[E.jsx(h_,{flipped:t==="json2csv"}),E.jsx("span",{"data-testid":"divider-switch-label",children:Wg(t)})]})}const RT=[{question:"How does it work?",answer:"Paste CSV or JSON into the left pane and the conversion runs as you type — no upload, no submit button. Flip the direction with the switch between the panes to convert JSON back to CSV, then copy the result or download it as a file. The converter understands quoted fields, embedded separators, and Unicode."},{question:"What do the options do?",answer:"Separator picks the delimiter — auto-detect covers comma, semicolon, and tab. Parse numbers is on by default with smart semantics — plain numbers like 5 or 19.99 become real JSON numbers, while leading-zero values like 00721 and very long IDs stay strings; uncheck it to keep numeric cells as strings — booleans, null, and containers still convert while Parse JSON is on. Parse JSON converts null, true, false, [] and {} cells into real JSON values instead of strings. Transpose flips rows and columns; Hash output makes the first column the object key; Minify removes indentation from JSON output. On the JSON to CSV side, Flatten explodes nested arrays into extra rows with dotted keys."},{question:"TSV vs CSV — what changes?",answer:"Only the delimiter: TSV separates cells with tabs, CSV with commas. Anything you can paste from Excel or Google Sheets is tab-separated, and auto-detect picks that up — or choose Tab in the separator menu. Quoting rules only apply to comma and semicolon output; TSV rarely needs them."},{question:"Does my data ever leave the browser?",answer:"No. The conversion runs entirely in your browser — nothing is uploaded, nothing is stored, nothing is logged. Files you open are read locally in the page, there is no account and no server processing. The site's analytics never see your data: Plausible counts visits cookieless, and the Google tag is a standard conversion-measurement tag that uses the page URL, referrer, and a first-party conversion cookie to measure ad performance. Your files and converted output never leave the browser. When you send feedback, we store your vote and anything you choose to write — nothing else."}],g_={"@context":"https://schema.org","@type":"FAQPage",mainEntity:RT.map(t=>({"@type":"Question",name:t.question,acceptedAnswer:{"@type":"Answer",text:t.answer}}))};function m_(){const[t,e]=y.useState(!1),n=y.useId();return E.jsxs("section",{"data-testid":"faq","aria-label":"How it works and frequently asked questions",className:"flex-shrink-0 border-t border-border bg-panel px-4",children:[E.jsxs("button",{type:"button","data-testid":"faq-toggle","aria-expanded":t,"aria-controls":n,onClick:()=>e(r=>!r),className:"flex w-full cursor-pointer items-center gap-1.5 py-2 text-[12.5px] text-muted-foreground hover:text-foreground",children:[E.jsx("span",{"aria-hidden":"true",className:"w-3 text-center",children:t?"▾":"▸"}),"How it works & FAQ"]}),E.jsx("div",{id:n,"data-testid":"faq-content",hidden:!t,className:"max-w-3xl pb-4 text-[13px] leading-relaxed text-muted-foreground",children:RT.map(r=>E.jsxs("div",{className:"mb-3 last:mb-0",children:[E.jsx("h2",{className:"mb-0.5 text-[11px] font-semibold uppercase tracking-[0.1em] text-foreground",children:r.question}),E.jsx("p",{children:r.answer})]},r.question))}),E.jsx("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(g_)}})]})}const y_="https://github.com/FlatFilers/csvjson-app/discussions/163";function v_(){return E.jsx("div",{"data-testid":"feedback-banner",className:"flex flex-shrink-0 items-center justify-center border-b border-border bg-muted px-3 py-1.5 text-xs text-muted-foreground sm:px-4 sm:text-sm",children:E.jsxs("p",{className:"text-center",children:["Enjoy a cleaner, simpler CSVJSON."," ",E.jsx("a",{"data-testid":"feedback-link",href:y_,target:"_blank",rel:"noopener noreferrer",className:"rounded-sm font-medium text-foreground underline decoration-border underline-offset-2 transition-colors hover:decoration-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:"Leave feedback or ask for features here"}),"."]})})}const OT="csvjson:feedback.v1",w_=[{value:"wrong_output",label:"The conversion is wrong"},{value:"hard_to_use",label:"Hard to use"},{value:"missing_feature",label:"Missing a feature"},{value:"slower",label:"Slower than the old site"},{value:"looks_worse",label:"Looks worse"},{value:"other",label:"Other"}];function b_(t){if(typeof t!="object"||t===null)return!1;const e=t;return typeof e.clientId=="string"&&e.clientId.length<=64&&(e.vote===1||e.vote===-1)&&(typeof e.reasonCode=="string"||e.reasonCode===null)&&(typeof e.reasonText=="string"||e.reasonText===null)&&typeof e.pending=="boolean"}function bb(){try{const t=window.localStorage.getItem(OT);if(t===null)return null;const e=JSON.parse(t);return b_(e)?e:null}catch{return null}}function xb(t){try{window.localStorage.setItem(OT,JSON.stringify(t))}catch{}}function kb(){var n,r,i;if(typeof((n=globalThis.crypto)==null?void 0:n.randomUUID)=="function")return globalThis.crypto.randomUUID();const t=(i=(r=globalThis.crypto)==null?void 0:r.getRandomValues)==null?void 0:i.call(r,new Uint8Array(16));if(t===void 0)throw new Error("no secure randomness available");t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=Array.from(t,s=>s.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}function x_(t){const e=window.location.pathname;return t.vote===1?{clientId:t.clientId,vote:1,path:e}:{clientId:t.clientId,vote:-1,reasonCode:t.reasonCode,reasonText:t.reasonText,path:e}}async function k_(t){try{return(await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(x_(t))})).ok?"ok":"failed"}catch{return"failed"}}function Sb(t){return["flex h-7 w-7 cursor-pointer items-center justify-center rounded-md transition-colors",t?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"].join(" ")}function S_(){const[t,e]=y.useState(bb),[n,r]=y.useState(!1),[i,s]=y.useState(null),[o,l]=y.useState(""),[a,u]=y.useState(!1),[c,f]=y.useState(!1),d=y.useRef(null),h=y.useRef(0),p=y.useCallback((x,C)=>{const T={...x,pending:C==="failed"};xb(T),e(T),C==="ok"?BI({vote:x.vote,with_reason:x.reasonCode!==null}):u(!1)},[]),g=y.useCallback((x,C)=>{const T=++h.current;C&&f(!0),k_(x).then(A=>{h.current===T&&(p(x,A),A==="ok"&&u(!0))}).finally(()=>{C&&h.current===T&&f(!1)})},[p]),b=x=>{const C={...x,pending:!0};xb(C),e(C),g(C,!0)},m=y.useRef(!1);y.useEffect(()=>{if(m.current)return;m.current=!0;const x=bb();x!=null&&x.pending&&g(x,!1)},[g]),y.useEffect(()=>{if(!a)return;const x=setTimeout(()=>u(!1),3e3);return()=>clearTimeout(x)},[a]),y.useEffect(()=>{if(!n)return;const x=T=>{T.key==="Escape"&&r(!1)},C=T=>{const A=d.current;A===null||!(T.target instanceof Node)||A.contains(T.target)||r(!1)};return document.addEventListener("keydown",x),document.addEventListener("mousedown",C),()=>{document.removeEventListener("keydown",x),document.removeEventListener("mousedown",C)}},[n]);const v=()=>{if((t==null?void 0:t.vote)===1&&!t.pending){u(!0);return}b({clientId:(t==null?void 0:t.clientId)??kb(),vote:1,reasonCode:null,reasonText:null})},w=()=>{if(n){r(!1);return}s(null),l(""),r(!0)},k=()=>{if(i===null)return;const x=o.trim();b({clientId:(t==null?void 0:t.clientId)??kb(),vote:-1,reasonCode:i,reasonText:x===""?null:x}),r(!1)};return E.jsxs("div",{"data-testid":"feedback-vote",ref:d,className:"relative flex items-center gap-1 max-sm:static",children:[E.jsx("button",{type:"button","data-testid":"feedback-up",onClick:v,"aria-pressed":(t==null?void 0:t.vote)===1,"aria-label":"Helpful — send an upvote",title:"Helpful",className:Sb((t==null?void 0:t.vote)===1),children:E.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[E.jsx("path",{d:"M7 10v12"}),E.jsx("path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"})]})}),E.jsx("button",{type:"button","data-testid":"feedback-down",onClick:w,"aria-pressed":(t==null?void 0:t.vote)===-1,"aria-haspopup":"dialog","aria-expanded":n,"aria-label":"Not helpful — send a downvote",title:"Not helpful",className:Sb((t==null?void 0:t.vote)===-1),children:E.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[E.jsx("path",{d:"M17 14V2"}),E.jsx("path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"})]})}),a&&E.jsx("span",{"data-testid":"feedback-thanks",className:"text-xs text-muted-foreground",children:"Thanks for the feedback!"}),(t==null?void 0:t.pending)&&!c&&E.jsx("span",{"data-testid":"feedback-pending",role:"status",className:"max-w-44 text-right text-xs text-muted-foreground sm:max-w-none",children:"Feedback couldn't send — your vote is kept on this device and will send automatically once the service is back."}),n&&E.jsxs("div",{"data-testid":"feedback-popover",role:"dialog","aria-label":"What went wrong?",className:"absolute right-0 top-9 z-50 w-72 rounded-md border border-border bg-panel p-3 shadow-md max-sm:inset-x-2 max-sm:top-14 max-sm:w-auto",children:[E.jsx("p",{className:"mb-2 text-xs font-medium text-foreground",children:"What went wrong?"}),E.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:w_.map(x=>E.jsx("button",{type:"button","data-testid":`feedback-reason-${x.value}`,"aria-pressed":i===x.value,onClick:()=>s(x.value),className:["cursor-pointer rounded-sm border px-2 py-0.5 text-xs transition-colors",i===x.value?"border-foreground bg-foreground text-panel":"border-border text-muted-foreground hover:border-foreground hover:text-foreground"].join(" "),children:x.label},x.value))}),E.jsx("textarea",{"data-testid":"feedback-text",value:o,maxLength:500,rows:2,onChange:x=>l(x.target.value),placeholder:"Anything more? (optional)",className:"mb-2 w-full resize-none rounded-sm border border-border bg-panel px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/60 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring"}),E.jsxs("div",{className:"flex items-center justify-end gap-2",children:[E.jsxs("span",{className:"text-[10px] text-muted-foreground/70",children:[o.length,"/500"]}),E.jsx("button",{type:"button","data-testid":"feedback-submit",onClick:k,disabled:i===null,className:"cursor-pointer rounded-sm border border-border px-2.5 py-1 text-xs font-medium text-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50",children:"Send"})]})]})]})}function PT(t="This should not happen"){throw new Error(t)}function Yr(t,e="Assertion failed"){if(!t)return PT(e)}function Hc(t,e){return PT(e??"Hell froze over")}function C_(t,e){try{return t()}catch{return e}}const Cb=Object.prototype.hasOwnProperty;function Va(t,e){let n,r;if(t===e)return!0;if(t&&e&&(n=t.constructor)===e.constructor){if(n===Date)return t.getTime()===e.getTime();if(n===RegExp)return t.toString()===e.toString();if(n===Array){if((r=t.length)===e.length)for(;r--&&Va(t[r],e[r]););return r===-1}if(!n||typeof t=="object"){r=0;for(n in t)if(Cb.call(t,n)&&++r&&!Cb.call(e,n)||!(n in e)||!Va(t[n],e[n]))return!1;return Object.keys(e).length===r}}return t!==t&&e!==e}var T_=Object.prototype,E_=T_.hasOwnProperty;function A_(t,e){return t!=null&&E_.call(t,e)}var M_=A_,R_=Array.isArray,As=R_,O_=typeof So=="object"&&So&&So.Object===Object&&So,IT=O_,P_=IT,I_=typeof self=="object"&&self&&self.Object===Object&&self,N_=P_||I_||Function("return this")(),Ms=N_,__=Ms,D_=__.Symbol,sf=D_,Tb=sf,NT=Object.prototype,L_=NT.hasOwnProperty,$_=NT.toString,Du=Tb?Tb.toStringTag:void 0;function F_(t){var e=L_.call(t,Du),n=t[Du];try{t[Du]=void 0;var r=!0}catch{}var i=$_.call(t);return r&&(e?t[Du]=n:delete t[Du]),i}var z_=F_,B_=Object.prototype,j_=B_.toString;function H_(t){return j_.call(t)}var W_=H_,Eb=sf,V_=z_,U_=W_,K_="[object Null]",X_="[object Undefined]",Ab=Eb?Eb.toStringTag:void 0;function G_(t){return t==null?t===void 0?X_:K_:Ab&&Ab in Object(t)?V_(t):U_(t)}var of=G_;function q_(t){return t!=null&&typeof t=="object"}var lf=q_,Y_=of,J_=lf,Q_="[object Symbol]";function Z_(t){return typeof t=="symbol"||J_(t)&&Y_(t)==Q_}var Ep=Z_,eD=As,tD=Ep,nD=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,rD=/^\w*$/;function iD(t,e){if(eD(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||tD(t)?!0:rD.test(t)||!nD.test(t)||e!=null&&t in Object(e)}var jv=iD;function sD(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var $l=sD,oD=of,lD=$l,aD="[object AsyncFunction]",uD="[object Function]",cD="[object GeneratorFunction]",fD="[object Proxy]";function dD(t){if(!lD(t))return!1;var e=oD(t);return e==uD||e==cD||e==aD||e==fD}var _T=dD,hD=Ms,pD=hD["__core-js_shared__"],gD=pD,Vg=gD,Mb=function(){var t=/[^.]+$/.exec(Vg&&Vg.keys&&Vg.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function mD(t){return!!Mb&&Mb in t}var yD=mD,vD=Function.prototype,wD=vD.toString;function bD(t){if(t!=null){try{return wD.call(t)}catch{}try{return t+""}catch{}}return""}var DT=bD,xD=_T,kD=yD,SD=$l,CD=DT,TD=/[\\^$.*+?()[\]{}|]/g,ED=/^\[object .+?Constructor\]$/,AD=Function.prototype,MD=Object.prototype,RD=AD.toString,OD=MD.hasOwnProperty,PD=RegExp("^"+RD.call(OD).replace(TD,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ID(t){if(!SD(t)||kD(t))return!1;var e=xD(t)?PD:ED;return e.test(CD(t))}var ND=ID;function _D(t,e){return t==null?void 0:t[e]}var DD=_D,LD=ND,$D=DD;function FD(t,e){var n=$D(t,e);return LD(n)?n:void 0}var Fl=FD,zD=Fl,BD=zD(Object,"create"),Ap=BD,Rb=Ap;function jD(){this.__data__=Rb?Rb(null):{},this.size=0}var HD=jD;function WD(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var VD=WD,UD=Ap,KD="__lodash_hash_undefined__",XD=Object.prototype,GD=XD.hasOwnProperty;function qD(t){var e=this.__data__;if(UD){var n=e[t];return n===KD?void 0:n}return GD.call(e,t)?e[t]:void 0}var YD=qD,JD=Ap,QD=Object.prototype,ZD=QD.hasOwnProperty;function eL(t){var e=this.__data__;return JD?e[t]!==void 0:ZD.call(e,t)}var tL=eL,nL=Ap,rL="__lodash_hash_undefined__";function iL(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=nL&&e===void 0?rL:e,this}var sL=iL,oL=HD,lL=VD,aL=YD,uL=tL,cL=sL;function ou(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e-1}var AL=EL,ML=Mp;function RL(t,e){var n=this.__data__,r=ML(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}var OL=RL,PL=hL,IL=xL,NL=CL,_L=AL,DL=OL;function lu(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e-1&&t%1==0&&t-1&&t%1==0&&t<=X3}var Gv=G3,q3=Ep;function Y3(t){if(typeof t=="string"||q3(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}var Pp=Y3,J3=FT,Q3=Kv,Z3=As,e$=Xv,t$=Gv,n$=Pp;function r$(t,e,n){e=J3(e,t);for(var r=-1,i=e.length,s=!1;++r[r[0]+e,r[1]+e]);return new Ns(n)}add(e){const n=typeof e=="number"?[e,e+1]:e,r=c$([...this.items,n]);return new Ns(r)}remove(e){const n=[...this.items],r=typeof e=="number"?e:e[0],i=typeof e=="number"?e+1:e[1];for(const[s,o]of n.entries()){const[l,a]=o;if(l<=i&&r<=a){const u=[];l=r&&e$b??($b=new Ns([]))),St(Ns,"fromSingleSelection",e=>Ns.empty().add(e));let Pt=Ns;function f$(t){var e=Object.create(null);return function(n){return e[n]===void 0&&(e[n]=t(n)),e[n]}}var d$=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,Ug=f$(function(t){return d$.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),h$=function(){const e=Array.prototype.slice.call(arguments).filter(Boolean),n={},r=[];e.forEach(s=>{(s?s.split(" "):[]).forEach(l=>{if(l.startsWith("atm_")){const[,a]=l.split("_");n[a]=l}else r.push(l)})});const i=[];for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&i.push(n[s]);return i.push(...r),i.join(" ")},Fb=h$,p$=t=>t.toUpperCase()===t,g$=t=>e=>t.indexOf(e)===-1,jT=(t,e)=>{const n={};return Object.keys(t).filter(g$(e)).forEach(r=>{n[r]=t[r]}),n};function m$(t,e,n){const r=jT(e,n);if(!t){const i=typeof Ug=="function"?{default:Ug}:Ug;Object.keys(r).forEach(s=>{i.default(s)||delete r[s]})}return r}var y$=(t,e)=>{};function v$(t){let e="";return n=>{const r=(s,o)=>{const{as:l=t,class:a=e}=s,u=n.propsAsIs===void 0?!(typeof l=="string"&&l.indexOf("-")===-1&&!p$(l[0])):n.propsAsIs,c=m$(u,s,["as","class"]);c.ref=o,c.className=n.atomic?Fb(n.class,c.className||a):Fb(c.className||a,n.class);const{vars:f}=n;if(f){const d={};for(const g in f){const b=f[g],m=b[0],v=b[1]||"",w=typeof m=="function"?m(s):m;y$(w,n.name),d[`--${g}`]=`${w}${v}`}const h=c.style||{},p=Object.keys(h);p.length>0&&p.forEach(g=>{d[g]=h[g]}),c.style=d}return t.__linaria&&t!==l?(c.as=l,Vn.createElement(t,c)):Vn.createElement(l,c)},i=Vn.forwardRef?Vn.forwardRef(r):s=>{const o=jT(s,["innerRef"]);return r(o,s.innerRef)};return i.displayName=n.name,i.__linaria={className:n.class||e,extends:t},i}}var ii=v$;const w$=ii("div")({name:"ImageOverlayEditorStyle",class:"gdg-i2iowwq",propsAsIs:!1});var HT={},Ip={},Yv={},Kg={},Xg={exports:{}},Gg,zb;function b$(){if(zb)return Gg;zb=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Gg=t,Gg}var qg,Bb;function x$(){if(Bb)return qg;Bb=1;var t=b$();function e(){}function n(){}return n.resetWarningCache=e,qg=function(){function r(o,l,a,u,c,f){if(f!==t){var d=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw d.name="Invariant Violation",d}}r.isRequired=r;function i(){return r}var s={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:i,element:r,elementType:r,instanceOf:i,node:r,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:n,resetWarningCache:e};return s.PropTypes=s,s},qg}var jb;function k$(){return jb||(jb=1,Xg.exports=x$()()),Xg.exports}var Hb;function S$(){return Hb||(Hb=1,function(t){(function(e,n){n(t,y,k$())})(So,function(e,n,r){Object.defineProperty(e,"__esModule",{value:!0}),e.setHasSupportToCaptureOption=p;var i=o(n),s=o(r);function o(v){return v&&v.__esModule?v:{default:v}}var l=Object.assign||function(v){for(var w=1;w=0||Object.prototype.hasOwnProperty.call(v,x)&&(k[x]=v[x]);return k}function u(v,w){if(!(v instanceof w))throw new TypeError("Cannot call a class as a function")}var c=function(){function v(w,k){for(var x=0;x0&&arguments[0]!==void 0?arguments[0]:{capture:!0};return h?v:v.capture}function b(v){if("touches"in v){var w=v.touches[0],k=w.pageX,x=w.pageY;return{x:k,y:x}}var C=v.screenX,T=v.screenY;return{x:C,y:T}}var m=function(v){d(w,v);function w(){var k;u(this,w);for(var x=arguments.length,C=Array(x),T=0;TC&&this.props.onSwipeRight(1,x),this.movePosition.deltaY<-C?this.props.onSwipeUp(1,x):this.movePosition.deltaY>C&&this.props.onSwipeDown(1,x)),this.moveStart=null,this.moving=!1,this.movePosition=null}},{key:"_setSwiperRef",value:function(x){this.swiper=x,this.props.innerRef(x)}},{key:"render",value:function(){var x=this.props;x.tagName;var C=x.className,T=x.style,A=x.children;x.allowMouseEvents,x.onSwipeUp,x.onSwipeDown,x.onSwipeLeft,x.onSwipeRight,x.onSwipeStart,x.onSwipeMove,x.onSwipeEnd,x.innerRef,x.tolerance;var R=a(x,["tagName","className","style","children","allowMouseEvents","onSwipeUp","onSwipeDown","onSwipeLeft","onSwipeRight","onSwipeStart","onSwipeMove","onSwipeEnd","innerRef","tolerance"]);return i.default.createElement(this.props.tagName,l({ref:this._setSwiperRef,onMouseDown:this._onMouseDown,onTouchStart:this._handleSwipeStart,onTouchEnd:this._handleSwipeEnd,className:C,style:T},R),A)}}]),w}(n.Component);m.displayName="ReactSwipe",m.propTypes={tagName:s.default.string,className:s.default.string,style:s.default.object,children:s.default.node,allowMouseEvents:s.default.bool,onSwipeUp:s.default.func,onSwipeDown:s.default.func,onSwipeLeft:s.default.func,onSwipeRight:s.default.func,onSwipeStart:s.default.func,onSwipeMove:s.default.func,onSwipeEnd:s.default.func,innerRef:s.default.func,tolerance:s.default.number.isRequired},m.defaultProps={tagName:"div",allowMouseEvents:!1,onSwipeUp:function(){},onSwipeDown:function(){},onSwipeLeft:function(){},onSwipeRight:function(){},onSwipeStart:function(){},onSwipeMove:function(){},onSwipeEnd:function(){},innerRef:function(){},tolerance:0},e.default=m})}(Kg)),Kg}(function(t){(function(e,n){n(t,S$())})(So,function(e,n){Object.defineProperty(e,"__esModule",{value:!0});var r=i(n);function i(s){return s&&s.__esModule?s:{default:s}}e.default=r.default})})(Yv);var af={},WT={exports:{}};/*! - Copyright (c) 2018 Jed Watson. - Licensed under the MIT License (MIT), see - http://jedwatson.github.io/classnames -*/(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var s="",o=0;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Rh(t){return Rh=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Rh(t)}function fr(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var j$=function(e){return e.hasOwnProperty("key")},Jv=function(t){$$(n,t);var e=F$(n);function n(r){var i;return _$(this,n),i=e.call(this,r),fr(xr(i),"itemsWrapperRef",void 0),fr(xr(i),"itemsListRef",void 0),fr(xr(i),"thumbsRef",void 0),fr(xr(i),"setItemsWrapperRef",function(s){i.itemsWrapperRef=s}),fr(xr(i),"setItemsListRef",function(s){i.itemsListRef=s}),fr(xr(i),"setThumbsRef",function(s,o){i.thumbsRef||(i.thumbsRef=[]),i.thumbsRef[o]=s}),fr(xr(i),"updateSizes",function(){if(!(!i.props.children||!i.itemsWrapperRef||!i.thumbsRef)){var s=Li.Children.count(i.props.children),o=i.itemsWrapperRef.clientWidth,l=i.props.thumbWidth?i.props.thumbWidth:(0,P$.outerWidth)(i.thumbsRef[0]),a=Math.floor(o/l),u=a0&&(o=0),u===f&&o<0&&(o=0);var d=i.itemsWrapperRef.clientWidth,h=u+100/(d/o);return i.itemsListRef&&["WebkitTransform","MozTransform","MsTransform","OTransform","transform","msTransform"].forEach(function(p){i.itemsListRef.style[p]=(0,Wb.default)(h,"%",i.props.axis)}),!0}),fr(xr(i),"slideRight",function(s){i.moveTo(i.state.firstItem-(typeof s=="number"?s:1))}),fr(xr(i),"slideLeft",function(s){i.moveTo(i.state.firstItem+(typeof s=="number"?s:1))}),fr(xr(i),"moveTo",function(s){s=s<0?0:s,s=s>=i.state.lastPosition?i.state.lastPosition:s,i.setState({firstItem:s})}),i.state={selectedItem:r.selectedItem,swiping:!1,showArrows:!1,firstItem:0,visibleItems:0,lastPosition:0},i}return L$(n,[{key:"componentDidMount",value:function(){this.setupThumbs()}},{key:"componentDidUpdate",value:function(i){this.props.selectedItem!==this.state.selectedItem&&this.setState({selectedItem:this.props.selectedItem,firstItem:this.getFirstItem(this.props.selectedItem)}),this.props.children!==i.children&&this.updateSizes()}},{key:"componentWillUnmount",value:function(){this.destroyThumbs()}},{key:"setupThumbs",value:function(){(0,ed.default)().addEventListener("resize",this.updateSizes),(0,ed.default)().addEventListener("DOMContentLoaded",this.updateSizes),this.updateSizes()}},{key:"destroyThumbs",value:function(){(0,ed.default)().removeEventListener("resize",this.updateSizes),(0,ed.default)().removeEventListener("DOMContentLoaded",this.updateSizes)}},{key:"getFirstItem",value:function(i){var s=i;return i>=this.state.lastPosition&&(s=this.state.lastPosition),i1,o=this.state.showArrows&&this.state.firstItem>0,l=this.state.showArrows&&this.state.firstItemo);if(l)return s<0?e.centerMode&&e.centerSlidePercentage&&e.axis==="horizontal"?r.itemListStyle=(0,vs.setPosition)(-(o+2)*e.centerSlidePercentage-(100-e.centerSlidePercentage)/2,e.axis):r.itemListStyle=(0,vs.setPosition)(-(o+2)*100,e.axis):s>o&&(r.itemListStyle=(0,vs.setPosition)(0,e.axis)),r;var a=(0,vs.getPosition)(i,e),u=(0,J$.default)(a,"%",e.axis),c=e.transitionTime+"ms";return r.itemListStyle={WebkitTransform:u,msTransform:u,OTransform:u,transform:u},n.swiping||(r.itemListStyle=dl(dl({},r.itemListStyle),{},{WebkitTransitionDuration:c,MozTransitionDuration:c,OTransitionDuration:c,transitionDuration:c,msTransitionDuration:c})),r};ys.slideAnimationHandler=eF;var tF=function(e,n,r,i){var s={},o=n.axis==="horizontal",l=UT.Children.count(n.children),a=0,u=(0,vs.getPosition)(r.selectedItem,n),c=n.infiniteLoop?(0,vs.getPosition)(l-1,n)-100:(0,vs.getPosition)(l-1,n),f=o?e.x:e.y,d=f;u===a&&f>0&&(d=0),u===c&&f<0&&(d=0);var h=u+100/(r.itemSize/d),p=Math.abs(f)>n.swipeScrollTolerance;return n.infiniteLoop&&p&&(r.selectedItem===0&&h>-100?h-=l*100:r.selectedItem===l-1&&h<-l*100&&(h+=l*100)),(!n.preventMovementUntilSwipeScrollTolerance||p||r.swipeMovementStarted)&&(r.swipeMovementStarted||i({swipeMovementStarted:!0}),s.itemListStyle=(0,vs.setPosition)(h,n.axis)),p&&!r.cancelClick&&i({cancelClick:!0}),s};ys.slideSwipeAnimationHandler=tF;var nF=function(e,n){var r=(0,vs.getPosition)(n.selectedItem,e),i=(0,vs.setPosition)(r,e.axis);return{itemListStyle:i}};ys.slideStopSwipingHandler=nF;var rF=function(e,n){var r=e.transitionTime+"ms",i="ease-in-out",s={position:"absolute",display:"block",zIndex:-2,minHeight:"100%",opacity:0,top:0,right:0,left:0,bottom:0,transitionTimingFunction:i,msTransitionTimingFunction:i,MozTransitionTimingFunction:i,WebkitTransitionTimingFunction:i,OTransitionTimingFunction:i};return n.swiping||(s=dl(dl({},s),{},{WebkitTransitionDuration:r,MozTransitionDuration:r,OTransitionDuration:r,transitionDuration:r,msTransitionDuration:r})),{slideStyle:s,selectedStyle:dl(dl({},s),{},{opacity:1,position:"relative"}),prevStyle:dl({},s)}};ys.fadeAnimationHandler=rF;Object.defineProperty(Ip,"__esModule",{value:!0});Ip.default=void 0;var Ut=oF(y),iF=ff(Yv),Ds=ff(af),sF=ff(uf),td=ff(Dp),nd=ff(cf),Qu=Qr,Oh=ys;function ff(t){return t&&t.__esModule?t:{default:t}}function KT(){if(typeof WeakMap!="function")return null;var t=new WeakMap;return KT=function(){return t},t}function oF(t){if(t&&t.__esModule)return t;if(t===null||fc(t)!=="object"&&typeof t!="function")return{default:t};var e=KT();if(e&&e.has(t))return e.get(t);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=r?Object.getOwnPropertyDescriptor(t,i):null;s&&(s.get||s.set)?Object.defineProperty(n,i,s):n[i]=t[i]}return n.default=t,e&&e.set(t,n),n}function fc(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?fc=function(n){return typeof n}:fc=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},fc(t)}function D0(){return D0=Object.assign||function(t){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Ph(t){return Ph=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Ph(t)}function Ct(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var Qv=function(t){cF(n,t);var e=fF(n);function n(r){var i;lF(this,n),i=e.call(this,r),Ct(Et(i),"thumbsRef",void 0),Ct(Et(i),"carouselWrapperRef",void 0),Ct(Et(i),"listRef",void 0),Ct(Et(i),"itemsRef",void 0),Ct(Et(i),"timer",void 0),Ct(Et(i),"animationHandler",void 0),Ct(Et(i),"setThumbsRef",function(o){i.thumbsRef=o}),Ct(Et(i),"setCarouselWrapperRef",function(o){i.carouselWrapperRef=o}),Ct(Et(i),"setListRef",function(o){i.listRef=o}),Ct(Et(i),"setItemsRef",function(o,l){i.itemsRef||(i.itemsRef=[]),i.itemsRef[l]=o}),Ct(Et(i),"autoPlay",function(){Ut.Children.count(i.props.children)<=1||(i.clearAutoPlay(),i.props.autoPlay&&(i.timer=setTimeout(function(){i.increment()},i.props.interval)))}),Ct(Et(i),"clearAutoPlay",function(){i.timer&&clearTimeout(i.timer)}),Ct(Et(i),"resetAutoPlay",function(){i.clearAutoPlay(),i.autoPlay()}),Ct(Et(i),"stopOnHover",function(){i.setState({isMouseEntered:!0},i.clearAutoPlay)}),Ct(Et(i),"startOnLeave",function(){i.setState({isMouseEntered:!1},i.autoPlay)}),Ct(Et(i),"isFocusWithinTheCarousel",function(){return i.carouselWrapperRef?!!((0,td.default)().activeElement===i.carouselWrapperRef||i.carouselWrapperRef.contains((0,td.default)().activeElement)):!1}),Ct(Et(i),"navigateWithKeyboard",function(o){if(i.isFocusWithinTheCarousel()){var l=i.props.axis,a=l==="horizontal",u={ArrowUp:38,ArrowRight:39,ArrowDown:40,ArrowLeft:37},c=a?u.ArrowRight:u.ArrowDown,f=a?u.ArrowLeft:u.ArrowUp;c===o.keyCode?i.increment():f===o.keyCode&&i.decrement()}}),Ct(Et(i),"updateSizes",function(){if(!(!i.state.initialized||!i.itemsRef||i.itemsRef.length===0)){var o=i.props.axis==="horizontal",l=i.itemsRef[0];if(l){var a=o?l.clientWidth:l.clientHeight;i.setState({itemSize:a}),i.thumbsRef&&i.thumbsRef.updateSizes()}}}),Ct(Et(i),"setMountState",function(){i.setState({hasMount:!0}),i.updateSizes()}),Ct(Et(i),"handleClickItem",function(o,l){if(Ut.Children.count(i.props.children)!==0){if(i.state.cancelClick){i.setState({cancelClick:!1});return}i.props.onClickItem(o,l),o!==i.state.selectedItem&&i.setState({selectedItem:o})}}),Ct(Et(i),"handleOnChange",function(o,l){Ut.Children.count(i.props.children)<=1||i.props.onChange(o,l)}),Ct(Et(i),"handleClickThumb",function(o,l){i.props.onClickThumb(o,l),i.moveTo(o)}),Ct(Et(i),"onSwipeStart",function(o){i.setState({swiping:!0}),i.props.onSwipeStart(o)}),Ct(Et(i),"onSwipeEnd",function(o){i.setState({swiping:!1,cancelClick:!1,swipeMovementStarted:!1}),i.props.onSwipeEnd(o),i.clearAutoPlay(),i.state.autoPlay&&i.autoPlay()}),Ct(Et(i),"onSwipeMove",function(o,l){i.props.onSwipeMove(l);var a=i.props.swipeAnimationHandler(o,i.props,i.state,i.setState.bind(Et(i)));return i.setState($i({},a)),!!Object.keys(a).length}),Ct(Et(i),"decrement",function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;i.moveTo(i.state.selectedItem-(typeof o=="number"?o:1))}),Ct(Et(i),"increment",function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;i.moveTo(i.state.selectedItem+(typeof o=="number"?o:1))}),Ct(Et(i),"moveTo",function(o){if(typeof o=="number"){var l=Ut.Children.count(i.props.children)-1;o<0&&(o=i.props.infiniteLoop?l:0),o>l&&(o=i.props.infiniteLoop?0:l),i.selectItem({selectedItem:o}),i.state.autoPlay&&i.state.isMouseEntered===!1&&i.resetAutoPlay()}}),Ct(Et(i),"onClickNext",function(){i.increment(1)}),Ct(Et(i),"onClickPrev",function(){i.decrement(1)}),Ct(Et(i),"onSwipeForward",function(){i.increment(1),i.props.emulateTouch&&i.setState({cancelClick:!0})}),Ct(Et(i),"onSwipeBackwards",function(){i.decrement(1),i.props.emulateTouch&&i.setState({cancelClick:!0})}),Ct(Et(i),"changeItem",function(o){return function(l){(!(0,Qu.isKeyboardEvent)(l)||l.key==="Enter")&&i.moveTo(o)}}),Ct(Et(i),"selectItem",function(o){i.setState($i({previousItem:i.state.selectedItem},o),function(){i.setState(i.animationHandler(i.props,i.state))}),i.handleOnChange(o.selectedItem,Ut.Children.toArray(i.props.children)[o.selectedItem])}),Ct(Et(i),"getInitialImage",function(){var o=i.props.selectedItem,l=i.itemsRef&&i.itemsRef[o],a=l&&l.getElementsByTagName("img")||[];return a[0]}),Ct(Et(i),"getVariableItemHeight",function(o){var l=i.itemsRef&&i.itemsRef[o];if(i.state.hasMount&&l&&l.children.length){var a=l.children[0].getElementsByTagName("img")||[];if(a.length>0){var u=a[0];if(!u.complete){var c=function h(){i.forceUpdate(),u.removeEventListener("load",h)};u.addEventListener("load",c)}}var f=a[0]||l.children[0],d=f.clientHeight;return d>0?d:null}return null});var s={initialized:!1,previousItem:r.selectedItem,selectedItem:r.selectedItem,hasMount:!1,isMouseEntered:!1,autoPlay:r.autoPlay,swiping:!1,swipeMovementStarted:!1,cancelClick:!1,itemSize:1,itemListStyle:{},slideStyle:{},selectedStyle:{},prevStyle:{}};return i.animationHandler=typeof r.animationHandler=="function"&&r.animationHandler||r.animationHandler==="fade"&&Oh.fadeAnimationHandler||Oh.slideAnimationHandler,i.state=$i($i({},s),i.animationHandler(r,s)),i}return uF(n,[{key:"componentDidMount",value:function(){this.props.children&&this.setupCarousel()}},{key:"componentDidUpdate",value:function(i,s){!i.children&&this.props.children&&!this.state.initialized&&this.setupCarousel(),!i.autoFocus&&this.props.autoFocus&&this.forceFocus(),s.swiping&&!this.state.swiping&&this.setState($i({},this.props.stopSwipingHandler(this.props,this.state))),(i.selectedItem!==this.props.selectedItem||i.centerMode!==this.props.centerMode)&&(this.updateSizes(),this.moveTo(this.props.selectedItem)),i.autoPlay!==this.props.autoPlay&&(this.props.autoPlay?this.setupAutoPlay():this.destroyAutoPlay(),this.setState({autoPlay:this.props.autoPlay}))}},{key:"componentWillUnmount",value:function(){this.destroyCarousel()}},{key:"setupCarousel",value:function(){var i=this;this.bindEvents(),this.state.autoPlay&&Ut.Children.count(this.props.children)>1&&this.setupAutoPlay(),this.props.autoFocus&&this.forceFocus(),this.setState({initialized:!0},function(){var s=i.getInitialImage();s&&!s.complete?s.addEventListener("load",i.setMountState):i.setMountState()})}},{key:"destroyCarousel",value:function(){this.state.initialized&&(this.unbindEvents(),this.destroyAutoPlay())}},{key:"setupAutoPlay",value:function(){this.autoPlay();var i=this.carouselWrapperRef;this.props.stopOnHover&&i&&(i.addEventListener("mouseenter",this.stopOnHover),i.addEventListener("mouseleave",this.startOnLeave))}},{key:"destroyAutoPlay",value:function(){this.clearAutoPlay();var i=this.carouselWrapperRef;this.props.stopOnHover&&i&&(i.removeEventListener("mouseenter",this.stopOnHover),i.removeEventListener("mouseleave",this.startOnLeave))}},{key:"bindEvents",value:function(){(0,nd.default)().addEventListener("resize",this.updateSizes),(0,nd.default)().addEventListener("DOMContentLoaded",this.updateSizes),this.props.useKeyboardArrows&&(0,td.default)().addEventListener("keydown",this.navigateWithKeyboard)}},{key:"unbindEvents",value:function(){(0,nd.default)().removeEventListener("resize",this.updateSizes),(0,nd.default)().removeEventListener("DOMContentLoaded",this.updateSizes);var i=this.getInitialImage();i&&i.removeEventListener("load",this.setMountState),this.props.useKeyboardArrows&&(0,td.default)().removeEventListener("keydown",this.navigateWithKeyboard)}},{key:"forceFocus",value:function(){var i;(i=this.carouselWrapperRef)===null||i===void 0||i.focus()}},{key:"renderItems",value:function(i){var s=this;return this.props.children?Ut.Children.map(this.props.children,function(o,l){var a=l===s.state.selectedItem,u=l===s.state.previousItem,c=a&&s.state.selectedStyle||u&&s.state.prevStyle||s.state.slideStyle||{};s.props.centerMode&&s.props.axis==="horizontal"&&(c=$i($i({},c),{},{minWidth:s.props.centerSlidePercentage+"%"})),s.state.swiping&&s.state.swipeMovementStarted&&(c=$i($i({},c),{},{pointerEvents:"none"}));var f={ref:function(h){return s.setItemsRef(h,l)},key:"itemKey"+l+(i?"clone":""),className:Ds.default.ITEM(!0,l===s.state.selectedItem,l===s.state.previousItem),onClick:s.handleClickItem.bind(s,l,o),style:c};return Ut.default.createElement("li",f,s.props.renderItem(o,{isSelected:l===s.state.selectedItem,isPrevious:l===s.state.previousItem}))}):[]}},{key:"renderControls",value:function(){var i=this,s=this.props,o=s.showIndicators,l=s.labels,a=s.renderIndicator,u=s.children;return o?Ut.default.createElement("ul",{className:"control-dots"},Ut.Children.map(u,function(c,f){return a&&a(i.changeItem(f),f===i.state.selectedItem,f,l.item)})):null}},{key:"renderStatus",value:function(){return this.props.showStatus?Ut.default.createElement("p",{className:"carousel-status"},this.props.statusFormatter(this.state.selectedItem+1,Ut.Children.count(this.props.children))):null}},{key:"renderThumbs",value:function(){return!this.props.showThumbs||!this.props.children||Ut.Children.count(this.props.children)===0?null:Ut.default.createElement(sF.default,{ref:this.setThumbsRef,onSelectItem:this.handleClickThumb,selectedItem:this.state.selectedItem,transitionTime:this.props.transitionTime,thumbWidth:this.props.thumbWidth,labels:this.props.labels,emulateTouch:this.props.emulateTouch},this.props.renderThumbs(this.props.children))}},{key:"render",value:function(){var i=this;if(!this.props.children||Ut.Children.count(this.props.children)===0)return null;var s=this.props.swipeable&&Ut.Children.count(this.props.children)>1,o=this.props.axis==="horizontal",l=this.props.showArrows&&Ut.Children.count(this.props.children)>1,a=l&&(this.state.selectedItem>0||this.props.infiniteLoop)||!1,u=l&&(this.state.selectedItem=e||T<0||f&&A>=s}function m(){var C=Yg();if(b(C))return v(C);l=setTimeout(m,g(C))}function v(C){return l=void 0,d&&r?h(C):(r=i=void 0,o)}function w(){l!==void 0&&clearTimeout(l),u=0,r=a=i=l=void 0}function k(){return l===void 0?o:v(Yg())}function x(){var C=Yg(),T=b(C);if(r=arguments,i=this,a=C,T){if(l===void 0)return p(a);if(f)return clearTimeout(l),l=setTimeout(m,e),h(a)}return l===void 0&&(l=setTimeout(m,e)),o}return x.cancel=w,x.flush=k,x}var XT=LF;const GT=Qi(XT);function er(t,e,n,r,i=!1){const s=y.useRef();s.current=e,y.useEffect(()=>{if(n===null||n.addEventListener===void 0)return;const o=n,l=a=>{var u;(u=s.current)==null||u.call(o,a)};return o.addEventListener(t,l,{passive:r,capture:i}),()=>{o.removeEventListener(t,l,{capture:i})}},[t,n,r,i])}function ta(t,e){return t===void 0?void 0:e}const $F=Math.PI;function qb(t){return t*$F/180}const qT=(t,e,n)=>({x1:t-n/2,y1:e-n/2,x2:t+n/2,y2:e+n/2}),YT=(t,e,n,r,i)=>{switch(t){case"left":return Math.floor(e)+r+i/2;case"center":return Math.floor(e+n/2);case"right":return Math.floor(e+n)-r-i/2}},JT=(t,e,n)=>Math.min(t,e-n*2),QT=(t,e,n)=>n.x1<=t&&t<=n.x2&&n.y1<=e&&e<=n.y2,ew=t=>{const e=t.fgColor??"currentColor";return y.createElement("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},y.createElement("path",{d:"M12.7073 7.05029C7.87391 11.8837 10.4544 9.30322 6.03024 13.7273C5.77392 13.9836 5.58981 14.3071 5.50189 14.6587L4.52521 18.5655C4.38789 19.1148 4.88543 19.6123 5.43472 19.475L9.34146 18.4983C9.69313 18.4104 10.0143 18.2286 10.2706 17.9722L16.9499 11.2929",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}),y.createElement("path",{d:"M20.4854 4.92901L19.0712 3.5148C18.2901 2.73375 17.0238 2.73375 16.2428 3.5148L14.475 5.28257C15.5326 7.71912 16.4736 8.6278 18.7176 9.52521L20.4854 7.75744C21.2665 6.97639 21.2665 5.71006 20.4854 4.92901Z",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}))},FF=t=>{const e=t.fgColor??"currentColor";return y.createElement("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},y.createElement("path",{d:"M19 6L10.3802 17L5.34071 11.8758",vectorEffect:"non-scaling-stroke",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))};function zF(t,e,n){const[r,i]=y.useState(t),s=y.useRef(!0);y.useEffect(()=>()=>{s.current=!1},[]);const o=y.useRef(GT(l=>{s.current&&i(l)},n));return y.useLayoutEffect(()=>{s.current&&o.current(()=>t())},e),r}const BF="֑-߿יִ-﷽ﹰ-ﻼ",jF="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",HF=new RegExp("^[^"+jF+"]*["+BF+"]");function tw(t){return HF.test(t)?"rtl":"not-rtl"}let rd;function $0(){if(typeof document>"u")return 0;if(rd!==void 0)return rd;const t=document.createElement("p");t.style.width="100%",t.style.height="200px";const e=document.createElement("div");e.id="testScrollbar",e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.style.width="200px",e.style.height="150px",e.style.overflow="hidden",e.append(t),document.body.append(e);const n=t.offsetWidth;e.style.overflow="scroll";let r=t.offsetWidth;return n===r&&(r=e.clientWidth),e.remove(),rd=n-r,rd}const rl=Symbol();function WF(t){const e=y.useRef([rl,t]);e.current[1]!==t&&(e.current[0]=t),e.current[1]=t;const[n,r]=y.useState(t),[,i]=y.useState(),s=y.useCallback(l=>{const a=e.current[0];a!==rl&&(l=typeof l=="function"?l(a):l,l===a)||(a!==rl&&i({}),r(u=>typeof l=="function"?l(a===rl?u:a):l),e.current[0]=rl)},[]),o=y.useCallback(()=>{e.current[0]=rl,i({})},[]);return[e.current[0]===rl?n:e.current[0],s,o]}function ZT(t){if(t.length===0)return"";let e=0,n=0;for(const r of t){if(n+=r.length,n>1e4)break;e++}return t.slice(0,e).join(", ")}function VF(t){const e=y.useRef(t);return Va(t,e.current)||(e.current=t),e.current}const UF=t=>{const{urls:e,canWrite:n,onEditClick:r,renderImage:i}=t,s=e.filter(l=>l!=="");if(s.length===0)return null;const o=s.length>1;return y.createElement(w$,{"data-testid":"GDG-default-image-overlay-editor"},y.createElement(HT.Carousel,{showArrows:o,showThumbs:!1,swipeable:o,emulateTouch:o,infiniteLoop:o},s.map(l=>{const a=(i==null?void 0:i(l))??y.createElement("img",{draggable:!1,src:l});return y.createElement("div",{className:"gdg-centering-container",key:l},a)})),n&&r&&y.createElement("button",{className:"gdg-edit-icon",onClick:r},y.createElement(ew,null)))};function eE(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let zl=eE();function KF(t){zl=t}const tE=/[&<>"']/,XF=new RegExp(tE.source,"g"),nE=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,GF=new RegExp(nE.source,"g"),qF={"&":"&","<":"<",">":">",'"':""","'":"'"},Yb=t=>qF[t];function dr(t,e){if(e){if(tE.test(t))return t.replace(XF,Yb)}else if(nE.test(t))return t.replace(GF,Yb);return t}const YF=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function rE(t){return t.replace(YF,(e,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const JF=/(^|[^\[])\^/g;function sn(t,e){t=typeof t=="string"?t:t.source,e=e||"";const n={replace:(r,i)=>(i=i.source||i,i=i.replace(JF,"$1"),t=t.replace(r,i),n),getRegex:()=>new RegExp(t,e)};return n}const QF=/[^\w:]/g,ZF=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Jb(t,e,n){if(t){let r;try{r=decodeURIComponent(rE(n)).replace(QF,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}e&&!ZF.test(n)&&(n=r4(e,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const id={},e4=/^[^:]+:\/*[^/]*$/,t4=/^([^:]+:)[\s\S]*$/,n4=/^([^:]+:\/*[^/]*)[\s\S]*$/;function r4(t,e){id[" "+t]||(e4.test(t)?id[" "+t]=t+"/":id[" "+t]=Vd(t,"/",!0)),t=id[" "+t];const n=t.indexOf(":")===-1;return e.substring(0,2)==="//"?n?e:t.replace(t4,"$1")+e:e.charAt(0)==="/"?n?e:t.replace(n4,"$1")+e:t+e}const Ih={exec:function(){}};function Qb(t,e){const n=t.replace(/\|/g,(s,o,l)=>{let a=!1,u=o;for(;--u>=0&&l[u]==="\\";)a=!a;return a?"|":" |"}),r=n.split(/ \|/);let i=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>e)r.splice(e);else for(;r.length1;)e&1&&(n+=t),e>>=1,t+=t;return n+t}function ex(t,e,n,r){const i=e.href,s=e.title?dr(e.title):null,o=t[1].replace(/\\([\[\]])/g,"$1");if(t[0].charAt(0)!=="!"){r.state.inLink=!0;const l={type:"link",raw:n,href:i,title:s,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,l}return{type:"image",raw:n,href:i,title:s,text:dr(o)}}function o4(t,e){const n=t.match(/^(\s+)(?:```)/);if(n===null)return e;const r=n[1];return e.split(` -`).map(i=>{const s=i.match(/^\s+/);if(s===null)return i;const[o]=s;return o.length>=r.length?i.slice(r.length):i}).join(` -`)}class nw{constructor(e){this.options=e||zl}space(e){const n=this.rules.block.newline.exec(e);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(e){const n=this.rules.block.code.exec(e);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Vd(r,` -`)}}}fences(e){const n=this.rules.block.fences.exec(e);if(n){const r=n[0],i=o4(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:i}}}heading(e){const n=this.rules.block.heading.exec(e);if(n){let r=n[2].trim();if(/#$/.test(r)){const i=Vd(r,"#");(this.options.pedantic||!i||/ $/.test(i))&&(r=i.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(e){const n=this.rules.block.hr.exec(e);if(n)return{type:"hr",raw:n[0]}}blockquote(e){const n=this.rules.block.blockquote.exec(e);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),i=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=i,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(e){let n=this.rules.block.list.exec(e);if(n){let r,i,s,o,l,a,u,c,f,d,h,p,g=n[1].trim();const b=g.length>1,m={type:"list",raw:"",ordered:b,start:b?+g.slice(0,-1):"",loose:!1,items:[]};g=b?`\\d{1,9}\\${g.slice(-1)}`:`\\${g}`,this.options.pedantic&&(g=b?g:"[*+-]");const v=new RegExp(`^( {0,3}${g})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;e&&(p=!1,!(!(n=v.exec(e))||this.rules.block.hr.test(e)));){if(r=n[0],e=e.substring(r.length),c=n[2].split(` -`,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),f=e.split(` -`,1)[0],this.options.pedantic?(o=2,h=c.trimLeft()):(o=n[2].search(/[^ ]/),o=o>4?1:o,h=c.slice(o),o+=n[1].length),a=!1,!c&&/^ *$/.test(f)&&(r+=f+` -`,e=e.substring(f.length+1),p=!0),!p){const k=new RegExp(`^ {0,${Math.min(3,o-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),x=new RegExp(`^ {0,${Math.min(3,o-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),C=new RegExp(`^ {0,${Math.min(3,o-1)}}(?:\`\`\`|~~~)`),T=new RegExp(`^ {0,${Math.min(3,o-1)}}#`);for(;e&&(d=e.split(` -`,1)[0],f=d,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(C.test(f)||T.test(f)||k.test(f)||x.test(e)));){if(f.search(/[^ ]/)>=o||!f.trim())h+=` -`+f.slice(o);else{if(a||c.search(/[^ ]/)>=4||C.test(c)||T.test(c)||x.test(c))break;h+=` -`+f}!a&&!f.trim()&&(a=!0),r+=d+` -`,e=e.substring(d.length+1),c=f.slice(o)}}m.loose||(u?m.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(i=/^\[[ xX]\] /.exec(h),i&&(s=i[0]!=="[ ] ",h=h.replace(/^\[[ xX]\] +/,""))),m.items.push({type:"list_item",raw:r,task:!!i,checked:s,loose:!1,text:h}),m.raw+=r}m.items[m.items.length-1].raw=r.trimRight(),m.items[m.items.length-1].text=h.trimRight(),m.raw=m.raw.trimRight();const w=m.items.length;for(l=0;lC.type==="space"),x=k.length>0&&k.some(C=>/\n.*\n/.test(C.raw));m.loose=x}if(m.loose)for(l=0;l$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:i,title:s}}}table(e){const n=this.rules.block.table.exec(e);if(n){const r={type:"table",header:Qb(n[1]).map(i=>({text:i})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(` -`):[]};if(r.header.length===r.align.length){r.raw=n[0];let i=r.align.length,s,o,l,a;for(s=0;s({text:u}));for(i=r.header.length,o=0;o/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):dr(n[0]):n[0]}}link(e){const n=this.rules.inline.link.exec(e);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^$/.test(r))return;const o=Vd(r.slice(0,-1),"\\");if((r.length-o.length)%2===0)return}else{const o=i4(n[2],"()");if(o>-1){const a=(n[0].indexOf("!")===0?5:4)+n[1].length+o;n[2]=n[2].substring(0,o),n[0]=n[0].substring(0,a).trim(),n[3]=""}}let i=n[2],s="";if(this.options.pedantic){const o=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);o&&(i=o[1],s=o[3])}else s=n[3]?n[3].slice(1,-1):"";return i=i.trim(),/^$/.test(r)?i=i.slice(1):i=i.slice(1,-1)),ex(n,{href:i&&i.replace(this.rules.inline._escapes,"$1"),title:s&&s.replace(this.rules.inline._escapes,"$1")},n[0],this.lexer)}}reflink(e,n){let r;if((r=this.rules.inline.reflink.exec(e))||(r=this.rules.inline.nolink.exec(e))){let i=(r[2]||r[1]).replace(/\s+/g," ");if(i=n[i.toLowerCase()],!i){const s=r[0].charAt(0);return{type:"text",raw:s,text:s}}return ex(r,i,r[0],this.lexer)}}emStrong(e,n,r=""){let i=this.rules.inline.emStrong.lDelim.exec(e);if(!i||i[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=i[1]||i[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const o=i[0].length-1;let l,a,u=o,c=0;const f=i[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*e.length+o);(i=f.exec(n))!=null;){if(l=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!l)continue;if(a=l.length,i[3]||i[4]){u+=a;continue}else if((i[5]||i[6])&&o%3&&!((o+a)%3)){c+=a;continue}if(u-=a,u>0)continue;a=Math.min(a,a+u+c);const d=e.slice(0,o+i.index+(i[0].length-l.length)+a);if(Math.min(o,a)%2){const p=d.slice(1,-1);return{type:"em",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}const h=d.slice(2,-2);return{type:"strong",raw:d,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(e){const n=this.rules.inline.code.exec(e);if(n){let r=n[2].replace(/\n/g," ");const i=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return i&&s&&(r=r.substring(1,r.length-1)),r=dr(r,!0),{type:"codespan",raw:n[0],text:r}}}br(e){const n=this.rules.inline.br.exec(e);if(n)return{type:"br",raw:n[0]}}del(e){const n=this.rules.inline.del.exec(e);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(e,n){const r=this.rules.inline.autolink.exec(e);if(r){let i,s;return r[2]==="@"?(i=dr(this.options.mangle?n(r[1]):r[1]),s="mailto:"+i):(i=dr(r[1]),s=i),{type:"link",raw:r[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}url(e,n){let r;if(r=this.rules.inline.url.exec(e)){let i,s;if(r[2]==="@")i=dr(this.options.mangle?n(r[0]):r[0]),s="mailto:"+i;else{let o;do o=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(o!==r[0]);i=dr(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e,n){const r=this.rules.inline.text.exec(e);if(r){let i;return this.lexer.state.inRawBlock?i=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):dr(r[0]):r[0]:i=dr(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:i}}}}const Ze={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Ih,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Ze._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/;Ze._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;Ze.def=sn(Ze.def).replace("label",Ze._label).replace("title",Ze._title).getRegex();Ze.bullet=/(?:[*+-]|\d{1,9}[.)])/;Ze.listItemStart=sn(/^( *)(bull) */).replace("bull",Ze.bullet).getRegex();Ze.list=sn(Ze.list).replace(/bull/g,Ze.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Ze.def.source+")").getRegex();Ze._tag="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|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";Ze._comment=/|$)/;Ze.html=sn(Ze.html,"i").replace("comment",Ze._comment).replace("tag",Ze._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();Ze.paragraph=sn(Ze._paragraph).replace("hr",Ze.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ze._tag).getRegex();Ze.blockquote=sn(Ze.blockquote).replace("paragraph",Ze.paragraph).getRegex();Ze.normal={...Ze};Ze.gfm={...Ze.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"};Ze.gfm.table=sn(Ze.gfm.table).replace("hr",Ze.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ze._tag).getRegex();Ze.gfm.paragraph=sn(Ze._paragraph).replace("hr",Ze.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Ze.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ze._tag).getRegex();Ze.pedantic={...Ze.normal,html:sn(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ze._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ih,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:sn(Ze.normal._paragraph).replace("hr",Ze.hr).replace("heading",` *#{1,6} *[^ -]`).replace("lheading",Ze.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const Le={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ih,tag:"^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Ih,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\?@\\[\\]`^{|}~";Le.punctuation=sn(Le.punctuation).replace(/punctuation/g,Le._punctuation).getRegex();Le.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;Le.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g;Le._comment=sn(Ze._comment).replace("(?:-->|$)","-->").getRegex();Le.emStrong.lDelim=sn(Le.emStrong.lDelim).replace(/punct/g,Le._punctuation).getRegex();Le.emStrong.rDelimAst=sn(Le.emStrong.rDelimAst,"g").replace(/punct/g,Le._punctuation).getRegex();Le.emStrong.rDelimUnd=sn(Le.emStrong.rDelimUnd,"g").replace(/punct/g,Le._punctuation).getRegex();Le._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;Le._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;Le._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;Le.autolink=sn(Le.autolink).replace("scheme",Le._scheme).replace("email",Le._email).getRegex();Le._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;Le.tag=sn(Le.tag).replace("comment",Le._comment).replace("attribute",Le._attribute).getRegex();Le._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;Le._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;Le._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;Le.link=sn(Le.link).replace("label",Le._label).replace("href",Le._href).replace("title",Le._title).getRegex();Le.reflink=sn(Le.reflink).replace("label",Le._label).replace("ref",Ze._label).getRegex();Le.nolink=sn(Le.nolink).replace("ref",Ze._label).getRegex();Le.reflinkSearch=sn(Le.reflinkSearch,"g").replace("reflink",Le.reflink).replace("nolink",Le.nolink).getRegex();Le.normal={...Le};Le.pedantic={...Le.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:sn(/^!?\[(label)\]\((.*?)\)/).replace("label",Le._label).getRegex(),reflink:sn(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Le._label).getRegex()};Le.gfm={...Le.normal,escape:sn(Le.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\.5&&(r="x"+r.toString(16)),e+="&#"+r+";";return e}class zo{constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||zl,this.options.tokenizer=this.options.tokenizer||new nw,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:Ze.normal,inline:Le.normal};this.options.pedantic?(n.block=Ze.pedantic,n.inline=Le.pedantic):this.options.gfm&&(n.block=Ze.gfm,this.options.breaks?n.inline=Le.breaks:n.inline=Le.gfm),this.tokenizer.rules=n}static get rules(){return{block:Ze,inline:Le}}static lex(e,n){return new zo(n).lex(e)}static lexInline(e,n){return new zo(n).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,` -`),this.blockTokens(e,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(e,n=[]){this.options.pedantic?e=e.replace(/\t/g," ").replace(/^ +$/gm,""):e=e.replace(/^( *)(\t+)/gm,(l,a,u)=>a+" ".repeat(u.length));let r,i,s,o;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(l=>(r=l.call({lexer:this},e,n))?(e=e.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=` -`:n.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=` -`+r.raw,i.text+=` -`+r.text,this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=` -`+r.raw,i.text+=` -`+r.raw,this.inlineQueue[this.inlineQueue.length-1].src=i.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),n.push(r);continue}if(s=e,this.options.extensions&&this.options.extensions.startBlock){let l=1/0;const a=e.slice(1);let u;this.options.extensions.startBlock.forEach(function(c){u=c.call({lexer:this},a),typeof u=="number"&&u>=0&&(l=Math.min(l,u))}),l<1/0&&l>=0&&(s=e.substring(0,l+1))}if(this.state.top&&(r=this.tokenizer.paragraph(s))){i=n[n.length-1],o&&i.type==="paragraph"?(i.raw+=` -`+r.raw,i.text+=` -`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r),o=s.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&i.type==="text"?(i.raw+=` -`+r.raw,i.text+=` -`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r);continue}if(e){const l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let r,i,s,o=e,l,a,u;if(this.tokens.links){const c=Object.keys(this.tokens.links);if(c.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(o))!=null;)c.includes(l[0].slice(l[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,l.index)+"["+Zb("a",l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(l=this.tokenizer.rules.inline.blockSkip.exec(o))!=null;)o=o.slice(0,l.index)+"["+Zb("a",l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(l=this.tokenizer.rules.inline.escapedEmSt.exec(o))!=null;)o=o.slice(0,l.index+l[0].length-2)+"++"+o.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;e;)if(a||(u=""),a=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(c=>(r=c.call({lexer:this},e,n))?(e=e.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&r.type==="text"&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length),i=n[n.length-1],i&&r.type==="text"&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(e,o,u)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(e,tx)){e=e.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e,tx))){e=e.substring(r.raw.length),n.push(r);continue}if(s=e,this.options.extensions&&this.options.extensions.startInline){let c=1/0;const f=e.slice(1);let d;this.options.extensions.startInline.forEach(function(h){d=h.call({lexer:this},f),typeof d=="number"&&d>=0&&(c=Math.min(c,d))}),c<1/0&&c>=0&&(s=e.substring(0,c+1))}if(r=this.tokenizer.inlineText(s,l4)){e=e.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=r.raw.slice(-1)),a=!0,i=n[n.length-1],i&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(e){const c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return n}}class rw{constructor(e){this.options=e||zl}code(e,n,r){const i=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(e,i);s!=null&&s!==e&&(r=!0,e=s)}return e=e.replace(/\n$/,"")+` -`,i?'
'+(r?e:dr(e,!0))+`
-`:"
"+(r?e:dr(e,!0))+`
-`}blockquote(e){return`
-${e}
-`}html(e){return e}heading(e,n,r,i){if(this.options.headerIds){const s=this.options.headerPrefix+i.slug(r);return`${e} -`}return`${e} -`}hr(){return this.options.xhtml?`
-`:`
-`}list(e,n,r){const i=n?"ol":"ul",s=n&&r!==1?' start="'+r+'"':"";return"<"+i+s+`> -`+e+" -`}listitem(e){return`
  • ${e}
  • -`}checkbox(e){return" "}paragraph(e){return`

    ${e}

    -`}table(e,n){return n&&(n=`${n}`),` - -`+e+` -`+n+`
    -`}tablerow(e){return` -${e} -`}tablecell(e,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+e+` -`}strong(e){return`${e}`}em(e){return`${e}`}codespan(e){return`${e}`}br(){return this.options.xhtml?"
    ":"
    "}del(e){return`${e}`}link(e,n,r){if(e=Jb(this.options.sanitize,this.options.baseUrl,e),e===null)return r;let i='",i}image(e,n,r){if(e=Jb(this.options.sanitize,this.options.baseUrl,e),e===null)return r;let i=`${r}":">",i}text(e){return e}}class iE{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,n,r){return""+r}image(e,n,r){return""+r}br(){return""}}class sE{constructor(){this.seen={}}serialize(e){return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(e,n){let r=e,i=0;if(this.seen.hasOwnProperty(r)){i=this.seen[e];do i++,r=e+"-"+i;while(this.seen.hasOwnProperty(r))}return n||(this.seen[e]=i,this.seen[r]=0),r}slug(e,n={}){const r=this.serialize(e);return this.getNextSafeSlug(r,n.dryrun)}}let df=class F0{constructor(e){this.options=e||zl,this.options.renderer=this.options.renderer||new rw,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new iE,this.slugger=new sE}static parse(e,n){return new F0(n).parse(e)}static parseInline(e,n){return new F0(n).parseInline(e)}parse(e,n=!0){let r="",i,s,o,l,a,u,c,f,d,h,p,g,b,m,v,w,k,x,C;const T=e.length;for(i=0;i0&&v.tokens[0].type==="paragraph"?(v.tokens[0].text=x+" "+v.tokens[0].text,v.tokens[0].tokens&&v.tokens[0].tokens.length>0&&v.tokens[0].tokens[0].type==="text"&&(v.tokens[0].tokens[0].text=x+" "+v.tokens[0].tokens[0].text)):v.tokens.unshift({type:"text",text:x}):m+=x),m+=this.parse(v.tokens,b),d+=this.renderer.listitem(m,k,w);r+=this.renderer.list(d,p,g);continue}case"html":{r+=this.renderer.html(h.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(h.tokens));continue}case"text":{for(d=h.tokens?this.parseInline(h.tokens):h.text;i+1{if(r.message+=` -Please report this to https://github.com/markedjs/marked.`,t){const i="

    An error occurred:

    "+dr(r.message+"",!0)+"
    ";if(e)return Promise.resolve(i);if(n){n(null,i);return}return i}if(e)return Promise.reject(r);if(n){n(r);return}throw r}}function oE(t,e){return(n,r,i)=>{typeof r=="function"&&(i=r,r=null);const s={...r};r={...nt.defaults,...s};const o=a4(r.silent,r.async,i);if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(s4(r),r.hooks&&(r.hooks.options=r),i){const l=r.highlight;let a;try{r.hooks&&(n=r.hooks.preprocess(n)),a=t(n,r)}catch(f){return o(f)}const u=function(f){let d;if(!f)try{r.walkTokens&&nt.walkTokens(a,r.walkTokens),d=e(a,r),r.hooks&&(d=r.hooks.postprocess(d))}catch(h){f=h}return r.highlight=l,f?o(f):i(null,d)};if(!l||l.length<3||(delete r.highlight,!a.length))return u();let c=0;nt.walkTokens(a,function(f){f.type==="code"&&(c++,setTimeout(()=>{l(f.text,f.lang,function(d,h){if(d)return u(d);h!=null&&h!==f.text&&(f.text=h,f.escaped=!0),c--,c===0&&u()})},0))}),c===0&&u();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(l=>t(l,r)).then(l=>r.walkTokens?Promise.all(nt.walkTokens(l,r.walkTokens)).then(()=>l):l).then(l=>e(l,r)).then(l=>r.hooks?r.hooks.postprocess(l):l).catch(o);try{r.hooks&&(n=r.hooks.preprocess(n));const l=t(n,r);r.walkTokens&&nt.walkTokens(l,r.walkTokens);let a=e(l,r);return r.hooks&&(a=r.hooks.postprocess(a)),a}catch(l){return o(l)}}}function nt(t,e,n){return oE(zo.lex,df.parse)(t,e,n)}nt.options=nt.setOptions=function(t){return nt.defaults={...nt.defaults,...t},KF(nt.defaults),nt};nt.getDefaults=eE;nt.defaults=zl;nt.use=function(...t){const e=nt.defaults.extensions||{renderers:{},childTokens:{}};t.forEach(n=>{const r={...n};if(r.async=nt.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if(i.renderer){const s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let l=i.renderer.apply(this,o);return l===!1&&(l=s.apply(this,o)),l}:e.renderers[i.name]=i.renderer}if(i.tokenizer){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");e[i.level]?e[i.level].unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){const i=nt.defaults.renderer||new rw;for(const s in n.renderer){const o=i[s];i[s]=(...l)=>{let a=n.renderer[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.renderer=i}if(n.tokenizer){const i=nt.defaults.tokenizer||new nw;for(const s in n.tokenizer){const o=i[s];i[s]=(...l)=>{let a=n.tokenizer[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.tokenizer=i}if(n.hooks){const i=nt.defaults.hooks||new Nh;for(const s in n.hooks){const o=i[s];Nh.passThroughHooks.has(s)?i[s]=l=>{if(nt.defaults.async)return Promise.resolve(n.hooks[s].call(i,l)).then(u=>o.call(i,u));const a=n.hooks[s].call(i,l);return o.call(i,a)}:i[s]=(...l)=>{let a=n.hooks[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.hooks=i}if(n.walkTokens){const i=nt.defaults.walkTokens;r.walkTokens=function(s){let o=[];return o.push(n.walkTokens.call(this,s)),i&&(o=o.concat(i.call(this,s))),o}}nt.setOptions(r)})};nt.walkTokens=function(t,e){let n=[];for(const r of t)switch(n=n.concat(e.call(nt,r)),r.type){case"table":{for(const i of r.header)n=n.concat(nt.walkTokens(i.tokens,e));for(const i of r.rows)for(const s of i)n=n.concat(nt.walkTokens(s.tokens,e));break}case"list":{n=n.concat(nt.walkTokens(r.items,e));break}default:nt.defaults.extensions&&nt.defaults.extensions.childTokens&&nt.defaults.extensions.childTokens[r.type]?nt.defaults.extensions.childTokens[r.type].forEach(function(i){n=n.concat(nt.walkTokens(r[i],e))}):r.tokens&&(n=n.concat(nt.walkTokens(r.tokens,e)))}return n};nt.parseInline=oE(zo.lexInline,df.parseInline);nt.Parser=df;nt.parser=df.parse;nt.Renderer=rw;nt.TextRenderer=iE;nt.Lexer=zo;nt.lexer=zo.lex;nt.Tokenizer=nw;nt.Slugger=sE;nt.Hooks=Nh;nt.parse=nt;nt.options;nt.setOptions;nt.use;nt.walkTokens;nt.parseInline;df.parse;zo.lex;const u4=ii("div")({name:"MarkdownContainer",class:"gdg-mnuv029",propsAsIs:!1});class c4 extends Vn.PureComponent{constructor(){super(...arguments);St(this,"targetElement",null);St(this,"containerRefHook",n=>{this.targetElement=n,this.renderMarkdownIntoDiv()})}renderMarkdownIntoDiv(){const{targetElement:n,props:r}=this;if(n===null)return;const{contents:i,createNode:s}=r,o=nt(i),l=document.createRange();l.selectNodeContents(n),l.deleteContents();let a=s==null?void 0:s(o);if(a===void 0){const c=document.createElement("template");c.innerHTML=o,a=c.content}n.append(a);const u=n.getElementsByTagName("a");for(const c of u)c.target="_blank",c.rel="noreferrer noopener"}render(){return this.renderMarkdownIntoDiv(),Vn.createElement(u4,{ref:this.containerRefHook})}}const f4=ii("textarea")({name:"InputBox",class:"gdg-izpuzkl",propsAsIs:!1}),d4=ii("div")({name:"ShadowBox",class:"gdg-s69h75o",propsAsIs:!1}),h4=ii("div")({name:"GrowingEntryStyle",class:"gdg-g1y0xocz",propsAsIs:!1});let nx=0;const Lp=t=>{const{placeholder:e,value:n,onKeyDown:r,highlight:i,altNewline:s,validatedSelection:o,...l}=t,{onChange:a,className:u}=l,c=y.useRef(null),f=n??"";Yr(a!==void 0,"GrowingEntry must be a controlled input area");const[d]=y.useState(()=>"input-box-"+(nx=(nx+1)%1e7));y.useEffect(()=>{const p=c.current;if(p===null||p.disabled)return;const g=f.toString().length;p.focus(),p.setSelectionRange(i?0:g,g)},[]),y.useLayoutEffect(()=>{var p;if(o!==void 0){const g=typeof o=="number"?[o,null]:o;(p=c.current)==null||p.setSelectionRange(g[0],g[1])}},[o]);const h=y.useCallback(p=>{p.key==="Enter"&&p.shiftKey&&s===!0||r==null||r(p)},[s,r]);return y.createElement(h4,{className:"gdg-growing-entry"},y.createElement(d4,{className:u},f+` -`),y.createElement(f4,{...l,className:(u??"")+" gdg-input",id:d,ref:c,onKeyDown:h,value:f,placeholder:e,dir:"auto"}))},Jg={};let uo=null;function p4(){const t=document.createElement("div");return t.style.opacity="0",t.style.pointerEvents="none",t.style.position="fixed",document.body.append(t),t}function z0(t){const e=t.toLowerCase().trim();if(Jg[e]!==void 0)return Jg[e];uo=uo||p4(),uo.style.color="#000",uo.style.color=e;const n=getComputedStyle(uo).color;uo.style.color="#fff",uo.style.color=e;const r=getComputedStyle(uo).color;if(r!==n)return[0,0,0,1];let i=r.replace(/[^\d.,]/g,"").split(",").map(Number.parseFloat);return i.length<4&&i.push(1),i=i.map(s=>Number.isNaN(s)?0:s),Jg[e]=i,i}function Ol(t,e){const[n,r,i]=z0(t);return`rgba(${n}, ${r}, ${i}, ${e})`}const rx=new Map;function ix(t,e){const n=`${t}-${e}`,r=rx.get(n);if(r!==void 0)return r;const i=Jr(t,e);return rx.set(n,i),i}function Jr(t,e){if(e===void 0)return t;const[n,r,i,s]=z0(t);if(s===1)return t;const[o,l,a,u]=z0(e),c=s+u*(1-s),f=(s*n+u*o*(1-s))/c,d=(s*r+u*l*(1-s))/c,h=(s*i+u*a*(1-s))/c;return`rgba(${f}, ${d}, ${h}, ${c})`}var sa=new Map,ba=new Map,B0=new Map;function g4(){sa.clear(),B0.clear(),ba.clear()}function m4(t,e,n,r,i){var s,o,l;let a=0,u={};for(let f of t)a+=(s=n.get(f))!=null?s:i,u[f]=((o=u[f])!=null?o:0)+1;let c=e-a;for(let f of Object.keys(u)){let d=u[f],h=(l=n.get(f))!=null?l:i,p=h*d/a,g=c*p*r/d,b=h+g;n.set(f,b)}}function y4(t,e){var n;let r=new Map,i=0;for(let u of"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890,.-+=?"){let c=t.measureText(u).width;r.set(u,c),i+=c}let s=i/r.size,o=3,l=(e/s+o)/(o+1),a=r.keys();for(let u of a)r.set(u,((n=r.get(u))!=null?n:s)*l);return r}function dc(t,e,n,r){var i,s;let o=ba.get(n);if(r&&o!==void 0&&o.count>2e4){let u=B0.get(n);if(u===void 0&&(u=y4(t,o.size),B0.set(n,u)),o.count>5e5){let f=0;for(let d of e)f+=(i=u.get(d))!=null?i:o.size;return f*1.01}let c=t.measureText(e);return m4(e,c.width,u,Math.max(.05,1-o.count/2e5),o.size),ba.set(n,{count:o.count+e.length,size:o.size}),c.width}let l=t.measureText(e),a=l.width/e.length;if(((s=o==null?void 0:o.count)!=null?s:0)>2e4)return l.width;if(o===void 0)ba.set(n,{count:e.length,size:a});else{let u=a-o.size,c=e.length/(o.count+e.length),f=o.size+u*c;ba.set(n,{count:o.count+e.length,size:f})}return l.width}function v4(t,e,n,r,i,s,o,l){if(e.length<=1)return e.length;if(in;){let c=e.lastIndexOf(" ",a-1);c>0?a=c:a--,u=dc(t,e.slice(0,Math.max(0,a)),r,o)}if(e[a]!==" "){let c=0;c=e.lastIndexOf(" ",a),c>0&&(a=c)}return a}function w4(t,e,n,r,i,s){let o=`${e}_${n}_${r}px`,l=sa.get(o);if(l!==void 0)return l;if(r<=0)return[];let a=[],u=e.split(` -`),c=ba.get(n),f=c===void 0?e.length:r/c.size*1.5,d=i&&c!==void 0&&c.count>2e4;for(let h of u){let p=dc(t,h.slice(0,Math.max(0,f)),n,d),g=Math.min(h.length,f);if(p<=r)a.push(h);else{for(;p>r;){let b=v4(t,h,r,n,p,g,d),m=h.slice(0,Math.max(0,b));h=h.slice(m.length),a.push(m),p=dc(t,h.slice(0,Math.max(0,f)),n,d),g=Math.min(h.length,f)}p>0&&a.push(h)}}return a=a.map((h,p)=>p===0?h.trimEnd():h.trim()),sa.set(o,a),sa.size>500&&sa.delete(sa.keys().next().value),a}function b4(t,e){return Vn.useMemo(()=>t.map((n,r)=>({group:n.group,grow:n.grow,hasMenu:n.hasMenu,icon:n.icon,id:n.id,menuIcon:n.menuIcon,overlayIcon:n.overlayIcon,sourceIndex:r,sticky:r=s.x&&n=s.y&&r=e.span[0]&&n.current.cell[0]<=e.span[1]}function lE(t,e){const[n,r]=t;return n>=e.x&&n=e.y&&ro)return!1;if(e.span===void 0)return l>=r&&l<=i;const[u,c]=e.span;return u>=r&&u<=i||c>=r&&u<=i||ui}function S4(t,e,n,r){let i=0;if(n.current===void 0)return i;const s=n.current.range;(r||s.height*s.width>1)&&sx(t,e,s)&&i++;for(const o of n.current.rangeStack)sx(t,e,o)&&i++;return i}function uE(t,e){let n=t;if(e!==void 0){let r=[...t];const i=n[e.src];e.src>e.dest?(r.splice(e.src,1),r.splice(e.dest,0,i)):(r.splice(e.dest+1,0,i),r.splice(e.src,1)),r=r.map((s,o)=>({...s,sticky:t[o].sticky})),n=r}return n}function Ua(t,e){let n=0;const r=uE(t,e);for(let i=0;i0)for(const u of o)n-=u.width;let l=e,a=i??0;for(;a<=n&&l=f)return g}const d=s-u,h=t-(a??0);if(typeof o=="number"){const p=Math.floor((h-c)/o)+l;return p>=d?void 0:p}else{let p=c;for(let g=l;g"u";async function A4(){var t;E4||((t=document==null?void 0:document.fonts)==null?void 0:t.ready)===void 0||(await document.fonts.ready,Ud=0,pc={},g4())}A4();function cE(t,e,n,r){return`${t}_${r??(e==null?void 0:e.font)}_${n}`}function hf(t,e,n,r="middle"){const i=cE(t,e,r,n);let s=pc[i];return s===void 0&&(s=e.measureText(t),pc[i]=s,Ud++),Ud>1e4&&(pc={},Ud=0),s}function M4(t,e){const n=cE(t,void 0,"middle",e);return pc[n]}function Ys(t,e){return typeof e!="string"&&(e=e.baseFontFull),R4(t,e)}function ox(t,e){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ";t.save(),t.textBaseline=e;const r=t.measureText(n);return t.restore(),r}const lx=[];function R4(t,e){for(const s of lx)if(s.key===e)return s.val;const n=ox(t,"alphabetic"),i=-(ox(t,"middle").actualBoundingBoxDescent-n.actualBoundingBoxDescent)+n.actualBoundingBoxAscent/2;return lx.push({key:e,val:i}),i}function O4(t,e,n,r,i,s){const{ctx:o,rect:l,theme:a}=t;let u=Number.MAX_SAFE_INTEGER;const c=500;if(e!==void 0&&(u=n-e,un&&(t=t.slice(0,n)),t}function I4(t,e,n,r,i,s,o,l,a,u){const c=l.baseFontFull,f=w4(t,e,c,i-l.cellHorizontalPadding*2,u??!1),d=dE(t,c),h=l.lineHeight*d,p=d+h*(f.length-1),g=p+l.cellVerticalPadding>s;g&&(t.save(),t.rect(n,r,i,s),t.clip());const b=r+s/2-p/2;let m=Math.max(r+l.cellVerticalPadding,b);for(const v of f)if(fE(t,v,n,m,i,d,o,l,a),m+=h,m>r+s)break;g&&t.restore()}function $s(t,e,n,r,i){const{ctx:s,rect:o,theme:l}=t,{x:a,y:u,width:c,height:f}=o;r=r??!1,r||(e=P4(e,c));const d=Ys(s,l),h=tw(e)==="rtl";if(n===void 0&&h&&(n="right"),h&&(s.direction="rtl"),e.length>0){let p=!1;n==="right"?(s.textAlign="right",p=!0):n!==void 0&&n!=="left"&&(s.textAlign=n,p=!0),r?I4(s,e,a,u,c,f,d,l,n,i):fE(s,e,a,u,c,f,d,l,n),p&&(s.textAlign="start"),h&&(s.direction="inherit")}}function Cs(t,e,n,r,i,s){typeof s=="number"&&(s={tl:s,tr:s,br:s,bl:s}),s={tl:Math.max(0,Math.min(s.tl,i/2,r/2)),tr:Math.max(0,Math.min(s.tr,i/2,r/2)),bl:Math.max(0,Math.min(s.bl,i/2,r/2)),br:Math.max(0,Math.min(s.br,i/2,r/2))},t.moveTo(e+s.tl,n),t.arcTo(e+r,n,e+r,n+s.tr,s.tr),t.arcTo(e+r,n+i,e+r-s.br,n+i,s.br),t.arcTo(e,n+i,e,n+i-s.bl,s.bl),t.arcTo(e,n,e+s.tl,n,s.tl)}function N4(t,e,n){t.arc(e,n-1.25*3.5,1.25,0,2*Math.PI,!1),t.arc(e,n,1.25,0,2*Math.PI,!1),t.arc(e,n+1.25*3.5,1.25,0,2*Math.PI,!1)}function _4(t,e,n){const r=function(l,a){const u=a.x-l.x,c=a.y-l.y,f=Math.sqrt(u*u+c*c),d=u/f,h=c/f;return{x:u,y:a.y-l.y,len:f,nx:d,ny:h,ang:Math.atan2(h,d)}};let i;const s=e.length;let o=e[s-1];for(let l=0;l1?1:d),g=1,b=!1;h<0?p<0?p=Math.PI+p:(p=Math.PI-p,g=-1,b=!0):p>0&&(g=-1,b=!0),i=a.radius!==void 0?a.radius:n;const m=p/2;let v=Math.abs(Math.cos(m)*i/Math.sin(m)),w;v>Math.min(c.len/2,f.len/2)?(v=Math.min(c.len/2,f.len/2),w=Math.abs(v*Math.sin(m)/Math.cos(m))):w=i;let k=a.x+f.nx*v,x=a.y+f.ny*v;k+=-f.ny*w*g,x+=f.nx*w*g,t.arc(k,x,w,c.ang+Math.PI/2*g,f.ang-Math.PI/2*g,b),o=a,a=u}t.closePath()}function H0(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p){const g={x:0,y:s+u,width:0,height:0};if(t>=h.length||e>=c||e<-2||t<0)return g;const b=s-i;if(t>=f){const m=o>t?-1:1,v=Ua(h);g.x+=v+a;for(let w=o;w!==t;w+=m)g.x+=h[m===1?w:w-1].width*m}else for(let m=0;m0&&Wc(h[m-1].group,v)&&h[m-1].sticky===w;){const x=h[m-1];g.x-=x.width,g.width+=x.width,m--}let k=t;for(;k+1n&&(g.width=n-g.x)}}else if(e>=c-d){let m=c-e;for(g.y=r;m>0;){const v=e+m-1;g.height=typeof p=="number"?p:p(v),g.y-=g.height,m--}g.height+=1}else{const m=l>e?-1:1;if(typeof p=="number"){const v=e-l;g.y+=v*p}else for(let v=l;v!==e;v+=m)g.y+=p(v)*m;g.height=(typeof p=="number"?p:p(e))+1}return g}const iw=1<<21;function Hi(t,e){return(e+2)*iw+t}function hE(t){return t%iw}function sw(t){return Math.floor(t/iw)-2}function ow(t){const e=hE(t),n=sw(t);return[e,n]}class pE{constructor(){St(this,"visibleWindow",{x:0,y:0,width:0,height:0});St(this,"freezeCols",0);St(this,"freezeRows",[]);St(this,"isInWindow",e=>{const n=hE(e),r=sw(e),i=this.visibleWindow,s=n>=i.x&&n<=i.x+i.width||n=i.y&&r<=i.y+i.height||this.freezeRows.includes(r);return s&&o})}setWindow(e,n,r){this.visibleWindow.x===e.x&&this.visibleWindow.y===e.y&&this.visibleWindow.width===e.width&&this.visibleWindow.height===e.height&&this.freezeCols===n&&Va(this.freezeRows,r)||(this.visibleWindow=e,this.freezeCols=n,this.freezeRows=r,this.clearOutOfWindow())}}class D4 extends pE{constructor(){super(...arguments);St(this,"cache",new Map);St(this,"setValue",(n,r)=>{this.cache.set(Hi(n[0],n[1]),r)});St(this,"getValue",n=>this.cache.get(Hi(n[0],n[1])));St(this,"clearOutOfWindow",()=>{for(const[n]of this.cache.entries())this.isInWindow(n)||this.cache.delete(n)})}}class gc{constructor(e=[]){St(this,"cells");this.cells=new Set(e.map(n=>Hi(n[0],n[1])))}add(e){this.cells.add(Hi(e[0],e[1]))}has(e){return e===void 0?!1:this.cells.has(Hi(e[0],e[1]))}remove(e){this.cells.delete(Hi(e[0],e[1]))}clear(){this.cells.clear()}get size(){return this.cells.size}hasHeader(){for(const e of this.cells)if(sw(e)<0)return!0;return!1}hasItemInRectangle(e){for(let n=e.y;n{const h=F4(t,d[r],e,a);return u=Math.max(u,h),h});if(c.length>5&&l){u=0;let d=0;for(const p of c)d+=p;const h=d/c.length;for(let p=0;p=h*2?c[p]=0:u=Math.max(u,c[p])}u=Math.max(u,t.measureText(n.title).width+16+(n.icon===void 0?0:28));const f=Math.max(Math.ceil(s),Math.min(Math.floor(o),Math.ceil(u)));return{...n,width:f}}function z4(t,e,n,r,i,s,o,l,a){const u=y.useRef(e),c=y.useRef(n),f=y.useRef(o);u.current=e,c.current=n,f.current=o;const[d,h]=y.useMemo(()=>{if(typeof window>"u")return[null,null];const v=document.createElement("canvas");return v.style.display="none",v.style.opacity="0",v.style.position="fixed",[v,v.getContext("2d",{alpha:!1})]},[]);y.useLayoutEffect(()=>(d&&document.documentElement.append(d),()=>{d==null||d.remove()}),[d]);const p=y.useRef({}),g=y.useRef(),[b,m]=y.useState();return y.useLayoutEffect(()=>{const v=c.current;if(v===void 0||t.every(Zf))return;let w=Math.max(1,10-Math.floor(t.length/1e4)),k=0;w1&&(w--,k=1);const x={x:0,y:0,width:t.length,height:Math.min(u.current,w)},C={x:0,y:u.current-1,width:t.length,height:1};(async()=>{const A=v(x,a.signal),R=k>0?v(C,a.signal):void 0;let P;typeof A=="object"?P=A:P=await Lb(A),R!==void 0&&(typeof R=="object"?P=[...P,...R]:P=[...P,...await Lb(R)]),g.current=t,m(P)})()},[a.signal,t]),y.useMemo(()=>{let w=t.every(Zf)?t:h===null?t.map(T=>Zf(T)?T:{...T,width:W0}):(h.font=f.current.baseFontFull,t.map((T,A)=>{if(Zf(T))return T;if(p.current[T.id]!==void 0)return{...T,width:p.current[T.id]};if(b===void 0||g.current!==t||T.id===void 0)return{...T,width:W0};const R=yE(h,o,T,A,b,i,s,!0,l);return p.current[T.id]=R.width,R})),k=0,x=0;const C=[];for(const[T,A]of w.entries())k+=A.width,A.grow!==void 0&&A.grow>0&&(x+=A.grow,C.push(T));if(k0){const T=[...w],A=r-k;let R=A;for(let P=0;P0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=Promise.allSettled(n.map(a=>{if(a=j4(a),a in ax)return;ax[a]=!0;const u=a.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${a}"]${c}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":B4,u||(f.as="script"),f.crossOrigin="",f.href=a,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((d,h)=>{f.addEventListener("load",d),f.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${a}`)))})}))}function s(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return i.then(o=>{for(const l of o||[])l.status==="rejected"&&s(l.reason);return e().catch(s)})};function H4(t,e,n){return t===t&&(n!==void 0&&(t=t<=n?t:n),e!==void 0&&(t=t>=e?t:e)),t}var W4=H4,V4=W4,Qg=Zv;function U4(t,e,n){return n===void 0&&(n=e,e=void 0),n!==void 0&&(n=Qg(n),n=n===n?n:0),e!==void 0&&(e=Qg(e),e=e===e?e:0),V4(Qg(t),e,n)}var K4=U4;const ji=Qi(K4);var X4="__lodash_hash_undefined__";function G4(t){return this.__data__.set(t,X4),this}var q4=G4;function Y4(t){return this.__data__.has(t)}var J4=Y4,Q4=Vv,Z4=q4,e5=J4;function _h(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new Q4;++e-1}var p5=h5;function g5(t,e,n){for(var r=-1,i=t==null?0:t.length;++r=D5){var u=e?null:N5(t);if(u)return _5(u);o=!1,i=I5,a=new R5}else a=e?[]:l;e:for(;++r0&&n(l)?e>1?SE(l,e-1,n,r,i):X5(i,l):r||(i[i.length]=l)}return i}var q5=SE,Y5=q5;function J5(t){var e=t==null?0:t.length;return e?Y5(t,1):[]}var Q5=J5;const fx=Qi(Q5);var Z5=Math.ceil,ez=Math.max;function tz(t,e,n,r){for(var i=-1,s=ez(Z5((e-t)/(n||1)),0),o=Array(s);s--;)o[r?s:++i]=t,t+=n;return o}var nz=tz,rz=_T,iz=Gv;function sz(t){return t!=null&&iz(t.length)&&!rz(t)}var aw=sz,oz=Hv,lz=aw,az=Xv,uz=$l;function cz(t,e,n){if(!uz(n))return!1;var r=typeof e;return(r=="number"?lz(n)&&az(e,n.length):r=="string"&&e in n)?oz(n[e],t):!1}var fz=cz,dz=Zv,dx=1/0,hz=17976931348623157e292;function pz(t){if(!t)return t===0?t:0;if(t=dz(t),t===dx||t===-dx){var e=t<0?-1:1;return e*hz}return t===t?t:0}var gz=pz,mz=nz,yz=fz,em=gz;function vz(t){return function(e,n,r){return r&&typeof r!="number"&&yz(e,n,r)&&(n=r=void 0),e=em(e),n===void 0?(n=e,e=0):n=em(n),r=r===void 0?e{g.drawImage(b,0,0,f,f)}).finally(()=>{this.inFlight--,this.inFlight===0&&this.onSettled()})}else a<1&&(r.globalAlpha=a),r.drawImage(h,0,0,f,f,i,s,o,o),a<1&&(r.globalAlpha=1)}}function CE(t){if(t.length===0)return;let e;for(const n of t)e=Math.min(e??n.y,n.y)}function $p(t,e,n,r,i,s,o,l,a){l=l??e;let u=e,c=t;const f=r-s;let d=!1;for(;ul&&a(u,c,h,!1,o&&c===r-1)===!0){d=!0;break}u+=h,c++}if(!d){u=n;for(let h=0;h!h.sticky))==null?void 0:d.sourceIndex)??0;if(a>f){const h=Math.max(l,f);let p=e,g=r;for(let b=s.sourceIndex-1;b>=h;b--)p-=o[b].width,g+=o[b].width;for(let b=s.sourceIndex+1;b<=a;b++)g+=o[b].width;c={x:p,y:n,width:g,height:i}}if(f>l){const h=Math.min(a,f-1);let p=e,g=r;for(let b=s.sourceIndex-1;b>=l;b--)p-=o[b].width,g+=o[b].width;for(let b=s.sourceIndex+1;b<=h;b++)g+=o[b].width;u={x:p,y:n,width:g,height:i}}return[u,c]}function Tz(t,e,n,r){if(r==="any")return AE(t,{x:e,y:n,width:1,height:1});if(r==="vertical"&&(e=t.x),r==="horizontal"&&(n=t.y),lE([e,n],t))return;const i=e-t.x,s=t.x+t.width-e,o=n-t.y+1,l=t.y+t.height-n,a=Math.min(r==="vertical"?Number.MAX_SAFE_INTEGER:i,r==="vertical"?Number.MAX_SAFE_INTEGER:s,r==="horizontal"?Number.MAX_SAFE_INTEGER:o,r==="horizontal"?Number.MAX_SAFE_INTEGER:l);return a===l?{x:t.x,y:t.y+t.height,width:t.width,height:n-t.y-t.height+1}:a===o?{x:t.x,y:n,width:t.width,height:t.y-n}:a===s?{x:t.x+t.width,y:t.y,width:e-t.x-t.width+1,height:t.height}:{x:e,y:t.y,width:t.x-e,height:t.height}}function Dh(t,e,n,r,i,s,o,l){return t<=i+o&&i<=t+n&&e<=s+l&&s<=e+r}function Fp(t,e,n){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height}function AE(t,e){const n=Math.min(t.x,e.x),r=Math.min(t.y,e.y),i=Math.max(t.x+t.width,e.x+e.width)-n,s=Math.max(t.y+t.height,e.y+e.height)-r;return{x:n,y:r,width:i,height:s}}function Ez(t,e){return t.x<=e.x&&t.y<=e.y&&t.x+t.width>=e.x+e.width&&t.y+t.height>=e.y+e.height}function Az(t,e,n,r){if(t.x>e||t.y>n||t.x<0&&t.y<0&&t.x+t.width>e&&t.y+t.height>n)return;if(t.x>=0&&t.y>=0&&t.x+t.width<=e&&t.y+t.height<=n)return t;const i=-4,s=-4,o=e+4,l=n+4,a=i-t.x,u=t.x+t.width-o,c=s-t.y,f=t.y+t.height-l,d=a>0?t.x+Math.floor(a/r)*r:t.x,h=u>0?t.x+t.width-Math.floor(u/r)*r:t.x+t.width,p=c>0?t.y+Math.floor(c/r)*r:t.y,g=f>0?t.y+t.height-Math.floor(f/r)*r:t.y+t.height;return{x:d,y:p,width:h-d,height:g-p}}function Mz(t,e,n,r,i){const[s,o,l,a]=e,[u,c,f,d]=i,{x:h,y:p,width:g,height:b}=t,m=[];if(g<=0||b<=0)return m;const v=h+g,w=p+b,k=hl,T=p+b>a,A=h>=s&&hs&&v<=l||hl,R=p>=o&&po&&w<=a||pa;if(A&&R){const _=Math.max(h,s),O=Math.max(p,o),D=Math.min(v,l),N=Math.min(w,a);m.push({rect:{x:_,y:O,width:D-_,height:N-O},clip:{x:u,y:c,width:f-u+1,height:d-c+1}})}if(k&&x){const _=h,O=p,D=Math.min(v,s),N=Math.min(w,o);m.push({rect:{x:_,y:O,width:D-_,height:N-O},clip:{x:0,y:0,width:u+1,height:c+1}})}if(x&&A){const _=Math.max(h,s),O=p,D=Math.min(v,l),N=Math.min(w,o);m.push({rect:{x:_,y:O,width:D-_,height:N-O},clip:{x:u,y:0,width:f-u+1,height:c+1}})}if(x&&C){const _=Math.max(h,l),O=p,D=v,N=Math.min(w,o);m.push({rect:{x:_,y:O,width:D-_,height:N-O},clip:{x:f,y:0,width:n-f+1,height:c+1}})}if(k&&R){const _=h,O=Math.max(p,o),D=Math.min(v,s),N=Math.min(w,a);m.push({rect:{x:_,y:O,width:D-_,height:N-O},clip:{x:0,y:c,width:u+1,height:d-c+1}})}if(C&&R){const _=Math.max(h,l),O=Math.max(p,o),D=v,N=Math.min(w,a);m.push({rect:{x:_,y:O,width:D-_,height:N-O},clip:{x:f,y:c,width:n-f+1,height:d-c+1}})}if(k&&T){const _=h,O=Math.max(p,a),D=Math.min(v,s),N=w;m.push({rect:{x:_,y:O,width:D-_,height:N-O},clip:{x:0,y:d,width:u+1,height:r-d+1}})}if(T&&A){const _=Math.max(h,s),O=Math.max(p,a),D=Math.min(v,l),N=w;m.push({rect:{x:_,y:O,width:D-_,height:N-O},clip:{x:u,y:d,width:f-u+1,height:r-d+1}})}if(C&&T){const _=Math.max(h,l),O=Math.max(p,a),D=v,N=w;m.push({rect:{x:_,y:O,width:D-_,height:N-O},clip:{x:f,y:d,width:n-f+1,height:r-d+1}})}return m}const Rz={kind:Ee.Loading,allowOverlay:!1};function hx(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,g,b,m,v,w,k,x,C,T,A,R,P,_,O,D,N,ne,ie,V,j){let G=(w==null?void 0:w.size)??Number.MAX_SAFE_INTEGER;const M=performance.now();let I=D.baseFontFull;t.font=I;const $={ctx:t},B=[0,0],Y=b>0?Bl(a,b,u):0;let W,de;const le=CE(v);return Xo(e,l,s,o,i,(ge,$e,ke,ye,lt)=>{const Fe=Math.max(0,ye-$e),He=$e+Fe,be=i+1,Rt=ge.width-Fe,me=r-i-1;if(v.length>0){let We=!1;for(let it=0;it{t.save(),t.beginPath(),t.rect(He,be,Rt,me),t.clip()},Pe=k.columns.hasIndex(ge.sourceIndex),Xe=f(ge.group??"").overrideTheme,rt=ge.themeOverride===void 0&&Xe===void 0?D:Lo(D,Xe,ge.themeOverride),_e=rt.baseFontFull;_e!==I&&(I=_e,t.font=_e),Se();let yt;return $p(lt,ke,r,a,u,b,m,le,(We,it,pe,at,dt)=>{var ln,kn,Jn;if(it<0||(B[0]=ge.sourceIndex,B[1]=it,w!==void 0&&!w.has(B)))return;if(v.length>0){let gt=!1;for(let Bt=0;Btvt.span!==void 0&>>=vt.span[0]&><=vt.span[1]);jn&&!p&&g?zt=0:jn&&g&&(zt=Math.max(zt,1)),Ln&&zt++,jn||(Ge&&zt++,Pe&&!dt&&zt++);const Br=vt.kind===Ee.Protected?Ht.bgCellMedium:Ht.bgCell;let $t;if((at||Br!==D.bgCell)&&($t=Jr(Br,$t)),zt>0||on){on&&($t=Jr(Ht.bgHeader,$t));for(let gt=0;gtj&&!Zt){const gt=Ht.baseFontFull;gt!==I&&(t.font=gt,I=gt),yt=ME(t,vt,ge.sourceIndex,it,ft,Wt,Be,We,ht,pe,zt>0,Ht,$t??Ht.bgCell,T,A,(qt==null?void 0:qt.hoverAmount)??0,P,O,M,_,yt,N,ne,ie,V)}return et&&t.restore(),vt.style==="faded"&&(t.globalAlpha=1),G--,Gt&&(t.restore(),(Jn=yt==null?void 0:yt.deprep)==null||Jn.call(yt,$),yt=void 0,Se(),I=_e,t.font=_e),G<=0}),t.restore(),G<=0}),W}const Lu=[0,0],$u={x:0,y:0,width:0,height:0},tm=[void 0,()=>{}];let V0=!1;function Oz(){V0=!0}function ME(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,g,b,m,v,w,k,x,C,T,A){var ne,ie;let R,P;b!==void 0&&b[0][0]===n&&b[0][1]===r&&(R=b[1][0],P=b[1][1]);let _;Lu[0]=n,Lu[1]=r,$u.x=o,$u.y=l,$u.width=a,$u.height=u,tm[0]=C.getValue(Lu),tm[1]=V=>C.setValue(Lu,V),V0=!1;const O={ctx:t,theme:f,col:n,row:r,cell:e,rect:$u,highlighted:c,cellFillColor:d,hoverAmount:g,frameTime:v,hoverX:R,drawState:tm,hoverY:P,imageLoader:h,spriteManager:p,hyperWrapping:m,overrideCursor:R!==void 0?A:void 0,requestAnimationFrame:Oz},D=O4(O,e.lastUpdated,v,k,i,s),N=T(e);if(N!==void 0){(k==null?void 0:k.renderer)!==N&&((ne=k==null?void 0:k.deprep)==null||ne.call(k,O),k=void 0);const V=(ie=N.drawPrep)==null?void 0:ie.call(N,O,k);w!==void 0&&!wa(O.cell)?w(O,()=>N.draw(O,e)):N.draw(O,e),_=V===void 0?void 0:{deprep:V==null?void 0:V.deprep,fillStyle:V==null?void 0:V.fillStyle,font:V==null?void 0:V.font,renderer:N}}return(D||V0)&&(x==null||x(Lu)),_}function uw(t,e,n,r,i,s,o,l,a=-20,u=-20,c=32,f="center",d="square"){const h=Math.floor(i+o/2),p=d==="circle"?1e4:e.roundingRadius??4;let g=JT(c,o,e.cellVerticalPadding),b=g/2;const m=YT(f,r,s,e.cellHorizontalPadding,g),v=qT(m,h,g),w=QT(r+a,i+u,v);switch(n){case!0:{t.beginPath(),Cs(t,m-g/2,h-g/2,g,g,p),d==="circle"&&(b*=.8,g*=.8),t.fillStyle=l?e.accentColor:e.textMedium,t.fill(),t.beginPath(),t.moveTo(m-b+g/4.23,h-b+g/1.97),t.lineTo(m-b+g/2.42,h-b+g/1.44),t.lineTo(m-b+g/1.29,h-b+g/3.25),t.strokeStyle=e.bgCell,t.lineJoin="round",t.lineCap="round",t.lineWidth=1.9,t.stroke();break}case Ah:case!1:{t.beginPath(),Cs(t,m-g/2+.5,h-g/2+.5,g-1,g-1,p),t.lineWidth=1,t.strokeStyle=w?e.textDark:e.textMedium,t.stroke();break}case qv:{t.beginPath(),Cs(t,m-g/2,h-g/2,g,g,p),t.fillStyle=w?e.textMedium:e.textLight,t.fill(),d==="circle"&&(b*=.8,g*=.8),t.beginPath(),t.moveTo(m-g/3,h),t.lineTo(m+g/3,h),t.strokeStyle=e.bgCell,t.lineCap="round",t.lineWidth=1.9,t.stroke();break}default:Hc()}}function Pz(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,g,b,m,v){const w=o+l;if(w<=0)return;t.fillStyle=f.bgHeader,t.fillRect(0,0,i,w);const[k,x]=(r==null?void 0:r[0])??[],C=f.headerFontFull;t.font=C,Xo(e,0,s,0,w,(T,A,R,P)=>{var $;if(b!==void 0&&!b.has([T.sourceIndex,-1]))return;const _=Math.max(0,P-A);t.save(),t.beginPath(),t.rect(A+_,l,T.width-_,o),t.clip();const O=g(T.group??"").overrideTheme,D=T.themeOverride===void 0&&O===void 0?f:Lo(f,O,T.themeOverride);D.bgHeader!==f.bgHeader&&(t.fillStyle=D.bgHeader,t.fill()),D!==f&&(t.font=D.baseFontFull);const N=c.columns.hasIndex(T.sourceIndex),ne=a!==void 0||u,ie=!ne&&x===-1&&k===T.sourceIndex,V=ne?0:(($=h.find(B=>B.item[0]===T.sourceIndex&&B.item[1]===-1))==null?void 0:$.hoverAmount)??0,j=(c==null?void 0:c.current)!==void 0&&c.current.cell[0]===T.sourceIndex,G=N?D.accentColor:j?D.bgHeaderHasFocus:D.bgHeader,M=n?l:0,I=T.sourceIndex===0?0:1;N?(t.fillStyle=G,t.fillRect(A+I,M,T.width-I,o)):(j||V>0)&&(t.beginPath(),t.rect(A+I,M,T.width-I,o),j&&(t.fillStyle=D.bgHeaderHasFocus,t.fill()),V>0&&(t.globalAlpha=V,t.fillStyle=D.bgHeaderHovered,t.fill(),t.globalAlpha=1)),PE(t,A,M,T.width,o,T,N,D,ie,j,V,d,m,v),t.restore()}),n&&Iz(t,e,i,s,l,r,f,d,h,p,g,b)}function Iz(t,e,n,r,i,s,o,l,a,u,c,f){const[h,p]=(s==null?void 0:s[0])??[];let g=0;TE(e,n,r,i,(b,m,v,w,k,x)=>{if(f!==void 0&&!f.hasItemInRectangle({x:b[0],y:-2,width:b[1]-b[0]+1,height:1}))return;t.save(),t.beginPath(),t.rect(v,w,k,x),t.clip();const C=c(m),T=(C==null?void 0:C.overrideTheme)===void 0?o:Lo(o,C.overrideTheme),A=p===-2&&h!==void 0&&h>=b[0]&&h<=b[1],R=A?T.bgHeaderHovered:T.bgHeader;if(R!==o.bgHeader&&(t.fillStyle=R,t.fill()),t.fillStyle=T.textGroupHeader??T.textHeader,C!==void 0){let P=v;if(C.icon!==void 0&&(l.drawSprite(C.icon,"normal",t,P+8,(i-20)/2,20,T),P+=26),t.fillText(C.name,P+8,i/2+Ys(t,o.headerFontFull)),C.actions!==void 0&&A){const _=OE({x:v,y:w,width:k,height:x},C.actions);t.beginPath();const O=_[0].x-10,D=v+k-O;t.rect(O,0,D,i);const N=t.createLinearGradient(O,0,O+D,0),ne=Ol(R,0);N.addColorStop(0,ne),N.addColorStop(10/D,R),N.addColorStop(1,R),t.fillStyle=N,t.fill(),t.globalAlpha=.6;const[ie,V]=(s==null?void 0:s[1])??[-1,-1];for(let j=0;j35){const k=d?35:r-35,x=d?35*.7:r-35*.7,C=k/r,T=x/r,A=t.createLinearGradient(e,0,e+r,0),R=Ol(g,0);A.addColorStop(d?1:0,g),A.addColorStop(C,g),A.addColorStop(T,R),A.addColorStop(d?0:1,R),t.fillStyle=A}else t.fillStyle=g;if(d&&(t.textAlign="right"),t.fillText(s.title,v,n+i/2+Ys(t,l.headerFontFull)),d&&(t.textAlign="left"),b&&s.hasMenu===!0)if(s.menuIcon===void 0||s.menuIcon===Mh.Triangle){t.beginPath();const w=h.x+h.width/2-5.5,k=h.y+h.height/2-3;_4(t,[{x:w,y:k},{x:w+11,y:k},{x:w+5.5,y:k+6}],1),t.fillStyle=g,t.fill()}else if(s.menuIcon===Mh.Dots){t.beginPath();const w=h.x+h.width/2,k=h.y+h.height/2;N4(t,w,k),t.fillStyle=g,t.fill()}else{const w=h.x+(h.width-l.headerIconSize)/2,k=h.y+(h.height-l.headerIconSize)/2;c.drawSprite(s.menuIcon,"normal",t,w,k,l.headerIconSize,l)}}function PE(t,e,n,r,i,s,o,l,a,u,c,f,d,h){const p=tw(s.title)==="rtl",g=RE(e,n,r,i,p);d!==void 0?d({ctx:t,theme:l,rect:{x:e,y:n,width:r,height:i},column:s,columnIndex:s.sourceIndex,isSelected:o,hoverAmount:c,isHovered:a,hasSelectedCell:u,spriteManager:f,menuBounds:g},()=>px(t,e,n,r,i,s,o,l,a,c,f,h,p,g)):px(t,e,n,r,i,s,o,l,a,c,f,h,p,g)}var Nz=Fl,_z=function(){try{var t=Nz(Object,"defineProperty");return t({},"",{}),t}catch{}}(),Dz=_z,gx=Dz;function Lz(t,e,n){e=="__proto__"&&gx?gx(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var $z=Lz;function Fz(t,e,n,r){for(var i=-1,s=t==null?0:t.length;++il))return!1;var u=s.get(t),c=s.get(e);if(u&&c)return u==e&&c==t;var f=-1,d=!0,h=n&Uj?new jj:void 0;for(s.set(t,e),s.set(e,t);++f{if(k!==e[e.length-1])return;x+=k.width;const R=Math.max(x,T);R>r||(t.save(),t.beginPath(),t.rect(R,s+1,1e4,i-s-1),t.clip(),$p(A,C,i,u,c,p,g,w,(P,_,O,D)=>{if(!D&&b.length>0&&!b.some(j=>Dh(x,P,1e4,O,j.x,j.y,j.width,j.height)))return;const N=d.hasIndex(_),ne=h.hasIndex(_);t.beginPath();const ie=f==null?void 0:f(_),V=ie===void 0?v:Lo(v,ie);V.bgCell!==v.bgCell&&(t.fillStyle=V.bgCell,t.fillRect(x,P,1e4,O)),ne&&(t.fillStyle=V.bgHeader,t.fillRect(x,P,1e4,O)),N&&(t.fillStyle=V.accentLight,t.fillRect(x,P,1e4,O))}),t.restore())})}function LW(t,e,n,r,i,s,o,l,a){let u=!1;for(const p of e)if(!p.sticky){u=o(p.sourceIndex);break}const c=a.horizontalBorderColor??a.borderColor,f=a.borderColor,d=u?Ua(e):0;let h;if(d!==0&&(h=ix(f,a.bgCell),t.beginPath(),t.moveTo(d+.5,0),t.lineTo(d+.5,r),t.strokeStyle=h,t.stroke()),i>0){const p=f===c&&h!==void 0?h:ix(c,a.bgCell),g=Bl(s,i,l);t.beginPath(),t.moveTo(0,r-g+.5),t.lineTo(n,r-g+.5),t.strokeStyle=p,t.stroke()}}const HE=(t,e,n)=>{let r=0,i=e,s=0,o=n;if(t!==void 0&&t.length>0){r=Number.MAX_SAFE_INTEGER,s=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER,o=Number.MIN_SAFE_INTEGER;for(const l of t)r=Math.min(r,l.x-1),i=Math.max(i,l.x+l.width+1),s=Math.min(s,l.y-1),o=Math.max(o,l.y+l.height+1)}return{minX:r,maxX:i,minY:s,maxY:o}};function $W(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p){var O;const g=p.bgCell,{minX:b,maxX:m,minY:v,maxY:w}=HE(l,s,o),k=[],x=o-Bl(h,d,u);let C=a,T=n,A=0;for(;C+i=v&&D<=w-1){const ne=c==null?void 0:c(T),ie=ne==null?void 0:ne.bgCell;ie!==void 0&&ie!==g&&T>=h-d&&k.push({x:b,y:D,w:m-b,h:N,color:ie})}C+=N,T0)for(let D=0;D=b&&ne<=m&&f(D+1)&&k.push({x:ne,y:A,w:N.width,h:P,color:ie}),R+=N.width}if(k.length===0)return;let _;t.beginPath();for(let D=k.length-1;D>=0;D--){const N=k[D];_===void 0?_=N.color:N.color!==_&&(t.fillStyle=_,t.fill(),t.beginPath(),_=N.color),t.rect(N.x,N.y,N.w,N.h)}_!==void 0&&(t.fillStyle=_,t.fill()),t.beginPath()}function Dx(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,g,b,m=!1){if(a!==void 0){t.beginPath(),t.save(),t.rect(0,0,s,o);for(const O of a)t.rect(O.x+1,O.y+1,O.width-1,O.height-1);t.clip("evenodd")}const v=b.horizontalBorderColor??b.borderColor,w=b.borderColor,{minX:k,maxX:x,minY:C,maxY:T}=HE(l,s,o),A=[];t.beginPath();let R=.5;for(let O=0;O=k&&N<=x&&h(O+1)&&A.push({x1:N,y1:Math.max(u,C),x2:N,y2:Math.min(o,T),color:w})}let P=o+.5;for(let O=g-p;O=C&&ne<=T-1){const ie=d==null?void 0:d(D);A.push({x1:k,y1:ne,x2:x,y2:ne,color:(ie==null?void 0:ie.horizontalBorderColor)??(ie==null?void 0:ie.borderColor)??v})}O+=f(D),D++}}const _=_W(A,O=>O.color);for(const O of Object.keys(_)){t.strokeStyle=O;for(const D of _[O])t.moveTo(D.x1,D.y1),t.lineTo(D.x2,D.y2);t.stroke(),t.beginPath()}a!==void 0&&t.restore()}function FW(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,g,b,m,v){const w=[];t.imageSmoothingEnabled=!1;const k=Math.min(i.cellYOffset,o),x=Math.max(i.cellYOffset,o);let C=0;if(typeof m=="number")C+=(x-k)*m;else for(let N=k;Ni.cellYOffset&&(C=-C),C+=a-i.translateY;const T=Math.min(i.cellXOffset,s),A=Math.max(i.cellXOffset,s);let R=0;for(let N=T;Ni.cellXOffset&&(R=-R),R+=l-i.translateX;const P=Ua(b);if(R!==0&&C!==0)return{regions:[]};const _=u>0?Bl(d,u,m):0,O=c-P-Math.abs(R),D=f-h-_-Math.abs(C)-1;if(O>150&&D>150){const N={sx:0,sy:0,sw:c*p,sh:f*p,dx:0,dy:0,dw:c*p,dh:f*p};if(C>0?(N.sy=(h+1)*p,N.sh=D*p,N.dy=(C+h+1)*p,N.dh=D*p,w.push({x:0,y:h,width:c,height:C+1})):C<0&&(N.sy=(-C+h+1)*p,N.sh=D*p,N.dy=(h+1)*p,N.dh=D*p,w.push({x:0,y:f+C-_,width:c,height:-C+_})),R>0?(N.sx=P*p,N.sw=O*p,N.dx=(R+P)*p,N.dw=O*p,w.push({x:P-1,y:0,width:R+2,height:f})):R<0&&(N.sx=(P-R)*p,N.sw=O*p,N.dx=P*p,N.dw=O*p,w.push({x:c+R,y:0,width:-R,height:f})),t.setTransform(1,0,0,1,0,0),v){if(P>0&&R!==0&&C===0&&(r===void 0||(n==null?void 0:n[1])!==!1)){const ne=P*p,ie=f*p;t.drawImage(e,0,0,ne,ie,0,0,ne,ie)}if(_>0&&R===0&&C!==0&&(r===void 0||(n==null?void 0:n[0])!==!1)){const ne=(f-_)*p,ie=c*p,V=_*p;t.drawImage(e,0,ne,ie,V,0,ne,ie,V)}}t.drawImage(e,N.sx,N.sy,N.sw,N.sh,N.dx,N.dy,N.dw,N.dh),t.scale(p,p)}return t.imageSmoothingEnabled=!0,{regions:w}}function zW(t,e,n,r,i,s,o,l,a,u){const c=[];return e!==t.cellXOffset||n!==t.cellYOffset||r!==t.translateX||i!==t.translateY||Xo(a,n,r,i,l,(f,d,h,p)=>{if(f.sourceIndex===u){const g=Math.max(d,p)+1;return c.push({x:g,y:0,width:s-g,height:o}),!0}}),c}function BW(t,e){if(e===void 0||t.width!==e.width||t.height!==e.height||t.theme!==e.theme||t.headerHeight!==e.headerHeight||t.rowHeight!==e.rowHeight||t.rows!==e.rows||t.freezeColumns!==e.freezeColumns||t.getRowThemeOverride!==e.getRowThemeOverride||t.isFocused!==e.isFocused||t.isResizing!==e.isResizing||t.verticalBorder!==e.verticalBorder||t.getCellContent!==e.getCellContent||t.highlightRegions!==e.highlightRegions||t.selection!==e.selection||t.dragAndDropState!==e.dragAndDropState||t.prelightCells!==e.prelightCells||t.touchMode!==e.touchMode||t.maxScaleFactor!==e.maxScaleFactor)return!1;if(t.mappedColumns!==e.mappedColumns){if(t.mappedColumns.length>100||t.mappedColumns.length!==e.mappedColumns.length)return!1;let n;for(let r=0;rT.style!=="no-outline");if(b===void 0||b.length===0)return;const m=Ua(l),v=Bl(h,d,f),w=[a,0,l.length,h-d],k=[m,0,e,n-v],x=b.map(T=>{const A=T.range,R=T.style??"dashed";return Mz(A,w,e,n,k).map(P=>{const _=P.rect,O=H0(_.x,_.y,e,n,c,u+c,r,i,s,o,h,a,d,l,f),D=_.width===1&&_.height===1?O:H0(_.x+_.width-1,_.y+_.height-1,e,n,c,u+c,r,i,s,o,h,a,d,l,f);return _.x+_.width>=l.length&&(D.width-=1),_.y+_.height>=h&&(D.height-=1),{color:T.color,style:R,clip:P.clip,rect:Az({x:O.x,y:O.y,width:D.x+D.width-O.x,height:D.y+D.height-O.y},e,n,8)}})}),C=()=>{t.lineWidth=1;let T=!1;for(const A of x)for(const R of A)if((R==null?void 0:R.rect)!==void 0&&Dh(0,0,e,n,R.rect.x,R.rect.y,R.rect.width,R.rect.height)){const P=T,_=!Ez(R.clip,R.rect);_&&(t.save(),t.rect(R.clip.x,R.clip.y,R.clip.width,R.clip.height),t.clip()),R.style==="dashed"&&!T?(t.setLineDash([5,3]),T=!0):(R.style==="solid"||R.style==="solid-outline")&&T&&(t.setLineDash([]),T=!1),t.strokeStyle=R.style==="solid-outline"?Jr(Jr(R.color,g.borderColor),g.bgCell):Ol(R.color,1),t.strokeRect(R.rect.x+.5,R.rect.y+.5,R.rect.width-1,R.rect.height-1),_&&(t.restore(),T=P)}T&&t.setLineDash([])};return C(),C}function $x(t,e,n,r,i){t.beginPath(),t.moveTo(e,n),t.lineTo(e,r),t.lineWidth=2,t.strokeStyle=i,t.stroke(),t.globalAlpha=1}function im(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,g,b){if(c.current===void 0)return;const m=c.current.range,v=c.current.cell,w=[m.x+m.width-1,m.y+m.height-1];if(v[1]>=b&&w[1]>=b||!o.some(N=>N.sourceIndex===v[0]||N.sourceIndex===w[0]))return;const[x,C]=c.current.cell,T=d(c.current.cell),A=T.span??[x,x],R=C>=b-h,P=h>0&&!R?Bl(b,h,f)-1:0,_=w[1];let O;if(Xo(o,r,i,s,u,(N,ne,ie,V,j)=>{if(N.sticky&&x>N.sourceIndex)return;const G=N.sourceIndexA[1],I=N.sourceIndex===w[0];if(!(!I&&(G||M)))return $p(j,ie,n,b,f,h,p,void 0,($,B,Y)=>{if(B!==C&&B!==_)return;let W=ne,de=N.width;if(T.span!==void 0){const ge=EE(T.span,ne,$,N.width,Y,N,l),$e=N.sticky?ge[0]:ge[1];$e!==void 0&&(W=$e.x,de=$e.width)}return B===_&&I&&g&&(O=()=>{var ge;V>W&&!N.sticky&&(t.beginPath(),t.rect(V,0,e-V,n),t.clip()),t.beginPath(),t.rect(W+de-4,$+Y-4,4,4),t.fillStyle=((ge=N.themeOverride)==null?void 0:ge.accentColor)??a.accentColor,t.fill()}),O!==void 0}),O!==void 0}),O===void 0)return;const D=()=>{t.save(),t.beginPath(),t.rect(0,u,e,n-u-P),t.clip(),O==null||O(),t.restore()};return D(),D}function jW(t,e,n,r,i,s,o,l,a){a===void 0||a.size===0||(t.beginPath(),TE(e,n,s,r,(u,c,f,d,h,p)=>{a.hasItemInRectangle({x:u[0],y:-2,width:u[1]-u[0]+1,height:1})&&t.rect(f,d,h,p)}),Xo(e,l,s,o,i,(u,c,f,d)=>{const h=Math.max(0,d-c),p=c+h+1,g=u.width-h-1;a.has([u.sourceIndex,-1])&&t.rect(p,r,g,i-r)}),t.clip())}function HW(t,e,n,r,i,s,o,l,a,u){let c=0;return Xo(t,s,r,i,n,(f,d,h,p,g)=>($p(g,h,e,o,l,a,u,void 0,(b,m,v,w)=>{w||(c=Math.max(m,c))}),!0)),c}function Fx(t,e){var et;const{canvasCtx:n,headerCanvasCtx:r,width:i,height:s,cellXOffset:o,cellYOffset:l,translateX:a,translateY:u,mappedColumns:c,enableGroups:f,freezeColumns:d,dragAndDropState:h,theme:p,drawFocus:g,headerHeight:b,groupHeaderHeight:m,disabledRows:v,rowHeight:w,verticalBorder:k,overrideCursor:x,isResizing:C,selection:T,fillHandle:A,freezeTrailingRows:R,rows:P,getCellContent:_,getGroupDetails:O,getRowThemeOverride:D,isFocused:N,drawHeaderCallback:ne,prelightCells:ie,drawCellCallback:V,highlightRegions:j,resizeCol:G,imageLoader:M,lastBlitData:I,hoverValues:$,hyperWrapping:B,hoverInfo:Y,spriteManager:W,maxScaleFactor:de,hasAppendRow:le,touchMode:ge,enqueue:$e,renderStateProvider:ke,getCellRenderer:ye,renderStrategy:lt,bufferACtx:Fe,bufferBCtx:He,damage:be,minimumCellWidth:Rt}=t;if(i===0||s===0)return;const me=lt==="double-buffer",Se=Math.min(de,Math.ceil(window.devicePixelRatio??1)),Pe=lt!=="direct"&&BW(t,e),Xe=n.canvas;(Xe.width!==i*Se||Xe.height!==s*Se)&&(Xe.width=i*Se,Xe.height=s*Se,Xe.style.width=i+"px",Xe.style.height=s+"px");const rt=r.canvas,_e=f?m+b:b,yt=_e+1;(rt.width!==i*Se||rt.height!==yt*Se)&&(rt.width=i*Se,rt.height=yt*Se,rt.style.width=i+"px",rt.style.height=yt+"px");const We=Fe.canvas,it=He.canvas;me&&(We.width!==i*Se||We.height!==s*Se)&&(We.width=i*Se,We.height=s*Se,I.current!==void 0&&(I.current.aBufferScroll=void 0)),me&&(it.width!==i*Se||it.height!==s*Se)&&(it.width=i*Se,it.height=s*Se,I.current!==void 0&&(I.current.bBufferScroll=void 0));const pe=I.current;if(Pe===!0&&o===(pe==null?void 0:pe.cellXOffset)&&l===(pe==null?void 0:pe.cellYOffset)&&a===(pe==null?void 0:pe.translateX)&&u===(pe==null?void 0:pe.translateY))return;let at=null;me&&(at=n);const dt=r;let Ge;me?be!==void 0?Ge=(pe==null?void 0:pe.lastBuffer)==="b"?He:Fe:Ge=(pe==null?void 0:pe.lastBuffer)==="b"?Fe:He:Ge=n;const on=Ge.canvas,vt=me?on===We?it:We:Xe,Be=typeof w=="number"?()=>w:w;dt.save(),Ge.save(),dt.beginPath(),Ge.beginPath(),dt.textBaseline="middle",Ge.textBaseline="middle",Se!==1&&(dt.scale(Se,Se),Ge.scale(Se,Se));const ht=j0(c,o,i,h,a);let Gt=[];const Zt=g&&((et=T.current)==null?void 0:et.cell[1])===l&&u===0;let Bn=!1;if(j!==void 0){for(const ft of j)if(ft.style!=="no-outline"&&ft.range.y===l&&u===0){Bn=!0;break}}const Yn=()=>{Pz(dt,ht,f,Y,i,a,b,m,h,C,T,p,W,$,k,O,be,ne,ge),Dx(dt,ht,l,a,u,i,s,void 0,void 0,m,_e,Be,D,k,R,P,p,!0),dt.beginPath(),dt.moveTo(0,yt-.5),dt.lineTo(i,yt-.5),dt.strokeStyle=Jr(p.headerBottomBorderColor??p.horizontalBorderColor??p.borderColor,p.bgHeader),dt.stroke(),Bn&&Lx(dt,i,s,o,l,a,u,c,d,b,m,w,R,P,j,p),Zt&&im(dt,i,s,l,a,u,ht,c,p,_e,T,Be,_,R,le,A,P)};if(be!==void 0){const ft=ht[ht.length-1].sourceIndex+1,Wt=be.hasItemInRegion([{x:o,y:-2,width:ft,height:2},{x:o,y:l,width:ft,height:300},{x:0,y:l,width:d,height:300},{x:0,y:-2,width:d,height:2},{x:o,y:P-R,width:ft,height:R,when:R>0}]),qt=ln=>{hx(ln,ht,c,s,_e,a,u,l,P,Be,_,O,D,v,N,g,R,le,Gt,be,T,ie,j,M,W,$,Y,V,B,p,$e,ke,ye,x,Rt);const kn=T.current;A&&g&&kn!==void 0&&be.has(aE(kn.range))&&im(ln,i,s,l,a,u,ht,c,p,_e,T,Be,_,R,le,A,P)};Wt&&(qt(Ge),at!==null&&(at.save(),at.scale(Se,Se),at.textBaseline="middle",qt(at),at.restore()),be.hasHeader()&&(jW(dt,ht,i,m,_e,a,u,l,be),Yn())),Ge.restore(),dt.restore();return}if((Pe!==!0||o!==(pe==null?void 0:pe.cellXOffset)||a!==(pe==null?void 0:pe.translateX)||Zt!==(pe==null?void 0:pe.mustDrawFocusOnHeader)||Bn!==(pe==null?void 0:pe.mustDrawHighlightRingsOnHeader))&&Yn(),Pe===!0){Yr(vt!==void 0&&pe!==void 0);const{regions:ft}=FW(Ge,vt,vt===We?pe.aBufferScroll:pe.bBufferScroll,vt===We?pe.bBufferScroll:pe.aBufferScroll,pe,o,l,a,u,R,i,s,P,_e,Se,c,ht,w,me);Gt=ft}else Pe!==!1&&(Yr(pe!==void 0),Gt=zW(pe,o,l,a,u,i,s,_e,ht,Pe));LW(Ge,ht,i,s,R,P,k,Be,p);const Ht=Lx(Ge,i,s,o,l,a,u,c,d,b,m,w,R,P,j,p),jn=g?im(Ge,i,s,l,a,u,ht,c,p,_e,T,Be,_,R,le,A,P):void 0;if(Ge.fillStyle=p.bgCell,Gt.length>0){Ge.beginPath();for(const ft of Gt)Ge.rect(ft.x,ft.y,ft.width,ft.height);Ge.clip(),Ge.fill(),Ge.beginPath()}else Ge.fillRect(0,0,i,s);const zt=hx(Ge,ht,c,s,_e,a,u,l,P,Be,_,O,D,v,N,g,R,le,Gt,be,T,ie,j,M,W,$,Y,V,B,p,$e,ke,ye,x,Rt);DW(Ge,ht,c,i,s,_e,a,u,l,P,Be,D,T.rows,v,R,le,Gt,be,p),$W(Ge,ht,l,a,u,i,s,Gt,_e,Be,D,k,R,P,p),Dx(Ge,ht,l,a,u,i,s,Gt,zt,m,_e,Be,D,k,R,P,p),Ht==null||Ht(),jn==null||jn(),C&&Xo(ht,0,a,0,_e,(ft,Wt)=>ft.sourceIndex===G?($x(dt,Wt+ft.width,0,_e+1,Jr(p.resizeIndicatorColor??p.accentLight,p.bgHeader)),$x(Ge,Wt+ft.width,_e,s,Jr(p.resizeIndicatorColor??p.accentLight,p.bgCell)),!0):!1),at!==null&&(at.fillStyle=p.bgCell,at.fillRect(0,0,i,s),at.drawImage(Ge.canvas,0,0));const Ln=HW(ht,s,_e,a,u,l,P,Be,R,le);M==null||M.setWindow({x:o,y:l,width:ht.length,height:Ln-l},d,Array.from({length:R},(ft,Wt)=>P-1-Wt));const Br=pe!==void 0&&(o!==pe.cellXOffset||a!==pe.translateX),$t=pe!==void 0&&(l!==pe.cellYOffset||u!==pe.translateY);I.current={cellXOffset:o,cellYOffset:l,translateX:a,translateY:u,mustDrawFocusOnHeader:Zt,mustDrawHighlightRingsOnHeader:Bn,lastBuffer:me?on===We?"a":"b":void 0,aBufferScroll:on===We?[Br,$t]:pe==null?void 0:pe.aBufferScroll,bBufferScroll:on===it?[Br,$t]:pe==null?void 0:pe.bBufferScroll},Ge.restore(),dt.restore()}const WW=80;function VW(t){const e=t-1;return e*e*e+1}class UW{constructor(e){St(this,"callback");St(this,"currentHoveredItem");St(this,"leavingItems",[]);St(this,"lastAnimationTime");St(this,"addToLeavingItems",e=>{this.leavingItems.some(r=>hc(r.item,e.item))||this.leavingItems.push(e)});St(this,"removeFromLeavingItems",e=>{const n=this.leavingItems.find(r=>hc(r.item,e));return this.leavingItems=this.leavingItems.filter(r=>r!==n),(n==null?void 0:n.hoverAmount)??0});St(this,"cleanUpLeavingElements",()=>{this.leavingItems=this.leavingItems.filter(e=>e.hoverAmount>0)});St(this,"shouldStep",()=>{const e=this.leavingItems.length>0,n=this.currentHoveredItem!==void 0&&this.currentHoveredItem.hoverAmount<1;return e||n});St(this,"getAnimatingItems",()=>this.currentHoveredItem!==void 0?[...this.leavingItems,this.currentHoveredItem]:this.leavingItems.map(e=>({...e,hoverAmount:VW(e.hoverAmount)})));St(this,"step",e=>{if(this.lastAnimationTime===void 0)this.lastAnimationTime=e;else{const r=(e-this.lastAnimationTime)/WW;for(const s of this.leavingItems)s.hoverAmount=ji(s.hoverAmount-r,0,1);this.currentHoveredItem!==void 0&&(this.currentHoveredItem.hoverAmount=ji(this.currentHoveredItem.hoverAmount+r,0,1));const i=this.getAnimatingItems();this.callback(i),this.cleanUpLeavingElements()}this.shouldStep()?(this.lastAnimationTime=e,window.requestAnimationFrame(this.step)):this.lastAnimationTime=void 0});St(this,"setHovered",e=>{var n;if(!hc((n=this.currentHoveredItem)==null?void 0:n.item,e)){if(this.currentHoveredItem!==void 0&&this.addToLeavingItems(this.currentHoveredItem),e!==void 0){const r=this.removeFromLeavingItems(e);this.currentHoveredItem={item:e,hoverAmount:r}}else this.currentHoveredItem=void 0;this.lastAnimationTime===void 0&&window.requestAnimationFrame(this.step)}});this.callback=e}}class KW{constructor(e){St(this,"fn");St(this,"val");this.fn=e}get value(){return this.val??(this.val=this.fn())}}function fw(t){return new KW(t)}const XW=fw(()=>window.navigator.userAgent.includes("Firefox")),Fh=fw(()=>window.navigator.userAgent.includes("Mac OS")&&window.navigator.userAgent.includes("Safari")&&!window.navigator.userAgent.includes("Chrome")),zh=fw(()=>window.navigator.platform.toLowerCase().startsWith("mac"));function GW(t){const e=y.useRef([]),n=y.useRef(0),r=y.useRef(t);r.current=t;const i=y.useCallback(()=>{const s=()=>window.requestAnimationFrame(o),o=()=>{const l=e.current.map(ow);e.current=[],r.current(new gc(l)),e.current.length>0?n.current++:n.current=0};window.requestAnimationFrame(n.current>600?s:o)},[]);return y.useCallback(s=>{e.current.length===0&&i();const o=Hi(s[0],s[1]);e.current.includes(o)||e.current.push(o)},[i])}const po="header",qr="group-header",Bh="out-of-bounds";var xa;(function(t){t[t.Start=-2]="Start",t[t.StartPadding=-1]="StartPadding",t[t.Center=0]="Center",t[t.EndPadding=1]="EndPadding",t[t.End=2]="End"})(xa||(xa={}));function WE(t,e){return t===e?!0:(t==null?void 0:t.kind)==="out-of-bounds"?(t==null?void 0:t.kind)===(e==null?void 0:e.kind)&&(t==null?void 0:t.location[0])===(e==null?void 0:e.location[0])&&(t==null?void 0:t.location[1])===(e==null?void 0:e.location[1])&&(t==null?void 0:t.region[0])===(e==null?void 0:e.region[0])&&(t==null?void 0:t.region[1])===(e==null?void 0:e.region[1]):(t==null?void 0:t.kind)===(e==null?void 0:e.kind)&&(t==null?void 0:t.location[0])===(e==null?void 0:e.location[0])&&(t==null?void 0:t.location[1])===(e==null?void 0:e.location[1])}const zx=6,qW=(t,e)=>{if(t.kind===Ee.Custom)return t.copyData;const n=e==null?void 0:e(t);return(n==null?void 0:n.getAccessibilityString(t))??""},YW=(t,e)=>{const{width:n,height:r,accessibilityHeight:i,columns:s,cellXOffset:o,cellYOffset:l,headerHeight:a,fillHandle:u=!1,groupHeaderHeight:c,rowHeight:f,rows:d,getCellContent:h,getRowThemeOverride:p,onHeaderMenuClick:g,enableGroups:b,isFilling:m,onCanvasFocused:v,onCanvasBlur:w,isFocused:k,selection:x,freezeColumns:C,onContextMenu:T,freezeTrailingRows:A,fixedShadowX:R=!0,fixedShadowY:P=!0,drawFocusRing:_,onMouseDown:O,onMouseUp:D,onMouseMoveRaw:N,onMouseMove:ne,onItemHovered:ie,dragAndDropState:V,firstColAccessible:j,onKeyDown:G,onKeyUp:M,highlightRegions:I,canvasRef:$,onDragStart:B,onDragEnd:Y,eventTargetRef:W,isResizing:de,resizeColumn:le,isDragging:ge,isDraggable:$e=!1,allowResize:ke,disabledRows:ye,hasAppendRow:lt,getGroupDetails:Fe,theme:He,prelightCells:be,headerIcons:Rt,verticalBorder:me,drawCell:Se,drawHeader:Pe,onCellFocused:Xe,onDragOverCell:rt,onDrop:_e,onDragLeave:yt,imageWindowLoader:We,smoothScrollX:it=!1,smoothScrollY:pe=!1,experimental:at,getCellRenderer:dt}=t,Ge=t.translateX??0,on=t.translateY??0,vt=Math.max(C,Math.min(s.length-1,o)),Be=y.useRef(null),ht=We,Gt=y.useRef(),[Zt,Bn]=y.useState(!1),Yn=y.useRef([]),Ht=y.useRef(),[jn,zt]=y.useState(),[Ln,Br]=y.useState(),$t=y.useRef(null),[et,ft]=y.useState(),[Wt,qt]=y.useState(!1),ln=y.useRef(Wt);ln.current=Wt;const kn=y.useMemo(()=>new Cz(Rt,()=>{si.current=void 0,z.current()}),[Rt]),Jn=b?c+a:a,gt=y.useRef(-1),Bt=((at==null?void 0:at.enableFirefoxRescaling)??!1)&&XW.value,J=((at==null?void 0:at.enableSafariRescaling)??!1)&&Fh.value;y.useLayoutEffect(()=>{window.devicePixelRatio===1||!Bt&&!J||(gt.current!==-1&&Bn(!0),window.clearTimeout(gt.current),gt.current=window.setTimeout(()=>{Bn(!1),gt.current=-1},200))},[l,vt,Ge,on,Bt,J]);const Me=b4(s,C),ze=R?Ua(Me,V):0,It=y.useCallback((H,oe,Ce)=>{const we=H.getBoundingClientRect();if(oe>=Me.length||Ce>=d)return;const ue=we.width/n,Ie=H0(oe,Ce,n,r,c,Jn,vt,l,Ge,on,d,C,A,Me,f);return ue!==1&&(Ie.x*=ue,Ie.y*=ue,Ie.width*=ue,Ie.height*=ue),Ie.x+=we.x,Ie.y+=we.y,Ie},[n,r,c,Jn,vt,l,Ge,on,d,C,A,Me,f]),Yt=y.useCallback((H,oe,Ce,we)=>{const ue=H.getBoundingClientRect(),Ie=ue.width/n,st=(oe-ue.left)/Ie,ot=(Ce-ue.top)/Ie,Re=5,Lt=j0(Me,vt,n,void 0,Ge);let Ve=0,jt=0;we instanceof MouseEvent&&(Ve=we.button,jt=we.buttons);const pt=C4(st,Lt,Ge),Tt=T4(ot,r,b,a,c,d,f,l,on,A),Rn=(we==null?void 0:we.shiftKey)===!0,wt=(we==null?void 0:we.ctrlKey)===!0,Sn=(we==null?void 0:we.metaKey)===!0,oi=we!==void 0&&!(we instanceof MouseEvent)||(we==null?void 0:we.pointerType)==="touch",mn=[st<0?-1:nn||ot>r){const Nt=st>n?1:st<0?-1:0,On=ot>r?1:ot<0?-1:0;let Wr=Nt*2,rs=On*2;Nt===0&&(Wr=pt===-1?xa.EndPadding:xa.Center),On===0&&(rs=Tt===void 0?xa.EndPadding:xa.Center);let Pi=!1;if(pt===-1&&Tt===-1){const Jo=It(H,Me.length-1,-1);Yr(Jo!==void 0),Pi=oen&&str&&ot=0?(On=!0,Nt=It(H,Wr,Tt),Yr(Nt!==void 0),Hr={kind:b&&Tt===-2?qr:po,location:[Wr,Tt],bounds:Nt,group:Me[Wr].group??"",isEdge:On,shiftKey:Rn,ctrlKey:wt,metaKey:Sn,isTouch:oi,localEventX:oe-Nt.x,localEventY:Ce-Nt.y,button:Ve,buttons:jt,scrollEdge:mn}):Hr={kind:b&&Tt===-2?qr:po,group:Me[pt].group??"",location:[pt,Tt],bounds:Nt,isEdge:On,shiftKey:Rn,ctrlKey:wt,metaKey:Sn,isTouch:oi,localEventX:oe-Nt.x,localEventY:Ce-Nt.y,button:Ve,buttons:jt,scrollEdge:mn}}else{const Nt=It(H,pt,Tt);Yr(Nt!==void 0);const On=Nt!==void 0&&Nt.x+Nt.width-oe{}),ts=y.useRef(jn);ts.current=jn;const[Ci,Ti]=y.useMemo(()=>{const H=document.createElement("canvas"),oe=document.createElement("canvas");return H.style.display="none",H.style.opacity="0",H.style.position="fixed",oe.style.display="none",oe.style.opacity="0",oe.style.position="fixed",[H.getContext("2d",{alpha:!1}),oe.getContext("2d",{alpha:!1})]},[]);y.useLayoutEffect(()=>{if(!(Ci===null||Ti===null))return document.documentElement.append(Ci.canvas),document.documentElement.append(Ti.canvas),()=>{Ci.canvas.remove(),Ti.canvas.remove()}},[Ci,Ti]);const ns=y.useMemo(()=>new D4,[]),Hl=Bt&&Zt?1:J&&Zt?2:5,Wl=(at==null?void 0:at.disableMinimumCellWidth)===!0?1:10,si=y.useRef(),Js=y.useRef(null),Qs=y.useRef(null),Zs=y.useCallback(()=>{var st;const H=Be.current,oe=$t.current;if(H===null||oe===null||(Js.current===null&&(Js.current=H.getContext("2d",{alpha:!1}),H.width=0,H.height=0),Qs.current===null&&(Qs.current=oe.getContext("2d",{alpha:!1}),oe.width=0,oe.height=0),Js.current===null||Qs.current===null||Ci===null||Ti===null))return;let Ce=!1;const we=ot=>{Ce=!0,ft(ot)},ue=si.current,Ie={headerCanvasCtx:Qs.current,canvasCtx:Js.current,bufferACtx:Ci,bufferBCtx:Ti,width:n,height:r,cellXOffset:vt,cellYOffset:l,translateX:Math.round(Ge),translateY:Math.round(on),mappedColumns:Me,enableGroups:b,freezeColumns:C,dragAndDropState:V,theme:He,headerHeight:a,groupHeaderHeight:c,disabledRows:ye??Pt.empty(),rowHeight:f,verticalBorder:me,isResizing:de,resizeCol:le,isFocused:k,selection:x,fillHandle:u,drawCellCallback:Se,hasAppendRow:lt,overrideCursor:we,maxScaleFactor:Hl,freezeTrailingRows:A,rows:d,drawFocus:_,getCellContent:h,getGroupDetails:Fe??(ot=>({name:ot})),getRowThemeOverride:p,drawHeaderCallback:Pe,prelightCells:be,highlightRegions:I,imageLoader:ht,lastBlitData:Ht,damage:Gt.current,hoverValues:Yn.current,hoverInfo:ts.current,spriteManager:kn,scrolling:Zt,hyperWrapping:(at==null?void 0:at.hyperWrapping)??!1,touchMode:Wt,enqueue:jl.current,renderStateProvider:ns,renderStrategy:(at==null?void 0:at.renderStrategy)??(Fh.value?"double-buffer":"single-buffer"),getCellRenderer:dt,minimumCellWidth:Wl};Ie.damage===void 0?(si.current=Ie,Fx(Ie,ue)):Fx(Ie,void 0),!Ce&&(Ie.damage===void 0||Ie.damage.has((st=ts==null?void 0:ts.current)==null?void 0:st[0]))&&ft(void 0)},[Ci,Ti,n,r,vt,l,Ge,on,Me,b,C,V,He,a,c,ye,f,me,de,lt,le,k,x,u,A,d,_,Hl,h,Fe,p,Se,Pe,be,I,ht,kn,Zt,at==null?void 0:at.hyperWrapping,at==null?void 0:at.renderStrategy,Wt,ns,dt,Wl]),z=y.useRef(Zs);y.useLayoutEffect(()=>{Zs(),z.current=Zs},[Zs]),y.useLayoutEffect(()=>{(async()=>{var oe;((oe=document==null?void 0:document.fonts)==null?void 0:oe.ready)!==void 0&&(await document.fonts.ready,si.current=void 0,z.current())})()},[]);const re=y.useCallback(H=>{Gt.current=H,z.current(),Gt.current=void 0},[]),Q=GW(re);jl.current=Q;const he=y.useCallback(H=>{re(new gc(H.map(oe=>oe.cell)))},[re]);ht.setCallback(re);const[ve,mt]=y.useState(!1),[je,ut]=Jt??[],ct=je!==void 0&&ut===-1,Vt=je!==void 0&&ut===-2;let en=!1,$n=!1,tn=et;if(tn===void 0&&je!==void 0&&ut!==void 0&&ut>-1&&ut({contain:"strict",display:"block",cursor:vr}),[vr]),Ei=y.useRef("default"),Ai=W==null?void 0:W.current;Ai!=null&&Ei.current!==eo.cursor&&(Ai.style.cursor=Ei.current=eo.cursor);const sr=y.useCallback((H,oe,Ce,we)=>{if(Fe===void 0)return;const ue=Fe(H);if(ue.actions!==void 0){const Ie=OE(oe,ue.actions);for(const[st,ot]of Ie.entries())if(Fp(ot,Ce+oe.x,we+ot.y))return ue.actions[st]}},[Fe]),Mi=y.useCallback((H,oe,Ce,we)=>{const ue=s[oe];if(!ge&&!de&&ue.hasMenu===!0&&!(Ln??!1)){const Ie=It(H,oe,-1);Yr(Ie!==void 0);const st=RE(Ie.x,Ie.y,Ie.width,Ie.height,tw(ue.title)==="rtl");if(Ce>st.x&&Cest.y&&we{const oe=Be.current,Ce=W==null?void 0:W.current;if(oe===null||H.target!==oe&&H.target!==Ce)return;gu.current=!0;let we,ue;if(H instanceof MouseEvent?(we=H.clientX,ue=H.clientY):(we=H.touches[0].clientX,ue=H.touches[0].clientY),H.target===Ce&&Ce!==null){const st=Ce.getBoundingClientRect();if(we>st.right||ue>st.bottom)return}const Ie=Yt(oe,we,ue,H);to.current=Ie.location,Ie.isTouch&&(pu.current=Date.now()),ln.current!==Ie.isTouch&&qt(Ie.isTouch),!(Ie.kind===po&&Mi(oe,Ie.location[0],we,ue)!==void 0)&&(Ie.kind===qr&&sr(Ie.group,Ie.bounds,Ie.localEventX,Ie.localEventY)!==void 0||(O==null||O(Ie),!Ie.isTouch&&$e!==!0&&$e!==Ie.kind&&Ie.button<3&&Ie.button!==1&&H.preventDefault()))},[W,$e,Yt,sr,Mi,O]);er("touchstart",wr,window,!1),er("mousedown",wr,window,!1);const Vl=y.useRef(0),mu=y.useCallback(H=>{var jt,pt;const oe=Vl.current;Vl.current=Date.now();const Ce=Be.current;if(gu.current=!1,D===void 0||Ce===null)return;const we=W==null?void 0:W.current,ue=H.target!==Ce&&H.target!==we;let Ie,st,ot=!0;if(H instanceof MouseEvent){if(Ie=H.clientX,st=H.clientY,ot=H.button<3,H.pointerType==="touch")return}else Ie=H.changedTouches[0].clientX,st=H.changedTouches[0].clientY;let Re=Yt(Ce,Ie,st,H);Re.isTouch&&pu.current!==0&&Date.now()-pu.current>500&&(Re={...Re,isLongTouch:!0}),oe!==0&&Date.now()-oe<(Re.isTouch?1e3:500)&&(Re={...Re,isDoubleClick:!0}),ln.current!==Re.isTouch&&qt(Re.isTouch),!ue&&H.cancelable&&ot&&H.preventDefault();const[Lt]=Re.location,Ve=Mi(Ce,Lt,Ie,st);if(Re.kind===po&&Ve!==void 0){(Re.button!==0||((jt=to.current)==null?void 0:jt[0])!==Lt||((pt=to.current)==null?void 0:pt[1])!==-1)&&D(Re,!0);return}else if(Re.kind===qr){const Tt=sr(Re.group,Re.bounds,Re.localEventX,Re.localEventY);if(Tt!==void 0){Re.button===0&&Tt.onClick(Re);return}}D(Re,ue)},[D,W,Yt,Mi,sr]);er("mouseup",mu,window,!1),er("touchend",mu,window,!1);const xf=y.useCallback(H=>{var Ve,jt;const oe=Be.current;if(oe===null)return;const Ce=W==null?void 0:W.current,we=H.target!==oe&&H.target!==Ce;let ue,Ie,st=!0;H instanceof MouseEvent?(ue=H.clientX,Ie=H.clientY,st=H.button<3):(ue=H.changedTouches[0].clientX,Ie=H.changedTouches[0].clientY);const ot=Yt(oe,ue,Ie,H);ln.current!==ot.isTouch&&qt(ot.isTouch),!we&&H.cancelable&&st&&H.preventDefault();const[Re]=ot.location,Lt=Mi(oe,Re,ue,Ie);if(ot.kind===po&&Lt!==void 0)ot.button===0&&((Ve=to.current)==null?void 0:Ve[0])===Re&&((jt=to.current)==null?void 0:jt[1])===-1&&(g==null||g(Re,Lt));else if(ot.kind===qr){const pt=sr(ot.group,ot.bounds,ot.localEventX,ot.localEventY);pt!==void 0&&ot.button===0&&pt.onClick(ot)}},[W,Yt,Mi,g,sr]);er("click",xf,window,!1);const Qp=y.useCallback(H=>{const oe=Be.current,Ce=W==null?void 0:W.current;if(oe===null||H.target!==oe&&H.target!==Ce||T===void 0)return;const we=Yt(oe,H.clientX,H.clientY,H);T(we,()=>{H.cancelable&&H.preventDefault()})},[W,Yt,T]);er("contextmenu",Qp,(W==null?void 0:W.current)??null,!1);const kf=y.useCallback(H=>{Gt.current=new gc(H.map(oe=>oe.item)),Yn.current=H,z.current(),Gt.current=void 0},[]),Ri=y.useMemo(()=>new UW(kf),[kf]),Os=y.useRef(Ri);Os.current=Ri,y.useLayoutEffect(()=>{const H=Os.current;if(Jt===void 0||Jt[1]<0){H.setHovered(Jt);return}const oe=h(Jt,!0),Ce=dt(oe),we=Ce===void 0&&oe.kind===Ee.Custom||(Ce==null?void 0:Ce.needsHover)!==void 0&&(typeof Ce.needsHover=="boolean"?Ce.needsHover:Ce.needsHover(oe));H.setHovered(we?Jt:void 0)},[h,dt,Jt]);const jr=y.useRef(),X=y.useCallback(H=>{var ot;const oe=Be.current;if(oe===null)return;const Ce=W==null?void 0:W.current,we=H.target!==oe&&H.target!==Ce,ue=Yt(oe,H.clientX,H.clientY,H);if(ue.kind!=="out-of-bounds"&&we&&!gu.current&&!ue.isTouch)return;const Ie=(Re,Lt)=>{zt(Ve=>Ve===Re||(Ve==null?void 0:Ve[0][0])===(Re==null?void 0:Re[0][0])&&(Ve==null?void 0:Ve[0][1])===(Re==null?void 0:Re[0][1])&&((Ve==null?void 0:Ve[1][0])===(Re==null?void 0:Re[1][0])&&(Ve==null?void 0:Ve[1][1])===(Re==null?void 0:Re[1][1])||!Lt)?Ve:Re)};if(!WE(ue,jr.current))ft(void 0),ie==null||ie(ue),Ie(ue.kind===Bh?void 0:[ue.location,[ue.localEventX,ue.localEventY]],!0),jr.current=ue;else if(ue.kind==="cell"||ue.kind===po||ue.kind===qr){let Re=!1,Lt=!0;if(ue.kind==="cell"){const jt=h(ue.location);Lt=((ot=dt(jt))==null?void 0:ot.needsHoverPosition)??jt.kind===Ee.Custom,Re=Lt}else ue.kind===qr&&(Re=!0);const Ve=[ue.location,[ue.localEventX,ue.localEventY]];Ie(Ve,Lt),ts.current=Ve,Re&&re(new gc([ue.location]))}const st=ue.location[0]>=(j?0:1);Br(ue.kind===po&&ue.isEdge&&st&&ke===!0),mt(ue.kind==="cell"&&ue.isFillHandle),N==null||N(H),ne(ue)},[W,Yt,j,ke,N,ne,ie,h,dt,re]);er("mousemove",X,window,!0);const gn=y.useCallback(H=>{const oe=Be.current;if(oe===null)return;let Ce,we;x.current!==void 0&&(Ce=It(oe,x.current.cell[0],x.current.cell[1]),we=x.current.cell),G==null||G({bounds:Ce,stopPropagation:()=>H.stopPropagation(),preventDefault:()=>H.preventDefault(),cancel:()=>{},ctrlKey:H.ctrlKey,metaKey:H.metaKey,shiftKey:H.shiftKey,altKey:H.altKey,key:H.key,keyCode:H.keyCode,rawEvent:H,location:we})},[G,x,It]),Yo=y.useCallback(H=>{const oe=Be.current;if(oe===null)return;let Ce,we;x.current!==void 0&&(Ce=It(oe,x.current.cell[0],x.current.cell[1]),we=x.current.cell),M==null||M({bounds:Ce,stopPropagation:()=>H.stopPropagation(),preventDefault:()=>H.preventDefault(),cancel:()=>{},ctrlKey:H.ctrlKey,metaKey:H.metaKey,shiftKey:H.shiftKey,altKey:H.altKey,key:H.key,keyCode:H.keyCode,rawEvent:H,location:we})},[M,x,It]),Zp=y.useCallback(H=>{Be.current=H,$!==void 0&&($.current=H)},[$]),Sf=y.useCallback(H=>{const oe=Be.current;if(oe===null||$e===!1||de){H.preventDefault();return}let Ce,we;const ue=Yt(oe,H.clientX,H.clientY);if($e!==!0&&ue.kind!==$e){H.preventDefault();return}const Ie=(jt,pt)=>{Ce=jt,we=pt};let st,ot,Re;const Lt=(jt,pt,Tt)=>{st=jt,ot=pt,Re=Tt};let Ve=!1;if(B==null||B({...ue,setData:Ie,setDragImage:Lt,preventDefault:()=>Ve=!0,defaultPrevented:()=>Ve}),!Ve&&Ce!==void 0&&we!==void 0&&H.dataTransfer!==null)if(H.dataTransfer.setData(Ce,we),H.dataTransfer.effectAllowed="copyLink",st!==void 0&&ot!==void 0&&Re!==void 0)H.dataTransfer.setDragImage(st,ot,Re);else{const[jt,pt]=ue.location;if(pt!==void 0){const Tt=document.createElement("canvas"),Rn=It(oe,jt,pt);Yr(Rn!==void 0);const wt=Math.ceil(window.devicePixelRatio??1);Tt.width=Rn.width*wt,Tt.height=Rn.height*wt;const Sn=Tt.getContext("2d");Sn!==null&&(Sn.scale(wt,wt),Sn.textBaseline="middle",pt===-1?(Sn.font=He.headerFontFull,Sn.fillStyle=He.bgHeader,Sn.fillRect(0,0,Tt.width,Tt.height),PE(Sn,0,0,Rn.width,Rn.height,Me[jt],!1,He,!1,!1,0,kn,Pe,!1)):(Sn.font=He.baseFontFull,Sn.fillStyle=He.bgCell,Sn.fillRect(0,0,Tt.width,Tt.height),ME(Sn,h([jt,pt]),0,pt,!1,!1,0,0,Rn.width,Rn.height,!1,He,He.bgCell,ht,kn,1,void 0,!1,0,void 0,void 0,void 0,ns,dt,()=>{}))),Tt.style.left="-100%",Tt.style.position="absolute",Tt.style.width=`${Rn.width}px`,Tt.style.height=`${Rn.height}px`,document.body.append(Tt),H.dataTransfer.setDragImage(Tt,Rn.width/2,Rn.height/2),window.setTimeout(()=>{Tt.remove()},0)}}else H.preventDefault()},[$e,de,Yt,B,It,He,Me,kn,Pe,h,ht,ns,dt]);er("dragstart",Sf,(W==null?void 0:W.current)??null,!1,!1);const yu=y.useRef(),eg=y.useCallback(H=>{const oe=Be.current;if(_e!==void 0&&H.preventDefault(),oe===null||rt===void 0)return;const Ce=Yt(oe,H.clientX,H.clientY),[we,ue]=Ce.location,Ie=we-(j?0:1),[st,ot]=yu.current??[];(st!==Ie||ot!==ue)&&(yu.current=[Ie,ue],rt([Ie,ue],H.dataTransfer))},[j,Yt,rt,_e]);er("dragover",eg,(W==null?void 0:W.current)??null,!1,!1);const Ww=y.useCallback(()=>{yu.current=void 0,Y==null||Y()},[Y]);er("dragend",Ww,(W==null?void 0:W.current)??null,!1,!1);const Z=y.useCallback(H=>{const oe=Be.current;if(oe===null||_e===void 0)return;H.preventDefault();const Ce=Yt(oe,H.clientX,H.clientY),[we,ue]=Ce.location,Ie=we-(j?0:1);_e([Ie,ue],H.dataTransfer)},[j,Yt,_e]);er("drop",Z,(W==null?void 0:W.current)??null,!1,!1);const or=y.useCallback(()=>{yt==null||yt()},[yt]);er("dragleave",or,(W==null?void 0:W.current)??null,!1,!1);const Fn=y.useRef(x);Fn.current=x;const Ul=y.useRef(null),vu=y.useCallback(H=>{var oe;Be.current===null||!Be.current.contains(document.activeElement)||(H===null&&Fn.current.current!==void 0?(oe=$==null?void 0:$.current)==null||oe.focus({preventScroll:!0}):H!==null&&H.focus({preventScroll:!0}),Ul.current=H)},[$]);y.useImperativeHandle(e,()=>({focus:()=>{var oe;const H=Ul.current;H===null||!document.contains(H)?(oe=$==null?void 0:$.current)==null||oe.focus({preventScroll:!0}):H.focus({preventScroll:!0})},getBounds:(H,oe)=>{if(!($===void 0||$.current===null))return It($.current,H??0,oe??-1)},damage:he}),[$,he,It]);const no=y.useRef(),Rr=zF(()=>{var ot,Re,Lt;if(n<50||(at==null?void 0:at.disableAccessibilityTree)===!0)return null;let H=j0(Me,vt,n,V,Ge);const oe=j?0:-1;!j&&((ot=H[0])==null?void 0:ot.sourceIndex)===0&&(H=H.slice(1));const[Ce,we]=((Re=x.current)==null?void 0:Re.cell)??[],ue=(Lt=x.current)==null?void 0:Lt.range,Ie=H.map(Ve=>Ve.sourceIndex),st=hl(l,Math.min(d,l+i));return Ce!==void 0&&we!==void 0&&!(Ie.includes(Ce)&&st.includes(we))&&vu(null),y.createElement("table",{key:"access-tree",role:"grid","aria-rowcount":d+1,"aria-multiselectable":"true","aria-colcount":Me.length+oe},y.createElement("thead",{role:"rowgroup"},y.createElement("tr",{role:"row","aria-rowindex":1},H.map(Ve=>y.createElement("th",{role:"columnheader","aria-selected":x.columns.hasIndex(Ve.sourceIndex),"aria-colindex":Ve.sourceIndex+1+oe,tabIndex:-1,onFocus:jt=>{if(jt.target!==Ul.current)return Xe==null?void 0:Xe([Ve.sourceIndex,-1])},key:Ve.sourceIndex},Ve.title)))),y.createElement("tbody",{role:"rowgroup"},st.map(Ve=>y.createElement("tr",{role:"row","aria-selected":x.rows.hasIndex(Ve),key:Ve,"aria-rowindex":Ve+2},H.map(jt=>{const pt=jt.sourceIndex,Tt=Hi(pt,Ve),Rn=Ce===pt&&we===Ve,wt=ue!==void 0&&pt>=ue.x&&pt=ue.y&&Ve{const Hr=$==null?void 0:$.current;if(Hr!=null)return G==null?void 0:G({bounds:It(Hr,pt,Ve),cancel:()=>{},preventDefault:()=>{},stopPropagation:()=>{},ctrlKey:!1,key:"Enter",keyCode:13,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:oi})},onFocusCapture:Hr=>{var Nt,On;if(!(Hr.target===Ul.current||((Nt=no.current)==null?void 0:Nt[0])===pt&&((On=no.current)==null?void 0:On[1])===Ve))return no.current=oi,Xe==null?void 0:Xe(oi)},ref:Rn?vu:void 0,tabIndex:-1},qW(mn,dt))})))))},[n,Me,vt,V,Ge,d,l,i,x,vu,h,$,G,It,Xe],200),Oi=C===0||!R?0:vt>C?1:ji(-Ge/100,0,1),tg=-l*32+on,Kl=P?ji(-tg/100,0,1):0,ng=y.useMemo(()=>{if(!Oi&&!Kl)return null;const H={position:"absolute",top:0,left:ze,width:n-ze,height:r,opacity:Oi,pointerEvents:"none",transition:it?void 0:"opacity 0.2s",boxShadow:"inset 13px 0 10px -13px rgba(0, 0, 0, 0.2)"},oe={position:"absolute",top:Jn,left:0,width:n,height:r,opacity:Kl,pointerEvents:"none",transition:pe?void 0:"opacity 0.2s",boxShadow:"inset 0 13px 10px -13px rgba(0, 0, 0, 0.2)"};return y.createElement(y.Fragment,null,Oi>0&&y.createElement("div",{id:"shadow-x",style:H}),Kl>0&&y.createElement("div",{id:"shadow-y",style:oe}))},[Oi,Kl,ze,n,it,Jn,r,pe]),rg=y.useMemo(()=>({position:"absolute",top:0,left:0}),[]);return y.createElement(y.Fragment,null,y.createElement("canvas",{"data-testid":"data-grid-canvas",tabIndex:0,onKeyDown:gn,onKeyUp:Yo,onFocus:v,onBlur:w,ref:Zp,style:eo},Rr),y.createElement("canvas",{ref:$t,style:rg}),ng)},JW=y.memo(y.forwardRef(YW));function Fu(t,e,n,r){return ji(Math.round(e-(t.growOffset??0)),Math.ceil(n),Math.floor(r))}const QW=t=>{const[e,n]=y.useState(),[r,i]=y.useState(),[s,o]=y.useState(),[l,a]=y.useState(),[u,c]=y.useState(!1),[f,d]=y.useState(),[h,p]=y.useState(),[g,b]=y.useState(),[m,v]=y.useState(!1),[w,k]=y.useState(),{onHeaderMenuClick:x,getCellContent:C,onColumnMoved:T,onColumnResize:A,onColumnResizeStart:R,onColumnResizeEnd:P,gridRef:_,maxColumnWidth:O,minColumnWidth:D,onRowMoved:N,lockColumns:ne,onColumnProposeMove:ie,onMouseDown:V,onMouseUp:j,onItemHovered:G,onDragStart:M,canvasRef:I}=t,$=(A??P??R)!==void 0,{columns:B,selection:Y}=t,W=Y.columns,de=y.useCallback(me=>{const[Se,Pe]=me.location;s!==void 0&&l!==Se&&Se>=ne?(c(!0),a(Se)):h!==void 0&&Pe!==void 0?(v(!0),b(Math.max(0,Pe))):r===void 0&&!u&&!m&&(G==null||G(me))},[s,h,l,G,ne,r,u,m]),le=T!==void 0,ge=y.useCallback(me=>{var Se;if(me.button===0){const[Pe,Xe]=me.location;if(me.kind==="out-of-bounds"&&me.isEdge&&$){const rt=(Se=_==null?void 0:_.current)==null?void 0:Se.getBounds(B.length-1,-1);rt!==void 0&&(n(rt.x),i(B.length-1))}else if(me.kind==="header"&&Pe>=ne){const rt=I==null?void 0:I.current;if(me.isEdge&&$&&rt){n(me.bounds.x),i(Pe);const yt=rt.getBoundingClientRect().width/rt.offsetWidth,We=me.bounds.width/yt;R==null||R(B[Pe],We,Pe,We+(B[Pe].growOffset??0))}else me.kind==="header"&&le&&(d(me.bounds.x),o(Pe))}else me.kind==="cell"&&ne>0&&Pe===0&&Xe!==void 0&&N!==void 0&&(k(me.bounds.y),p(Xe))}V==null||V(me)},[V,$,ne,N,_,B,le,R,I]),$e=y.useCallback((me,Se)=>{u||m||x==null||x(me,Se)},[u,m,x]),ke=y.useRef(-1),ye=y.useCallback(()=>{ke.current=-1,p(void 0),b(void 0),k(void 0),v(!1),o(void 0),a(void 0),d(void 0),c(!1),i(void 0),n(void 0)},[]),lt=y.useCallback((me,Se)=>{if(me.button===0){if(r!==void 0){if((W==null?void 0:W.hasIndex(r))===!0)for(const Xe of W){if(Xe===r)continue;const rt=B[Xe],_e=Fu(rt,ke.current,D,O);A==null||A(rt,_e,Xe,_e+(rt.growOffset??0))}const Pe=Fu(B[r],ke.current,D,O);if(P==null||P(B[r],Pe,r,Pe+(B[r].growOffset??0)),W.hasIndex(r))for(const Xe of W){if(Xe===r)continue;const rt=B[Xe],_e=Fu(rt,ke.current,D,O);P==null||P(rt,_e,Xe,_e+(rt.growOffset??0))}}ye(),s!==void 0&&l!==void 0&&(T==null||T(s,l)),h!==void 0&&g!==void 0&&(N==null||N(h,g))}j==null||j(me,Se)},[j,r,s,l,h,g,W,P,B,D,O,A,T,N,ye]),Fe=y.useMemo(()=>{if(!(s===void 0||l===void 0)&&s!==l&&(ie==null?void 0:ie(s,l))!==!1)return{src:s,dest:l}},[s,l,ie]),He=y.useCallback(me=>{const Se=I==null?void 0:I.current;if(s!==void 0&&f!==void 0)Math.abs(me.clientX-f)>20&&c(!0);else if(h!==void 0&&w!==void 0)Math.abs(me.clientY-w)>20&&v(!0);else if(r!==void 0&&e!==void 0&&Se){const Xe=Se.getBoundingClientRect().width/Se.offsetWidth,rt=(me.clientX-e)/Xe,_e=B[r],yt=Fu(_e,rt,D,O);if(A==null||A(_e,yt,r,yt+(_e.growOffset??0)),ke.current=rt,(W==null?void 0:W.first())===r)for(const We of W){if(We===r)continue;const it=B[We],pe=Fu(it,ke.current,D,O);A==null||A(it,pe,We,pe+(it.growOffset??0))}}},[s,f,h,w,r,e,B,D,O,A,W,I]),be=y.useCallback((me,Se)=>{if(h===void 0||g===void 0)return C(me,Se);let[Pe,Xe]=me;return Xe===g?Xe=h:(Xe>g&&(Xe-=1),Xe>=h&&(Xe+=1)),C([Pe,Xe],Se)},[h,g,C]),Rt=y.useCallback(me=>{M==null||M(me),me.defaultPrevented()||ye()},[ye,M]);return y.createElement(JW,{accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,columns:t.columns,disabledRows:t.disabledRows,drawFocusRing:t.drawFocusRing,drawHeader:t.drawHeader,drawCell:t.drawCell,enableGroups:t.enableGroups,eventTargetRef:t.eventTargetRef,experimental:t.experimental,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,headerIcons:t.headerIcons,height:t.height,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,resizeColumn:r,isDraggable:t.isDraggable,isFilling:t.isFilling,isFocused:t.isFocused,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDrop:t.onDrop,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseMove:t.onMouseMove,prelightCells:t.prelightCells,rowHeight:t.rowHeight,rows:t.rows,selection:t.selection,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,verticalBorder:t.verticalBorder,width:t.width,getCellContent:be,isResizing:r!==void 0,onHeaderMenuClick:$e,isDragging:u,onItemHovered:de,onDragStart:Rt,onMouseDown:ge,allowResize:$,onMouseUp:lt,dragAndDropState:Fe,onMouseMoveRaw:He,ref:_})};function ZW(t){const e=y.useRef(null),[n,r]=y.useState({width:t==null?void 0:t[0],height:t==null?void 0:t[1]});return y.useLayoutEffect(()=>{const i=o=>{for(const l of o){const{width:a,height:u}=l&&l.contentRect||{};r(c=>c.width===a&&c.height===u?c:{width:a,height:u})}},s=new window.ResizeObserver(i);return e.current&&s.observe(e.current,void 0),()=>{s.disconnect()}},[e.current]),{ref:e,...n}}const e6=(t,e,n)=>{const r=y.useRef(null),i=y.useRef(null),s=y.useRef(null),o=y.useRef(0),l=y.useRef(e);l.current=e;const a=n.current;y.useEffect(()=>{const u=()=>{var d,h;if(i.current===!1&&a!==null){const p=[a.scrollLeft,a.scrollTop];if(((d=s.current)==null?void 0:d[0])===p[0]&&((h=s.current)==null?void 0:h[1])===p[1])if(o.current>10){s.current=null,i.current=null;return}else o.current++;else o.current=0,l.current(p[0],p[1]),s.current=p;r.current=window.setTimeout(u,8.333333333333334)}},c=()=>{i.current=!0,s.current=null,r.current!==null&&(window.clearTimeout(r.current),r.current=null)},f=d=>{d.touches.length===0&&(i.current=!1,o.current=0,r.current=window.setTimeout(u,8.333333333333334))};if(t&&a!==null){const d=a;return d.addEventListener("touchstart",c),d.addEventListener("touchend",f),()=>{d.removeEventListener("touchstart",c),d.removeEventListener("touchend",f),r.current!==null&&window.clearTimeout(r.current)}}},[t,a])},t6=()=>t=>t.isSafari?"scroll":"auto",n6=ii("div")({name:"ScrollRegionStyle",class:"gdg-s1dgczr6",propsAsIs:!1,vars:{"s1dgczr6-0":[t6()]}});function r6(t){const[e,n]=y.useState(!1),r=typeof window>"u"?null:window,i=y.useRef(0);return er("touchstart",y.useCallback(()=>{window.clearTimeout(i.current),n(!0)},[]),r,!0,!1),er("touchend",y.useCallback(s=>{s.touches.length===0&&(i.current=window.setTimeout(()=>n(!1),t))},[t]),r,!0,!1),e}const i6=t=>{var B,Y;const{children:e,clientHeight:n,scrollHeight:r,scrollWidth:i,update:s,draggable:o,className:l,preventDiagonalScrolling:a=!1,paddingBottom:u=0,paddingRight:c=0,rightElement:f,rightElementProps:d,kineticScrollPerfHack:h=!1,scrollRef:p,initialSize:g}=t,b=[],m=(d==null?void 0:d.sticky)??!1,v=(d==null?void 0:d.fill)??!1,w=y.useRef(0),k=y.useRef(0),x=y.useRef(null),C=typeof window>"u"?1:window.devicePixelRatio,T=y.useRef({scrollLeft:0,scrollTop:0,lockDirection:void 0}),A=y.useRef(null),R=r6(200),[P,_]=y.useState(!0),O=y.useRef(0);y.useLayoutEffect(()=>{if(!P||R||T.current.lockDirection===void 0)return;const W=x.current;if(W===null)return;const[de,le]=T.current.lockDirection;de!==void 0?W.scrollLeft=de:le!==void 0&&(W.scrollTop=le),T.current.lockDirection=void 0},[R,P]);const D=y.useCallback((W,de)=>{var Se;const le=x.current;if(le===null)return;de=de??le.scrollTop,W=W??le.scrollLeft;const ge=T.current.scrollTop,$e=T.current.scrollLeft,ke=W-$e,ye=de-ge;R&&ke!==0&&ye!==0&&(Math.abs(ke)>3||Math.abs(ye)>3)&&a&&T.current.lockDirection===void 0&&(T.current.lockDirection=Math.abs(ke)0&&(Math.abs(Rt)>2e3||be===0||be===me)&&r>le.scrollHeight+5){const Pe=be/me,Xe=(r-He)*Pe;w.current=Xe-be}lt!==void 0&&(window.clearTimeout(O.current),_(!1),O.current=window.setTimeout(()=>_(!0),200)),s({x:W,y:be+w.current,width:Fe-c,height:He-u,paddingRight:((Se=A.current)==null?void 0:Se.clientWidth)??0})},[u,c,r,s,a,R]);e6(h&&Fh.value,D,x);const N=y.useRef(D);N.current=D;const ne=y.useRef(),ie=y.useRef(!1);y.useLayoutEffect(()=>{ie.current?D():ie.current=!0},[D,u,c]);const V=y.useCallback(W=>{x.current=W,p!==void 0&&(p.current=W)},[p]);let j=0,G=0;for(b.push(y.createElement("div",{key:j++,style:{width:i,height:0}}));GN.current(),0),ne.current={width:I,height:$}),(I??0)===0||($??0)===0?y.createElement("div",{ref:M}):y.createElement("div",{ref:M},y.createElement(n6,{isSafari:Fh.value},y.createElement("div",{className:"dvn-underlay"},e),y.createElement("div",{ref:V,style:ne.current,draggable:o,onDragStart:W=>{o||(W.stopPropagation(),W.preventDefault())},className:"dvn-scroller "+(l??""),onScroll:()=>D()},y.createElement("div",{className:"dvn-scroll-inner"+(f===void 0?" dvn-hidden":"")},y.createElement("div",{className:"dvn-stack"},b),f!==void 0&&y.createElement(y.Fragment,null,!v&&y.createElement("div",{className:"dvn-spacer"}),y.createElement("div",{ref:A,style:{height:$,maxHeight:n-Math.ceil(C%1),position:"sticky",top:0,paddingLeft:1,marginBottom:-40,marginRight:c,flexGrow:v?1:void 0,right:m?c??0:void 0,pointerEvents:"auto"}},f))))))},s6=t=>{const{columns:e,rows:n,rowHeight:r,headerHeight:i,groupHeaderHeight:s,enableGroups:o,freezeColumns:l,experimental:a,nonGrowWidth:u,clientSize:c,className:f,onVisibleRegionChanged:d,scrollRef:h,preventDiagonalScrolling:p,rightElement:g,rightElementProps:b,overscrollX:m,overscrollY:v,initialSize:w,smoothScrollX:k=!1,smoothScrollY:x=!1,isDraggable:C}=t,{paddingRight:T,paddingBottom:A}=a??{},[R,P]=c,_=y.useRef(),O=y.useRef(),D=y.useRef(),N=y.useRef(),ne=u+Math.max(0,m??0);let ie=o?i+s:i;if(typeof r=="number")ie+=n*r;else for(let M=0;M{var ye,lt;if(V.current===void 0)return;const M={...V.current};let I=0,$=M.x<0?-M.x:0,B=0,Y=0;M.x=M.x<0?0:M.x;let W=0;for(let Fe=0;Fe=He+Fe.width)I+=Fe.width,Y++,B++;else if(M.x>He)I+=Fe.width,k?$+=He-M.x:Y++,B++;else if(M.x+M.width>He)I+=Fe.width,B++;else break}let de=0,le=0,ge=0;if(typeof r=="number")x?(le=Math.floor(M.y/r),de=le*r-M.y):le=Math.ceil(M.y/r),ge=Math.ceil(M.height/r)+le,de<0&&ge++;else{let Fe=0;for(let He=0;He=Fe+be)Fe+=be,le++,ge++;else if(M.y>Rt)Fe+=be,x?de+=Rt-M.y:le++,ge++;else if(M.y+M.height>be/2+Fe)Fe+=be,ge++;else break}}const $e={x:Y,y:le,width:B-Y,height:ge-le},ke=_.current;(ke===void 0||ke.y!==$e.y||ke.x!==$e.x||ke.height!==$e.height||ke.width!==$e.width||O.current!==$||D.current!==de||M.width!==((ye=N.current)==null?void 0:ye[0])||M.height!==((lt=N.current)==null?void 0:lt[1]))&&(d==null||d({x:Y,y:le,width:B-Y,height:ge-le},M.width,M.height,M.paddingRight??0,$,de),_.current=$e,O.current=$,D.current=de,N.current=[M.width,M.height])},[e,r,n,d,l,k,x]),G=y.useCallback(M=>{V.current=M,j()},[j]);return y.useEffect(()=>{j()},[j]),y.createElement(i6,{scrollRef:h,className:f,kineticScrollPerfHack:a==null?void 0:a.kineticScrollPerfHack,preventDiagonalScrolling:p,draggable:C===!0||typeof C=="string",scrollWidth:ne+(T??0),scrollHeight:ie+(A??0),clientHeight:P,rightElement:g,paddingBottom:A,paddingRight:T,rightElementProps:b,update:G,initialSize:w},y.createElement(QW,{eventTargetRef:h,width:R,height:P,accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,columns:t.columns,disabledRows:t.disabledRows,enableGroups:t.enableGroups,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellContent:t.getCellContent,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,isFilling:t.isFilling,isFocused:t.isFocused,lockColumns:t.lockColumns,maxColumnWidth:t.maxColumnWidth,minColumnWidth:t.minColumnWidth,onHeaderMenuClick:t.onHeaderMenuClick,onMouseMove:t.onMouseMove,prelightCells:t.prelightCells,rowHeight:t.rowHeight,rows:t.rows,selection:t.selection,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,onColumnProposeMove:t.onColumnProposeMove,verticalBorder:t.verticalBorder,drawFocusRing:t.drawFocusRing,drawHeader:t.drawHeader,drawCell:t.drawCell,experimental:t.experimental,gridRef:t.gridRef,headerIcons:t.headerIcons,isDraggable:t.isDraggable,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onColumnMoved:t.onColumnMoved,onColumnResize:t.onColumnResize,onColumnResizeEnd:t.onColumnResizeEnd,onColumnResizeStart:t.onColumnResizeStart,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDragStart:t.onDragStart,onDrop:t.onDrop,onItemHovered:t.onItemHovered,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onRowMoved:t.onRowMoved,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY}))},o6=ii("div")({name:"SearchWrapper",class:"gdg-seveqep",propsAsIs:!1}),l6=y.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},y.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 244l144-144 144 144M256 120v292"})),a6=y.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},y.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 268l144 144 144-144M256 392V100"})),u6=y.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},y.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"32",d:"M368 368L144 144M368 144L144 368"})),c6=10,f6=t=>{const{canvasRef:e,cellYOffset:n,rows:r,columns:i,searchInputRef:s,searchValue:o,searchResults:l,onSearchValueChange:a,getCellsForSelection:u,onSearchResultsChanged:c,showSearch:f=!1,onSearchClose:d}=t,[h]=y.useState(()=>"search-box-"+Math.round(Math.random()*1e3)),[p,g]=y.useState(""),b=o??p,m=y.useCallback(I=>{g(I),a==null||a(I)},[a]),[v,w]=y.useState(),k=y.useRef(v);k.current=v,y.useEffect(()=>{l!==void 0&&(l.length>0?w(I=>({rowsSearched:r,results:l.length,selectedIndex:(I==null?void 0:I.selectedIndex)??-1})):w(void 0))},[r,l]);const x=y.useRef();x.current===void 0&&(x.current=new AbortController);const C=y.useRef(),[T,A]=y.useState([]),R=l??T,P=y.useCallback(()=>{C.current!==void 0&&(window.cancelAnimationFrame(C.current),C.current=void 0,x.current.abort())},[]),_=y.useRef(n);_.current=n;const O=y.useCallback(I=>{const $=new RegExp(I.replace(/([$()*+.?[\\\]^{|}-])/g,"\\$1"),"i");let B=_.current,Y=Math.min(10,r),W=0;w(void 0),A([]);const de=[],le=async()=>{var me;if(u===void 0)return;const ge=performance.now(),$e=r-W;let ke=u({x:0,y:B,width:i.length,height:Math.min(Y,$e,r-B)},x.current.signal);typeof ke=="function"&&(ke=await ke());let ye=!1;for(const[Se,Pe]of ke.entries())for(const[Xe,rt]of Pe.entries()){let _e;switch(rt.kind){case Ee.Text:case Ee.Number:_e=rt.displayData;break;case Ee.Uri:case Ee.Markdown:_e=rt.data;break;case Ee.Boolean:_e=typeof rt.data=="boolean"?rt.data.toString():void 0;break;case Ee.Image:case Ee.Bubble:_e=rt.data.join("🐳");break;case Ee.Custom:_e=rt.copyData;break}_e!==void 0&&$.test(_e)&&(de.push([Xe,Se+B]),ye=!0)}const lt=performance.now();ye&&A([...de]),W+=ke.length,Yr(W<=r);const Fe=((me=k.current)==null?void 0:me.selectedIndex)??-1;w({results:de.length,rowsSearched:W,selectedIndex:Fe}),c==null||c(de,Fe),B+Y>=r?B=0:B+=Y;const He=lt-ge,be=Math.max(He,1),Rt=c6/be;Y=Math.ceil(Y*Rt),W{var I;d==null||d(),w(void 0),A([]),c==null||c([],-1),P(),(I=e==null?void 0:e.current)==null||I.focus()},[P,e,d,c]),N=y.useCallback(I=>{m(I.target.value),l===void 0&&(I.target.value===""?(w(void 0),A([]),P()):O(I.target.value))},[O,P,m,l]);y.useEffect(()=>{f&&s.current!==null&&(m(""),s.current.focus({preventScroll:!0}))},[f,s,m]);const ne=y.useCallback(I=>{var B;if((B=I==null?void 0:I.stopPropagation)==null||B.call(I),v===void 0)return;const $=(v.selectedIndex+1)%v.results;w({...v,selectedIndex:$}),c==null||c(R,$)},[v,c,R]),ie=y.useCallback(I=>{var B;if((B=I==null?void 0:I.stopPropagation)==null||B.call(I),v===void 0)return;let $=(v.selectedIndex-1)%v.results;$<0&&($+=v.results),w({...v,selectedIndex:$}),c==null||c(R,$)},[c,R,v]),V=y.useCallback(I=>{(I.ctrlKey||I.metaKey)&&I.nativeEvent.code==="KeyF"||I.key==="Escape"?(D(),I.stopPropagation(),I.preventDefault()):I.key==="Enter"&&(I.shiftKey?ie():ne())},[D,ne,ie]);y.useEffect(()=>()=>{P()},[P]);const[j,G]=y.useState(!1);y.useEffect(()=>{if(f)G(!0);else{const I=setTimeout(()=>G(!1),150);return()=>clearTimeout(I)}},[f]);const M=y.useMemo(()=>{if(!f&&!j)return null;let I;v!==void 0&&(I=v.results>=1e3?"over 1000":`${v.results} result${v.results!==1?"s":""}`,v.selectedIndex>=0&&(I=`${v.selectedIndex+1} of ${I}`));const $=W=>{W.stopPropagation()},Y={width:`${Math.floor(((v==null?void 0:v.rowsSearched)??0)/r*100)}%`};return y.createElement(o6,{className:f?"":"out",onMouseDown:$,onMouseMove:$,onMouseUp:$,onClick:$},y.createElement("div",{className:"gdg-search-bar-inner"},y.createElement("input",{id:h,"aria-hidden":!f,"data-testid":"search-input",ref:s,onChange:N,value:b,tabIndex:f?void 0:-1,onKeyDownCapture:V}),y.createElement("button",{"aria-label":"Previous Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:ie,disabled:((v==null?void 0:v.results)??0)===0},l6),y.createElement("button",{"aria-label":"Next Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:ne,disabled:((v==null?void 0:v.results)??0)===0},a6),d!==void 0&&y.createElement("button",{"aria-label":"Close Search","aria-hidden":!f,"data-testid":"search-close-button",tabIndex:f?void 0:-1,onClick:D},u6)),v!==void 0?y.createElement(y.Fragment,null,y.createElement("div",{className:"gdg-search-status"},y.createElement("div",{"data-testid":"search-result-area"},I)),y.createElement("div",{className:"gdg-search-progress",style:Y})):y.createElement("div",{className:"gdg-search-status"},y.createElement("label",{htmlFor:h},"Type to search")))},[f,j,v,r,h,s,N,b,V,ie,ne,d,D]);return y.createElement(y.Fragment,null,y.createElement(s6,{prelightCells:R,accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,className:t.className,clientSize:t.clientSize,columns:t.columns,disabledRows:t.disabledRows,enableGroups:t.enableGroups,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,nonGrowWidth:t.nonGrowWidth,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellContent:t.getCellContent,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,initialSize:t.initialSize,isFilling:t.isFilling,isFocused:t.isFocused,lockColumns:t.lockColumns,maxColumnWidth:t.maxColumnWidth,minColumnWidth:t.minColumnWidth,onHeaderMenuClick:t.onHeaderMenuClick,onMouseMove:t.onMouseMove,onVisibleRegionChanged:t.onVisibleRegionChanged,overscrollX:t.overscrollX,overscrollY:t.overscrollY,preventDiagonalScrolling:t.preventDiagonalScrolling,rightElement:t.rightElement,rightElementProps:t.rightElementProps,rowHeight:t.rowHeight,rows:t.rows,scrollRef:t.scrollRef,selection:t.selection,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,verticalBorder:t.verticalBorder,onColumnProposeMove:t.onColumnProposeMove,drawFocusRing:t.drawFocusRing,drawCell:t.drawCell,drawHeader:t.drawHeader,experimental:t.experimental,gridRef:t.gridRef,headerIcons:t.headerIcons,isDraggable:t.isDraggable,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onColumnMoved:t.onColumnMoved,onColumnResize:t.onColumnResize,onColumnResizeEnd:t.onColumnResizeEnd,onColumnResizeStart:t.onColumnResizeStart,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDragStart:t.onDragStart,onDrop:t.onDrop,onItemHovered:t.onItemHovered,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onRowMoved:t.onRowMoved,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY}),M)};class d6 extends y.PureComponent{constructor(){super(...arguments);St(this,"wrapperRef",y.createRef());St(this,"clickOutside",n=>{if(!(this.props.isOutsideClick&&!this.props.isOutsideClick(n))&&this.wrapperRef.current!==null&&!this.wrapperRef.current.contains(n.target)){let r=n.target;for(;r!==null;){if(r.classList.contains("click-outside-ignore"))return;r=r.parentElement}this.props.onClickOutside()}})}componentDidMount(){document.addEventListener("touchend",this.clickOutside,!0),document.addEventListener("mousedown",this.clickOutside,!0),document.addEventListener("contextmenu",this.clickOutside,!0)}componentWillUnmount(){document.removeEventListener("touchend",this.clickOutside,!0),document.removeEventListener("mousedown",this.clickOutside,!0),document.removeEventListener("contextmenu",this.clickOutside,!0)}render(){const{onClickOutside:n,isOutsideClick:r,...i}=this.props;return y.createElement("div",{...i,ref:this.wrapperRef},this.props.children)}}const h6=()=>t=>Math.max(16,t.targetHeight-10),p6=ii("input")({name:"RenameInput",class:"gdg-r17m35ur",propsAsIs:!1,vars:{"r17m35ur-0":[h6(),"px"]}}),g6=t=>{const{bounds:e,group:n,onClose:r,canvasBounds:i,onFinish:s}=t,[o,l]=Vn.useState(n);return Vn.createElement(d6,{style:{position:"absolute",left:e.x-i.left+1,top:e.y-i.top,width:e.width-2,height:e.height},className:"gdg-c1tqibwd",onClickOutside:r},Vn.createElement(p6,{targetHeight:e.height,"data-testid":"group-rename-input",value:o,onBlur:r,onFocus:a=>a.target.setSelectionRange(0,o.length),onChange:a=>l(a.target.value),onKeyDown:a=>{a.key==="Enter"?s(o):a.key==="Escape"&&r()},autoFocus:!0}))};function m6(t,e){return t===void 0?!1:t.length>1&&t.startsWith("_")?Number.parseInt(t.slice(1))===e.keyCode:t.length===1&&t>="a"&&t<="z"?t.toUpperCase().codePointAt(0)===e.keyCode:t===e.key}function xt(t,e,n){const r=VE(t,e);return r&&(n.didMatch=!0),r}function VE(t,e){if(t.length===0)return!1;if(t.includes("|")){const a=t.split("|");for(const u of a)if(VE(u,e))return!0;return!1}let n=!1,r=!1,i=!1,s=!1;const o=t.split("+"),l=o.pop();if(!m6(l,e))return!1;if(o[0]==="any")return!0;for(const a of o)switch(a){case"ctrl":n=!0;break;case"shift":r=!0;break;case"alt":i=!0;break;case"meta":s=!0;break;case"primary":zh.value?s=!0:n=!0;break}return e.altKey===i&&e.ctrlKey===n&&e.shiftKey===r&&e.metaKey===s}function y6(t,e,n,r,i,s){const o=Vn.useCallback((u,c,f,d)=>{var v;(s==="cell"||s==="multi-cell")&&u!==void 0&&(u={...u,range:{x:u.cell[0],y:u.cell[1],width:1,height:1}});const h=n==="mixed"&&(f||d==="drag"),p=r==="mixed"&&h,g=i==="mixed"&&h;let b={current:u===void 0?void 0:{...u,rangeStack:d==="drag"?((v=t.current)==null?void 0:v.rangeStack)??[]:[]},columns:p?t.columns:Pt.empty(),rows:g?t.rows:Pt.empty()};f&&(s==="multi-rect"||s==="multi-cell")&&b.current!==void 0&&t.current!==void 0&&(b={...b,current:{...b.current,rangeStack:[...t.current.rangeStack,t.current.range]}}),e(b,c)},[r,t,n,s,i,e]),l=Vn.useCallback((u,c,f)=>{u=u??t.rows,c!==void 0&&(u=u.add(c));let d;if(i==="exclusive"&&u.length>0)d={current:void 0,columns:Pt.empty(),rows:u};else{const h=f&&n==="mixed",p=f&&r==="mixed";d={current:h?t.current:void 0,columns:p?t.columns:Pt.empty(),rows:u}}e(d,!1)},[r,t,n,i,e]),a=Vn.useCallback((u,c,f)=>{u=u??t.columns,c!==void 0&&(u=u.add(c));let d;if(r==="exclusive"&&u.length>0)d={current:void 0,rows:Pt.empty(),columns:u};else{const h=f&&n==="mixed",p=f&&i==="mixed";d={current:h?t.current:void 0,rows:p?t.rows:Pt.empty(),columns:u}}e(d,!1)},[r,t,n,i,e]);return[o,l,a]}function v6(t,e,n,r,i){const s=y.useCallback(u=>{if(t===!0){const c=[];for(let f=u.y;f=i?d.push({kind:Ee.Loading,allowOverlay:!1}):d.push(e([h,f]));c.push(d)}return c}return(t==null?void 0:t(u,r.signal))??[]},[r.signal,e,t,i]),o=t!==void 0?s:void 0,l=y.useCallback(u=>{if(o===void 0)return[];const c={...u,x:u.x-n};if(c.x<0){c.x=0,c.width--;const f=o(c,r.signal);return typeof f=="function"?async()=>(await f()).map(d=>[{kind:Ee.Loading,allowOverlay:!1},...d]):f.map(d=>[{kind:Ee.Loading,allowOverlay:!1},...d])}return o(c,r.signal)},[r.signal,o,n]);return[t!==void 0?l:void 0,o]}function w6(t){if(t.copyData!==void 0)return{formatted:t.copyData,rawValue:t.copyData,format:"string"};switch(t.kind){case Ee.Boolean:return{formatted:t.data===!0?"TRUE":t.data===!1?"FALSE":t.data===qv?"INDETERMINATE":"",rawValue:t.data,format:"boolean"};case Ee.Custom:return{formatted:t.copyData,rawValue:t.copyData,format:"string"};case Ee.Image:case Ee.Bubble:return{formatted:t.data,rawValue:t.data,format:"string-array"};case Ee.Drilldown:return{formatted:t.data.map(e=>e.text),rawValue:t.data.map(e=>e.text),format:"string-array"};case Ee.Text:return{formatted:t.displayData??t.data,rawValue:t.data,format:"string"};case Ee.Uri:return{formatted:t.displayData??t.data,rawValue:t.data,format:"url"};case Ee.Markdown:case Ee.RowID:return{formatted:t.data,rawValue:t.data,format:"string"};case Ee.Number:return{formatted:t.displayData,rawValue:t.data,format:"number"};case Ee.Loading:return{formatted:"#LOADING",rawValue:"",format:"string"};case Ee.Protected:return{formatted:"************",rawValue:"",format:"string"};default:Hc()}}function b6(t,e){return t.map((r,i)=>{const s=e[i];return r.map(o=>o.span!==void 0&&o.span[0]!==s?{formatted:"",rawValue:"",format:"string"}:w6(o))})}function Bx(t,e){return(e?/[\t\n",]/:/[\t\n"]/).test(t)&&(t=`"${t.replace(/"/g,'""')}"`),t}function x6(t){var n;const e=[];for(const r of t){const i=[];for(const s of r)s.format==="url"?i.push(((n=s.rawValue)==null?void 0:n.toString())??""):s.format==="string-array"?i.push(s.formatted.map(o=>Bx(o,!0)).join(",")):i.push(Bx(s.formatted,!1));e.push(i.join(" "))}return e.join(` -`)}function sm(t){return t.replace(/\t/g," ").replace(/ {2,}/g,e=>" ".repeat(e.length))}function jx(t){return'"'+t.replace(/&/g,"&").replace(/"/g,""").replace(//g,">")+'"'}function k6(t){return t.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function S6(t){var n;const e=[];e.push('',"");for(const r of t){e.push("");for(const i of r){const s=`gdg-format="${i.format}"`;i.format==="url"?e.push(``):i.format==="string-array"?e.push(``):e.push(``)}e.push("")}return e.push("
    ${sm(i.formatted)}
      ${i.formatted.map((o,l)=>`
    1. `+sm(o)+"
    2. ").join("")}
    ${sm(i.formatted)}
    "),e.join("")}function C6(t,e){const n=b6(t,e),r=x6(n),i=S6(n);return{textPlain:r,textHtml:i}}function Hx(t){var o;const e=document.createElement("html");e.innerHTML=t.replace(/ /g," ");const n=e.querySelector("table");if(n===null)return;const r=[n],i=[];let s;for(;r.length>0;){const l=r.pop();if(l===void 0)break;if(l instanceof HTMLTableElement||l.nodeName==="TBODY")r.push(...[...l.children].reverse());else if(l instanceof HTMLTableRowElement)s!==void 0&&i.push(s),s=[],r.push(...[...l.children].reverse());else if(l instanceof HTMLTableCellElement){const a=l.cloneNode(!0),c=a.children.length===1&&a.children[0].nodeName==="P"?a.children[0]:null,f=(c==null?void 0:c.children.length)===1&&c.children[0].nodeName==="FONT",d=a.querySelectorAll("br");for(const g of d)g.replaceWith(` -`);const h=a.getAttribute("gdg-raw-value"),p=a.getAttribute("gdg-format")??"string";if(a.querySelector("a")!==null)s==null||s.push({rawValue:((o=a.querySelector("a"))==null?void 0:o.getAttribute("href"))??"",formatted:a.textContent??"",format:p});else if(a.querySelector("ol")!==null){const g=a.querySelectorAll("li");s==null||s.push({rawValue:[...g].map(b=>b.getAttribute("gdg-raw-value")??""),formatted:[...g].map(b=>b.textContent??""),format:"string-array"})}else if(h!==null)s==null||s.push({rawValue:k6(h),formatted:a.textContent??"",format:p});else{let g=a.textContent??"";f&&(g=g.replace(/\n(?!\n)/g,"")),s==null||s.push({rawValue:g??"",formatted:g??"",format:p})}}}return s!==void 0&&i.push(s),i}function T6(t,e,n,r,i){var l;const s=t;if(r==="allowPartial"||t.current===void 0||e===void 0)return t;let o=!1;do{if((t==null?void 0:t.current)===void 0)break;const a=(l=t.current)==null?void 0:l.range,u=[];if(a.width>2){const d=e({x:a.x,y:a.y,width:1,height:a.height},i.signal);if(typeof d=="function")return s;u.push(...d);const h=e({x:a.x+a.width-1,y:a.y,width:1,height:a.height},i.signal);if(typeof h=="function")return s;u.push(...h)}else{const d=e({x:a.x,y:a.y,width:a.width,height:a.height},i.signal);if(typeof d=="function")return s;u.push(...d)}let c=a.x-n,f=a.x+a.width-1-n;for(const d of u)for(const h of d)h.span!==void 0&&(c=Math.min(h.span[0],c),f=Math.max(h.span[1],f));c===a.x-n&&f===a.x+a.width-1-n?o=!0:t={current:{cell:t.current.cell??[0,0],range:{x:c+n,y:a.y,width:f-c+1,height:a.height},rangeStack:t.current.rangeStack},columns:t.columns,rows:t.rows}}while(!o);return t}function Wx(t){return t.startsWith('"')&&t.endsWith('"')&&(t=t.slice(1,-1).replace(/""/g,'"')),t}function E6(t){let e;(function(l){l[l.None=0]="None",l[l.inString=1]="inString",l[l.inStringPostQuote=2]="inStringPostQuote"})(e||(e={}));const n=[];let r=[],i=0,s=e.None;t=t.replace(/\r\n/g,` -`);let o=0;for(const l of t){switch(s){case e.None:l===" "||l===` -`?(r.push(t.slice(i,o)),i=o+1,l===` -`&&(n.push(r),r=[])):l==='"'&&(s=e.inString);break;case e.inString:l==='"'&&(s=e.inStringPostQuote);break;case e.inStringPostQuote:l==='"'?s=e.inString:((l===" "||l===` -`)&&(r.push(Wx(t.slice(i,o))),i=o+1,l===` -`&&(n.push(r),r=[])),s=e.None);break}o++}return il.map(a=>({rawValue:a,formatted:a,format:"string"})))}function Vx(t,e,n){var l;const r=C6(t,e),i=a=>{var u;(u=window.navigator.clipboard)==null||u.writeText(a)},s=(a,u)=>{var c;return((c=window.navigator.clipboard)==null?void 0:c.write)===void 0?!1:(window.navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([a],{type:"text/plain"}),"text/html":new Blob([u],{type:"text/html"})})]),!0)},o=(a,u)=>{var c,f;try{if(n===void 0||n.clipboardData===null)throw new Error("No clipboard data");(c=n==null?void 0:n.clipboardData)==null||c.setData("text/plain",a),(f=n==null?void 0:n.clipboardData)==null||f.setData("text/html",u)}catch{s(a,u)||i(a)}};((l=window.navigator.clipboard)==null?void 0:l.write)!==void 0||(n==null?void 0:n.clipboardData)!==void 0?o(r.textPlain,r.textHtml):i(r.textPlain),n==null||n.preventDefault()}function UE(t){return t!==!0}function Ux(t){return typeof t=="string"?t:`${t}px`}const A6=()=>t=>t.innerWidth,M6=()=>t=>t.innerHeight,R6=ii("div")({name:"Wrapper",class:"gdg-wmyidgi",propsAsIs:!1,vars:{"wmyidgi-0":[A6()],"wmyidgi-1":[M6()]}}),O6=t=>{const{inWidth:e,inHeight:n,children:r,...i}=t;return y.createElement(R6,{innerHeight:Ux(n),innerWidth:Ux(e),...i},r)},P6=2,I6=1300;function N6(t,e,n){const r=Vn.useRef(0),[i,s]=t??[0,0];Vn.useEffect(()=>{if(i===0&&s===0){r.current=0;return}let o=!1,l=0;const a=u=>{var c;if(!o){if(l===0)l=u;else{const f=u-l;r.current=Math.min(1,r.current+f/I6);const d=r.current**1.618*f*P6;(c=e.current)==null||c.scrollBy(i*d,s*d),l=u,n==null||n()}window.requestAnimationFrame(a)}};return window.requestAnimationFrame(a),()=>{o=!0}},[e,i,s,n])}function _6({rowHeight:t,headerHeight:e,groupHeaderHeight:n,theme:r,overscrollX:i,overscrollY:s,scaleToRem:o,remSize:l}){const[a,u,c,f,d,h]=Vn.useMemo(()=>{if(!o||l===16)return[t,e,n,r,i,s];const p=l/16,g=t,b=mE();return[typeof g=="number"?g*p:m=>Math.ceil(g(m)*p),Math.ceil(e*p),Math.ceil(n*p),{...r,headerIconSize:((r==null?void 0:r.headerIconSize)??b.headerIconSize)*p,cellHorizontalPadding:((r==null?void 0:r.cellHorizontalPadding)??b.cellHorizontalPadding)*p,cellVerticalPadding:((r==null?void 0:r.cellVerticalPadding)??b.cellVerticalPadding)*p},Math.ceil((i??0)*p),Math.ceil((s??0)*p)]},[n,e,i,s,l,t,o,r]);return{rowHeight:a,headerHeight:u,groupHeaderHeight:c,theme:f,overscrollX:d,overscrollY:h}}const co={downFill:!1,rightFill:!1,clear:!0,closeOverlay:!0,acceptOverlayDown:!0,acceptOverlayUp:!0,acceptOverlayLeft:!0,acceptOverlayRight:!0,copy:!0,paste:!0,cut:!0,search:!1,delete:!0,activateCell:!0,scrollToSelectedCell:!0,goToFirstCell:!0,goToFirstColumn:!0,goToFirstRow:!0,goToLastCell:!0,goToLastColumn:!0,goToLastRow:!0,goToNextPage:!0,goToPreviousPage:!0,selectToFirstCell:!0,selectToFirstColumn:!0,selectToFirstRow:!0,selectToLastCell:!0,selectToLastColumn:!0,selectToLastRow:!0,selectAll:!0,selectRow:!0,selectColumn:!0,goUpCell:!0,goRightCell:!0,goDownCell:!0,goLeftCell:!0,goUpCellRetainSelection:!0,goRightCellRetainSelection:!0,goDownCellRetainSelection:!0,goLeftCellRetainSelection:!0,selectGrowUp:!0,selectGrowRight:!0,selectGrowDown:!0,selectGrowLeft:!0};function kt(t,e){return t===!0?e:t===!1?"":t}function Kx(t){const e=zh.value;return{activateCell:kt(t.activateCell," |Enter|shift+Enter"),clear:kt(t.clear,"any+Escape"),closeOverlay:kt(t.closeOverlay,"any+Escape"),acceptOverlayDown:kt(t.acceptOverlayDown,"Enter"),acceptOverlayUp:kt(t.acceptOverlayUp,"shift+Enter"),acceptOverlayLeft:kt(t.acceptOverlayLeft,"shift+Tab"),acceptOverlayRight:kt(t.acceptOverlayRight,"Tab"),copy:t.copy,cut:t.cut,delete:kt(t.delete,e?"Backspace|Delete":"Delete"),downFill:kt(t.downFill,"primary+_68"),scrollToSelectedCell:kt(t.scrollToSelectedCell,"primary+Enter"),goDownCell:kt(t.goDownCell,"ArrowDown"),goDownCellRetainSelection:kt(t.goDownCellRetainSelection,"alt+ArrowDown"),goLeftCell:kt(t.goLeftCell,"ArrowLeft|shift+Tab"),goLeftCellRetainSelection:kt(t.goLeftCellRetainSelection,"alt+ArrowLeft"),goRightCell:kt(t.goRightCell,"ArrowRight|Tab"),goRightCellRetainSelection:kt(t.goRightCellRetainSelection,"alt+ArrowRight"),goUpCell:kt(t.goUpCell,"ArrowUp"),goUpCellRetainSelection:kt(t.goUpCellRetainSelection,"alt+ArrowUp"),goToFirstCell:kt(t.goToFirstCell,"primary+Home"),goToFirstColumn:kt(t.goToFirstColumn,"Home|primary+ArrowLeft"),goToFirstRow:kt(t.goToFirstRow,"primary+ArrowUp"),goToLastCell:kt(t.goToLastCell,"primary+End"),goToLastColumn:kt(t.goToLastColumn,"End|primary+ArrowRight"),goToLastRow:kt(t.goToLastRow,"primary+ArrowDown"),goToNextPage:kt(t.goToNextPage,"PageDown"),goToPreviousPage:kt(t.goToPreviousPage,"PageUp"),paste:t.paste,rightFill:kt(t.rightFill,"primary+_82"),search:kt(t.search,"primary+f"),selectAll:kt(t.selectAll,"primary+a"),selectColumn:kt(t.selectColumn,"ctrl+ "),selectGrowDown:kt(t.selectGrowDown,"shift+ArrowDown"),selectGrowLeft:kt(t.selectGrowLeft,"shift+ArrowLeft"),selectGrowRight:kt(t.selectGrowRight,"shift+ArrowRight"),selectGrowUp:kt(t.selectGrowUp,"shift+ArrowUp"),selectRow:kt(t.selectRow,"shift+ "),selectToFirstCell:kt(t.selectToFirstCell,"primary+shift+Home"),selectToFirstColumn:kt(t.selectToFirstColumn,"primary+shift+ArrowLeft"),selectToFirstRow:kt(t.selectToFirstRow,"primary+shift+ArrowUp"),selectToLastCell:kt(t.selectToLastCell,"primary+shift+End"),selectToLastColumn:kt(t.selectToLastColumn,"primary+shift+ArrowRight"),selectToLastRow:kt(t.selectToLastRow,"primary+shift+ArrowDown")}}function D6(t){const e=VF(t);return Vn.useMemo(()=>{if(e===void 0)return Kx(co);const n={...e,goToNextPage:(e==null?void 0:e.goToNextPage)??(e==null?void 0:e.pageDown)??co.goToNextPage,goToPreviousPage:(e==null?void 0:e.goToPreviousPage)??(e==null?void 0:e.pageUp)??co.goToPreviousPage,goToFirstCell:(e==null?void 0:e.goToFirstCell)??(e==null?void 0:e.first)??co.goToFirstCell,goToLastCell:(e==null?void 0:e.goToLastCell)??(e==null?void 0:e.last)??co.goToLastCell,selectToFirstCell:(e==null?void 0:e.selectToFirstCell)??(e==null?void 0:e.first)??co.selectToFirstCell,selectToLastCell:(e==null?void 0:e.selectToLastCell)??(e==null?void 0:e.last)??co.selectToLastCell};return Kx({...co,...n})},[e])}const L6=y.lazy(async()=>await vE(()=>import("./data-grid-overlay-editor-C3DdHprK.js"),[]));let $6=0;function F6(t){return j5(fx(fx(t).filter(e=>e.span!==void 0).map(e=>{var n,r;return hl((((n=e.span)==null?void 0:n[0])??0)+1,(((r=e.span)==null?void 0:r[1])??0)+1)})))}function od(t,e){return t===void 0||e===0||t.columns.length===0&&t.current===void 0?t:{current:t.current===void 0?void 0:{cell:[t.current.cell[0]+e,t.current.cell[1]],range:{...t.current.range,x:t.current.range.x+e},rangeStack:t.current.rangeStack.map(n=>({...n,x:n.x+e}))},rows:t.rows,columns:t.columns.offset(e)}}const om={kind:Ee.Loading,allowOverlay:!1},ld={columns:Pt.empty(),rows:Pt.empty(),current:void 0},z6=(t,e)=>{var r1,i1,s1;const[n,r]=y.useState(ld),[i,s]=y.useState(),o=y.useRef(null),l=y.useRef(null),[a,u]=y.useState(),c=y.useRef(null),f=y.useRef(),d=typeof window>"u"?null:window,{imageEditorOverride:h,getRowThemeOverride:p,markdownDivCreateNode:g,width:b,height:m,columns:v,rows:w,getCellContent:k,onCellClicked:x,onCellActivated:C,onFillPattern:T,onFinishedEditing:A,coercePasteValue:R,drawHeader:P,drawCell:_,editorBloom:O,onHeaderClicked:D,onColumnProposeMove:N,spanRangeBehavior:ne="default",onGroupHeaderClicked:ie,onCellContextMenu:V,className:j,onHeaderContextMenu:G,getCellsForSelection:M,onGroupHeaderContextMenu:I,onGroupHeaderRenamed:$,onCellEdited:B,onCellsEdited:Y,onSearchResultsChanged:W,searchResults:de,onSearchValueChange:le,searchValue:ge,onKeyDown:$e,onKeyUp:ke,keybindings:ye,editOnType:lt=!0,onRowAppended:Fe,onColumnMoved:He,validateCell:be,highlightRegions:Rt,rangeSelect:me="rect",columnSelect:Se="multi",rowSelect:Pe="multi",rangeSelectionBlending:Xe="exclusive",columnSelectionBlending:rt="exclusive",rowSelectionBlending:_e="exclusive",onDelete:yt,onDragStart:We,onMouseMove:it,onPaste:pe,copyHeaders:at=!1,freezeColumns:dt=0,cellActivationBehavior:Ge="second-click",rowSelectionMode:on="auto",onHeaderMenuClick:vt,getGroupDetails:Be,onSearchClose:ht,onItemHovered:Gt,onSelectionCleared:Zt,showSearch:Bn,onVisibleRegionChanged:Yn,gridSelection:Ht,onGridSelectionChange:jn,minColumnWidth:zt=50,maxColumnWidth:Ln=500,maxColumnAutoWidth:Br,provideEditor:$t,trailingRowOptions:et,freezeTrailingRows:ft=0,allowedFillDirections:Wt="orthogonal",scrollOffsetX:qt,scrollOffsetY:ln,verticalBorder:kn,onDragOverCell:Jn,onDrop:gt,onColumnResize:Bt,onColumnResizeEnd:J,onColumnResizeStart:Me,customRenderers:ze,fillHandle:It,drawFocusRing:Yt=!0,experimental:Jt,fixedShadowX:jl,fixedShadowY:ts,headerIcons:Ci,imageWindowLoader:Ti,initialSize:ns,isDraggable:Hl,onDragLeave:Wl,onRowMoved:si,overscrollX:Js,overscrollY:Qs,preventDiagonalScrolling:Zs,rightElement:z,rightElementProps:re,trapFocus:Q=!1,smoothScrollX:he,smoothScrollY:ve,scaleToRem:mt=!1,rowHeight:je=34,headerHeight:ut=36,groupHeaderHeight:ct=ut,theme:Vt,isOutsideClick:en,renderers:$n}=t,tn=typeof t.rowMarkers=="string"?void 0:t.rowMarkers,vn=(tn==null?void 0:tn.kind)??t.rowMarkers??"none",vr=(tn==null?void 0:tn.width)??t.rowMarkerWidth,eo=(tn==null?void 0:tn.startIndex)??t.rowMarkerStartIndex??1,Ei=(tn==null?void 0:tn.theme)??t.rowMarkerTheme,Ai=(tn==null?void 0:tn.checkboxStyle)??"square",sr=Math.max(zt,20),Mi=Math.max(Ln,sr),pu=Math.max(Br??Mi,sr),to=y.useMemo(()=>typeof window>"u"?{fontSize:"16px"}:window.getComputedStyle(document.documentElement),[]),gu=y.useMemo(()=>Number.parseFloat(to.fontSize),[to]),{rowHeight:wr,headerHeight:Vl,groupHeaderHeight:mu,theme:xf,overscrollX:Qp,overscrollY:kf}=_6({groupHeaderHeight:ct,headerHeight:ut,overscrollX:Js,overscrollY:Qs,remSize:gu,rowHeight:je,scaleToRem:mt,theme:Vt}),Ri=D6(ye),Os=vr??(w>1e4?48:w>1e3?44:w>100?36:32),jr=vn!=="none",X=jr?1:0,gn=Fe!==void 0,Yo=(et==null?void 0:et.sticky)===!0,[Zp,Sf]=y.useState(!1),yu=Bn??Zp,eg=y.useCallback(()=>{ht!==void 0?ht():Sf(!1)},[ht]),Z=y.useMemo(()=>Ht===void 0?void 0:od(Ht,X),[Ht,X])??n,or=y.useRef();or.current===void 0&&(or.current=new AbortController),y.useEffect(()=>()=>or==null?void 0:or.current.abort(),[]);const[Fn,Ul]=v6(M,k,X,or.current,w),vu=y.useCallback((S,F,L)=>{if(be===void 0)return!0;const U=[S[0]-X,S[1]];return be==null?void 0:be(U,F,L)},[X,be]),no=y.useRef(Ht),Rr=y.useCallback((S,F)=>{F&&(S=T6(S,Fn,X,ne,or.current)),jn!==void 0?(no.current=od(S,-X),jn(no.current)):r(S)},[jn,Fn,X,ne]),Oi=ta(Bt,y.useCallback((S,F,L,U)=>{Bt==null||Bt(v[L-X],F,L-X,U)},[Bt,X,v])),tg=ta(J,y.useCallback((S,F,L,U)=>{J==null||J(v[L-X],F,L-X,U)},[J,X,v])),Kl=ta(Me,y.useCallback((S,F,L,U)=>{Me==null||Me(v[L-X],F,L-X,U)},[Me,X,v])),ng=ta(P,y.useCallback((S,F)=>(P==null?void 0:P({...S,columnIndex:S.columnIndex-X},F))??!1,[P,X])),rg=ta(_,y.useCallback((S,F)=>(_==null?void 0:_({...S,col:S.col-X},F))??!1,[_,X])),H=y.useCallback(S=>{if(yt!==void 0){const F=yt(od(S,-X));return typeof F=="boolean"?F:od(F,X)}return!0},[yt,X]),[oe,Ce,we]=y6(Z,Rr,Xe,rt,_e,me),ue=y.useMemo(()=>Lo(mE(),xf),[xf]),[Ie,st]=y.useState([0,0,0]),ot=y.useMemo(()=>{if($n===void 0)return{};const S={};for(const F of $n)S[F.kind]=F;return S},[$n]),Re=y.useCallback(S=>S.kind!==Ee.Custom?ot[S.kind]:ze==null?void 0:ze.find(F=>F.isMatch(S)),[ze,ot]);let{sizedColumns:Lt,nonGrowWidth:Ve}=z4(v,w,Ul,Ie[0]-(X===0?0:Os)-Ie[2],sr,pu,ue,Re,or.current);vn!=="none"&&(Ve+=Os);const jt=y.useMemo(()=>Lt.some(S=>S.group!==void 0),[Lt]),pt=jt?Vl+mu:Vl,Tt=Z.rows.length,Rn=vn==="none"?void 0:Tt===0?!1:Tt===w?!0:void 0,wt=y.useMemo(()=>vn==="none"?Lt:[{title:"",width:Os,icon:void 0,hasMenu:!1,style:"normal",themeOverride:Ei,rowMarker:Ai,rowMarkerChecked:Rn},...Lt],[vn,Lt,Os,Ei,Ai,Rn]),[Sn,oi]=y.useMemo(()=>[ln!==void 0&&typeof wr=="number"?Math.floor(ln/wr):0,ln!==void 0&&typeof wr=="number"?-(ln%wr):0],[ln,wr]),mn=y.useRef({height:1,width:1,x:0,y:0}),Hr=y.useMemo(()=>({x:mn.current.x,y:Sn,width:mn.current.width??1,height:mn.current.height??1,ty:oi}),[oi,Sn]),Nt=y.useRef(!1),[On,Wr,rs]=WF(Hr);mn.current=On;const Pi=(On.height??1)>1;y.useLayoutEffect(()=>{if(ln!==void 0&&c.current!==null&&Pi){if(c.current.scrollTop===ln)return;c.current.scrollTop=ln,c.current.scrollTop!==ln&&rs(),Nt.current=!0}},[ln,Pi,rs]);const Xl=(On.width??1)>1;y.useLayoutEffect(()=>{if(qt!==void 0&&c.current!==null&&Xl){if(c.current.scrollLeft===qt)return;c.current.scrollLeft=qt,c.current.scrollLeft!==qt&&rs(),Nt.current=!0}},[qt,Xl,rs]);const Jo=On.x+X,Cf=On.y,Or=y.useRef(null),br=y.useCallback(S=>{var F;S===!0?(F=Or.current)==null||F.focus():window.requestAnimationFrame(()=>{var L;(L=Or.current)==null||L.focus()})},[]),lr=gn?w+1:w,li=y.useCallback(S=>{const F=X===0?S:S.map(U=>({...U,location:[U.location[0]-X,U.location[1]]})),L=Y==null?void 0:Y(F);if(L!==!0)for(const U of F)B==null||B(U.location,U.value);return L},[B,Y,X]),[Qo,ig]=y.useState(),Tf=Z.current!==void 0&&Z.current.range.width*Z.current.range.height>1?Z.current.range:void 0,Gl=Yt?(r1=Z.current)==null?void 0:r1.cell:void 0,Ef=Gl==null?void 0:Gl[0],Af=Gl==null?void 0:Gl[1],RR=y.useMemo(()=>{if((Rt===void 0||Rt.length===0)&&(Tf??Ef??Af??Qo)===void 0)return;const S=[];if(Rt!==void 0)for(const F of Rt){const L=wt.length-F.range.x-X;L>0&&S.push({color:F.color,range:{...F.range,x:F.range.x+X,width:Math.min(L,F.range.width)},style:F.style})}return Qo!==void 0&&S.push({color:Ol(ue.accentColor,0),range:Qo,style:"dashed"}),Tf!==void 0&&S.push({color:Ol(ue.accentColor,.5),range:Tf,style:"solid-outline"}),Ef!==void 0&&Af!==void 0&&S.push({color:ue.accentColor,range:{x:Ef,y:Af,width:1,height:1},style:"solid-outline"}),S.length>0?S:void 0},[Qo,Tf,Ef,Af,Rt,wt.length,ue.accentColor,X]),Vw=y.useRef(wt);Vw.current=wt;const Vr=y.useCallback(([S,F],L=!1)=>{var te,q,ee,ae,se,Ae,Ne;const U=gn&&F===lr-1;if(S===0&&jr)return U?om:{kind:hi.Marker,allowOverlay:!1,checkboxStyle:Ai,checked:(Z==null?void 0:Z.rows.hasIndex(F))===!0,markerKind:vn==="clickable-number"?"number":vn,row:eo+F,drawHandle:si!==void 0,cursor:vn==="clickable-number"?"pointer":void 0};if(U){const qe=S===X?(et==null?void 0:et.hint)??"":"",Qe=Vw.current[S];if(((te=Qe==null?void 0:Qe.trailingRowOptions)==null?void 0:te.disabled)===!0)return om;{const Ot=((q=Qe==null?void 0:Qe.trailingRowOptions)==null?void 0:q.hint)??qe,tt=((ee=Qe==null?void 0:Qe.trailingRowOptions)==null?void 0:ee.addIcon)??(et==null?void 0:et.addIcon);return{kind:hi.NewRow,hint:Ot,allowOverlay:!1,icon:tt}}}else{const Te=S-X;if(L||(Jt==null?void 0:Jt.strict)===!0){const Qe=mn.current,Ot=Qe.x>Te||Te>Qe.x+Qe.width||Qe.y>F||F>Qe.y+Qe.height||F>=og.current,tt=Te===((se=(ae=Qe.extras)==null?void 0:ae.selected)==null?void 0:se[0])&&F===((Ae=Qe.extras)==null?void 0:Ae.selected[1]);let Ke=!1;if(((Ne=Qe.extras)==null?void 0:Ne.freezeRegions)!==void 0){for(const an of Qe.extras.freezeRegions)if(Fp(an,Te,F)){Ke=!0;break}}if(Ot&&!tt&&!Ke)return om}let qe=k([Te,F]);return X!==0&&qe.span!==void 0&&(qe={...qe,span:[qe.span[0]+X,qe.span[1]+X]}),qe}},[gn,lr,jr,Ai,Z==null?void 0:Z.rows,vn,eo,si,X,et==null?void 0:et.hint,et==null?void 0:et.addIcon,Jt==null?void 0:Jt.strict,k]),sg=y.useCallback(S=>{let F=(Be==null?void 0:Be(S))??{name:S};return $!==void 0&&S!==""&&(F={icon:F.icon,name:F.name,overrideTheme:F.overrideTheme,actions:[...F.actions??[],{title:"Rename",icon:"renameIcon",onClick:L=>ag({group:F.name,bounds:L.bounds})}]}),F},[Be,$]),Mf=y.useCallback(S=>{var ee;const[F,L]=S.cell,U=wt[F],K=(U==null?void 0:U.group)!==void 0?(ee=sg(U.group))==null?void 0:ee.overrideTheme:void 0,te=U==null?void 0:U.themeOverride,q=p==null?void 0:p(L);s({...S,theme:Lo(ue,K,te,q,S.content.themeOverride)})},[p,wt,sg,ue]),ql=y.useCallback((S,F,L)=>{var q;if(Z.current===void 0)return;const[U,K]=Z.current.cell,te=Vr([U,K]);if(te.kind!==Ee.Boolean&&te.allowOverlay){let ee=te;if(L!==void 0)switch(ee.kind){case Ee.Number:{const ae=C_(()=>L==="-"?-0:Number.parseFloat(L),0);ee={...ee,data:Number.isNaN(ae)?0:ae};break}case Ee.Text:case Ee.Markdown:case Ee.Uri:ee={...ee,data:L};break}Mf({target:S,content:ee,initialValue:L,cell:[U,K],highlight:L===void 0,forceEditMode:L!==void 0})}else te.kind===Ee.Boolean&&F&&te.readonly!==!0&&(li([{location:Z.current.cell,value:{...te,data:UE(te.data)}}]),(q=Or.current)==null||q.damage([{cell:Z.current.cell}]))},[Vr,Z,li,Mf]),Uw=y.useCallback((S,F)=>{var K;const L=(K=Or.current)==null?void 0:K.getBounds(S,F);if(L===void 0||c.current===null)return;const U=Vr([S,F]);U.allowOverlay&&Mf({target:L,content:U,initialValue:void 0,highlight:!0,cell:[S,F],forceEditMode:!0})},[Vr,Mf]),Pn=y.useCallback((S,F,L="both",U=0,K=0,te=void 0)=>{if(c.current!==null){const q=Or.current,ee=l.current,ae=typeof S!="number"?S.unit==="cell"?S.amount:void 0:S,se=typeof F!="number"?F.unit==="cell"?F.amount:void 0:F,Ae=typeof S!="number"&&S.unit==="px"?S.amount:void 0,Ne=typeof F!="number"&&F.unit==="px"?F.amount:void 0;if(q!==null&&ee!==null){let Te={x:0,y:0,width:0,height:0},qe=0,Qe=0;if((ae!==void 0||se!==void 0)&&(Te=q.getBounds((ae??0)+X,se??0)??Te,Te.width===0||Te.height===0))return;const Ot=ee.getBoundingClientRect(),tt=Ot.width/ee.offsetWidth;if(Ae!==void 0&&(Te={...Te,x:Ae-Ot.left-c.current.scrollLeft,width:1}),Ne!==void 0&&(Te={...Te,y:Ne+Ot.top-c.current.scrollTop,height:1}),Te!==void 0){const Ke={x:Te.x-U,y:Te.y-K,width:Te.width+2*U,height:Te.height+2*K};let an=0;for(let pg=0;pg0&&(ar=Bl(lr,In,wr));let Ni=an*tt+Ot.left+X*Os*tt,ss=Ot.right,_i=Ot.top+pt*tt,os=Ot.bottom-ar*tt;const _f=Te.width+U*2;switch(te==null?void 0:te.hAlign){case"start":ss=Ni+_f;break;case"end":Ni=ss-_f;break;case"center":Ni=Math.floor((Ni+ss)/2)-_f/2,ss=Ni+_f;break}const Df=Te.height+K*2;switch(te==null?void 0:te.vAlign){case"start":os=_i+Df;break;case"end":_i=os-Df;break;case"center":_i=Math.floor((_i+os)/2)-Df/2,os=_i+Df;break}Ni>Ke.x?qe=Ke.x-Ni:ssKe.y?Qe=Ke.y-_i:os=lr-In)&&(Qe=0),(qe!==0||Qe!==0)&&(tt!==1&&(qe/=tt,Qe/=tt),c.current.scrollTo(qe+c.current.scrollLeft,Qe+c.current.scrollTop))}}}},[X,ft,Os,pt,dt,Lt,lr,Yo,wr]),Kw=y.useRef(Uw),Xw=y.useRef(k),og=y.useRef(w);Kw.current=Uw,Xw.current=k,og.current=w;const Yl=y.useCallback(async(S,F=!0)=>{var ae;const L=wt[S];if(((ae=L==null?void 0:L.trailingRowOptions)==null?void 0:ae.disabled)===!0)return;const U=Fe==null?void 0:Fe();let K,te=!0;U!==void 0&&(K=await U,K==="top"&&(te=!1),typeof K=="number"&&(te=!1));let q=0;const ee=()=>{if(og.current<=w){q<500&&window.setTimeout(ee,q),q=50+q*2;return}const se=typeof K=="number"?K:te?w:0;Nf.current(S-X,se),oe({cell:[S,se],range:{x:S,y:se,width:1,height:1}},!1,!1,"edit");const Ae=Xw.current([S-X,se]);Ae.allowOverlay&&Ju(Ae)&&Ae.readonly!==!0&&F&&window.setTimeout(()=>{Kw.current(S,se)},0)};ee()},[wt,Fe,X,w,oe]),Rf=y.useCallback(S=>{var L,U;const F=((U=(L=Lt[S])==null?void 0:L.trailingRowOptions)==null?void 0:U.targetColumn)??(et==null?void 0:et.targetColumn);if(typeof F=="number")return F+(jr?1:0);if(typeof F=="object"){const K=v.indexOf(F);if(K>=0)return K+(jr?1:0)}},[Lt,v,jr,et==null?void 0:et.targetColumn]),ro=y.useRef(),Jl=y.useRef(),wu=y.useCallback((S,F)=>{var K;const[L,U]=F;return Lo(ue,(K=wt[L])==null?void 0:K.themeOverride,p==null?void 0:p(U),S.themeOverride)},[p,wt,ue]),bu=y.useCallback(S=>{var Ae,Ne,Te;const F=zh.value?S.metaKey:S.ctrlKey,L=F&&Pe==="multi",U=F&&Se==="multi",[K,te]=S.location,q=Z.columns,ee=Z.rows,[ae,se]=((Ae=Z.current)==null?void 0:Ae.cell)??[];if(S.kind==="cell"){if(Jl.current=void 0,Zo.current=[K,te],K===0&&jr){if(gn===!0&&te===w||vn==="number"||Pe==="none")return;const qe=Vr(S.location);if(qe.kind!==hi.Marker)return;if(si!==void 0){const tt=Re(qe);Yr((tt==null?void 0:tt.kind)===hi.Marker);const Ke=(Ne=tt==null?void 0:tt.onClick)==null?void 0:Ne.call(tt,{...S,cell:qe,posX:S.localEventX,posY:S.localEventY,bounds:S.bounds,theme:wu(qe,S.location),preventDefault:()=>{}});if(Ke===void 0||Ke.checked===qe.checked)return}s(void 0),br();const Qe=ee.hasIndex(te),Ot=ro.current;if(Pe==="multi"&&(S.shiftKey||S.isLongTouch===!0)&&Ot!==void 0&&ee.hasIndex(Ot)){const tt=[Math.min(Ot,te),Math.max(Ot,te)+1];L||on==="multi"?Ce(void 0,tt,!0):Ce(Pt.fromSingleSelection(tt),void 0,L)}else L||S.isTouch||on==="multi"?Qe?Ce(ee.remove(te),void 0,!0):(Ce(void 0,te,!0),ro.current=te):Qe&&ee.length===1?Ce(Pt.empty(),void 0,F):(Ce(Pt.fromSingleSelection(te),void 0,F),ro.current=te)}else if(K>=X&&gn&&te===w){const qe=Rf(K);Yl(qe??K)}else if(ae!==K||se!==te){const qe=Vr(S.location),Qe=Re(qe);if((Qe==null?void 0:Qe.onSelect)!==void 0){let Ke=!1;if(Qe.onSelect({...S,cell:qe,posX:S.localEventX,posY:S.localEventY,bounds:S.bounds,preventDefault:()=>Ke=!0,theme:wu(qe,S.location)}),Ke)return}const Ot=Yo&&te===w,tt=Yo&&Z!==void 0&&((Te=Z.current)==null?void 0:Te.cell[1])===w;if((S.shiftKey||S.isLongTouch===!0)&&ae!==void 0&&se!==void 0&&Z.current!==void 0&&!tt){if(Ot)return;const Ke=Math.min(K,ae),an=Math.max(K,ae),ar=Math.min(te,se),In=Math.max(te,se);oe({...Z.current,range:{x:Ke,y:ar,width:an-Ke+1,height:In-ar+1}},!0,F,"click"),ro.current=void 0,br()}else oe({cell:[K,te],range:{x:K,y:te,width:1,height:1}},!0,F,"click"),ro.current=void 0,s(void 0),br()}}else if(S.kind==="header")if(Zo.current=[K,te],s(void 0),jr&&K===0)ro.current=void 0,Jl.current=void 0,Pe==="multi"&&(ee.length!==w?Ce(Pt.fromSingleSelection([0,w]),void 0,F):Ce(Pt.empty(),void 0,F),br());else{const qe=Jl.current;if(Se==="multi"&&(S.shiftKey||S.isLongTouch===!0)&&qe!==void 0&&q.hasIndex(qe)){const Qe=[Math.min(qe,K),Math.max(qe,K)+1];U?we(void 0,Qe,F):we(Pt.fromSingleSelection(Qe),void 0,F)}else U?(q.hasIndex(K)?we(q.remove(K),void 0,F):we(void 0,K,F),Jl.current=K):Se!=="none"&&(we(Pt.fromSingleSelection(K),void 0,F),Jl.current=K);ro.current=void 0,br()}else S.kind===qr?Zo.current=[K,te]:S.kind===Bh&&!S.isMaybeScrollbar&&(Rr(ld,!1),s(void 0),br(),Zt==null||Zt(),ro.current=void 0,Jl.current=void 0)},[Yl,Se,br,Re,Rf,Vr,Z,jr,Yo,Zt,si,X,vn,Pe,on,w,oe,Rr,we,Ce,gn,wu]),xu=y.useRef(!1),Zo=y.useRef(),Gw=y.useRef(On),ai=y.useRef(),OR=y.useCallback(S=>{if(Ql.current=!1,Gw.current=mn.current,S.button!==0&&S.button!==1){ai.current=void 0;return}const F=performance.now();ai.current={button:S.button,time:F,location:S.location},(S==null?void 0:S.kind)==="header"&&(xu.current=!0);const L=S.kind==="cell"&&S.isFillHandle;!L&&S.kind!=="cell"&&S.isEdge||(u({previousSelection:Z,fillHandle:L}),Zo.current=void 0,!S.isTouch&&S.button===0&&!L?bu(S):!S.isTouch&&S.button===1&&(Zo.current=S.location))},[Z,bu]),[lg,ag]=y.useState(),qw=y.useCallback(S=>{if(S.kind!==qr||Se!=="multi")return;const F=zh.value?S.metaKey:S.ctrlKey,[L]=S.location,U=Z.columns;if(L=X&&Wc(K.group,wt[ee].group);ee--)te--;for(let ee=L+1;ee{if(Fn!==void 0&&Oi!==void 0){const F=mn.current.y,L=mn.current.height;let U=Fn({x:S,y:F,width:1,height:Math.min(L,w-F)},or.current.signal);typeof U!="object"&&(U=await U());const K=Lt[S-X],q=document.createElement("canvas").getContext("2d",{alpha:!1});if(q!==null){q.font=ue.baseFontFull;const ee=yE(q,ue,K,0,U,sr,Mi,!1,Re);Oi==null||Oi(K,ee.width,S,ee.width)}}},[Lt,Fn,Mi,ue,sr,Oi,X,w,Re]),[PR,ug]=y.useState(),Zl=y.useCallback(async(S,F)=>{var ee,ae;const L=(ee=S.current)==null?void 0:ee.range;if(L===void 0||Fn===void 0||F.current===void 0)return;const U=F.current.range;if(T!==void 0){let se=!1;if(T({fillDestination:{...U,x:U.x-X},patternSource:{...L,x:L.x-X},preventDefault:()=>se=!0}),se)return}let K=Fn(L,or.current.signal);typeof K!="object"&&(K=await K());const te=K,q=[];for(let se=0;se({cell:se.location})))},[Fn,li,T,X]),Yw=y.useCallback(()=>{if(Z.current===void 0||Z.current.range.width<=1)return;const S={...Z,current:{...Z.current,range:{...Z.current.range,width:1}}};Zl(S,Z)},[Zl,Z]),Jw=y.useCallback(()=>{if(Z.current===void 0||Z.current.range.height<=1)return;const S={...Z,current:{...Z.current,range:{...Z.current.range,height:1}}};Zl(S,Z)},[Zl,Z]),IR=y.useCallback((S,F)=>{var Ae,Ne;const L=a;if(u(void 0),ig(void 0),ug(void 0),xu.current=!1,F)return;if((L==null?void 0:L.fillHandle)===!0&&Z.current!==void 0&&((Ae=L.previousSelection)==null?void 0:Ae.current)!==void 0){if(Qo===void 0)return;const Te={...Z,current:{...Z.current,range:AE(L.previousSelection.current.range,Qo)}};Zl(L.previousSelection,Te),Rr(Te,!0);return}const[U,K]=S.location,[te,q]=Zo.current??[],ee=()=>{Ql.current=!0},ae=Te=>{var Qe,Ot,tt;const qe=Te.isTouch||te===U&&q===K;if(qe&&(x==null||x([U-X,K],{...Te,preventDefault:ee})),Te.button===1)return!Ql.current;if(!Ql.current){const Ke=Vr(S.location),an=Re(Ke);if(an!==void 0&&an.onClick!==void 0&&qe){const In=an.onClick({...Te,cell:Ke,posX:Te.localEventX,posY:Te.localEventY,bounds:Te.bounds,theme:wu(Ke,S.location),preventDefault:ee});In!==void 0&&!wa(In)&&ia(In)&&(li([{location:Te.location,value:In}]),(Qe=Or.current)==null||Qe.damage([{cell:Te.location}]))}if(Ql.current||Z.current===void 0)return!1;let ar=!1;switch(Ke.activationBehaviorOverride??Ge){case"double-click":case"second-click":{if(((tt=(Ot=L==null?void 0:L.previousSelection)==null?void 0:Ot.current)==null?void 0:tt.cell)===void 0)break;const[In,Ni]=Z.current.cell,[ss,_i]=L.previousSelection.current.cell;ar=U===In&&U===ss&&K===Ni&&K===_i&&(Te.isDoubleClick===!0||Ge==="second-click");break}case"single-click":{ar=!0;break}}if(ar)return C==null||C([U-X,K]),ql(Te.bounds,!1),!0}return!1},se=S.location[0]-X;if(S.isTouch){const Te=mn.current,qe=Gw.current;if(Te.x!==qe.x||Te.y!==qe.y)return;if(S.isLongTouch===!0){if(S.kind==="cell"&&hc((Ne=Z.current)==null?void 0:Ne.cell,S.location)){V==null||V([se,S.location[1]],{...S,preventDefault:ee});return}else if(S.kind==="header"&&Z.columns.hasIndex(U)){G==null||G(se,{...S,preventDefault:ee});return}else if(S.kind===qr){if(se<0)return;I==null||I(se,{...S,preventDefault:ee});return}}S.kind==="cell"?ae(S)||bu(S):S.kind===qr?ie==null||ie(se,{...S,preventDefault:ee}):(S.kind===po&&(D==null||D(se,{...S,preventDefault:ee})),bu(S));return}if(S.kind==="header"){if(se<0)return;S.isEdge?S.isDoubleClick===!0&&Of(U):S.button===0&&U===te&&K===q&&(D==null||D(se,{...S,preventDefault:ee}))}if(S.kind===qr){if(se<0)return;S.button===0&&U===te&&K===q&&(ie==null||ie(se,{...S,preventDefault:ee}),Ql.current||qw(S))}S.kind==="cell"&&(S.button===0||S.button===1)&&ae(S),Zo.current=void 0},[a,Z,X,Qo,Zl,Rr,x,Vr,Re,Ge,wu,li,C,ql,V,G,I,bu,ie,D,Of,qw]),NR=y.useCallback(S=>{const F={...S,location:[S.location[0]-X,S.location[1]]};it==null||it(F),a!==void 0&&S.buttons===0&&(u(void 0),ig(void 0),ug(void 0),xu.current=!1),ug(L=>{var U;return xu.current?[S.scrollEdge[0],0]:S.scrollEdge[0]===(L==null?void 0:L[0])&&S.scrollEdge[1]===L[1]?L:a===void 0||(((U=ai.current)==null?void 0:U.location[0])??0){vt==null||vt(S-X,F)},[vt,X]),is=(i1=Z==null?void 0:Z.current)==null?void 0:i1.cell,DR=y.useCallback((S,F,L,U,K,te)=>{Nt.current=!1;let q=is;q!==void 0&&(q=[q[0]-X,q[1]]);const ee=dt===0?void 0:{x:0,y:S.y,width:dt,height:S.height},ae=[];ee!==void 0&&ae.push(ee),ft>0&&(ae.push({x:S.x-X,y:w-ft,width:S.width,height:ft}),dt>0&&ae.push({x:0,y:w-ft,width:dt,height:ft}));const se={x:S.x-X,y:S.y,width:S.width,height:gn&&S.y+S.height>=w?S.height-1:S.height,tx:K,ty:te,extras:{selected:q,freezeRegion:ee,freezeRegions:ae}};mn.current=se,Wr(se),st([F,L,U]),Yn==null||Yn(se,se.tx,se.ty,se.extras)},[is,X,gn,w,dt,ft,Wr,Yn]),LR=ta(He,y.useCallback((S,F)=>{He==null||He(S-X,F-X),Se!=="none"&&we(Pt.fromSingleSelection(F),void 0,!0)},[Se,He,X,we])),cg=y.useRef(!1),$R=y.useCallback(S=>{if(S.location[0]===0&&X>0){S.preventDefault();return}We==null||We({...S,location:[S.location[0]-X,S.location[1]]}),S.defaultPrevented()||(cg.current=!0),u(void 0)},[We,X]),FR=y.useCallback(()=>{cg.current=!1},[]),fg=y.useRef(),dg=y.useCallback(S=>{var F,L,U;if(!WE(S,fg.current)&&(fg.current=S,!(((F=ai==null?void 0:ai.current)==null?void 0:F.button)!==void 0&&ai.current.button>=1))){if(S.buttons!==0&&a!==void 0&&((L=ai.current)==null?void 0:L.location[0])===0&&S.location[0]===0&&X===1&&Pe==="multi"&&a.previousSelection&&!a.previousSelection.rows.hasIndex(ai.current.location[1])&&Z.rows.hasIndex(ai.current.location[1])){const K=Math.min(ai.current.location[1],S.location[1]),te=Math.max(ai.current.location[1],S.location[1])+1;Ce(Pt.fromSingleSelection([K,te]),void 0,!1)}if(S.buttons!==0&&a!==void 0&&Z.current!==void 0&&!cg.current&&!xu.current&&(me==="rect"||me==="multi-rect")){const[K,te]=Z.current.cell;let[q,ee]=S.location;if(ee<0&&(ee=mn.current.y),a.fillHandle===!0&&((U=a.previousSelection)==null?void 0:U.current)!==void 0){const ae=a.previousSelection.current.range;ee=Math.min(ee,gn?w-1:w);const se=Tz(ae,q,ee,Wt);ig(se)}else{if(gn&&te===w)return;if(gn&&ee===w)if(S.kind===Bh)ee--;else return;q=Math.max(q,X);const Ae=q-K,Ne=ee-te,Te={x:Ae>=0?K:q,y:Ne>=0?te:ee,width:Math.abs(Ae)+1,height:Math.abs(Ne)+1};oe({...Z.current,range:Te},!0,!1,"drag")}}Gt==null||Gt({...S,location:[S.location[0]-X,S.location[1]]})}},[Wt,a,X,Pe,Z,me,Gt,Ce,gn,w,oe]),zR=y.useCallback(()=>{var q,ee;const S=fg.current;if(S===void 0)return;const[F,L]=S.scrollEdge;let[U,K]=S.location;const te=mn.current;F===-1?U=((ee=(q=te.extras)==null?void 0:q.freezeRegion)==null?void 0:ee.x)??te.x:F===1&&(U=te.x+te.width),L===-1?K=Math.max(0,te.y):L===1&&(K=Math.min(w-1,te.y+te.height)),U=ji(U,0,wt.length-1),K=ji(K,0,w-1),dg({...S,location:[U,K]})},[wt.length,dg,w]);N6(PR,c,zR);const Ii=y.useCallback(S=>{if(Z.current===void 0)return;const[F,L]=S,[U,K]=Z.current.cell,te=Z.current.range;let q=te.x,ee=te.x+te.width,ae=te.y,se=te.y+te.height;if(L!==0)switch(L){case 2:{se=w,ae=K,Pn(0,se,"vertical");break}case-2:{ae=0,se=K+1,Pn(0,ae,"vertical");break}case 1:{aeK+1?(se--,Pn(0,se,"vertical")):(ae=Math.max(0,ae-1),Pn(0,ae,"vertical"));break}default:Hc()}if(F!==0)if(F===2)ee=wt.length,q=U,Pn(ee-1-X,0,"horizontal");else if(F===-2)q=X,ee=U+1,Pn(q-X,0,"horizontal");else{let Ae=[];if(Fn!==void 0){const Ne=Fn({x:q,y:ae,width:ee-q-X,height:se-ae},or.current.signal);typeof Ne=="object"&&(Ae=F6(Ne))}if(F===1){let Ne=!1;if(q0){const Te=hl(q+1,U+1).find(qe=>!Ae.includes(qe-X));Te!==void 0&&(q=Te,Ne=!0)}else q++,Ne=!0;Ne&&Pn(q,0,"horizontal")}Ne||(ee=Math.min(wt.length,ee+1),Pn(ee-1-X,0,"horizontal"))}else if(F===-1){let Ne=!1;if(ee>U+1){if(Ae.length>0){const Te=hl(ee-1,U,-1).find(qe=>!Ae.includes(qe-X));Te!==void 0&&(ee=Te,Ne=!0)}else ee--,Ne=!0;Ne&&Pn(ee-X,0,"horizontal")}Ne||(q=Math.max(X,q-1),Pn(q-X,0,"horizontal"))}else Hc()}oe({cell:Z.current.cell,range:{x:q,y:ae,width:ee-q,height:se-ae}},!0,!1,"keyboard-select")},[Fn,Z,wt.length,X,w,Pn,oe]),io=y.useCallback((S,F,L,U)=>{const K=lr-(L?0:1);if(S=ji(S,X,Lt.length-1+X),F=ji(F,0,K),S===(is==null?void 0:is[0])&&F===(is==null?void 0:is[1]))return!1;if(U&&Z.current!==void 0){const te=[...Z.current.rangeStack];(Z.current.range.width>1||Z.current.range.height>1)&&te.push(Z.current.range),Rr({...Z,current:{cell:[S,F],range:{x:S,y:F,width:1,height:1},rangeStack:te}},!0)}else oe({cell:[S,F],range:{x:S,y:F,width:1,height:1}},!0,!1,"keyboard-nav");return f.current!==void 0&&f.current[0]===S&&f.current[1]===F&&(f.current=void 0),Pn(S-X,F),!0},[lr,X,Lt.length,is,Z,Pn,Rr,oe]),BR=y.useCallback((S,F)=>{(i==null?void 0:i.cell)!==void 0&&S!==void 0&&ia(S)&&(li([{location:i.cell,value:S}]),window.requestAnimationFrame(()=>{var K;(K=Or.current)==null||K.damage([{cell:i.cell}])})),br(!0),s(void 0);const[L,U]=F;if(Z.current!==void 0&&(L!==0||U!==0)){const K=Z.current.cell[1]===lr-1&&S!==void 0;io(ji(Z.current.cell[0]+L,0,wt.length-1),ji(Z.current.cell[1]+U,0,lr-1),K,!1)}A==null||A(S,F)},[i==null?void 0:i.cell,br,Z,A,li,lr,io,wt.length]),jR=y.useMemo(()=>`gdg-overlay-${$6++}`,[]),el=y.useCallback(S=>{var L,U,K,te;br();const F=[];for(let q=S.x;q({cell:q.location})))},[br,k,Re,li,X]),ku=i!==void 0,Qw=y.useCallback(S=>{var qe,Qe;const F=()=>{S.stopPropagation(),S.preventDefault()},L={didMatch:!1},{bounds:U}=S,K=Z.columns,te=Z.rows,q=Ri;if(!ku&&xt(q.clear,S,L))Rr(ld,!1),Zt==null||Zt();else if(!ku&&xt(q.selectAll,S,L))Rr({columns:Pt.empty(),rows:Pt.empty(),current:{cell:((qe=Z.current)==null?void 0:qe.cell)??[X,0],range:{x:X,y:0,width:v.length,height:w},rangeStack:[]}},!1);else if(xt(q.search,S,L))(Qe=o==null?void 0:o.current)==null||Qe.focus({preventScroll:!0}),Sf(!0);else if(xt(q.delete,S,L)){const Ot=(H==null?void 0:H(Z))??!0;if(Ot!==!1){const tt=Ot===!0?Z:Ot;if(tt.current!==void 0){el(tt.current.range);for(const Ke of tt.current.rangeStack)el(Ke)}for(const Ke of tt.rows)el({x:X,y:Ke,width:v.length,height:1});for(const Ke of tt.columns)el({x:Ke,y:0,width:1,height:w})}}if(L.didMatch)return F(),!0;if(Z.current===void 0)return!1;let[ee,ae]=Z.current.cell,se=!1,Ae=!1;xt(q.scrollToSelectedCell,S,L)?Nf.current(ee-X,ae):Se!=="none"&&xt(q.selectColumn,S,L)?K.hasIndex(ee)?we(K.remove(ee),void 0,!0):Se==="single"?we(Pt.fromSingleSelection(ee),void 0,!0):we(void 0,ee,!0):Pe!=="none"&&xt(q.selectRow,S,L)?te.hasIndex(ae)?Ce(te.remove(ae),void 0,!0):Pe==="single"?Ce(Pt.fromSingleSelection(ae),void 0,!0):Ce(void 0,ae,!0):!ku&&U!==void 0&&xt(q.activateCell,S,L)?ae===w&&gn?window.setTimeout(()=>{const Ot=Rf(ee);Yl(Ot??ee)},0):(C==null||C([ee-X,ae]),ql(U,!0)):Z.current.range.height>1&&xt(q.downFill,S,L)?Jw():Z.current.range.width>1&&xt(q.rightFill,S,L)?Yw():xt(q.goToNextPage,S,L)?ae+=Math.max(1,mn.current.height-4):xt(q.goToPreviousPage,S,L)?ae-=Math.max(1,mn.current.height-4):xt(q.goToFirstCell,S,L)?(s(void 0),ae=0,ee=0):xt(q.goToLastCell,S,L)?(s(void 0),ae=Number.MAX_SAFE_INTEGER,ee=Number.MAX_SAFE_INTEGER):xt(q.selectToFirstCell,S,L)?(s(void 0),Ii([-2,-2])):xt(q.selectToLastCell,S,L)?(s(void 0),Ii([2,2])):ku?(xt(q.closeOverlay,S,L)&&s(void 0),xt(q.acceptOverlayDown,S,L)&&(s(void 0),ae++),xt(q.acceptOverlayUp,S,L)&&(s(void 0),ae--),xt(q.acceptOverlayLeft,S,L)&&(s(void 0),ee--),xt(q.acceptOverlayRight,S,L)&&(s(void 0),ee++)):(xt(q.goDownCell,S,L)?ae+=1:xt(q.goUpCell,S,L)?ae-=1:xt(q.goRightCell,S,L)?ee+=1:xt(q.goLeftCell,S,L)?ee-=1:xt(q.goDownCellRetainSelection,S,L)?(ae+=1,se=!0):xt(q.goUpCellRetainSelection,S,L)?(ae-=1,se=!0):xt(q.goRightCellRetainSelection,S,L)?(ee+=1,se=!0):xt(q.goLeftCellRetainSelection,S,L)?(ee-=1,se=!0):xt(q.goToLastRow,S,L)?ae=w-1:xt(q.goToFirstRow,S,L)?ae=Number.MIN_SAFE_INTEGER:xt(q.goToLastColumn,S,L)?ee=Number.MAX_SAFE_INTEGER:xt(q.goToFirstColumn,S,L)?ee=Number.MIN_SAFE_INTEGER:(me==="rect"||me==="multi-rect")&&(xt(q.selectGrowDown,S,L)?Ii([0,1]):xt(q.selectGrowUp,S,L)?Ii([0,-1]):xt(q.selectGrowRight,S,L)?Ii([1,0]):xt(q.selectGrowLeft,S,L)?Ii([-1,0]):xt(q.selectToLastRow,S,L)?Ii([0,2]):xt(q.selectToFirstRow,S,L)?Ii([0,-2]):xt(q.selectToLastColumn,S,L)?Ii([2,0]):xt(q.selectToFirstColumn,S,L)&&Ii([-2,0])),Ae=L.didMatch);const Ne=io(ee,ae,!1,se),Te=L.didMatch;return Te&&(Ne||!Ae||Q)&&F(),Te},[ku,Z,Ri,Se,Pe,me,X,w,io,Rr,Zt,v.length,H,Q,el,we,Ce,gn,Rf,Yl,C,ql,Jw,Yw,Ii]),Su=y.useCallback(S=>{let F=!1;if($e!==void 0&&$e({...S,cancel:()=>{F=!0}}),F||Qw(S)||Z.current===void 0)return;const[L,U]=Z.current.cell,K=mn.current;if(lt&&!S.metaKey&&!S.ctrlKey&&Z.current!==void 0&&S.key.length===1&&/[ -~]/g.test(S.key)&&S.bounds!==void 0&&Ju(k([L-X,Math.max(0,Math.min(U,w-1))]))){if((!gn||U!==w)&&(K.y>U||U>K.y+K.height||K.x>L||L>K.x+K.width))return;ql(S.bounds,!0,S.key),S.stopPropagation(),S.preventDefault()}},[lt,$e,Qw,Z,k,X,w,gn,ql]),HR=y.useCallback((S,F)=>{const L=S.location[0]-X;if(S.kind==="header"&&(G==null||G(L,{...S,preventDefault:F})),S.kind===qr){if(L<0)return;I==null||I(L,{...S,preventDefault:F})}if(S.kind==="cell"){const[U,K]=S.location;V==null||V([L,K],{...S,preventDefault:F}),x4(Z,S.location)||io(U,K,!1,!1)}},[Z,V,I,G,X,io]),hg=y.useCallback(async S=>{var q,ee,ae;if(!Ri.paste)return;function F(se,Ae,Ne,Te){var Qe,Ot;const qe=typeof Ne=="object"?(Ne==null?void 0:Ne.join(` -`))??"":(Ne==null?void 0:Ne.toString())??"";if(!wa(se)&&Ju(se)&&se.readonly!==!0){const tt=R==null?void 0:R(qe,se);if(tt!==void 0&&ia(tt))return{location:Ae,value:tt};const Ke=Re(se);if(Ke===void 0)return;if(Ke.kind===Ee.Custom){Yr(se.kind===Ee.Custom);const an=(Qe=Ke.onPaste)==null?void 0:Qe.call(Ke,qe,se.data);return an===void 0?void 0:{location:Ae,value:{...se,data:an}}}else{const an=(Ot=Ke.onPaste)==null?void 0:Ot.call(Ke,qe,se,{formatted:Te,formattedString:typeof Te=="string"?Te:Te==null?void 0:Te.join(` -`),rawValue:Ne});return an===void 0?void 0:(Yr(an.kind===se.kind),{location:Ae,value:an})}}}const L=Z.columns,U=Z.rows,K=((q=c.current)==null?void 0:q.contains(document.activeElement))===!0||((ee=l.current)==null?void 0:ee.contains(document.activeElement))===!0;let te;if(Z.current!==void 0?te=[Z.current.range.x,Z.current.range.y]:L.length===1?te=[L.first()??0,0]:U.length===1&&(te=[X,U.first()??0]),K&&te!==void 0){let se,Ae;const Ne="text/plain",Te="text/html";if(navigator.clipboard.read!==void 0){const tt=await navigator.clipboard.read();for(const Ke of tt){if(Ke.types.includes(Te)){const ar=await(await Ke.getType(Te)).text(),In=Hx(ar);if(In!==void 0){se=In;break}}Ke.types.includes(Ne)&&(Ae=await(await Ke.getType(Ne)).text())}}else if(navigator.clipboard.readText!==void 0)Ae=await navigator.clipboard.readText();else if(S!==void 0&&(S==null?void 0:S.clipboardData)!==null){if(S.clipboardData.types.includes(Te)){const tt=S.clipboardData.getData(Te);se=Hx(tt)}se===void 0&&S.clipboardData.types.includes(Ne)&&(Ae=S.clipboardData.getData(Ne))}else return;const[qe,Qe]=te,Ot=[];do{if(pe===void 0){const tt=Vr(te),Ke=Ae??(se==null?void 0:se.map(ar=>ar.map(In=>In.rawValue).join(" ")).join(" "))??"",an=F(tt,te,Ke,void 0);an!==void 0&&Ot.push(an);break}if(se===void 0){if(Ae===void 0)return;se=E6(Ae)}if(pe===!1||typeof pe=="function"&&(pe==null?void 0:pe([te[0]-X,te[1]],se.map(tt=>tt.map(Ke=>{var an;return((an=Ke.rawValue)==null?void 0:an.toString())??""}))))!==!0)return;for(const[tt,Ke]of se.entries()){if(tt+Qe>=w)break;for(const[an,ar]of Ke.entries()){const In=[an+qe,tt+Qe],[Ni,ss]=In;if(Ni>=wt.length||ss>=lr)continue;const _i=Vr(In),os=F(_i,In,ar.rawValue,ar.formatted);os!==void 0&&Ot.push(os)}}}while(!1);li(Ot),(ae=Or.current)==null||ae.damage(Ot.map(tt=>({cell:tt.location})))}},[R,Re,Vr,Z,Ri.paste,wt.length,li,lr,pe,X,w]);er("paste",hg,d,!1,!0);const Cu=y.useCallback(async(S,F)=>{var q,ee;if(!Ri.copy)return;const L=F===!0||((q=c.current)==null?void 0:q.contains(document.activeElement))===!0||((ee=l.current)==null?void 0:ee.contains(document.activeElement))===!0,U=Z.columns,K=Z.rows,te=(ae,se)=>{if(!at)Vx(ae,se,S);else{const Ae=se.map(Ne=>({kind:Ee.Text,data:v[Ne].title,displayData:v[Ne].title,allowOverlay:!1}));Vx([Ae,...ae],se,S)}};if(L&&Fn!==void 0){if(Z.current!==void 0){let ae=Fn(Z.current.range,or.current.signal);typeof ae!="object"&&(ae=await ae()),te(ae,hl(Z.current.range.x-X,Z.current.range.x+Z.current.range.width-X))}else if(K!==void 0&&K.length>0){const se=[...K].map(Ae=>{const Ne=Fn({x:X,y:Ae,width:v.length,height:1},or.current.signal);return typeof Ne=="object"?Ne[0]:Ne().then(Te=>Te[0])});if(se.some(Ae=>Ae instanceof Promise)){const Ae=await Promise.all(se);te(Ae,hl(v.length))}else te(se,hl(v.length))}else if(U.length>0){const ae=[],se=[];for(const Ae of U){let Ne=Fn({x:Ae,y:0,width:1,height:w},or.current.signal);typeof Ne!="object"&&(Ne=await Ne()),ae.push(Ne),se.push(Ae-X)}if(ae.length===1)te(ae[0],se);else{const Ae=ae.reduce((Ne,Te)=>Ne.map((qe,Qe)=>[...qe,...Te[Qe]]));te(Ae,se)}}}},[v,Fn,Z,Ri.copy,X,w,at]);er("copy",Cu,d,!1,!1);const WR=y.useCallback(async S=>{var L,U;if(!(!Ri.cut||!(((L=c.current)==null?void 0:L.contains(document.activeElement))===!0||((U=l.current)==null?void 0:U.contains(document.activeElement))===!0))&&(await Cu(S),Z.current!==void 0)){let K={current:{cell:Z.current.cell,range:Z.current.range,rangeStack:[]},rows:Pt.empty(),columns:Pt.empty()};const te=H==null?void 0:H(K);if(te===!1||(K=te===!0?K:te,K.current===void 0))return;el(K.current.range)}},[el,Z,Ri.cut,Cu,H]);er("cut",WR,d,!1,!1);const VR=y.useCallback((S,F)=>{if(W!==void 0){X!==0&&(S=S.map(K=>[K[0]-X,K[1]])),W(S,F);return}if(S.length===0||F===-1)return;const[L,U]=S[F];f.current!==void 0&&f.current[0]===L&&f.current[1]===U||(f.current=[L,U],io(L,U,!1,!1))},[W,X,io]),[Pf,If]=((s1=Ht==null?void 0:Ht.current)==null?void 0:s1.cell)??[],Nf=y.useRef(Pn);Nf.current=Pn,y.useLayoutEffect(()=>{var S,F,L,U;!Nt.current&&Pf!==void 0&&If!==void 0&&(Pf!==((F=(S=no.current)==null?void 0:S.current)==null?void 0:F.cell[0])||If!==((U=(L=no.current)==null?void 0:L.current)==null?void 0:U.cell[1]))&&Nf.current(Pf,If),Nt.current=!1},[Pf,If]);const Zw=Z.current!==void 0&&(Z.current.cell[0]>=wt.length||Z.current.cell[1]>=lr);y.useLayoutEffect(()=>{Zw&&Rr(ld,!1)},[Zw,Rr]);const UR=y.useMemo(()=>gn===!0&&(et==null?void 0:et.tint)===!0?Pt.fromSingleSelection(lr-1):Pt.empty(),[lr,gn,et==null?void 0:et.tint]),KR=y.useCallback(S=>typeof kn=="boolean"?kn:(kn==null?void 0:kn(S-X))??!0,[X,kn]),XR=y.useMemo(()=>{if(lg===void 0||l.current===null)return null;const{bounds:S,group:F}=lg,L=l.current.getBoundingClientRect();return y.createElement(g6,{bounds:S,group:F,canvasBounds:L,onClose:()=>ag(void 0),onFinish:U=>{ag(void 0),$==null||$(F,U)}})},[$,lg]),GR=Math.min(wt.length,dt+(jr?1:0));y.useImperativeHandle(e,()=>({appendRow:(S,F)=>Yl(S+X,F),updateCells:S=>{var F;return X!==0&&(S=S.map(L=>({cell:[L.cell[0]+X,L.cell[1]]}))),(F=Or.current)==null?void 0:F.damage(S)},getBounds:(S,F)=>{var L;if(!((l==null?void 0:l.current)===null||(c==null?void 0:c.current)===null)){if(S===void 0&&F===void 0){const U=l.current.getBoundingClientRect(),K=U.width/c.current.clientWidth;return{x:U.x-c.current.scrollLeft*K,y:U.y-c.current.scrollTop*K,width:c.current.scrollWidth*K,height:c.current.scrollHeight*K}}return(L=Or.current)==null?void 0:L.getBounds((S??0)+X,F)}},focus:()=>{var S;return(S=Or.current)==null?void 0:S.focus()},emit:async S=>{switch(S){case"delete":Su({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!1,key:"Delete",keyCode:46,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"fill-right":Su({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!0,key:"r",keyCode:82,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"fill-down":Su({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!0,key:"d",keyCode:68,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"copy":await Cu(void 0,!0);break;case"paste":await hg();break}},scrollTo:Pn,remeasureColumns:S=>{for(const F of S)Of(F+X)}}),[Yl,Of,Cu,Su,hg,X,Pn]);const[e1,t1]=is??[],qR=y.useCallback(S=>{const[F,L]=S;if(L===-1){Se!=="none"&&(we(Pt.fromSingleSelection(F),void 0,!1),br());return}e1===F&&t1===L||(oe({cell:S,range:{x:F,y:L,width:1,height:1}},!0,!1,"keyboard-nav"),Pn(F,L))},[Se,br,Pn,e1,t1,oe,we]),[YR,JR]=y.useState(!1),n1=y.useRef(GT(S=>{JR(S)},5)),QR=y.useCallback(()=>{n1.current(!0),Z.current===void 0&&Z.columns.length===0&&Z.rows.length===0&&a===void 0&&oe({cell:[X,Cf],range:{x:X,y:Cf,width:1,height:1}},!0,!1,"keyboard-select")},[Cf,Z,a,X,oe]),ZR=y.useCallback(()=>{n1.current(!1)},[]),[eO,tO]=y.useMemo(()=>{let S;const F=(Jt==null?void 0:Jt.scrollbarWidthOverride)??$0(),L=w+(gn?1:0);if(typeof wr=="number")S=pt+L*wr;else{let K=0;const te=Math.min(L,10);for(let q=0;qte.width+K,0)+F;return[`${Math.min(1e5,U)}px`,`${Math.min(1e5,S)}px`]},[wt,Jt==null?void 0:Jt.scrollbarWidthOverride,wr,w,gn,pt]),nO=y.useMemo(()=>L4(ue),[ue]);return y.createElement($4.Provider,{value:ue},y.createElement(O6,{style:nO,className:j,inWidth:b??eO,inHeight:m??tO},y.createElement(f6,{fillHandle:It,drawFocusRing:Yt,experimental:Jt,fixedShadowX:jl,fixedShadowY:ts,getRowThemeOverride:p,headerIcons:Ci,imageWindowLoader:Ti,initialSize:ns,isDraggable:Hl,onDragLeave:Wl,onRowMoved:si,overscrollX:Qp,overscrollY:kf,preventDiagonalScrolling:Zs,rightElement:z,rightElementProps:re,smoothScrollX:he,smoothScrollY:ve,className:j,enableGroups:jt,onCanvasFocused:QR,onCanvasBlur:ZR,canvasRef:l,onContextMenu:HR,theme:ue,cellXOffset:Jo,cellYOffset:Cf,accessibilityHeight:On.height,onDragEnd:FR,columns:wt,nonGrowWidth:Ve,drawHeader:ng,onColumnProposeMove:N,drawCell:rg,disabledRows:UR,freezeColumns:GR,lockColumns:X,firstColAccessible:X===0,getCellContent:Vr,minColumnWidth:sr,maxColumnWidth:Mi,searchInputRef:o,showSearch:yu,onSearchClose:eg,highlightRegions:RR,getCellsForSelection:Fn,getGroupDetails:sg,headerHeight:Vl,isFocused:YR,groupHeaderHeight:jt?mu:0,freezeTrailingRows:ft+(gn&&(et==null?void 0:et.sticky)===!0?1:0),hasAppendRow:gn,onColumnResize:Oi,onColumnResizeEnd:tg,onColumnResizeStart:Kl,onCellFocused:qR,onColumnMoved:LR,onDragStart:$R,onHeaderMenuClick:_R,onItemHovered:dg,isFilling:(a==null?void 0:a.fillHandle)===!0,onMouseMove:NR,onKeyDown:Su,onKeyUp:ke,onMouseDown:OR,onMouseUp:IR,onDragOverCell:Jn,onDrop:gt,onSearchResultsChanged:VR,onVisibleRegionChanged:DR,clientSize:Ie,rowHeight:wr,searchResults:de,searchValue:ge,onSearchValueChange:le,rows:lr,scrollRef:c,selection:Z,translateX:On.tx,translateY:On.ty,verticalBorder:KR,gridRef:Or,getCellRenderer:Re}),XR,i!==void 0&&y.createElement(y.Suspense,{fallback:null},y.createElement(L6,{...i,validateCell:vu,bloom:O,id:jR,getCellRenderer:Re,className:(Jt==null?void 0:Jt.isSubGrid)===!0?"click-outside-ignore":void 0,provideEditor:$t,imageEditorOverride:h,onFinishEditing:BR,markdownDivCreateNode:g,isOutsideClick:en}))))},B6=y.forwardRef(z6),Xx=20,j6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??"false"},kind:Ee.Boolean,needsHover:!0,useLabel:!1,needsHoverPosition:!0,measure:()=>50,draw:t=>H6(t,t.cell.data,I0(t.cell),t.cell.maxSize??Xx),onDelete:t=>({...t,data:!1}),onClick:t=>{const{cell:e,posX:n,posY:r,bounds:i,theme:s}=t,{width:o,height:l,x:a,y:u}=i,c=e.maxSize??Xx,f=Math.floor(i.y+l/2),d=JT(c,l,s.cellVerticalPadding),h=YT(e.contentAlign??"center",a,o,s.cellHorizontalPadding,d),p=qT(h,f,d),g=QT(a+n,u+r,p);if(I0(e)&&g)return{...e,data:UE(e.data)}},onPaste:(t,e)=>{let n=Ah;return t.toLowerCase()==="true"?n=!0:t.toLowerCase()==="false"?n=!1:t.toLowerCase()==="indeterminate"&&(n=qv),n===e.data?void 0:{...e,data:n}}};function H6(t,e,n,r){if(!n&&e===Ah)return;const{ctx:i,hoverAmount:s,theme:o,rect:l,highlighted:a,hoverX:u,hoverY:c,cell:{contentAlign:f}}=t,{x:d,y:h,width:p,height:g}=l,b=.35;let m=n?1-b+b*s:.4;e===Ah&&(m*=s),m!==0&&(i.globalAlpha=m,uw(i,o,e,d,h,p,g,a,u,c,r,f),i.globalAlpha=1)}const W6=ii("div")({name:"BubblesOverlayEditorStyle",class:"gdg-b1ygi5by",propsAsIs:!1}),V6=t=>{const{bubbles:e}=t;return y.createElement(W6,null,e.map((n,r)=>y.createElement("div",{key:r,className:"boe-bubble"},n)),y.createElement("textarea",{className:"gdg-input",autoFocus:!0}))},U6={getAccessibilityString:t=>ZT(t.data),kind:Ee.Bubble,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(t,e,n)=>e.data.reduce((r,i)=>t.measureText(i).width+r+20,0)+2*n.cellHorizontalPadding-4,draw:t=>X6(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return y.createElement(V6,{bubbles:e.data})},onPaste:()=>{}},K6=4;function X6(t,e){const{rect:n,theme:r,ctx:i,highlighted:s}=t,{x:o,y:l,width:a,height:u}=n,c=20,f=8,d=K6;let h=o+r.cellHorizontalPadding;const p=[];for(const g of e){if(h>o+a)break;const b=hf(g,i,r.baseFontFull).width;p.push({x:h,width:b}),h+=b+f*2+d}i.beginPath();for(const g of p)Cs(i,g.x,l+(u-c)/2,g.width+f*2,c,r.roundingRadius??c/2);i.fillStyle=s?r.bgBubbleSelected:r.bgBubble,i.fill();for(const[g,b]of p.entries())i.beginPath(),i.fillStyle=r.textBubble,i.fillText(e[g],b.x+f,l+u/2+Ys(i,r))}const G6=ii("div")({name:"DrilldownOverlayEditorStyle",class:"gdg-d4zsq0x",propsAsIs:!1}),q6=t=>{const{drilldowns:e}=t;return y.createElement(G6,null,e.map((n,r)=>y.createElement("div",{key:r,className:"doe-bubble"},n.img!==void 0&&y.createElement("img",{src:n.img}),y.createElement("div",null,n.text))))},Y6={getAccessibilityString:t=>ZT(t.data.map(e=>e.text)),kind:Ee.Drilldown,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(t,e,n)=>e.data.reduce((r,i)=>t.measureText(i.text).width+r+20+(i.img!==void 0?18:0),0)+2*n.cellHorizontalPadding-4,draw:t=>Z6(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return y.createElement(q6,{drilldowns:e.data})},onPaste:()=>{}},J6=4,lm={};function Q6(t,e,n,r){const i=Math.ceil(window.devicePixelRatio),s=5,o=n-s*2,l=4,a=n*i,u=r+s,c=r*3,f=(c+s*2)*i,d=`${t},${e},${i},${n}`;if(lm[d]!==void 0)return{el:lm[d],height:a,width:f,middleWidth:l*i,sideWidth:u*i,padding:s*i,dpr:i};const h=document.createElement("canvas"),p=h.getContext("2d");return p===null?null:(h.width=f,h.height=a,p.scale(i,i),lm[d]=h,p.beginPath(),Cs(p,s,s,c,o,r),p.shadowColor="rgba(24, 25, 34, 0.4)",p.shadowBlur=1,p.fillStyle=t,p.fill(),p.shadowColor="rgba(24, 25, 34, 0.3)",p.shadowOffsetY=1,p.shadowBlur=5,p.fillStyle=t,p.fill(),p.shadowOffsetY=0,p.shadowBlur=0,p.shadowBlur=0,p.beginPath(),Cs(p,s+.5,s+.5,c,o,r),p.strokeStyle=e,p.lineWidth=1,p.stroke(),{el:h,height:a,width:f,sideWidth:u*i,middleWidth:r*i,padding:s*i,dpr:i})}function Z6(t,e){const{rect:n,theme:r,ctx:i,imageLoader:s,col:o,row:l}=t,{x:a,width:u}=n,c=r.baseFontFull,f=dE(i,c),d=Math.min(n.height,Math.max(16,Math.ceil(f*r.lineHeight)*2)),h=Math.floor(n.y+(n.height-d)/2),p=d-10,g=8,b=J6;let m=a+r.cellHorizontalPadding;const v=r.roundingRadius??6,w=Q6(r.bgCell,r.drilldownBorder,d,v),k=[];for(const x of e){if(m>a+u)break;const T=hf(x.text,i,c).width;let A=0;x.img!==void 0&&s.loadOrGetImage(x.img,o,l)!==void 0&&(A=p-8+4);const R=T+A+g*2;k.push({x:m,width:R}),m+=R+b}if(w!==null){const{el:x,height:C,middleWidth:T,sideWidth:A,width:R,dpr:P,padding:_}=w,O=A/P,D=_/P;for(const N of k){const ne=Math.floor(N.x),ie=Math.floor(N.width),V=ie-(O-D)*2;i.imageSmoothingEnabled=!1,i.drawImage(x,0,0,A,C,ne-D,h,O,d),V>0&&i.drawImage(x,A,0,T,C,ne+(O-D),h,V,d),i.drawImage(x,R-A,0,A,C,ne+ie-(O-D),h,O,d),i.imageSmoothingEnabled=!0}}i.beginPath();for(const[x,C]of k.entries()){const T=e[x];let A=C.x+g;if(T.img!==void 0){const R=s.loadOrGetImage(T.img,o,l);if(R!==void 0){const P=p-8;let _=0,O=0,D=R.width,N=R.height;D>N?(_+=(D-N)/2,D=N):N>D&&(O+=(N-D)/2,N=D),i.beginPath(),Cs(i,A,h+d/2-P/2,P,P,r.roundingRadius??3),i.save(),i.clip(),i.drawImage(R,_,O,D,N,A,h+d/2-P/2,P,P),i.restore(),A+=P+4}}i.beginPath(),i.fillStyle=r.textBubble,i.fillText(T.text,A,h+d/2+Ys(i,r))}}const e9={getAccessibilityString:t=>t.data.join(", "),kind:Ee.Image,needsHover:!1,useLabel:!1,needsHoverPosition:!1,draw:t=>t9(t,t.cell.displayData??t.cell.data,t.cell.rounding??t.theme.roundingRadius??4,t.cell.contentAlign),measure:(t,e)=>e.data.length*50,onDelete:t=>({...t,data:[]}),provideEditor:()=>t=>{const{value:e,onFinishedEditing:n,imageEditorOverride:r}=t,i=r??UF;return y.createElement(i,{urls:e.data,canWrite:e.readonly!==!1,onCancel:n,onChange:s=>{n({...e,data:[s]})}})},onPaste:(t,e)=>{t=t.trim();const r=t.split(",").map(i=>{try{return new URL(i),i}catch{return}}).filter(i=>i!==void 0);if(!(r.length===e.data.length&&r.every((i,s)=>i===e.data[s])))return{...e,data:r}}},am=4;function t9(t,e,n,r){const{rect:i,col:s,row:o,theme:l,ctx:a,imageLoader:u}=t,{x:c,y:f,height:d,width:h}=i,p=d-l.cellVerticalPadding*2,g=[];let b=0;for(let v=0;v0&&(a.beginPath(),Cs(a,m,f+l.cellVerticalPadding,w,p,n),a.save(),a.clip()),a.drawImage(v,m,f+l.cellVerticalPadding,w,p),n>0&&a.restore(),m+=w+am}}function n9(t,e){let n=t*49632+e*325176;return n^=n<<13,n^=n>>17,n^=n<<5,n/4294967295*2}const r9={getAccessibilityString:()=>"",kind:Ee.Loading,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:()=>120,draw:t=>{const{cell:e,col:n,row:r,ctx:i,rect:s,theme:o}=t;if(e.skeletonWidth===void 0||e.skeletonWidth===0)return;let l=e.skeletonWidth;e.skeletonWidthVariability!==void 0&&e.skeletonWidthVariability>0&&(l+=Math.round(n9(n,r)*e.skeletonWidthVariability));const a=o.cellHorizontalPadding,u=e.skeletonHeight??Math.min(18,s.height-2*o.cellVerticalPadding);Cs(i,s.x+a,s.y+(s.height-u)/2,l,u,o.roundingRadius??3),i.fillStyle=Ol(o.textDark,.1),i.fill()},onPaste:()=>{}},i9=()=>t=>t.targetWidth,Gx=ii("div")({name:"MarkdownOverlayEditorStyle",class:"gdg-m1pnx84e",propsAsIs:!1,vars:{"m1pnx84e-0":[i9(),"px"]}}),s9=t=>{const{value:e,onChange:n,forceEditMode:r,createNode:i,targetRect:s,onFinish:o,validatedSelection:l}=t,a=e.data,u=e.readonly===!0,[c,f]=y.useState(a===""||r),d=y.useCallback(()=>{f(p=>!p)},[]),h=a?"gdg-ml-6":"";return c?y.createElement(Gx,{targetWidth:s.width-20},y.createElement(Lp,{autoFocus:!0,highlight:!1,validatedSelection:l,value:a,onKeyDown:p=>{p.key==="Enter"&&p.stopPropagation()},onChange:n}),y.createElement("div",{className:`gdg-edit-icon gdg-checkmark-hover ${h}`,onClick:()=>o(e)},y.createElement(FF,null))):y.createElement(Gx,{targetWidth:s.width},y.createElement(c4,{contents:a,createNode:i}),!u&&y.createElement(y.Fragment,null,y.createElement("div",{className:"spacer"}),y.createElement("div",{className:`gdg-edit-icon gdg-edit-hover ${h}`,onClick:d},y.createElement(ew,null))),y.createElement("textarea",{className:"gdg-md-edit-textarea gdg-input",autoFocus:!0}))},o9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Ee.Markdown,needsHover:!1,needsHoverPosition:!1,drawPrep:pf,measure:(t,e,n)=>{const r=e.data.split(` -`)[0];return t.measureText(r).width+2*n.cellHorizontalPadding},draw:t=>$s(t,t.cell.data,t.cell.contentAlign),onDelete:t=>({...t,data:""}),provideEditor:()=>t=>{const{onChange:e,value:n,target:r,onFinishedEditing:i,markdownDivCreateNode:s,forceEditMode:o,validatedSelection:l}=t;return y.createElement(s9,{onFinish:i,targetRect:r,value:n,validatedSelection:l,onChange:a=>e({...n,data:a.target.value}),forceEditMode:o,createNode:s})},onPaste:(t,e)=>t===e.data?void 0:{...e,data:t}},l9={getAccessibilityString:t=>t.row.toString(),kind:hi.Marker,needsHover:!0,needsHoverPosition:!1,drawPrep:a9,measure:()=>44,draw:t=>c9(t,t.cell.row,t.cell.checked,t.cell.markerKind,t.cell.drawHandle,t.cell.checkboxStyle),onClick:t=>{const{bounds:e,cell:n,posX:r,posY:i}=t,{width:s,height:o}=e,l=n.drawHandle?7+(s-7)/2:s/2,a=o/2;if(Math.abs(r-l)<=10&&Math.abs(i-a)<=10)return{...n,checked:!n.checked}},onPaste:()=>{}};function a9(t,e){const{ctx:n,theme:r}=t,i=r.markerFontFull,s=e??{};return(s==null?void 0:s.font)!==i&&(n.font=i,s.font=i),s.deprep=u9,n.textAlign="center",s}function u9(t){const{ctx:e}=t;e.textAlign="start"}function c9(t,e,n,r,i,s){const{ctx:o,rect:l,hoverAmount:a,theme:u}=t,{x:c,y:f,width:d,height:h}=l,p=n?1:r==="checkbox-visible"?.6+.4*a:a;if(r!=="number"&&p>0){o.globalAlpha=p;const g=7*(n?a:1);if(uw(o,u,n,i?c+g:c,f,i?d-g:d,h,!0,void 0,void 0,18,"center",s),i){o.globalAlpha=a,o.beginPath();for(const b of[3,6])for(const m of[-5,-1,3])o.rect(c+b,f+h/2+m,2,2);o.fillStyle=u.textLight,o.fill(),o.beginPath()}o.globalAlpha=1}if(r==="number"||r==="both"&&!n){const g=e.toString(),b=u.markerFontFull,m=c+d/2;r==="both"&&a!==0&&(o.globalAlpha=1-a),o.fillStyle=u.textLight,o.font=b,o.fillText(g,m,f+h/2+Ys(o,b)),a!==0&&(o.globalAlpha=1)}}const f9={getAccessibilityString:()=>"",kind:hi.NewRow,needsHover:!0,needsHoverPosition:!1,measure:()=>200,draw:t=>d9(t,t.cell.hint,t.cell.icon),onPaste:()=>{}};function d9(t,e,n){const{ctx:r,rect:i,hoverAmount:s,theme:o,spriteManager:l}=t,{x:a,y:u,width:c,height:f}=i;r.beginPath(),r.globalAlpha=s,r.rect(a+1,u+1,c,f-2),r.fillStyle=o.bgHeaderHovered,r.fill(),r.globalAlpha=1,r.beginPath();const d=e!=="";let h=0;if(n!==void 0){const g=f-8,b=a+8/2,m=u+8/2;l.drawSprite(n,"normal",r,b,m,g,o,d?1:s),h=g}else{h=24;const p=12,g=d?p:s*p,b=d?0:(1-s)*p*.5,m=o.cellHorizontalPadding+4;g>0&&(r.moveTo(a+m+b,u+f/2),r.lineTo(a+m+b+g,u+f/2),r.moveTo(a+m+b+g*.5,u+f/2-g*.5),r.lineTo(a+m+b+g*.5,u+f/2+g*.5),r.lineWidth=2,r.strokeStyle=o.bgIconHeader,r.lineCap="round",r.stroke())}r.fillStyle=o.textMedium,r.fillText(e,h+a+o.cellHorizontalPadding+.5,u+f/2+Ys(r,o)),r.beginPath()}const h9=y.lazy(async()=>await vE(()=>import("./number-overlay-editor-B1A_c6JJ.js"),[])),p9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Ee.Number,needsHover:!1,needsHoverPosition:!1,useLabel:!0,drawPrep:pf,draw:t=>$s(t,t.cell.displayData,t.cell.contentAlign),measure:(t,e,n)=>t.measureText(e.displayData).width+n.cellHorizontalPadding*2,onDelete:t=>({...t,data:void 0}),provideEditor:()=>t=>{const{isHighlighted:e,onChange:n,value:r,validatedSelection:i}=t;return y.createElement(y.Suspense,{fallback:null},y.createElement(h9,{highlight:e,disabled:r.readonly===!0,value:r.data,fixedDecimals:r.fixedDecimals,allowNegative:r.allowNegative,thousandSeparator:r.thousandSeparator,decimalSeparator:r.decimalSeparator,validatedSelection:i,onChange:s=>n({...r,data:Number.isNaN(s.floatValue??0)?0:s.floatValue})}))},onPaste:(t,e,n)=>{const r=typeof n.rawValue=="number"?n.rawValue:Number.parseFloat(typeof n.rawValue=="string"?n.rawValue:t);if(!(Number.isNaN(r)||e.data===r))return{...e,data:r,displayData:n.formattedString??e.displayData}}},g9={getAccessibilityString:()=>"",measure:()=>108,kind:Ee.Protected,needsHover:!1,needsHoverPosition:!1,draw:m9,onPaste:()=>{}};function m9(t){const{ctx:e,theme:n,rect:r}=t,{x:i,y:s,height:o}=r;e.beginPath();const l=2.5;let a=i+n.cellHorizontalPadding+l;const u=s+o/2,c=Math.cos(qb(30))*l,f=Math.sin(qb(30))*l;for(let d=0;d<12;d++)e.moveTo(a,u-l),e.lineTo(a,u+l),e.moveTo(a+c,u-f),e.lineTo(a-c,u+f),e.moveTo(a-c,u-f),e.lineTo(a+c,u+f),a+=8;e.lineWidth=1.1,e.lineCap="square",e.strokeStyle=n.textLight,e.stroke()}const y9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Ee.RowID,needsHover:!1,needsHoverPosition:!1,drawPrep:(t,e)=>pf(t,e,t.theme.textLight),draw:t=>$s(t,t.cell.data,t.cell.contentAlign),measure:(t,e,n)=>t.measureText(e.data).width+n.cellHorizontalPadding*2,provideEditor:()=>t=>{const{isHighlighted:e,onChange:n,value:r,validatedSelection:i}=t;return Vn.createElement(Lp,{highlight:e,autoFocus:r.readonly!==!0,disabled:r.readonly!==!1,value:r.data,validatedSelection:i,onChange:s=>n({...r,data:s.target.value})})},onPaste:()=>{}},v9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Ee.Text,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!1,drawPrep:pf,useLabel:!0,draw:t=>{const{cell:e,hoverAmount:n,hyperWrapping:r,ctx:i,rect:s,theme:o,overrideCursor:l}=t,{displayData:a,contentAlign:u,hoverEffect:c,allowWrapping:f}=e;if(c===!0&&n>0){i.textBaseline="alphabetic";const d=o.cellHorizontalPadding,h=o.cellVerticalPadding,p=hf(a,i,o.baseFontFull,"alphabetic"),g=s.height-h,b=Math.min(g,p.actualBoundingBoxAscent*2.5);i.beginPath(),Cs(i,s.x+d/2,s.y+(s.height-b)/2+1,p.width+d*3,b-1,o.roundingRadius??4),i.globalAlpha=n,i.fillStyle=Ol(o.textDark,.1),i.fill(),i.globalAlpha=1,i.fillStyle=o.textDark,i.textBaseline="middle",l==null||l("text")}$s(t,a,u,f,r)},measure:(t,e,n)=>{const r=e.displayData.split(` -`,e.allowWrapping===!0?void 0:1);let i=0;for(const s of r)i=Math.max(i,t.measureText(s).width);return i+2*n.cellHorizontalPadding},onDelete:t=>({...t,data:""}),provideEditor:t=>({disablePadding:t.allowWrapping===!0,editor:e=>{const{isHighlighted:n,onChange:r,value:i,validatedSelection:s}=e;return y.createElement(Lp,{style:t.allowWrapping===!0?{padding:"3px 8.5px"}:void 0,highlight:n,autoFocus:i.readonly!==!0,disabled:i.readonly===!0,altNewline:!0,value:i.data,validatedSelection:s,onChange:o=>r({...i,data:o.target.value})})}}),onPaste:(t,e,n)=>t===e.data?void 0:{...e,data:t,displayData:n.formattedString??e.displayData}},w9=ii("div")({name:"UriOverlayEditorStyle",class:"gdg-u1rrojo",propsAsIs:!1}),b9=t=>{const{uri:e,onChange:n,forceEditMode:r,readonly:i,validatedSelection:s,preview:o}=t,[l,a]=y.useState(!i&&(e===""||r)),u=y.useCallback(()=>{a(!0)},[]);return l?y.createElement(Lp,{validatedSelection:s,highlight:!0,autoFocus:!0,value:e,onChange:n}):y.createElement(w9,null,y.createElement("a",{className:"gdg-link-area",href:e,target:"_blank",rel:"noopener noreferrer"},o),!i&&y.createElement("div",{className:"gdg-edit-icon",onClick:u},y.createElement(ew,null)),y.createElement("textarea",{className:"gdg-input",autoFocus:!0}))};function qx(t,e,n,r){let i=n.cellHorizontalPadding;const s=e.height/2-t.actualBoundingBoxAscent/2,o=t.width,l=t.actualBoundingBoxAscent;return r==="right"?i=e.width-o-n.cellHorizontalPadding:r==="center"&&(i=e.width/2-o/2),{x:i,y:s,width:o,height:l}}const x9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Ee.Uri,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!0,useLabel:!0,drawPrep:pf,draw:t=>{const{cell:e,theme:n,overrideCursor:r,hoverX:i,hoverY:s,rect:o,ctx:l}=t,a=e.displayData??e.data,u=e.hoverEffect===!0;if(r!==void 0&&u&&i!==void 0&&s!==void 0){const c=hf(a,l,n.baseFontFull),f=qx(c,o,n,e.contentAlign),{x:d,y:h,width:p,height:g}=f;if(i>=d-4&&i<=d-4+p+8&&s>=h-4&&s<=h-4+g+8){const b=Ys(l,n.baseFontFull);r("pointer");const m=5,v=h-b;l.beginPath(),l.moveTo(o.x+d,Math.floor(o.y+v+g+m)+.5),l.lineTo(o.x+d+p,Math.floor(o.y+v+g+m)+.5),l.strokeStyle=n.linkColor,l.stroke(),l.save(),l.fillStyle=t.cellFillColor,$s({...t,rect:{...o,x:o.x-1}},a,e.contentAlign),$s({...t,rect:{...o,x:o.x-2}},a,e.contentAlign),$s({...t,rect:{...o,x:o.x+1}},a,e.contentAlign),$s({...t,rect:{...o,x:o.x+2}},a,e.contentAlign),l.restore()}}l.fillStyle=u?n.linkColor:n.textDark,$s(t,a,e.contentAlign)},onClick:t=>{const{cell:e,bounds:n,posX:r,posY:i,theme:s}=t,o=e.displayData??e.data;if(e.hoverEffect!==!0||e.onClickUri===void 0)return;const l=M4(o,s.baseFontFull);if(l===void 0)return;const a=qx(l,n,s,e.contentAlign);Fp({x:a.x-4,y:a.y-4,width:a.width+8,height:a.height+8},r,i)&&e.onClickUri(t)},measure:(t,e,n)=>t.measureText(e.displayData??e.data).width+n.cellHorizontalPadding*2,onDelete:t=>({...t,data:""}),provideEditor:t=>e=>{const{onChange:n,value:r,forceEditMode:i,validatedSelection:s}=e;return y.createElement(b9,{forceEditMode:r.readonly!==!0&&(i||t.hoverEffect===!0&&t.onClickUri!==void 0),uri:r.data,preview:r.displayData??r.data,validatedSelection:s,readonly:r.readonly===!0,onChange:o=>n({...r,data:o.target.value})})},onPaste:(t,e,n)=>t===e.data?void 0:{...e,data:t,displayData:n.formattedString??e.displayData}},k9=[l9,f9,j6,U6,Y6,e9,r9,o9,p9,g9,y9,v9,x9];var S9=XT,C9=$l,T9="Expected a function";function E9(t,e,n){var r=!0,i=!0;if(typeof t!="function")throw new TypeError(T9);return C9(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),S9(t,e,{leading:r,maxWait:e,trailing:i})}var A9=E9;const M9=Qi(A9),um=[];class R9 extends pE{constructor(){super(...arguments);St(this,"imageLoaded",()=>{});St(this,"loadedLocations",[]);St(this,"cache",{});St(this,"sendLoaded",M9(()=>{this.imageLoaded(new gc(this.loadedLocations)),this.loadedLocations=[]},20));St(this,"clearOutOfWindow",()=>{const n=Object.keys(this.cache);for(const r of n){const i=this.cache[r];let s=!1;for(let o=0;o{a||(a=!0,um.length<12?um.unshift(l):o||(l.src=""))}},c=new Promise(f=>l.addEventListener("load",()=>f(null)));requestAnimationFrame(async()=>{try{l.src=n,await c,await l.decode();const f=this.cache[s];if(f!==void 0&&!a){f.img=l;for(const d of f.cells)this.loadedLocations.push(ow(d));o=!0,this.sendLoaded()}}catch{u.cancel()}}),this.cache[s]=u}loadOrGetImage(n,r,i){const s=n,o=this.cache[s];if(o!==void 0){const l=Hi(r,i);return o.cells.includes(l)||o.cells.push(l),o.img}else this.loadImage(n,r,i,s)}}const Yx="\uFEFF",ad=/^\s*(?:\|?\s*:?-{2,}:?\s*(?:\|\s*:?-{2,}:?\s*)+\|?|\|\s*:?-{2,}:?\s*\|)\s*$/,Kd=/^\s*\+[-=]+(?:\+[-=]+)*\+\s*$/,KE=/^\s*[-=]+(?:\+[-=]+)+\s*$/,O9=/^\s*(?:\(\d+\s+rows?\)|\d+\s+rows?\s+in\s+set(?:\s*\([^)]*\))?)\s*$/i;function zu(t){for(let e=0;e=0&&t[n]==="\\";n--)e++;return e%2===0}function Jx(t){let e=t.trim();e.startsWith("|")&&(e=e.slice(1)),P9(e)&&(e=e.slice(0,-1));const n=[];let r="";for(let i=0;ir.trim())}function I9(t,e){const n=[],r=Math.min(t.length,32768);let i=0;for(let s=0;s<=r;s++){const l=s===r?` -`:t[s];if(l===` -`||l==="\r"){const a=t.slice(i,s);if(a.trim().length>0&&(n.push(a),n.length>=e))return n;l==="\r"&&t[s+1]===` -`&&s++,i=s+1}}return n}function Bu(t){return Kd.test(t)||KE.test(t)}function gf(t){if(!t)return null;const e=t.startsWith(Yx)?t.slice(Yx.length):t,n=I9(e,3);if(n.length<2)return null;const r=zu(n[0])&&!Bu(n[0])&&!ad.test(n[0])&&ad.test(n[1]),i=zu(n[0])&&!Bu(n[0])&&(KE.test(n[1])||Kd.test(n[1])),s=Kd.test(n[0])&&zu(n[1])&&!Bu(n[1])&&(n.length<3||Bu(n[2])||zu(n[2]));if(!r&&!i&&!s)return null;const o=e.split(/\r?\n/).filter(g=>g.trim().length>0);if(o.length<2)return null;if(r&&ad.test(o[1])){const g=Jx(o[0]);if(g.length===0||g.every(v=>v===""))return null;const b=[];for(let v=2;v=2&&O9.test(o[l-1])&&l--;let a=!1;const u=[];for(let g=0;gg===""))return null;const h=u.slice(1).map(g=>Qx(g,f));return{cleanedCsv:mc(d,h,","),rows:h.length,cols:d.length,kind:"box"}}const cm="\uFEFF";function N9(t){const e={",":0,";":0," ":0};let n=",",r=-1,i=0,s=!1;for(let o=0;or&&(n=o,r=e[o]);return n}function _9(t,e,n){if(t[e]==='"'){let i="",s=e+1;for(;;){if(s>=t.length)return[i,s];const o=t[s];if(o==='"')if(t[s+1]==='"')i+='"',s+=2;else{for(s++;s=s.length)break;if(s[k]===l){d=k+1,h=!0;continue}d=s[k]==="\r"&&s[k+1]===` -`?k+2:k+1,a.push(c),u.push({start:f+o,end:k+o}),c=[]}c.length>0?(a.push(c),u.push({start:f+o,end:s.length+o})):a.length===0&&c.length===0&&s.length>0&&(a.push([""]),u.push({start:0+o,end:s.length+o}));const p=a.length>0?a[0]:[],g=p.length,b=a.slice(1),m=b.map(w=>w.length),v=b.map(w=>w.length===g?w:w.length>g?w.slice(0,g):[...w,...Array(g-w.length).fill("")]);return{headers:p,rows:v,delimiter:l,rowWidths:m,rowSpans:u.slice(1)}}function Ka(t,e=","){const n=r=>r.includes('"')?`"${r.replaceAll('"','""')}"`:r.includes(e)||r.includes(` -`)||r.includes("\r")?`"${r}"`:r;return t.map(n).join(e)}function mc(t,e,n=","){return[t,...e].map(r=>Ka(r,n)).join(` -`)}function dw(t,e){return mf(t,e).headers}function D9(t){const e=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/,n=Array.from({length:t.headers.length},()=>!0),r=Array.from({length:t.headers.length},()=>!1);for(const i of t.rows)for(let s=0;si&&r[s])}function XE(t,e){let n="",r=0;for(const{start:i,end:s,replacement:o}of e)n+=t.slice(r,i)+o,r=s;return n+t.slice(r)}function L9(t,e){return t[e]==="\r"?t[e+1]===` -`?2:1:t[e]===` -`?1:0}function Zx(t,e){return t[e-2]==="\r"&&t[e-1]===` -`?2:t[e-1]==="\r"||t[e-1]===` -`?1:0}const ek="\uFEFF";function GE(t,e){const n=t.startsWith(ek)?ek.length:0,r=e.rowSpans[0];if(r!==void 0)return{start:n,end:r.start-Zx(t,r.start)};const i=t.slice(n);return{start:n,end:n+i.length-Zx(t,t.length)}}function fm(t,e,n){const r=[...new Set(n)].flatMap(i=>{const s=e.rowSpans[i];return s===void 0?[]:[s]}).sort((i,s)=>i.start-s.start).map(i=>({start:i.start,end:i.end+L9(t,i.end),replacement:""}));return r.length===0?t:XE(t,r)}function tk(t,e,n){const r=new Set([...n].filter(o=>o>=0&&ou!r.has(c));s.push({start:o.start,end:o.end,replacement:Ka(a,e.delimiter)})}return XE(t,s)}function $9(t,e,n,r){if(!t||n<0||n>=e.headers.length)return t;const i=GE(t,e),s=dw(t.slice(i.start,i.end),e.delimiter);if(n>=s.length||s[n]===r)return t;const o=s.map((a,u)=>u===n?r:a),l=Ka(o,e.delimiter);return t.slice(0,i.start)+l+t.slice(i.end)}const Y0=50;function il(t=""){return{past:[],present:t,future:[]}}function nk(t,e,n=Y0){if(e===t.present)return t;if(t.present===""&&t.past.length===0&&t.future.length===0)return{past:[],present:e,future:[]};const r=[...t.past,t.present];return{past:r.length>n?r.slice(r.length-n):r,present:e,future:[]}}function F9(t){if(t.past.length===0)return t;const e=t.past[t.past.length-1];return{past:t.past.slice(0,t.past.length-1),present:e,future:[t.present,...t.future]}}function z9(t){if(t.future.length===0)return t;const[e,...n]=t.future,r=[...t.past,t.present];return{past:r.length>Y0?r.slice(r.length-Y0):r,present:e,future:n}}function B9(t){if(t.altKey||!t.metaKey&&!t.ctrlKey)return null;const e=t.key.toLowerCase();return e==="z"?t.shiftKey?"redo":"undo":e==="y"&&!t.shiftKey?"redo":null}const rk=/^[+-]?\d{16,}$/;function j9(t,e){const n=Array.from({length:t.length},(i,s)=>s);if(e==="")return n;const r=e.toLowerCase();return n.filter(i=>{const s=t[i];for(let o=0;o{var c,f;const a=((c=e[o])==null?void 0:c[n])??"",u=((f=e[l])==null?void 0:f[n])??"";if(i){const d=a===""?NaN:Number(a),h=u===""?NaN:Number(u),p=Number.isNaN(d),g=Number.isNaN(h);if(p||g)return p&&g?0:p?1:-1;if(rk.test(a)&&rk.test(u)){const b=BigInt(a),m=BigInt(u);return s*(bm?1:0)}return s*(d-h)}return s*a.localeCompare(u)})}function W9(t,e,n){if(n.length===0||t.headers.length===0)return"";const r=t.delimiter||",",i=Ka(n.map(o=>t.headers[o]??""),r),s=e.filter(o=>o>=0&&oKa(n.map(l=>{var a;return((a=t.rows[o])==null?void 0:a[l])??""}),r));return[i,...s].join(` -`)}const V9=` - -`;function ud(t,e){return Math.max(0,Math.min(t,e))}function ik(t,e,n,r){const i=t.headers.length,s=[];for(const a of n.ranges){const u=ud(a.x,r+i),c=ud(a.x+a.width,r+i);if(c<=r)continue;const f=Math.max(0,u-r),d=c-r;if(d<=f)continue;const h=ud(a.y,e.length),p=ud(a.y+a.height,e.length);if(p<=h)continue;const g=t.headers.slice(f,d),b=[];for(let m=h;mw[f+x]??""))}b.length!==0&&s.push(mc(g,b,t.delimiter))}if(s.length>0)return s.join(V9);const o=[...n.rows].filter(a=>a>=0&&ae[a]).filter(a=>a!==void 0);if(o.length>0)return mc(t.headers,o.map(a=>t.rows[a]??[]),t.delimiter);const l=[...n.columns].filter(a=>a>=r&&a0){const a=l.map(c=>t.headers[c-r]),u=e.map(c=>{const f=t.rows[c]??[];return l.map(d=>f[d-r]??"")});return mc(a,u,t.delimiter)}return null}const sl=1e5,U9=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?$/;function K9(t,e,n,r){var p;const i=t.headers.length,s=e.length;if(i===0||s===0)return null;const o=new Set;for(const g of n.ranges){if(o.size>=sl)break;const b=Math.max(0,g.x-r),m=Math.min(i,g.x+g.width-r);if(m<=b)continue;const v=Math.max(0,g.y),w=Math.min(s,g.y+g.height);if(!(w<=v))for(let k=v;k=sl);k++){const x=k*i;for(let C=b;C=sl));C++);}}for(const g of n.rows){if(o.size>=sl)break;if(g<0||g>=s)continue;const b=g*i;for(let m=0;m=sl));m++);}for(const g of n.columns){if(o.size>=sl)break;const b=g-r;if(!(b<0||b>=i))for(let m=0;m=sl));m++);}const l=o.size;if(l===0||l<2&&n.rows.length===0&&n.columns.length===0)return null;let a=0,u=0,c=0,f=null,d=null;const h=new Set;for(const g of o){const b=Math.floor(g/i),m=g%i,v=e[b],k=((v!==void 0?(p=t.rows[v])==null?void 0:p[m]:void 0)??"").trim();if(k===""){a+=1;continue}if(h.add(k),U9.test(k)){const x=Number(k);Number.isFinite(x)&&(u+=1,c+=x,(f===null||xd)&&(d=x))}}return{cellCount:l,distinctCount:h.size,emptyCount:a,numericCount:u,sum:u>0?c:null,avg:u>0?c/u:null,min:u>0?f:null,max:u>0?d:null}}const sk=24,dm=26,ok=110,hm=40,X9=12,Qn=1,lk='ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',ak='ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',G9=[{mode:"auto",label:"Auto"},{mode:"string",label:"String"},{mode:"number",label:"Number"},{mode:"boolean",label:"Boolean"}];function uk(t){return t==="string"?"STR":t==="number"?"NUM":t==="boolean"?"BOOL":null}function ck(t){if(!(t instanceof HTMLElement))return!1;const e=t.tagName;return e==="INPUT"||e==="TEXTAREA"||t.isContentEditable}const ol="inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background px-1.5 py-0.5 text-[11px] font-medium text-foreground hover:bg-muted outline-none focus-visible:ring-3 focus-visible:ring-ring/50",Xd=new Intl.NumberFormat("en-US",{maximumFractionDigits:4});function cd(t){return Xd.format(Object.is(t,-0)?0:t)}function q9(t){const e=[`Cells: ${Xd.format(t.cellCount)}`,`Distinct: ${Xd.format(t.distinctCount)}`];return t.emptyCount>0&&e.push(`Empty: ${Xd.format(t.emptyCount)}`),t.numericCount>0&&t.sum!==null&&t.avg!==null&&t.min!==null&&t.max!==null&&e.push(`Sum: ${cd(t.sum)}`,`Avg: ${cd(t.avg)}`,`Min: ${cd(t.min)}`,`Max: ${cd(t.max)}`),e.join(" · ")}function Y9(t){return t?{accentColor:"hsl(0 0% 98%)",accentFg:"hsl(240 10% 3.9%)",accentLight:"hsla(240, 4.9%, 70%, 0.18)",textDark:"hsl(0 0% 98%)",textMedium:"hsl(240 5% 64.9%)",textLight:"hsla(240, 5%, 64.9%, 0.4)",textBubble:"hsl(0 0% 98%)",textHeader:"hsl(240 5% 64.9%)",textHeaderSelected:"hsl(0 0% 98%)",bgCell:"hsl(240 6% 7%)",bgCellMedium:"hsl(240 6% 7%)",bgHeader:"hsl(240 6% 7%)",bgHeaderHasFocus:"hsl(240 3.7% 15.9%)",bgHeaderHovered:"hsl(240 3.7% 15.9%)",bgBubble:"hsl(240 3.7% 15.9%)",bgBubbleSelected:"hsl(240 6% 7%)",bgSearchResult:"hsl(240 3.7% 15.9%)",borderColor:"hsl(240 3.7% 15.9%)",horizontalBorderColor:"hsla(240, 3.7%, 15.9%, 0.6)",headerBottomBorderColor:"hsl(240 3.7% 15.9%)",linkColor:"hsl(0 0% 98%)",cellHorizontalPadding:8,cellVerticalPadding:3,headerFontStyle:"600 11px",baseFontStyle:"12px",editorFontSize:"12px",fontFamily:ak,lineHeight:1}:{accentColor:"hsl(240 10% 3.9%)",accentFg:"hsl(0 0% 100%)",accentLight:"hsla(240, 4.8%, 45%, 0.14)",textDark:"hsl(240 10% 3.9%)",textMedium:"hsl(240 3.8% 46.1%)",textLight:"hsla(240, 3.8%, 46.1%, 0.4)",textBubble:"hsl(240 10% 3.9%)",textHeader:"hsl(240 3.8% 46.1%)",textHeaderSelected:"hsl(240 10% 3.9%)",bgCell:"hsl(0 0% 100%)",bgCellMedium:"hsl(0 0% 100%)",bgHeader:"hsl(0 0% 100%)",bgHeaderHasFocus:"hsl(240 4.8% 95.9%)",bgHeaderHovered:"hsl(240 4.8% 95.9%)",bgBubble:"hsl(240 4.8% 95.9%)",bgBubbleSelected:"hsl(0 0% 100%)",bgSearchResult:"hsl(48 96% 89%)",borderColor:"hsl(240 5.9% 90%)",horizontalBorderColor:"hsla(240, 5.9%, 90%, 0.6)",headerBottomBorderColor:"hsl(240 5.9% 90%)",linkColor:"hsl(240 10% 3.9%)",cellHorizontalPadding:8,cellVerticalPadding:3,headerFontStyle:"600 11px",baseFontStyle:"12px",editorFontSize:"12px",fontFamily:ak,lineHeight:1}}function J9(t){return t?"hsla(45, 96%, 65%, 0.3)":"hsl(48 96% 89%)"}function qE({text:t,delimiter:e,testId:n="csv-table",dark:r=!1,onCellCommit:i,onUndo:s,onRedo:o,onCopySelection:l,columnTypes:a,onChangeColumnTypes:u,onProjectedCsvChange:c}){const f=y.useRef(null),d=y.useRef(null),h=y.useRef(null),p=y.useRef(null),[g,b]=y.useState(""),[m,v]=y.useState(""),[w,k]=y.useState(null),x=y.useRef(w);x.current=w;const C=y.useRef(null),[T,A]=y.useState(null),[R,P]=y.useState(""),_=y.useRef(null),[O,D]=y.useState(()=>new Set),[N,ne]=y.useState(!1),[ie,V]=y.useState(!1),[j,G]=y.useState(void 0),[M,I]=y.useState(()=>new Set),$=y.useRef(M),[B,Y]=y.useState(0),[W,de]=y.useState({}),le=i!==void 0,ge=a??W,$e=y.useCallback(z=>{de(z),u==null||u(z)},[u]),ke=y.useMemo(()=>Y9(r),[r]),ye=J9(r),lt=r?"hsl(240 3.7% 15.9%)":"hsl(240 4.8% 95.9%)",Fe=y.useRef();Fe.current===void 0&&(Fe.current=new R9);const He=y.useMemo(()=>{var z;return e===void 0?((z=gf(t))==null?void 0:z.cleanedCsv)??t:t},[t,e]),be=y.useMemo(()=>mf(He,e),[He,e]),Rt=y.useMemo(()=>D9(be),[be]),me=be.headers.length,Se=y.useRef(be.headers);if(Se.current!==be.headers){const z=Se.current,re=be.headers;Se.current=re;const Q=z.length===re.length,he=Q?re.reduce((ve,mt,je)=>mt===z[je]?ve:ve+1,0):1/0;(!Q||he>1||he===1&&re.length<=1)&&O.size>0&&D(new Set)}const Pe=y.useMemo(()=>{const z=Array.from({length:me},(Q,he)=>he);if(O.size===0)return z;const re=z.filter(Q=>!O.has(Q));return re.length>0?re:z},[me,O]),Xe=y.useRef(Pe);Xe.current=Pe;const rt=y.useMemo(()=>Pe.length===be.headers.length?be:{...be,headers:Pe.map(z=>be.headers[z]??""),rows:be.rows.map(z=>Pe.map(re=>z[re]??""))},[be,Pe]),_e=y.useRef({text:He,table:be,visibleTable:rt});_e.current={text:He,table:be,visibleTable:rt};const yt=y.useRef(j);yt.current=j,y.useEffect(()=>{const z=window.setTimeout(()=>v(g),150);return()=>window.clearTimeout(z)},[g]);const We=y.useMemo(()=>{const z=j9(be.rows,m);return w?H9(z,be.rows,w.col,w.dir,Rt[w.col]??!1):z},[be,m,w,Rt]),it=y.useRef(We);it.current=We,y.useEffect(()=>{const z=d.current;if(!z||typeof ResizeObserver>"u")return;const re=new ResizeObserver(()=>Y(z.clientWidth));return re.observe(z),Y(z.clientWidth),()=>re.disconnect()},[]);const pe=Math.max(ok,Math.floor((B-hm)/Math.max(1,Pe.length)));y.useEffect(()=>{if(!N)return;const z=Q=>{Q.key==="Escape"&&(Q.stopPropagation(),ne(!1))},re=Q=>{const he=h.current;he===null||!(Q.target instanceof Node)||he.contains(Q.target)||ne(!1)};return document.addEventListener("keydown",z),document.addEventListener("click",re),()=>{document.removeEventListener("keydown",z),document.removeEventListener("click",re)}},[N]);const at=y.useCallback(z=>{D(re=>{const Q=new Set(re);if(Q.has(z))Q.delete(z);else{if(me-(Q.size+1)<1)return re;Q.add(z)}return Q}),G(re=>re&&re.columns.length>0?{...re,columns:Pt.empty()}:re)},[me]),dt=y.useCallback(()=>{D(new Set),G(z=>z&&z.columns.length>0?{...z,columns:Pt.empty()}:z)},[]),Ge=Pe.length!ie||!on?null:W9(be,We,Pe),[ie,on,be,We,Pe]),Be=y.useRef(c);Be.current=c,y.useEffect(()=>{var z;(z=Be.current)==null||z.call(Be,vt)},[vt]),y.useEffect(()=>()=>{var z;(z=Be.current)==null||z.call(Be,null)},[]),y.useEffect(()=>{I(z=>{let re=!1;const Q=new Set;for(const he of z)he{G(z=>{if(!z||z.rows.length===0)return z;const re=[];for(const he of $.current){const ve=We.indexOf(he);ve!==-1&&re.push(ve)}re.sort((he,ve)=>he-ve);const Q=re.reduce((he,ve)=>he.add(ve),Pt.empty());return Q.equals(z.rows)?z:{...z,rows:Q}})},[We]),y.useEffect(()=>{k(z=>z!==null&&z.col>=me?null:z),A(z=>z!==null&&z.col>=me?null:z)},[me]);const ht=m!=="",Gt=be.rows.length,Zt=dm+Math.min(We.length,X9)*sk,Bn=()=>{b(""),v("")},Yn=y.useCallback((z,re)=>{var ve;if(z0||je.height>0)?{x:Math.max(0,ut.x-je.left),y:Math.max(0,ut.y-je.top),width:ut.width,height:ut.height}:ut??{x:hm+Q*pe,y:0,width:pe,height:dm};P(mt),A({col:he,bounds:ct});return}C.current=x.current,A(null),k(mt=>!mt||mt.col!==he?{col:he,dir:"asc"}:mt.dir==="asc"?{col:he,dir:"desc"}:null)}},[le,pe]),Ht=y.useCallback(()=>{if(!T)return;const{col:z}=T;if(A(null),!i)return;const{text:re,table:Q}=_e.current,he=Q.headers[z]??"",ve=$9(re,Q,z,R);if(ve!==re){if(he!==""&&he!==R&&ge[he]!==void 0){const mt={...ge},je=mt[he];delete mt[he],R!==""&&je!==void 0&&(mt[R]=je),$e(mt)}i(ve)}},[T,R,i,ge,$e]),jn=y.useCallback(()=>{A(null)},[]);y.useEffect(()=>{if(!T)return;const z=_.current;z&&(z.focus(),z.select())},[T]);const zt=y.useCallback((z,re)=>{const Q=it.current,he=Q[re];if(he===void 0)return;const ve=$.current,mt=p.current;let je;if(z.shiftKey&&mt!==null&&mt!==he){const ct=Q.indexOf(mt),Vt=Q.indexOf(he),en=ct===-1?Vt:ct,[$n,tn]=en<=Vt?[en,Vt]:[Vt,en];je=z.metaKey||z.ctrlKey?new Set(ve):new Set;for(let vn=$n;vn<=tn;vn++){const vr=Q[vn];vr!==void 0&&je.add(vr)}}else z.metaKey||z.ctrlKey?(je=new Set(ve),je.has(he)?je.delete(he):je.add(he)):je=new Set([he]);p.current=he,$.current=je,I(je);const ut=[...je].map(ct=>Q.indexOf(ct)).filter(ct=>ct!==-1).sort((ct,Vt)=>ct-Vt);G(ct=>({current:ct==null?void 0:ct.current,columns:(ct==null?void 0:ct.columns)??Pt.empty(),rows:ut.reduce((Vt,en)=>Vt.add(en),Pt.empty())}))},[]),Ln=y.useCallback(()=>{p.current=null,$.current=new Set,I(new Set),G(void 0)},[]),Br=y.useCallback(z=>{const re=new Set;for(const Q of z.rows){const he=it.current[Q];he!==void 0&&re.add(he)}$.current=re,I(re),G(z)},[]),$t=y.useCallback(()=>{Ln()},[Ln]),et=y.useMemo(()=>We.filter(z=>M.has(z)),[We,M]),ft=y.useMemo(()=>[...(j==null?void 0:j.columns)??[]].filter(z=>z>=Qn).map(z=>Pe[z-Qn]).filter(z=>z!==void 0),[j,Pe]),Wt=ft.length,qt=y.useMemo(()=>ft.map(z=>be.headers[z]).filter(z=>z!==void 0),[ft,be.headers]),ln=y.useMemo(()=>{if(qt.length===0)return null;const z=ge[qt[0]]??"auto";for(let re=1;re{if(!le||qt.length===0)return;const re={...ge};for(const Q of qt)z==="auto"?delete re[Q]:re[Q]=z;$e(re)},[le,qt,ge,$e]),Jn=y.useMemo(()=>le?be.headers.filter(z=>uk(ge[z])!==null).length:0,[le,be.headers,ge]),gt=y.useMemo(()=>({ranges:j!=null&&j.current?[j.current.range,...j.current.rangeStack]:[],columns:j?[...j.columns]:[],rows:M.size>0?We.reduce((z,re,Q)=>(M.has(re)&&z.push(Q),z),[]):j?[...j.rows]:[]}),[j,M,We]),Bt=Qn,J=y.useMemo(()=>K9(rt,We,gt,Bt),[rt,We,gt,Bt]),Me=et.length>0||Wt>0||J!==null,ze=y.useRef(l);ze.current=l;const It=()=>{var Q,he;const z=yt.current,re=ik(_e.current.visibleTable,it.current,{ranges:z!=null&&z.current?[z.current.range,...z.current.rangeStack]:[],columns:z?[...z.columns]:[],rows:z?[...z.rows]:[]},Qn);re!==null&&((Q=ze.current)==null||Q.call(ze),(he=navigator.clipboard)==null||he.writeText(re).catch(()=>{}))};y.useEffect(()=>{const z=re=>{var je,ut;const Q=f.current;if(!Q||!Q.contains(document.activeElement))return;const he=document.activeElement;if(he&&(he.tagName==="INPUT"||he.tagName==="TEXTAREA"||he.isContentEditable))return;const ve=yt.current,mt=ik(_e.current.visibleTable,it.current,{ranges:ve!=null&&ve.current?[ve.current.range,...ve.current.rangeStack]:[],columns:ve?[...ve.columns]:[],rows:ve?[...ve.rows]:[]},Qn);mt!==null&&(re.preventDefault(),re.stopImmediatePropagation(),(je=re.clipboardData)==null||je.setData("text/plain",mt),(ut=ze.current)==null||ut.call(ze))};return window.addEventListener("copy",z,{capture:!0}),()=>window.removeEventListener("copy",z,{capture:!0})},[]),y.useEffect(()=>{if(!s&&!o)return;const z=re=>{const Q=f.current;if(!Q)return;const he=re.target instanceof Node&&Q.contains(re.target),ve=document.activeElement instanceof Node&&Q.contains(document.activeElement);if(!he&&!ve||ck(re.target)||ck(document.activeElement))return;const mt=B9(re);mt==="undo"&&s?(re.preventDefault(),s()):mt==="redo"&&o&&(re.preventDefault(),o())};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[s,o]);const Yt=y.useCallback(z=>{var Q;const re=f.current!==null&&document.activeElement instanceof Node&&f.current.contains(document.activeElement);Ln(),i==null||i(z),re&&((Q=d.current)==null||Q.focus({preventScroll:!0}))},[Ln,i]),Jt=me>0&&ft.length>=me,jl=()=>{!le||et.length===0||Yt(fm(_e.current.text,_e.current.table,et))},ts=()=>{!le||Jt||ft.length===0||Yt(tk(_e.current.text,_e.current.table,ft))},Ci=y.useCallback(z=>{if(!i)return!1;const{text:Q,table:he}=_e.current,ve=it.current;if(z.rows.length>0){const ut=[...z.rows].map(ct=>ve[ct]).filter(ct=>ct!==void 0);if(ut.length>0)return Yt(fm(Q,he,ut)),!1}if(z.columns.length>0){const ut=[...z.columns].filter(ct=>ct>=Qn).map(ct=>Xe.current[ct-Qn]).filter(ct=>ct!==void 0&&ct>=0&&ct0&&ut.length0&&Yt(fm(Q,he,je)),!1},[Yt,i]),Ti=y.useCallback(z=>{const re=i;if(!re)return!1;const{text:Q,table:he}=_e.current,ve=it.current,mt=[...z].sort((ct,Vt)=>ct.location[1]-Vt.location[1]);let je=Q,ut=0;for(const{location:ct,value:Vt}of mt){const en=ct[0]-Qn,$n=en>=0?Xe.current[en]:void 0,tn=ct[1];if($n===void 0||$n<0||Vt.kind!==Ee.Text)continue;const vn=ve[tn],vr=vn===void 0?void 0:he.rowSpans[vn];if(!vr)continue;const eo=je.slice(vr.start+ut,vr.end+ut),Ei=dw(eo,he.delimiter);for(;Ei.length<=$n;)Ei.push("");const Ai=Vt.data??"";if(Ei[$n]===Ai)continue;Ei[$n]=Ai;const sr=Ka(Ei,he.delimiter);je=je.slice(0,vr.start+ut)+sr+je.slice(vr.end+ut),ut+=sr.length-(vr.end-vr.start)}return je!==Q&&re(je),!0},[i]),ns=y.useCallback(z=>{var je;const[re,Q]=z,he=it.current[Q];if(re{const re=[];for(let Q=z.y;Q{z[0]>=Qn||zt(re,z[1])},[zt]),si=y.useMemo(()=>{const z={title:"#",id:"__gutter",width:hm,themeOverride:{baseFontStyle:`11px ${lk}`,textDark:"hsla(240, 3.8%, 46.1%, 0.4)"}},re=Pe.map(Q=>{const he=be.headers[Q]??"",ve=le?uk(ge[he]):null;return{title:ve?`${he.toUpperCase()} [${ve}]`:he.toUpperCase(),id:`c${Q}`,width:pe,themeOverride:Rt[Q]?{baseFontStyle:`12px ${lk}`}:void 0}});return[z,...re]},[be.headers,Pe,Rt,pe,le,ge]),Js=y.useCallback((z,re)=>{const{ctx:Q,columnIndex:he,rect:ve,theme:mt,isSelected:je}=z;Q.save();try{if(Q.letterSpacing="0.5px",je&&(Q.fillStyle=mt.bgHeaderHovered,Q.fillRect(ve.x,ve.y,ve.width,ve.height),Q.fillStyle=mt.accentColor,Q.fillRect(ve.x,ve.y+ve.height-2,ve.width,2)),he{const{ctx:Q,cell:he,rect:ve,col:mt,theme:je}=z,ut=mt-Qn;if(ut>=0&&ht&&he.kind===Ee.Text){const ct=Q9(he.data,m);if(ct!==null){Q.save();try{const Vt=`${je.baseFontStyle} ${je.fontFamily}`;Q.font=Vt;let en=ve.x+je.cellHorizontalPadding;const $n=ve.y+ve.height/2+Ys(Q,Vt);for(const tn of ct){const vn=Q.measureText(tn.text).width;tn.hit&&vn>0&&(Q.fillStyle=ye,Q.fillRect(en-1,$n-7,vn+2,14)),en+=vn}}finally{Q.restore()}}}if(re(),ut>=0&&he.kind===Ee.Text&&he.data===""){Q.save();try{Q.font=`${je.baseFontStyle} ${je.fontFamily}`,Q.fillStyle=je.textLight,Q.fillText("—",ve.x+je.cellHorizontalPadding,ve.y+ve.height/2+.5)}finally{Q.restore()}}},[ht,m,ye]),Zs=y.useCallback(z=>{const re=it.current[z];return re!==void 0&&$.current.has(re)?{bgCell:lt,bgCellMedium:lt}:void 0},[lt]);return me===0?E.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"No columns detected."}):E.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",ref:f,children:[E.jsxs("div",{"data-testid":`${n}-toolbar`,className:"flex flex-none flex-wrap items-center gap-1.5 border-b border-border bg-panel px-2 py-1",children:[E.jsxs("div",{className:"relative min-w-32 flex-1 sm:max-w-64",children:[E.jsx(wN,{"aria-hidden":"true",className:"pointer-events-none absolute left-1.5 top-1/2 size-3 -translate-y-1/2 text-muted-foreground/60"}),E.jsx("input",{type:"text","data-testid":`${n}-search`,"aria-label":"Search rows",value:g,onChange:z=>b(z.target.value),onKeyDown:z=>{z.key==="Escape"&&Bn()},placeholder:"Search…",className:"h-6 w-full rounded-md border border-border bg-background pl-6 pr-6 text-xs text-foreground outline-none placeholder:text-muted-foreground/50 focus-visible:ring-3 focus-visible:ring-ring/50"}),g!==""&&E.jsx("button",{type:"button","data-testid":`${n}-clear-search`,"aria-label":"Clear search",onClick:Bn,className:"absolute right-1 top-1/2 -translate-y-1/2 cursor-pointer rounded p-0.5 text-muted-foreground/60 outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:E.jsx(Eh,{"aria-hidden":"true",className:"size-3"})})]}),E.jsx("span",{"data-testid":`${n}-count`,role:"status",className:"rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium tabular-nums text-muted-foreground",children:ht?`${We.length.toLocaleString()} of ${Gt.toLocaleString()}`:`${Gt.toLocaleString()} rows`}),le&&Jn>0&&E.jsxs("button",{type:"button","data-testid":"input-table-column-types-reset",onClick:()=>$e({}),title:"Reset all pinned column types to Auto",className:ol,children:[`${Jn} ${Jn===1?"column type":"column types"} pinned`,E.jsx(Eh,{"aria-hidden":"true",className:"size-3 text-muted-foreground"})]}),E.jsxs("div",{ref:h,className:"relative",children:[E.jsxs("button",{type:"button","data-testid":`${n}-columns-button`,"aria-expanded":N,"aria-haspopup":"dialog","aria-label":"Columns",onClick:()=>ne(z=>!z),className:Gn(ol,Ge&&"border-foreground/30 bg-muted font-semibold"),children:[E.jsx(lN,{"aria-hidden":"true",className:"size-3"}),E.jsx("span",{children:Ge?`Columns (${Pe.length}/${me})`:"Columns"})]}),N&&E.jsxs("div",{"data-testid":`${n}-columns-popout`,role:"dialog","aria-label":"Visible columns",className:"absolute left-0 top-7 z-30 min-w-44 max-w-64 rounded-md border border-border bg-panel p-1.5 shadow-md",children:[E.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 border-b border-border px-1.5 pb-1",children:[E.jsxs("span",{className:"text-[11px] font-semibold text-foreground",children:["Columns (",Pe.length,"/",me,")"]}),Ge&&E.jsx("button",{type:"button","data-testid":`${n}-columns-reset`,onClick:dt,className:"cursor-pointer rounded px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground",children:"Show all"})]}),E.jsx("div",{className:"max-h-56 overflow-y-auto",children:be.headers.map((z,re)=>{const Q=!O.has(re),he=Q&&Pe.length<=1,ve=z!==""?z:`Column ${re+1}`;return E.jsxs("label",{className:Gn("flex items-center gap-2 rounded px-1.5 py-1 text-xs",he?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-muted"),children:[E.jsx("input",{type:"checkbox","data-testid":`${n}-column-toggle-${re}`,checked:Q,disabled:he,onChange:()=>at(re),className:"size-3.5 accent-foreground"}),E.jsx("span",{className:"truncate font-mono text-[11px] text-foreground",children:ve})]},re)})})]})]}),on&&E.jsx("button",{type:"button","data-testid":`${n}-apply-view`,"aria-pressed":ie,onClick:()=>V(z=>!z),className:Gn("inline-flex cursor-pointer items-center gap-1 rounded-md border px-2 py-0.5 text-[11px] font-medium transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50",ie?"border-foreground bg-foreground text-background hover:bg-foreground/90":"border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground"),children:"Apply view to output"}),Me&&E.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[E.jsx("span",{"data-testid":`${n}-selected-count`,className:"text-[11px] font-medium tabular-nums text-muted-foreground",children:et.length>0?`${et.length.toLocaleString()} selected`:Wt>0?`${Wt.toLocaleString()} ${Wt===1?"column":"columns"} selected`:`${((J==null?void 0:J.cellCount)??0).toLocaleString()} cells selected`}),J!==null&&E.jsx("span",{"data-testid":`${n}-selection-stats`,className:"rounded-md bg-muted px-2 py-0.5 font-mono text-[11px] font-medium tabular-nums text-muted-foreground",children:q9(J)}),E.jsxs("button",{type:"button","data-testid":`${n}-copy`,onClick:It,className:ol,children:[E.jsx(zv,{"aria-hidden":"true",className:"size-3"}),"Copy as CSV"]}),le&&et.length>0&&E.jsxs("button",{type:"button","data-testid":`${n}-delete-rows`,onClick:jl,title:`Deletes the ${et.length} selected ${et.length===1?"row":"rows"} from the source CSV`,className:ol,children:[E.jsx(Th,{"aria-hidden":"true",className:"size-3"}),"Delete ",et.length.toLocaleString()," ",et.length===1?"row":"rows"]}),le&&Wt>0&&E.jsxs(E.Fragment,{children:[E.jsx("span",{role:"group","aria-label":"Column type override","data-testid":"input-table-column-type-group",className:"inline-flex items-center gap-0.5 rounded-md border border-border bg-muted/60 p-0.5",children:G9.map(({mode:z,label:re})=>{const Q=ln===z;return E.jsx("button",{type:"button","data-testid":`input-table-column-type-${z}`,"aria-pressed":Q,onClick:()=>kn(z),className:Q?"cursor-pointer rounded bg-background px-1.5 py-0.5 text-[11px] font-medium text-foreground shadow-2xs outline-none focus-visible:ring-3 focus-visible:ring-ring/50":"cursor-pointer rounded px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:re},z)})}),E.jsxs("button",{type:"button","data-testid":`${n}-delete-columns`,onClick:ts,disabled:Jt,title:Jt?"At least one column must remain — the converter needs a column to detect":`Deletes the ${Wt} selected ${Wt===1?"column":"columns"} from the source CSV`,className:`${ol} disabled:cursor-not-allowed disabled:opacity-50`,children:[E.jsx(Th,{"aria-hidden":"true",className:"size-3"}),"Delete ",Wt.toLocaleString()," ",Wt===1?"column":"columns"]})]}),E.jsx("button",{type:"button","data-testid":`${n}-clear-selection`,onClick:Ln,className:ol,children:"Clear"})]})]}),E.jsxs("div",{ref:d,"data-testid":n,role:"grid",tabIndex:-1,"aria-rowcount":We.length+1,className:"relative min-h-0 flex-1 outline-none",style:{minHeight:Zt},children:[E.jsx("div",{className:"absolute inset-0",children:E.jsx(B6,{imageWindowLoader:Fe.current,renderers:k9,columns:si,rows:We.length,getCellContent:ns,getCellsForSelection:Hl,onCellsEdited:le?Ti:void 0,onDelete:le?Ci:void 0,onCellClicked:Wl,onHeaderClicked:Yn,onGridSelectionChange:Br,onSelectionCleared:$t,gridSelection:j,rangeSelect:"multi-rect",columnSelect:"multi",rowSelect:"multi",rowHeight:sk,headerHeight:dm,freezeColumns:Qn,fillHandle:le,onPaste:le?()=>!0:!1,keybindings:{search:!1},theme:ke,drawHeader:Js,drawCell:Qs,getRowThemeOverride:Zs,minColumnWidth:ok,smoothScrollX:!0,smoothScrollY:!0,verticalBorder:!1})}),T!==null&&E.jsx("input",{ref:_,type:"text","data-testid":"csv-header-rename-input","aria-label":`Rename column ${be.headers[T.col]??""}`,value:R,onChange:z=>P(z.target.value),onBlur:Ht,onKeyDown:z=>{z.key==="Enter"?(z.preventDefault(),z.stopPropagation(),Ht()):z.key==="Escape"&&(z.preventDefault(),z.stopPropagation(),jn())},style:{left:T.bounds.x,top:T.bounds.y,width:Math.max(60,T.bounds.width),height:T.bounds.height},className:"absolute z-20 border border-ring bg-background px-2 font-mono text-[11px] font-semibold tracking-wider text-foreground outline-none ring-2 ring-ring/50"}),ht&&We.length===0&&E.jsxs("div",{"data-testid":`${n}-empty-filter`,className:"absolute inset-x-0 top-0 z-10 flex flex-col items-center gap-2 p-6 text-sm text-muted-foreground",children:[E.jsxs("span",{children:["No rows matching “",m,"”."]}),E.jsx("button",{type:"button",onClick:Bn,className:ol,children:"Show all rows"})]}),le&&!ht&&We.length===0&&E.jsx("div",{"data-testid":`${n}-empty-rows`,className:"absolute inset-x-0 top-0 z-10 flex flex-col items-center gap-2 p-6 text-sm text-muted-foreground",children:E.jsx("span",{children:"No rows. Paste or upload data to start over."})})]})]})}function Q9(t,e){if(e===""||t==="")return null;const n=e.toLowerCase();if(!t.toLowerCase().includes(n))return null;const r=[],i=t.toLowerCase();let s=0;for(;;){const o=i.indexOf(n,s);if(o===-1)break;o>s&&r.push({text:t.slice(s,o),hit:!1}),r.push({text:t.slice(o,o+n.length),hit:!0}),s=o+n.length}return s"u"?void 0:navigator),s=y.useRef(null);y.useEffect(()=>{var l;(l=s.current)==null||l.focus()},[]);const o=t==="CSV";return E.jsx("div",{"data-testid":"dropzone",className:"flex flex-1 flex-col items-center justify-center p-3 md:p-6 md:px-16",children:E.jsxs("div",{className:"flex w-full max-w-sm flex-col items-center gap-2.5 md:gap-3",children:[E.jsx("div",{"aria-hidden":"true",className:"flex size-9 items-center justify-center rounded-xl border border-border bg-muted/50 text-muted-foreground md:size-11",children:E.jsx(rN,{className:"size-4 md:size-5"})}),E.jsxs("p",{className:"text-sm font-medium text-foreground",children:["Paste ",o?"CSV or TSV":"JSON"," here"]}),E.jsx("textarea",{ref:s,"data-testid":"paste-field",rows:1,"aria-label":`Paste ${o?"CSV or TSV":"JSON"} data — or press ${i} to paste anywhere on this page`,placeholder:o?"Paste CSV or TSV text here":"Paste JSON here",spellCheck:!1,onChange:l=>{const a=l.currentTarget;a.rows=nV(a.value),e(a.value)},className:"min-h-11 w-full resize-none rounded-md border border-border bg-background px-3 py-2.5 font-mono text-[12.5px] leading-relaxed text-foreground transition-colors placeholder:text-muted-foreground focus:outline-none focus-visible:border-sky-600 dark:focus-visible:border-sky-400"}),E.jsxs("p",{className:"text-center text-[13px] leading-relaxed text-muted-foreground",children:["or drag & drop a file anywhere in this pane — you can also paste anywhere on the page (",E.jsx("kbd",{"data-testid":"paste-shortcut",className:"rounded border border-border bg-muted px-1.5 py-0.5 font-mono text-[11px] font-medium text-foreground",children:i}),")"]}),E.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[E.jsxs("button",{type:"button","data-testid":"choose-file",onClick:n,className:"inline-flex h-8 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-lg border border-border bg-background px-3 text-[13px] font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 [&_svg]:size-3.5",children:[E.jsx(kT,{"aria-hidden":"true"}),"Choose file"]}),E.jsxs("button",{type:"button","data-testid":"try-example",onClick:r,className:"inline-flex h-8 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-lg px-3 text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 [&_svg]:size-3.5",children:[E.jsx(xN,{"aria-hidden":"true"}),"Try an example"]})]})]})})}let J0=[],YE=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=YE[r])e=r+1;else return!0;if(e==n)return!1}}function fk(t){return t>=127462&&t<=127487}const dk=8205;function sV(t,e,n=!0,r=!0){return(n?JE:oV)(t,e,r)}function JE(t,e,n){if(e==t.length)return e;e&&QE(t.charCodeAt(e))&&ZE(t.charCodeAt(e-1))&&e--;let r=pm(t,e);for(e+=hk(r);e=0&&fk(pm(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function oV(t,e,n){for(;e>1;){let r=JE(t,e-2,n);if(r=56320&&t<57344}function ZE(t){return t>=55296&&t<56320}function hk(t){return t<65536?1:2}class _t{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=Xa(this,e,n);let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),ps.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=Xa(this,e,n);let r=[];return this.decompose(e,n,r,0),ps.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new yc(this),s=new yc(e);for(let o=n,l=n;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(l+=i.value.length,i.done||l>=r)return!0}}iter(e=1){return new yc(this,e)}iterRange(e,n=this.length){return new eA(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new tA(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?_t.empty:e.length<=32?new Nn(e):ps.from(Nn.split(e,[]))}}class Nn extends _t{constructor(e,n=lV(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.text[s],l=i+o.length;if((n?r:l)>=e)return new aV(i,l,r,o);i=l+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new Nn(pk(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),l=Gd(s.text,o.text.slice(),0,s.length);if(l.length<=32)r.push(new Nn(l,o.length+s.length));else{let a=l.length>>1;r.push(new Nn(l.slice(0,a)),new Nn(l.slice(a)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof Nn))return super.replace(e,n,r);[e,n]=Xa(this,e,n);let i=Gd(this.text,Gd(r.text,pk(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new Nn(i,s):ps.from(Nn.split(i,[]),s)}sliceString(e,n=this.length,r=` -`){[e,n]=Xa(this,e,n);let i="";for(let s=0,o=0;s<=n&&oe&&o&&(i+=r),es&&(i+=l.slice(Math.max(0,e-s),n-s)),s=a+1}return i}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],i=-1;for(let s of e)r.push(s),i+=s.length+1,r.length==32&&(n.push(new Nn(r,i)),r=[],i=-1);return i>-1&&n.push(new Nn(r,i)),n}}class ps extends _t{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.children[s],l=i+o.length,a=r+o.lines-1;if((n?a:l)>=e)return o.lineInner(e,n,r,i);i=l+1,r=a+1}}decompose(e,n,r,i){for(let s=0,o=0;o<=n&&s=o){let u=i&((o<=e?1:0)|(a>=n?2:0));o>=e&&a<=n&&!u?r.push(l):l.decompose(e-o,n-o,r,u)}o=a+1}}replace(e,n,r){if([e,n]=Xa(this,e,n),r.lines=s&&n<=l){let a=o.replace(e-s,n-s,r),u=this.lines-o.lines+a.lines;if(a.lines>4&&a.lines>u>>6){let c=this.children.slice();return c[i]=a,new ps(c,this.length-(n-e)+r.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` -`){[e,n]=Xa(this,e,n);let i="";for(let s=0,o=0;se&&s&&(i+=r),eo&&(i+=l.sliceString(e-o,n-o,r)),o=a+1}return i}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof ps))return 0;let r=0,[i,s,o,l]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=n,s+=n){if(i==o||s==l)return r;let a=this.children[i],u=e.children[s];if(a!=u)return r+a.scanIdentical(u,n);r+=a.length+1}}static from(e,n=e.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let h of e)r+=h.lines;if(r<32){let h=[];for(let p of e)p.flatten(h);return new Nn(h,n)}let i=Math.max(32,r>>5),s=i<<1,o=i>>1,l=[],a=0,u=-1,c=[];function f(h){let p;if(h.lines>s&&h instanceof ps)for(let g of h.children)f(g);else h.lines>o&&(a>o||!a)?(d(),l.push(h)):h instanceof Nn&&a&&(p=c[c.length-1])instanceof Nn&&h.lines+p.lines<=32?(a+=h.lines,u+=h.length+1,c[c.length-1]=new Nn(p.text.concat(h.text),p.length+1+h.length)):(a+h.lines>i&&d(),a+=h.lines,u+=h.length+1,c.push(h))}function d(){a!=0&&(l.push(c.length==1?c[0]:ps.from(c,u)),u=-1,a=c.length=0)}for(let h of e)f(h);return d(),l.length==1?l[0]:new ps(l,n)}}_t.empty=new Nn([""],0);function lV(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Gd(t,e,n=0,r=1e9){for(let i=0,s=0,o=!0;s=n&&(a>r&&(l=l.slice(0,r-i)),i0?1:(e instanceof Nn?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,i=this.nodes[r],s=this.offsets[r],o=s>>1,l=i instanceof Nn?i.text.length:i.children.length;if(o==(n>0?l:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(i instanceof Nn){let a=i.text[o+(n<0?-1:0)];if(this.offsets[r]+=n,a.length>Math.max(0,e))return this.value=e==0?a:n>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=i.children[o+(n<0?-1:0)];e>a.length?(e-=a.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(a),this.offsets.push(n>0?1:(a instanceof Nn?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class eA{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new yc(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*n,this.value=i.length<=r?i:n<0?i.slice(i.length-r):i.slice(0,r),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class tA{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:i}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(_t.prototype[Symbol.iterator]=function(){return this.iter()},yc.prototype[Symbol.iterator]=eA.prototype[Symbol.iterator]=tA.prototype[Symbol.iterator]=function(){return this});class aV{constructor(e,n,r,i){this.from=e,this.to=n,this.number=r,this.text=i}get length(){return this.to-this.from}}function Xa(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function gr(t,e,n=!0,r=!0){return sV(t,e,n,r)}function uV(t){return t>=56320&&t<57344}function cV(t){return t>=55296&&t<56320}function fV(t,e){let n=t.charCodeAt(e);if(!cV(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return uV(r)?(n-55296<<10)+(r-56320)+65536:n}function dV(t){return t<65536?1:2}const Q0=/\r\n?|\n/;var Ir=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(Ir||(Ir={}));class Ts{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return s+(e-i);s+=l}else{if(r!=Ir.Simple&&u>=e&&(r==Ir.TrackDel&&ie||r==Ir.TrackBefore&&ie))return null;if(u>e||u==e&&n<0&&!l)return e==i||n<0?s:s+a;s+=a}i=u}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return s}touchesRange(e,n=e){for(let r=0,i=0;r=0&&i<=n&&l>=e)return in?"cover":!0;i=l}return!1}toString(){let e="";for(let n=0;n=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Ts(e)}static create(e){return new Ts(e)}}class Wn extends Ts{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Z0(this,(n,r,i,s,o)=>e=e.replace(i,i+(r-n),o),!1),e}mapDesc(e,n=!1){return ey(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let i=0,s=0;i=0){n[i]=l,n[i+1]=o;let a=i>>1;for(;r.length0&&Eo(r,n,s.text),s.forward(c),l+=c}let u=e[o++];for(;l>1].toJSON()))}return e}static of(e,n,r){let i=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!i.length)return;od||f<0||d>n)throw new RangeError(`Invalid change range ${f} to ${d} (in doc of length ${n})`);let p=h?typeof h=="string"?_t.of(h.split(r||Q0)):h:_t.empty,g=p.length;if(f==d&&g==0)return;fo&&hr(i,f-o,-1),hr(i,d-f,g),Eo(s,i,p),o=d}}return u(e),a(!l),l}static empty(e){return new Wn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let i=0;il&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;r.length=0&&n<=0&&n==t[i+1]?t[i]+=e:i>=0&&e==0&&t[i]==0?t[i+1]+=n:r?(t[i]+=e,t[i+1]+=n):t.push(e,n)}function Eo(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||o==t.sections.length||t.sections[o+1]<0);)l=t.sections[o++],a=t.sections[o++];e(i,u,s,c,f),i=u,s=c}}}function ey(t,e,n,r=!1){let i=[],s=r?[]:null,o=new Vc(t),l=new Vc(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let u=Math.min(o.len,l.len);hr(i,u,-1),o.forward(u),l.forward(u)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len=0&&a=0){let u=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);u+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.lena||o.ins>=0&&o.len>a)&&(l||r.length>u),s.forward2(a),o.forward(a)}}}}class Vc{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?_t.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?_t.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class xo{constructor(e,n,r,i){this.from=e,this.to=n,this.flags=r,this.goalColumn=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,i;return this.empty?r=i=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new xo(r,i,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ce.range(e,n,void 0,void 0,r);let i=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ce.range(this.anchor,i,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return ce.range(e.anchor,e.head)}static create(e,n,r,i){return new xo(e,n,r,i)}}class ce{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ce.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ce(e.ranges.map(n=>xo.fromJSON(n)),e.main)}static single(e,n=e){return new ce([ce.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;ii.from-s.from),n=e.indexOf(r);for(let i=1;is.head?ce.range(a,l):ce.range(l,a))}}return new ce(e,n)}}function rA(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let hw=0;class Ue{constructor(e,n,r,i,s){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=hw++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:pw),!!e.static,e.enables)}of(e){return new qd([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new qd(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new qd(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function pw(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class qd{constructor(e,n,r,i){this.dependencies=e,this.facet=n,this.type=r,this.value=i,this.id=hw++}dynamicSlot(e){var n;let r=this.value,i=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,u=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?u=!0:((n=e[f.id])!==null&&n!==void 0?n:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=r(f),1},update(f,d){if(a&&d.docChanged||u&&(d.docChanged||d.selection)||ty(f,c)){let h=r(f);if(l?!gk(h,f.values[o],i):!i(h,f.values[o]))return f.values[o]=h,1}return 0},reconfigure:(f,d)=>{let h,p=d.config.address[s];if(p!=null){let g=Hh(d,p);if(this.dependencies.every(b=>b instanceof Ue?d.facet(b)===f.facet(b):b instanceof Rs?d.field(b,!1)==f.field(b,!1):!0)||(l?gk(h=r(f),g,i):i(h=r(f),g)))return f.values[o]=g,0}else h=r(f);return f.values[o]=h,1}}}get extension(){return this}}function gk(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[a.id]),i=n.map(a=>a.type),s=r.filter(a=>!(a&1)),o=t[e.id]>>1;function l(a){let u=[];for(let c=0;cr===i),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(fd).find(r=>r.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,i)=>{let s=r.values[n],o=this.updateF(s,i);return this.compareF(s,o)?0:(r.values[n]=o,1)},reconfigure:(r,i)=>{let s=r.facet(fd),o=i.facet(fd),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(r.values[n]=l.create(r),1):i.config.address[this.id]!=null?(r.values[n]=i.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,fd.of({field:this,create:e})]}get extension(){return this}}const pl={lowest:4,low:3,default:2,high:1,highest:0};function ju(t){return e=>new iA(e,t)}const gw={highest:ju(pl.highest),high:ju(pl.high),default:ju(pl.default),low:ju(pl.low),lowest:ju(pl.lowest)};class iA{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class Sl{of(e){return new ny(this,e)}reconfigure(e){return Sl.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class ny{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class jh{constructor(e,n,r,i,s,o){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=i,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let i=[],s=Object.create(null),o=new Map;for(let d of pV(e,n,o))d instanceof Rs?i.push(d):(s[d.facet.id]||(s[d.facet.id]=[])).push(d);let l=Object.create(null),a=[],u=[];for(let d of i)l[d.id]=u.length<<1,u.push(h=>d.slot(h));let c=r==null?void 0:r.config.facets;for(let d in s){let h=s[d],p=h[0].facet,g=c&&c[d]||[];if(h.every(b=>b.type==0))if(l[p.id]=a.length<<1|1,pw(g,h))a.push(r.facet(p));else{let b=p.combine(h.map(m=>m.value));a.push(r&&p.compare(b,r.facet(p))?r.facet(p):b)}else{for(let b of h)b.type==0?(l[b.id]=a.length<<1|1,a.push(b.value)):(l[b.id]=u.length<<1,u.push(m=>b.dynamicSlot(m)));l[p.id]=u.length<<1,u.push(b=>hV(b,p,h))}}let f=u.map(d=>d(l));return new jh(e,o,f,l,a,s)}}function pV(t,e,n){let r=[[],[],[],[],[]],i=new Map;function s(o,l){let a=i.get(o);if(a!=null){if(a<=l)return;let u=r[a].indexOf(o);u>-1&&r[a].splice(u,1),o instanceof ny&&n.delete(o.compartment)}if(i.set(o,l),Array.isArray(o))for(let u of o)s(u,l);else if(o instanceof ny){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;n.set(o.compartment,u),s(u,l)}else if(o instanceof iA)s(o.inner,o.prec);else if(o instanceof Rs)r[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof qd)r[l].push(o),o.facet.extensions&&s(o.facet.extensions,pl.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(u==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(u,l)}}return s(t,pl.default),r.reduce((o,l)=>o.concat(l))}function vc(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let i=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|i}function Hh(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const sA=Ue.define(),ry=Ue.define({combine:t=>t.some(e=>e),static:!0}),oA=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),lA=Ue.define(),aA=Ue.define(),uA=Ue.define(),cA=Ue.define({combine:t=>t.length?t[0]:!1});class Go{constructor(e,n){this.type=e,this.value=n}static define(){return new gV}}class gV{of(e){return new Go(this,e)}}class mV{constructor(e){this.map=e}of(e){return new rn(this,e)}}class rn{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new rn(this.type,n)}is(e){return this.type==e}static define(e={}){return new mV(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let i of e){let s=i.map(n);s&&r.push(s)}return r}}rn.reconfigure=rn.define();rn.appendConfig=rn.define();class Kn{constructor(e,n,r,i,s,o){this.startState=e,this.changes=n,this.selection=r,this.effects=i,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,r&&rA(r,n.newLength),s.some(l=>l.type==Kn.time)||(this.annotations=s.concat(Kn.time.of(Date.now())))}static create(e,n,r,i,s,o){return new Kn(e,n,r,i,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(Kn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}Kn.time=Go.define();Kn.userEvent=Go.define();Kn.addToHistory=Go.define();Kn.remote=Go.define();function yV(t,e){let n=[];for(let r=0,i=0;;){let s,o;if(r=t[r]))s=t[r++],o=t[r++];else if(i=0;i--){let s=r[i](t);s instanceof Kn?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Kn?t=s[0]:t=dA(e,Ia(s),!1)}return t}function wV(t){let e=t.startState,n=e.facet(uA),r=t;for(let i=n.length-1;i>=0;i--){let s=n[i](t);s&&Object.keys(s).length&&(r=fA(r,iy(e,s,t.changes.newLength),!0))}return r==t?t:Kn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const bV=[];function Ia(t){return t==null?bV:Array.isArray(t)?t:[t]}var js=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(js||(js={}));const xV=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let sy;try{sy=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function kV(t){if(sy)return sy.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||xV.test(n)))return!0}return!1}function SV(t){return e=>{if(!/\S/.test(e))return js.Space;if(kV(e))return js.Word;for(let n=0;n-1)return js.Word;return js.Other}}class Ft{constructor(e,n,r,i,s,o){this.config=e,this.doc=n,this.selection=r,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;li.set(u,a)),n=null),i.set(l.value.compartment,l.value.extension)):l.is(rn.reconfigure)?(n=null,r=l.value):l.is(rn.appendConfig)&&(n=null,r=Ia(r).concat(l.value));let s;n?s=e.startState.values.slice():(n=jh.resolve(r,i,this),s=new Ft(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(a,u)=>u.reconfigure(a,this),null).values);let o=e.startState.facet(ry)?e.newSelection:e.newSelection.asSingle();new Ft(n,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ce.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),i=this.changes(r.changes),s=[r.range],o=Ia(r.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return Ft.create({doc:e.doc,selection:ce.fromJSON(e.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(e={}){let n=jh.resolve(e.extensions||[],new Map),r=e.doc instanceof _t?e.doc:_t.of((e.doc||"").split(n.staticFacet(Ft.lineSeparator)||Q0)),i=e.selection?e.selection instanceof ce?e.selection:ce.single(e.selection.anchor,e.selection.head):ce.single(0);return rA(i,r.length),n.staticFacet(ry)||(i=i.asSingle()),new Ft(n,r,i,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(Ft.tabSize)}get lineBreak(){return this.facet(Ft.lineSeparator)||` -`}get readOnly(){return this.facet(cA)}phrase(e,...n){for(let r of this.facet(Ft.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,i)=>{if(i=="$")return"$";let s=+(i||1);return!s||s>n.length?r:n[s-1]})),e}languageDataAt(e,n,r=-1){let i=[];for(let s of this.facet(sA))for(let o of s(this,n,r))Object.prototype.hasOwnProperty.call(o,e)&&i.push(o[e]);return i}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return SV(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:i}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-r,l=e-r;for(;o>0;){let a=gr(n,o,!1);if(s(n.slice(a,o))!=js.Word)break;o=a}for(;lt.length?t[0]:4});Ft.lineSeparator=oA;Ft.readOnly=cA;Ft.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(i=>t[i]==e[i])}});Ft.languageData=sA;Ft.changeFilter=lA;Ft.transactionFilter=aA;Ft.transactionExtender=uA;Sl.reconfigure=rn.define();function hA(t,e,n={}){let r={};for(let i of t)for(let s of Object.keys(i)){let o=i[s],l=r[s];if(l===void 0)r[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(n,s))r[s]=n[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let i in e)r[i]===void 0&&(r[i]=e[i]);return r}class Pl{eq(e){return this==e}range(e,n=e){return oy.create(e,n,this)}}Pl.prototype.startSide=Pl.prototype.endSide=0;Pl.prototype.point=!1;Pl.prototype.mapMode=Ir.TrackDel;function mw(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let oy=class pA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new pA(e,n,r)}};function ly(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class yw{constructor(e,n,r,i){this.from=e,this.to=n,this.value=r,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,n,r,i=0){let s=r?this.to:this.from;for(let o=i,l=s.length;;){if(o==l)return o;let a=o+l>>1,u=s[a]-e||(r?this.value[a].endSide:this.value[a].startSide)-n;if(a==o)return u>=0?o:l;u>=0?l=a:o=a+1}}between(e,n,r,i){for(let s=this.findIndex(n,-1e9,!0),o=this.findIndex(r,1e9,!1,s);sh||d==h&&u.startSide>0&&u.endSide<=0)continue;(h-d||u.endSide-u.startSide)<0||(o<0&&(o=d),u.point&&(l=Math.max(l,h-d)),r.push(u),i.push(d-o),s.push(h-o))}return{mapped:r.length?new yw(i,s,r,l):null,pos:o}}}class Kt{constructor(e,n,r,i){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=i}static create(e,n,r,i){return new Kt(e,n,r,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:s=this.length}=e,o=e.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(ly)),this.isEmpty)return n.length?Kt.of(n):this;let l=new gA(this,null,-1).goto(0),a=0,u=[],c=new Ga;for(;l.value||a=0){let f=n[a++];c.addInner(f.from,f.to,f.value)||u.push(f)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||sl.to||s=s&&e<=s+o.length&&o.between(s,e-s,n-s,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return Uc.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return Uc.from(e).goto(n)}static compare(e,n,r,i,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=n.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=mk(o,l,r),u=new Hu(o,a,s),c=new Hu(l,a,s);r.iterGaps((f,d,h)=>yk(u,f,c,d,h,i)),r.empty&&r.length==0&&yk(u,0,c,0,0,i)}static eq(e,n,r=0,i){i==null&&(i=999999999);let s=e.filter(c=>!c.isEmpty&&n.indexOf(c)<0),o=n.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=mk(s,o),a=new Hu(s,l,0).goto(r),u=new Hu(o,l,0).goto(r);for(;;){if(a.to!=u.to||!ay(a.active,u.active)||a.point&&(!u.point||!mw(a.point,u.point)))return!1;if(a.to>i)return!0;a.next(),u.next()}}static spans(e,n,r,i,s=-1){let o=new Hu(e,null,s).goto(n),l=n,a=o.openStart;for(;;){let u=Math.min(o.to,r);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFroml&&(i.span(l,u,o.active,a),a=o.openEnd(u));if(o.to>r)return a+(o.point&&o.to>r?1:0);l=o.to,o.next()}}static of(e,n=!1){let r=new Ga;for(let i of e instanceof oy?[e]:n?CV(e):e)r.add(i.from,i.to,i.value);return r.finish()}static join(e){if(!e.length)return Kt.empty;let n=e[e.length-1];for(let r=e.length-2;r>=0;r--)for(let i=e[r];i!=Kt.empty;i=i.nextLayer)n=new Kt(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}}Kt.empty=new Kt([],[],null,-1);function CV(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(ly);e=r}return t}Kt.empty.nextLayer=Kt.empty;class Ga{finishChunk(e){this.chunks.push(new yw(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,n,r){this.addInner(e,n,r)||(this.nextLayer||(this.nextLayer=new Ga)).add(e,n,r)}addInner(e,n,r){let i=e-this.lastTo||r.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return i<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(Kt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=Kt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function mk(t,e,n){let r=new Map;for(let s of t)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&i.push(new gA(o,n,r,s));return i.length==1?i[0]:new Uc(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)gm(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)gm(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),gm(this.heap,0)}}}function gm(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let i=t[r];if(r+1=0&&(i=t[r+1],r++),n.compare(i)<0)break;t[r]=n,t[e]=i,e=r}}class Hu{constructor(e,n,r){this.minPoint=r,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Uc.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){dd(this.active,e),dd(this.activeTo,e),dd(this.activeRank,e),this.minActive=vk(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:i,rank:s}=this.cursor;for(;n0;)n++;hd(this.active,n,r),hd(this.activeTo,n,i),hd(this.activeRank,n,s),e&&hd(e,n,this.cursor.from),this.minActive=vk(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)<0){if(this.activeTo[i]>e){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),r&&dd(r,i)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[i]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function yk(t,e,n,r,i,s){t.goto(e),n.goto(r);let o=r+i,l=r,a=r-e,u=!!s.boundChange;for(let c=!1;;){let f=t.to+a-n.to,d=f||t.endSide-n.endSide,h=d<0?t.to+a:n.to,p=Math.min(h,o);if(t.point||n.point?(t.point&&n.point&&mw(t.point,n.point)&&ay(t.activeForPoint(t.to),n.activeForPoint(n.to))||s.comparePoint(l,p,t.point,n.point),c=!1):(c&&s.boundChange(l),p>l&&!ay(t.active,n.active)&&s.compareRange(l,p,t.active,n.active),u&&po)break;l=h,d<=0&&t.next(),d>=0&&n.next()}}function ay(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function vk(t,e){let n=-1,r=1e9;for(let i=0;i=e)return i;if(i==t.length)break;s+=t.charCodeAt(i)==9?n-s%n:1,i=gr(t,i)}return t.length}const uy="ͼ",wk=typeof Symbol>"u"?"__"+uy:Symbol.for(uy),cy=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),bk=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Bo{constructor(e,n){this.rules=[];let{finish:r}=n||{};function i(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,u){let c=[],f=/^@(\w+)\b/.exec(o[0]),d=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let h in l){let p=l[h];if(/&/.test(h))s(h.split(/,\s*/).map(g=>o.map(b=>g.replace(/&/,b))).reduce((g,b)=>g.concat(b)),p,a);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+h+") should be a primitive value.");s(i(h),p,c,d)}else p!=null&&c.push(h.replace(/_.*/,"").replace(/[A-Z]/g,g=>"-"+g.toLowerCase())+": "+p+";")}(c.length||d)&&a.push((r&&!f&&!u?o.map(r):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(i(o),e[o],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=bk[wk]||1;return bk[wk]=e+1,uy+e.toString(36)}static mount(e,n,r){let i=e[cy],s=r&&r.nonce;i?s&&i.setNonce(s):i=new EV(e,s),i.mount(Array.isArray(n)?n:[n],e)}}let xk=new Map;class EV{constructor(e,n){let r=e.ownerDocument||e,i=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let s=xk.get(r);if(s)return e[cy]=s;this.sheet=new i.CSSStyleSheet,xk.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[cy]=this}mount(e,n){let r=this.sheet,i=0,s=0;for(let o=0;o-1&&(this.modules.splice(a,1),s--,a=-1),a==-1){if(this.modules.splice(s++,0,l),r)for(let u=0;u",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},AV=typeof navigator<"u"&&/Mac/.test(navigator.platform),MV=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var nr=0;nr<10;nr++)jo[48+nr]=jo[96+nr]=String(nr);for(var nr=1;nr<=24;nr++)jo[nr+111]="F"+nr;for(var nr=65;nr<=90;nr++)jo[nr]=String.fromCharCode(nr+32),Kc[nr]=String.fromCharCode(nr);for(var mm in jo)Kc.hasOwnProperty(mm)||(Kc[mm]=jo[mm]);function RV(t){var e=AV&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||MV&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Kc:jo)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}function gs(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,n=arguments[1];if(n&&typeof n=="object"&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i=="string"?t.setAttribute(r,i):i!=null&&(t[r]=i)}e++}for(;e2);var Oe={mac:Ck||/Mac/.test(Sr.platform),windows:/Win/.test(Sr.platform),linux:/Linux|X11/.test(Sr.platform),ie:Bp,ie_version:yA?fy.documentMode||6:hy?+hy[1]:dy?+dy[1]:0,gecko:kk,gecko_version:kk?+(/Firefox\/(\d+)/.exec(Sr.userAgent)||[0,0])[1]:0,chrome:!!ym,chrome_version:ym?+ym[1]:0,ios:Ck,android:/Android\b/.test(Sr.userAgent),webkit:Sk,webkit_version:Sk?+(/\bAppleWebKit\/(\d+)/.exec(Sr.userAgent)||[0,0])[1]:0,safari:py,safari_version:py?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Sr.userAgent)||[0,0])[1]:0,tabSize:fy.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function vw(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const Wh=Object.create(null);function ww(t,e,n){if(t==e)return!0;t||(t=Wh),e||(e=Wh);let r=Object.keys(t),i=Object.keys(e);if(r.length-0!=i.length-0)return!1;for(let s of r)if(s!=n&&(i.indexOf(s)==-1||t[s]!==e[s]))return!1;return!0}function OV(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function Tk(t,e,n){let r=!1;if(e)for(let i in e)n&&i in n||(r=!0,i=="style"?t.style.cssText="":t.removeAttribute(i));if(n)for(let i in n)e&&e[i]==n[i]||(r=!0,i=="style"?t.style.cssText=n[i]:t.setAttribute(i,n[i]));return r}function PV(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new Il(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,i;if(e.isBlockGap)r=-5e8,i=4e8;else{let{start:s,end:o}=vA(e,n);r=(s?n?-3e8:-1:5e8)-1,i=(o?n?2e8:1:-6e8)+1}return new Il(e,r,i,n,e.widget||null,!0)}static line(e){return new vf(e)}static set(e,n=!1){return Kt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Qt.none=Kt.empty;class yf extends Qt{constructor(e){let{start:n,end:r}=vA(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?vw(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Wh}eq(e){return this==e||e instanceof yf&&this.tagName==e.tagName&&ww(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}yf.prototype.point=!1;class vf extends Qt{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof vf&&this.spec.class==e.spec.class&&ww(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}vf.prototype.mapMode=Ir.TrackBefore;vf.prototype.point=!0;class Il extends Qt{constructor(e,n,r,i,s,o){super(n,r,s,e),this.block=i,this.isReplace=o,this.mapMode=i?n<=0?Ir.TrackBefore:Ir.TrackAfter:Ir.TrackDel}get type(){return this.startSide!=this.endSide?vi.WidgetRange:this.startSide<=0?vi.WidgetBefore:vi.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Il&&IV(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}Il.prototype.point=!0;function vA(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function IV(t,e){return t==e||!!(t&&e&&t.compare(e))}function Na(t,e,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=t?n[i]=Math.max(n[i],e):n.push(t,e)}class Xc extends Pl{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Xc&&this.tagName==e.tagName&&ww(this.attributes,e.attributes)}static create(e){return new Xc(e.tagName,e.attributes||Wh,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return Kt.of(e,n)}}Xc.prototype.startSide=Xc.prototype.endSide=-1;function Gc(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function gy(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function wc(t,e){if(!e.anchorNode)return!1;try{return gy(t,e.anchorNode)}catch{return!1}}function bc(t){return t.nodeType==3?Yc(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function xc(t,e,n,r){return n?Ek(t,e,n,r,-1)||Ek(t,e,n,r,1):!1}function Ho(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function Vh(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function Ek(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Gs(t))){if(t.nodeName=="DIV")return!1;let s=t.parentNode;if(!s||s.nodeType!=1)return!1;e=Ho(t)+(i<0?0:1),t=s}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=i<0?Gs(t):0}else return!1}}function Gs(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function qc(t,e){let{left:n,right:r}=t;if(n==r)return t;let i=e?n:r;return{left:i,right:i,top:t.top,bottom:t.bottom}}function NV(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function wA(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function _V(t,e,n,r,i,s,o,l){let a=t.ownerDocument,u=a.defaultView||window;for(let c=t,f=!1;c&&!f;)if(c.nodeType==1){let d,h=c==a.body,p=1,g=1;if(h)d=NV(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let v=c.getBoundingClientRect();({scaleX:p,scaleY:g}=wA(c,v)),d={left:v.left,right:v.left+c.clientWidth*p,top:v.top,bottom:v.top+c.clientHeight*g}}let b=0,m=0;if(i=="nearest")e.top0&&e.bottom>d.bottom+m&&(m=e.bottom-d.bottom+o)):e.bottom>d.bottom-o&&(m=e.bottom-d.bottom+o,n<0&&e.top-m0&&e.right>d.right+b&&(b=e.right-d.right+s)):e.right>d.right-s&&(b=e.right-d.right+s,n<0&&e.leftd.bottom||e.leftd.right)&&(e={left:Math.max(e.left,d.left),right:Math.min(e.right,d.right),top:Math.max(e.top,d.top),bottom:Math.min(e.bottom,d.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function bA(t,e=!0){let n=t.ownerDocument,r=null,i=null;for(let s=t.parentNode;s&&!(s==n.body||(!e||r)&&i);)if(s.nodeType==1)!i&&s.scrollHeight>s.clientHeight&&(i=s),e&&!r&&s.scrollWidth>s.clientWidth&&(r=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:r,y:i}}class DV{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?Gs(n):0),r,Math.min(e.focusOffset,r?Gs(r):0))}set(e,n,r,i){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=i}}function xA(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function kA(t,e=!0){for(let{node:n,left:r,top:i}of t)e&&n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}let fl=null;Oe.safari&&Oe.safari_version>=26&&(fl=!1);function SA(t){if(t.setActive)return t.setActive();if(fl)return t.focus(fl);let e=xA(t);t.focus(fl==null?{get preventScroll(){return fl={preventScroll:!0},!0}}:void 0),fl||(fl=!1,kA(e))}let Ak;function Yc(t,e,n=e){let r=Ak||(Ak=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function _a(t,e,n,r){let i={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let s=new KeyboardEvent("keydown",i);s.synthetic=!0,t.dispatchEvent(s);let o=new KeyboardEvent("keyup",i);return o.synthetic=!0,t.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function LV(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function $V(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,Gs(n));;)if(r){if(n.nodeType!=1)return!1;let i=n.childNodes[r-1];i.contentEditable=="false"?r--:(n=i,r=Gs(n))}else{if(n==t)return!0;r=Ho(n),n=n.parentNode}}function CA(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function TA(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=Gs(n)}else if(n.parentNode&&!Vh(n))r=Ho(n),n=n.parentNode;else return null}}function EA(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(l.level==r)return o;(s<0||(i!=0?i<0?l.fromn:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function RA(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;g-=3)if(as[g+1]==-h){let b=as[g+2],m=b&2?i:b&4?b&1?s:i:0;m&&(nn[f]=nn[as[g]]=m),l=g;break}}else{if(as.length==189)break;as[l++]=f,as[l++]=d,as[l++]=a}else if((p=nn[f])==2||p==1){let g=p==i;a=g?0:1;for(let b=l-3;b>=0;b-=3){let m=as[b+2];if(m&2)break;if(g)as[b+2]|=2;else{if(m&4)break;as[b+2]|=4}}}}}function WV(t,e,n,r){for(let i=0,s=r;i<=n.length;i++){let o=i?n[i-1].to:t,l=ia;)p==b&&(p=n[--g].from,b=g?n[g-1].to:t),nn[--p]=h;a=c}else s=u,a++}}}function yy(t,e,n,r,i,s,o){let l=r%2?2:1;if(r%2==i%2)for(let a=e,u=0;aa&&o.push(new ws(a,g.from,h));let b=g.direction==Nl!=!(h%2);vy(t,b?r+1:r,i,g.inner,g.from,g.to,o),a=g.to}p=g.to}else{if(p==n||(c?nn[p]!=l:nn[p]==l))break;p++}d?yy(t,a,p,r+1,i,d,o):ae;){let c=!0,f=!1;if(!u||a>s[u-1].to){let g=nn[a-1];g!=l&&(c=!1,f=g==16)}let d=!c&&l==1?[]:null,h=c?r:r+1,p=a;e:for(;;)if(u&&p==s[u-1].to){if(f)break e;let g=s[--u];if(!c)for(let b=g.from,m=u;;){if(b==e)break e;if(m&&s[m-1].to==b)b=s[--m].from;else{if(nn[b-1]==l)break e;break}}if(d)d.push(g);else{g.tonn.length;)nn[nn.length]=256;let r=[],i=e==Nl?0:1;return vy(t,i,i,n,0,t.length,r),r}function OA(t){return[new ws(0,t,0)]}let PA="";function UV(t,e,n,r,i){var s;let o=r.head-t.from,l=ws.find(e,o,(s=r.bidiLevel)!==null&&s!==void 0?s:-1,r.assoc),a=e[l],u=a.side(i,n);if(o==u){let d=l+=i?1:-1;if(d<0||d>=e.length)return null;a=e[l=d],o=a.side(!i,n),u=a.side(i,n)}let c=gr(t.text,o,a.forward(i,n));(ca.to)&&(c=u),PA=t.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(i?e.length-1:0)?null:e[l+(i?1:-1)];return f&&c==u&&f.level+(i?0:1)t.some(e=>e)}),XV=Ue.define({combine:t=>t.some(e=>e)}),zA=Ue.define();class Da{constructor(e,n,r,i,s,o=!1){this.range=e,this.y=n,this.x=r,this.yMargin=i,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new Da(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Da(ce.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const pd=rn.define({map:(t,e)=>t.map(e)}),BA=rn.define();function pi(t,e,n){let r=t.facet(DA);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const Fs=Ue.define({combine:t=>t.length?t[0]:!0});let GV=0;const ka=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let a=[];return o&&a.push(jp.of(u=>{let c=u.plugin(l);return c?o(c):Qt.none})),s&&a.push(s(l)),a})}static fromClass(e,n){return ki.define((r,i)=>new e(r,i),n)}}class vm{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(pi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){pi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){pi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jA=Ue.define(),Sw=Ue.define(),jp=Ue.define(),HA=Ue.define(),Cw=Ue.define(),wf=Ue.define(),WA=Ue.define();function Mk(t,e){let n=t.state.facet(WA);if(!n.length)return n;let r=n.map(s=>s instanceof Function?s(t):s),i=[];return Kt.spans(r,e.from,e.to,{point(){},span(s,o,l,a){let u=s-e.from,c=o-e.from,f=i;for(let d=l.length-1;d>=0;d--,a--){let h=l[d].spec.bidiIsolate,p;if(h==null&&(h=KV(e.text,u,c)),a>0&&f.length&&(p=f[f.length-1]).to==u&&p.direction==h)p.to=c,f=p.inner;else{let g={from:u,to:c,direction:h,inner:[]};f.push(g),f=g.inner}}}}),i}const VA=Ue.define();function Tw(t){let e=0,n=0,r=0,i=0;for(let s of t.state.facet(VA)){let o=s(t);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:e,right:n,top:r,bottom:i}}const Zu=Ue.define();class gi{constructor(e,n,r,i){this.fromA=e,this.toA=n,this.fromB=r,this.toB=i}join(e){return new gi(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let i=e[n-1];if(!(i.fromA>r.toA)){if(i.toAi.push(new gi(s,o,l,a))),this.changedRanges=i}static create(e,n,r){return new Uh(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const qV=[];class An{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return qV}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&OV(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;for(let i of this.children){if(i==e)return r;r+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ho(this.dom),i=this.length?e>0:n>0;return new Vi(this.parent.dom,r+(i?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Wp)return e;return null}static get(e){return e.cmTile}}class Hp extends An{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,i,s=(e==null?void 0:e.node)==n?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,i=r?r.nextSibling:n.firstChild,s&&i!=l.dom&&(s.written=!0),l.dom.parentNode==n)for(;i&&i!=l.dom;)i=Rk(i);else n.insertBefore(l.dom,i);r=l.dom}for(i=r?r.nextSibling:n.firstChild,s&&i&&(s.written=!0);i;)i=Rk(i);this.length=o}}function Rk(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Wp extends Hp{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=An.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,i=0,s=0;;)if(i==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&s++,i=n.pop()}else{let o=r.children[i++];if(o instanceof Ws)n.push(i),r=o,i=0;else{let l=s+o.length,a=e(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(e,n){let r,i=-1,s,o=-1;if(this.blockTiles((l,a)=>{let u=a+l.length;if(e>=a&&e<=u){if(l.isWidget()&&n>=-1&&n<=1){if(l.flags&32)return!0;l.flags&16&&(r=void 0)}(ae||e==a&&(n>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-a)}}),!r&&!s)throw new Error("No tile at position "+e);return r&&n<0||!s?{tile:r,offset:i}:{tile:s,offset:o}}}class Ws extends Hp{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new Ws(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class qa extends Hp{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let i=new qa(n||document.createElement("div"),e);return(!n||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,n,r){let i=null,s=-1,o=null,l=-1;function a(c,f){for(let d=0,h=0;d=f&&(p.isComposite()?a(p,f-h):(!o||o.isHidden&&(n>0&&!(o.flags&32)||r&&JV(o,p)))&&(g>f||p.flags&32&&n<=1)?(o=p,l=f-h):(h=-1)&&(i=p,s=f-h)),h=g}}a(this,e);let u=(n<0?i:o)||i||o;return u?{tile:u,offset:u==i?s:l}:null}coordsIn(e,n,r){let i=this.resolveInline(e,n,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),n,r):YV(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:i,offset:s}=r;if(this.dom.contains(i.dom))return i.isText()?new Vi(i.dom,Math.min(i.dom.nodeValue.length,s)):i.domPosFor(s,i.flags&16?1:i.flags&32?-1:n);let o=r.tile.parent,l=!1;for(let a of o.children){if(l)return new Vi(a.dom,0);a==r.tile&&(l=!0)}}return new Vi(this.dom,0)}}function YV(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=bc(e);return n[n.length-1]||null}function JV(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.topi&&(e=i);let s=e,o=e,l=0;e==0&&n<0||e==i&&n>=0?Oe.chrome||Oe.gecko||(e?(s--,l=1):o=0)?0:a.length-1];return Oe.safari&&!l&&u.width==0&&(u=Array.prototype.find.call(a,c=>c.width)||u),r==null?u:qc(u,(l?l>0:n<0)==r)}static of(e,n){let r=new wl(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class _l extends An{constructor(e,n,r,i){super(e,n,i),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let i=this.widget.coordsAt(this.dom,e,n);if(i)return i;if(r)return qc(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?s.length-1:0;o=s[a],!(e>0?a==0:a==s.length-1||o.top0==r)}}class QV{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:i,index:s,beforeBreak:o,parents:l}=this;for(;e||n>0;)if(i.isComposite())if(o){if(!e)break;r&&r.break(),e--,o=!1}else if(s==i.children.length){if(!e&&!l.length)break;r&&r.leave(i),o=!!i.breakAfter,{tile:i,index:s}=l.pop(),s++}else{let a=i.children[s],u=a.breakAfter;(n>0?a.length<=e:a.length=0;l--){let a=n.marks[l],u=i.lastChild;if(u instanceof Nr&&u.mark.eq(a.mark))u.dom!=a.dom&&u.setDOM(wm(a.dom)),i=u;else{if(this.cache.reused.get(a)){let f=An.get(a.dom);f&&f.setDOM(wm(a.dom))}let c=Nr.of(a.mark,a.dom);i.append(c),i=c}this.cache.reused.set(a,2)}let s=An.get(e.text);s&&this.cache.reused.set(s,2);let o=new wl(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,i.append(o)}addInlineWidget(e,n,r){let i=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);i||this.flushBuffer();let s=this.ensureMarks(n,r);!i&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=UA);let i=qa.start(e,n||((r=this.cache.find(qa))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=i)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let i=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(n>0&&(l=i.lastChild)&&l instanceof Nr&&l.mark.eq(o))i=l,n--;else{let a=Nr.of(o,(r=this.cache.find(Nr,u=>u.mark.eq(o)))===null||r===void 0?void 0:r.dom);i.append(a),i=a,n=0}}return i}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Ok(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Ok(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(bm,0,32)||new _l(bm.toDOM(),0,bm,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,r=new ZV(e.from,e.to,e.value,n),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-r.rank||this.wrappers[i-1].to-r.to)<0;)i--;this.wrappers.splice(i,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let i=n.lastChild;if(r.fromo.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(s),n=s}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(Kh,void 0,1);return r&&(r.flags=n),r||new Kh(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class tU{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:i,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=i;let l=this.textOff=Math.min(e,i.length);return s?null:i.slice(0,l)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const Xh=[_l,qa,wl,Nr,Kh,Ws,Wp];for(let t=0;t[]),this.index=Xh.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let i=e.bucket,s=this.buckets[i],o=this.index[i];for(let l=0;l{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let i=0,s=0,o=0;;){let l=oi){let u=a-i;this.preserve(u,!o,!l),i=a,s+=u}if(!l)break;n&&l.fromA<=n.range.fromA&&l.toA>=n.range.toA?(this.forward(l.fromA,n.range.fromA,n.range.fromA{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let u=a>0||l{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof Nr&&i.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?i.length&&(i.length=s=0):o instanceof Nr&&(i.shift(),s=Math.min(s,i.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,i=this.builder,s=-1,o=Kt.spans(this.decorations,e,n,{point:(l,a,u,c,f,d)=>{if(u instanceof Il){if(this.disallowBlockEffectsFor[d]){if(u.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=c.length,f>c.length)i.continueWidget(a-l);else{let h=u.widget||(u.block?Ya.block:Ya.inline),p=iU(u),g=this.cache.findWidget(h,a-l,p)||_l.of(h,this.view,a-l,p);u.block?(u.startSide>0&&i.addLineStartIfNotCovered(r),i.addBlockWidget(g)):(i.ensureLine(r),i.addInlineWidget(g,c,f))}r=null}else r=sU(r,u);a>l&&this.text.skip(a-l)},span:(l,a,u,c)=>{for(let f=l;f-1&&(this.openWidget=o>s),this.openWidget||i.addLineStartIfNotCovered(r),this.openMarks=o}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let i=e.parentNode;;i=i.parentNode){let s=An.get(i);if(i==this.view.contentDOM)break;s instanceof Nr?n.push(s):s!=null&&s.isLine()?r=s:s instanceof Ws||(i.nodeName=="DIV"&&!r&&i!=this.view.contentDOM?r=new qa(i,UA):r||n.push(Nr.of(new yf({tagName:i.nodeName.toLowerCase(),attributes:PV(i)}),i)))}return{line:r,marks:n}}}function Ok(t,e){let n=r=>{for(let i of r.children)if((e?i.isText():i.length)||n(i))return!0;return!1};return n(t)}function iU(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const UA={class:"cm-line"};function sU(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&vw(n,t),r&&(t.class+=" "+r)),t}function oU(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Nr&&e.push(r.mark)}return e}function wm(t){let e=An.get(t);return e&&e.setDOM(t.cloneNode()),t}class Ya extends du{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Ya.inline=new Ya("span");Ya.block=new Ya("div");const bm=new class extends du{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Pk{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Qt.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Wp(e,e.contentDOM),this.updateInner([new gi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:c,toA:f})=>fthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let i=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?i=this.domChanged.newSel.head:!gU(e.changes,this.hasComposition)&&!e.selectionSet&&(i=e.state.selection.main.head));let s=i>-1?aU(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:f}=this.hasComposition;r=new gi(c,f,e.changes.mapPos(c,-1),e.changes.mapPos(f,1)).addToSet(r.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Oe.ie||Oe.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=fU(o,this.decorations,e.changes);a.length&&(r=gi.extendWithRanges(r,a));let u=hU(l,this.blockWrappers,e.changes);return u.length&&(r=gi.extendWithRanges(r,u)),s&&!r.some(c=>c.fromA<=s.range.fromA&&c.toA>=s.range.toA)&&(r=s.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let o=this.tile,l=new rU(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&An.get(n.text)&&l.cache.reused.set(An.get(n.text),2),this.tile=l.run(e,n),by(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||r.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let i=[];if(this.view.viewport.from||this.view.viewport.to-1)&&wc(r,this.view.observer.selectionRange)&&!(i&&r.contains(i));if(!(s||n||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,u,c;if(a.empty?c=u=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),u=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),Oe.gecko&&a.empty&&!this.hasComposition&&lU(u)){let d=document.createTextNode("");this.view.observer.ignore(()=>u.node.insertBefore(d,u.node.childNodes[u.offset]||null)),u=c=new Vi(d,0),l=!0}let f=this.view.observer.selectionRange;(l||!f.focusNode||(!xc(u.node,u.offset,f.anchorNode,f.anchorOffset)||!xc(c.node,c.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(f.focusNode)&&pU(f.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let d=Gc(this.view.root);if(d)if(a.empty){if(Oe.gecko){let h=uU(u.node,u.offset);if(h&&h!=3){let p=(h==1?TA:EA)(u.node,u.offset);p&&(u=new Vi(p.node,p.offset))}}d.collapse(u.node,u.offset),a.bidiLevel!=null&&d.caretBidiLevel!==void 0&&(d.caretBidiLevel=a.bidiLevel)}else if(d.extend){d.collapse(u.node,u.offset);try{d.extend(c.node,c.offset)}catch{}}else{let h=document.createRange();a.anchor>a.head&&([u,c]=[c,u]),h.setEnd(c.node,c.offset),h.setStart(u.node,u.offset),d.removeAllRanges(),d.addRange(h)}o&&this.view.root.activeElement==r&&(r.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(u,c)),this.impreciseAnchor=u.precise?null:new Vi(f.anchorNode,f.anchorOffset),this.impreciseHead=c.precise?null:new Vi(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&xc(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Gc(e.root),{anchorNode:i,anchorOffset:s}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let o=this.lineAt(n.head,n.assoc);if(!o)return;let l=o.posAtStart;if(n.head==l||n.head==l+o.length)return;let a=this.coordsAt(n.head,-1),u=this.coordsAt(n.head,1);if(!a||!u||a.bottom>u.top)return;let c=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(c.node,c.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=n.from&&r.collapse(i,s)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let i=r.posAtStart;if(r.isComposite()){let s;if(e==r.dom)s=r.dom.childNodes[n];else{let o=Gs(e)==0?0:n==0?-1:1;for(;;){let l=e.parentNode;if(l==r.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==r.dom.firstChild)return i;for(;s&&!An.get(s);)s=s.nextSibling;if(!s)return i+r.length;for(let o=0,l=i;;o++){let a=r.children[o];if(a.dom==s)return l;l+=a.length+a.breakAfter}}else return r.isText()?e==r.dom?i+n:i+(n?r.length:0):i}domAtPos(e,n){let{tile:r,offset:i}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(i,n):r.domIn(i,n)}inlineDOMNearPos(e,n){let r,i=-1,s=!1,o,l=-1,a=!1;return this.tile.blockTiles((u,c)=>{if(u.isWidget()){if(u.flags&32&&c>=e)return!0;u.flags&16&&(s=!0)}else{let f=c+u.length;if(c<=e&&(r=u,i=e-c,s=f=e&&!o&&(o=u,l=e-c,a=c>e),c>e&&o)return!0}}),!r&&!o?this.domAtPos(e,n):(s&&o?r=null:a&&r&&(o=null),r&&n<0||!o?r.domIn(i,n):o.domIn(l,n))}coordsAt(e,n,r){let{tile:i,offset:s}=this.tile.resolveBlock(e,n);return i.isWidget()?i.widget instanceof xm?null:i.coordsInWidget(s,n,!0):i.coordsIn(s,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function i(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let a=i(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(s.isText()&&oMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==En.LTR,u=0,c=(f,d,h)=>{for(let p=0;pi);p++){let g=f.children[p],b=d+g.length,m=g.dom.getBoundingClientRect(),{height:v}=m;if(h&&!p&&(u+=m.top-h.top),g instanceof Ws)b>r&&c(g,d,m);else if(d>=r&&(u>0&&n.push(-u),n.push(v+u),u=0,o)){let w=g.dom.lastChild,k=w?bc(w):[];if(k.length){let x=k[k.length-1],C=a?x.right-m.left:m.right-x.left;C>l&&(l=C,this.minWidth=s,this.minWidthFrom=d,this.minWidthTo=b)}}h&&p==f.children.length-1&&(u+=h.bottom-m.bottom),d=b+g.breakAfter}};return c(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?En.RTL:En.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let u of o.children){if(!u.isText()||/[^ -~]/.test(u.text))return;let c=bc(u.dom);if(c.length!=1)return;l+=c[0].width,a=c[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let n=document.createElement("div"),r,i,s;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let o=bc(n.firstChild)[0];r=n.getBoundingClientRect().height,i=o&&o.width?o.width/27:7,s=o&&o.height?o.height:r,n.remove()}),{lineHeight:r,charWidth:i,textHeight:s}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,i=0;;i++){let s=i==n.viewports.length?null:n.viewports[i],o=s?s.from-1:this.view.state.doc.length;if(o>r){let l=(n.lineBlockAt(o).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(Qt.replace({widget:new xm(l),block:!0,inclusive:!0,isBlockGap:!0}).range(r,o))}if(!s)break;r=s.to+1}return Qt.set(e)}updateDeco(){let e=1,n=this.view.state.facet(jp).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),r=!1,i=this.view.state.facet(Cw).map((s,o)=>{let l=typeof s=="function";return l&&(r=!0),l?s(this.view):s});for(i.length&&(this.dynamicDecorationMap[e++]=r,n.push(Kt.join(i))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let u=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=u.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let u of this.view.state.facet(zA))try{if(u(this.view,e.range,e))return!0}catch(c){pi(this.view.state,c,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),i;if(!r)return;!n.empty&&(i=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,i.left),top:Math.min(r.top,i.top),right:Math.max(r.right,i.right),bottom:Math.max(r.bottom,i.bottom)});let s=Tw(this.view),o={left:r.left-s.left,top:r.top-s.top,right:r.right+s.right,bottom:r.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(_V(this.view.scrollDOM,o,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){by(this.tile)}}function by(t,e){let n=e==null?void 0:e.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)by(r,e)}}function lU(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function KA(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=TA(n.focusNode,n.focusOffset),i=EA(n.focusNode,n.focusOffset),s=r||i;if(i&&r&&i.node!=r.node){let l=An.get(i.node);if(!l||l.isText()&&l.text!=i.node.nodeValue)s=i;else if(t.docView.lastCompositionAfterCursor){let a=An.get(r.node);!a||a.isText()&&a.text!=r.node.nodeValue||(s=i)}}if(t.docView.lastCompositionAfterCursor=s!=r,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function aU(t,e,n){let r=KA(t,n);if(!r)return null;let{node:i,from:s,to:o}=r,l=i.nodeValue;if(/[\n\r]/.test(l)||t.state.doc.sliceString(r.from,r.to)!=l)return null;let a=e.invertedDesc;return{range:new gi(a.mapPos(s),a.mapPos(o),s,o),text:i}}function uU(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class xm extends du{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function mU(t,e,n=1){let r=t.charCategorizer(e),i=t.doc.lineAt(e),s=e-i.from;if(i.length==0)return ce.cursor(e);s==0?n=1:s==i.length&&(n=-1);let o=s,l=s;n<0?o=gr(i.text,s,!1):l=gr(i.text,s);let a=r(i.text.slice(o,l));for(;o>0;){let u=gr(i.text,o,!1);if(r(i.text.slice(u,o))!=a)break;o=u}for(;lt.defaultLineHeight*1.5){let l=t.viewState.heightOracle.textHeight,a=Math.floor((i-n.top-(t.defaultLineHeight-l)*.5)/l);s+=a*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(n.from,n.to);return n.from+TV(o,s,t.state.tabSize)}function vU(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let i;for(let s of r.type){if(s.from>e)break;if(!(s.toe)return s;(!i||s.type==vi.Text&&(i.type!=s.type||(n<0?s.frome)))&&(i=s)}}return i||r}return r}function wU(t,e,n,r){let i=vU(t,e.head,e.assoc||-1),s=!r||i.type!=vi.Text||!(t.lineWrapping||i.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>i.from?e.head-1:e.head);if(s){let o=t.dom.getBoundingClientRect(),l=t.textDirectionAt(i.from),a=t.posAtCoords({x:n==(l==En.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return ce.cursor(a,n?-1:1)}return ce.cursor(n?i.to:i.from,n?-1:1)}function Ik(t,e,n,r){let i=t.state.doc.lineAt(e.head),s=t.bidiSpans(i),o=t.textDirectionAt(i.from);for(let l=e,a=null;;){let u=UV(i,s,o,l,n),c=PA;if(!u){if(i.number==(n?t.state.doc.lines:1))return l;c=` -`,i=t.state.doc.line(i.number+(n?1:-1)),s=t.bidiSpans(i),u=t.visualLineSide(i,!n)}if(a){if(!a(c))return l}else{if(!r)return u;a=r(c)}l=u}}function bU(t,e,n){let r=t.state.charCategorizer(e),i=r(n);return s=>{let o=r(s);return i==js.Space&&(i=o),i==o}}function xU(t,e,n,r){let i=e.head,s=n?1:-1;if(i==(n?t.state.doc.length:0))return ce.cursor(i,e.assoc);let o=e.goalColumn,l,a=t.contentDOM.getBoundingClientRect(),u=t.coordsAtPos(i,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),c=t.documentTop;if(u)o==null&&(o=u.left-a.left),l=s<0?u.top:u.bottom;else{let p=t.viewState.lineBlockAt(i);o==null&&(o=Math.min(a.right-a.left,t.defaultCharacterWidth*(i-p.from))),l=(s<0?p.top:p.bottom)+c}let f=a.left+o,d=t.viewState.heightOracle.textHeight>>1,h=r??d;for(let p=0;;p+=d){let g=l+(h+p)*s,b=xy(t,{x:f,y:g},!1,s);if(n?g>a.bottom:gl:v{if(e>s&&ei(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ce.cursor(r,rt.viewState.docHeight)return new ms(t.state.doc.length,-1);if(u=t.elementAtHeight(a),r==null)break;if(u.type==vi.Text){if(r<0?u.tot.viewport.to)break;let d=t.docView.coordsAt(r<0?u.from:u.to,r>0?-1:1);if(d&&(r<0?d.top<=a+s:d.bottom>=a+s))break}let f=t.viewState.heightOracle.textHeight/2;a=r>0?u.bottom+f:u.top-f}if(t.viewport.from>=u.to||t.viewport.to<=u.from){if(n)return null;if(u.type==vi.Text){let f=yU(t,i,u,o,l);return new ms(f,f==u.from?1:-1)}}if(u.type!=vi.Text)return a<(u.top+u.bottom)/2?new ms(u.from,1):new ms(u.to,-1);let c=t.docView.lineAt(u.from,2);return(!c||c.length!=u.length)&&(c=t.docView.lineAt(u.from,-2)),new kU(t,o,l,t.textDirectionAt(u.from)).scanTile(c,u.from)}class kU{constructor(e,n,r,i){this.view=e,this.x=n,this.y=r,this.baseDir=i,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+i.from>1;t:if(o.has(g)){for(let v=1;v=s&&(w-=p),!o.has(w)){g=w;break t}}break e}o.add(g);let b=n(g),m=0;if(b)for(let v=0;v1))if(w.bottomthis.y)(!u||u.top>w.top)&&(u=w),m=-1;else{let k=w.left>this.x?this.x-w.left:w.right(p+p+g)/3)return this.y=a.bottom-1,this.scan(e,n,!0);if(u&&u.top<(p+g+g)/3)return this.y=u.top+1,this.scan(e,n,!0)}let h=(l?this.dirAt(e[c],1):this.baseDir)==En.LTR;return{i:c,after:this.x>(d.left+d.right)/2==h}}scanText(e,n){let r=[];for(let s=0;s{let o=r[s]-n,l=r[s+1]-n;return Yc(e.dom,o,l).getClientRects()});return i.after?new ms(r[i.i+1],-1):new ms(r[i.i],1)}scanTile(e,n){if(!e.length)return new ms(n,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,n);if(l.isComposite())return this.scanTile(l,n)}let r=[n];for(let l=0,a=n;l{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:Yc(a.dom,0,a.length)).getClientRects()}),s=e.children[i.i],o=r[i.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):i.after?new ms(r[i.i+1],-1):new ms(o,1)}}const oa="￿";class SU{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(Ft.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=oa}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let i=e;;){this.findPointBefore(r,i);let s=this.text.length;this.readNode(i);let o=An.get(i),l=i.nextSibling;if(l==n){o!=null&&o.breakAfter&&!l&&r!=this.view.contentDOM&&this.lineBreak();break}let a=An.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Vh(i))||Vh(l)&&(i.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>s)&&!TU(l,n)&&this.lineBreak(),i=l}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=n.indexOf(this.lineSeparator,r),o=this.lineSeparator.length):(l=i.exec(n))&&(s=l.index,o=l[0].length),this.append(n.slice(r,s<0?n.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);r=s+o}}readNode(e){let n=An.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let i=r.iter();!i.next().done;)i.lineBreak?this.lineBreak():this.append(i.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(CU(e,r.node,r.offset)?n:0))}}function CU(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=GA(e.docView.tile,n,r,0))){let a=s||o?[]:MU(e),u=new SU(a,e);u.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=u.text,this.newSel=RU(a,this.bounds.from)}else{let a=e.observer.selectionRange,u=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!gy(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!gy(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),f=e.viewport;if((Oe.ios||Oe.chrome)&&u!=c&&Math.min(u,c)<=l.main.from&&Math.max(u,c)>=l.main.to&&(f.from>0||f.to-1&&l.ranges.length>1)this.newSel=l.replaceRange(ce.range(c,u));else if(e.lineWrapping&&c==u&&!(l.main.empty&&l.main.head==u)&&e.inputState.lastTouchTime>Date.now()-100){let d=e.coordsAtPos(u,-1),h=0;d&&(h=e.inputState.lastTouchY<=d.bottom?-1:1),this.newSel=ce.create([ce.cursor(u,h)])}else this.newSel=ce.single(c,u)}}}function GA(t,e,n,r){if(t.isComposite()){let i=-1,s=-1,o=-1,l=-1;for(let a=0,u=r,c=r;an)return GA(f,e,n,u);if(d>=e&&i==-1&&(i=a,s=u),u>n&&f.dom.parentNode==t.dom){o=a,l=c;break}c=d,u=d+f.breakAfter}return{from:s,to:l<0?r+t.length:l,startDOM:(i?t.children[i-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:o=0?t.children[o].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function qA(t,e){let n,{newSel:r}=e,{state:i}=t,s=i.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,u=s.from,c=null;(o===8||Oe.android&&e.text.length=l&&s.to<=a&&(e.typeOver||f!=e.text)&&f.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&f.slice(s.to-l)==e.text.slice(d=e.text.length-(f.length-(s.to-l)))?n={from:s.from,to:s.to,insert:_t.of(e.text.slice(s.from-l,d).split(oa))}:(h=YA(f,e.text,u-l,c))&&(Oe.chrome&&o==13&&h.toB==h.from+2&&e.text.slice(h.from,h.toB)==oa+oa&&h.toB--,n={from:l+h.from,to:l+h.toA,insert:_t.of(e.text.slice(h.from,h.toB).split(oa))})}else r&&(!t.hasFocus&&i.facet(Fs)||Gh(r,s))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==s.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ce.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:_t.of([n.insert.toString().replace("."," ")])}):i.doc.lineAt(s.from).toDate.now()-50?n={from:s.from,to:s.to,insert:i.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==s.head&&n.insert.toString()==` - `&&t.lineWrapping&&(r&&(r=ce.single(r.main.anchor-1,r.main.head-1)),n={from:s.from,to:s.to,insert:_t.of([" "])}),n)return Ew(t,n,r,o);if(r&&!Gh(r,s)){let l=!1,a="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(l=!0),a=t.inputState.lastSelectionOrigin,a=="select.pointer"&&(r=XA(i.facet(wf).map(u=>u(t)),r))),t.dispatch({selection:r,scrollIntoView:l,userEvent:a}),!0}else return!1}function Ew(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let i=t.state.selection.main;if(Oe.android&&(e.to==i.to&&(e.from==i.from||e.from==i.from-1&&t.state.sliceDoc(e.from,i.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&_a(t.contentDOM,"Enter",13)||(e.from==i.from-1&&e.to==i.to&&e.insert.length==0||r==8&&e.insert.lengthi.head)&&_a(t.contentDOM,"Backspace",8)||e.from==i.from&&e.to==i.to+1&&e.insert.length==0&&_a(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,l=()=>o||(o=AU(t,e,n));return t.state.facet(LA).some(a=>a(t,e.from,e.to,s,l))||t.dispatch(l()),!0}function AU(t,e,n){let r,i=t.state,s=i.selection.main,o=-1;if(e.from==e.to&&e.froms.to){let a=e.fromf(t)),u,a);e.from==c&&(o=c)}if(o>-1)r={changes:e,selection:ce.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let a=s.frome.to?i.sliceDoc(e.to,s.to):"";r=i.replaceSelection(t.state.toText(a+e.insert.sliceString(0,void 0,t.state.lineBreak)+u))}else{let a=i.changes(e),u=n&&n.main.to<=a.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let c=t.state.sliceDoc(e.from,e.to),f,d=n&&KA(t,n.main.head);if(d){let p=e.insert.length-(e.to-e.from);f={from:d.from,to:d.to-p}}else f=t.state.doc.lineAt(s.head);let h=s.to-e.to;r=i.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:u||p.map(a)};let g=p.to-h,b=g-c.length;if(t.state.sliceDoc(b,g)!=c||g>=f.from&&b<=f.to)return{range:p};let m=i.changes({from:b,to:g,insert:e.insert}),v=p.to-s.to;return{changes:m,range:u?ce.range(Math.max(0,u.anchor+v),Math.max(0,u.head+v)):p.map(m)}})}else r={changes:a,selection:u&&i.selection.replaceRange(u)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:l,scrollIntoView:!0})}function YA(t,e,n,r){let i=Math.min(t.length,e.length),s=0;for(;s0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(r=="end"){let a=Math.max(0,s-Math.min(o,l));n-=o+a-s}if(o=o?s-n:0;s-=a,l=s+(l-o),o=s}else if(l=l?s-n:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function MU(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}=t.observer.selectionRange;return n&&(e.push(new Nk(n,r)),(i!=n||s!=r)&&e.push(new Nk(i,s))),e}function RU(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ce.single(n+e,r+e):null}function Gh(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class OU{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&KU(e.contentDOM.ownerDocument)}handleEvent(e){!zU(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let i of r.observers)i(this.view,n);for(let i of r.handlers){if(n.defaultPrevented)break;if(i(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=IU(e),r=this.handlers,i=this.view.contentDOM;for(let s in n)if(s!="scroll"){let o=!n[s].handlers.length,l=r[s];l&&o!=!l.handlers.length&&(i.removeEventListener(s,this.handleEvent),l=null),l||i.addEventListener(s,this.handleEvent,{passive:o})}for(let s in r)s!="scroll"&&!n[s]&&i.removeEventListener(s,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&QA.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(JA.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||NU.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&PU(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function PU(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function _k(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(i){pi(n.state,i)}}}function IU(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let i=r.spec,s=i&&i.plugin.domEventHandlers,o=i&&i.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&n(l).handlers.push(_k(r.value,a))}if(o)for(let l in o){let a=o[l];a&&n(l).observers.push(_k(r.value,a))}}for(let r in Ji)n(r).handlers.push(Ji[r]);for(let r in Er)n(r).observers.push(Er[r]);return e}const JA=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],NU="dthko",QA=[16,17,18,20,91,92,224,225],gd=6;function md(t){return Math.max(0,t)*.7+8}function _U(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class DU{constructor(e,n,r,i){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=bA(e.contentDOM),this.atoms=e.state.facet(wf).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(Ft.allowMultipleSelections)&&LU(e,n),this.dragging=FU(e,n)&&tM(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&_U(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,i=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:i,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=Tw(this.view);e.clientX-a.left<=i+gd?n=-md(i-e.clientX):e.clientX+a.right>=o-gd&&(n=md(e.clientX-o)),e.clientY-a.top<=s+gd?r=-md(s-e.clientY):e.clientY+a.bottom>=l-gd&&(r=md(e.clientY-l)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=XA(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function LU(t,e){let n=t.state.facet(IA);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function $U(t,e){let n=t.state.facet(NA);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function FU(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Gc(t.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let s=0;s=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function zU(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=An.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Ji=Object.create(null),Er=Object.create(null),ZA=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function BU(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),eM(t,n.value)},50)}function Vp(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function eM(t,e){e=Vp(t.state,xw,e);let{state:n}=t,r,i=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(ky!=null&&n.selection.ranges.every(a=>a.empty)&&ky==s.toString()){let a=-1;r=n.changeByRange(u=>{let c=n.doc.lineAt(u.from);if(c.from==a)return{range:u};a=c.from;let f=n.toText((o?s.line(i++).text:e)+n.lineBreak);return{changes:{from:c.from,insert:f},range:ce.cursor(u.from+f.length)}})}else o?r=n.changeByRange(a=>{let u=s.line(i++);return{changes:{from:a.from,to:a.to,insert:u.text},range:ce.cursor(a.from+u.length)}}):r=n.replaceSelection(s);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}Er.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};Er.wheel=Er.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};Ji.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);Er.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")};Er.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};Er.touchend=(t,e)=>{t.inputState.touchActive=!1};Ji.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(_A))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=HU(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new DU(t,e,n,r)),r&&t.observer.ignore(()=>{SA(t.contentDOM);let s=t.root.activeElement;s&&!s.contains(t.contentDOM)&&s.blur()});let i=t.inputState.mouseSelection;if(i)return i.start(e),i.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Dk(t,e,n,r){if(r==1)return ce.cursor(e,n);if(r==2)return mU(t.state,e,n);{let i=t.docView.lineAt(e,n),s=t.state.doc.lineAt(i?i.posAtEnd:e),o=i?i.posAtStart:s.from,l=i?i.posAtEnd:s.to;return lDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?($k+1)%3:1}function HU(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=tM(e),i=t.state.selection;return{update(s){s.docChanged&&(n.pos=s.changes.mapPos(n.pos),i=i.map(s.changes))},get(s,o,l){let a=t.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),u,c=Dk(t,a.pos,a.assoc,r);if(n.pos!=a.pos&&!o){let f=Dk(t,n.pos,n.assoc,r),d=Math.min(f.from,c.from),h=Math.max(f.to,c.to);c=d1&&(u=WU(i,a.pos))?u:l?i.addRange(c):ce.create([c])}}}function WU(t,e){for(let n=0;n=e)return ce.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Ji.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let i=t.docView.tile.nearest(e.target);if(i&&i.isWidget()){let s=i.posAtStart,o=s+i.length;(s>=n.to||o<=n.from)&&(n=ce.undirectionalRange(s,o))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",Vp(t.state,kw,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Ji.dragend=t=>(t.inputState.draggedContent=null,!1);function zk(t,e,n,r){if(n=Vp(t.state,xw,n),!n)return;let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=r&&s&&$U(t,e)?{from:s.from,to:s.to}:null,l={from:i,insert:n},a=t.state.changes(o?[o,l]:l);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(i,-1),head:a.mapPos(i,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Ji.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,s=()=>{++i==n.length&&zk(t,e,r.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(r[o]=l.result),s()},l.readAsText(n[o])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return zk(t,e,r,!0),!0}return!1};Ji.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=ZA?null:e.clipboardData;return n?(eM(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(BU(t),!1)};function VU(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function UU(t){let e=[],n=[],r=!1;for(let i of t.selection.ranges)i.empty||(e.push(t.sliceDoc(i.from,i.to)),n.push(i));if(!e.length){let i=-1;for(let{from:s}of t.selection.ranges){let o=t.doc.lineAt(s);o.number>i&&(e.push(o.text),n.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),i=o.number}r=!0}return{text:Vp(t,kw,e.join(t.lineBreak)),ranges:n,linewise:r}}let ky=null;Ji.copy=Ji.cut=(t,e)=>{if(!wc(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=UU(t.state);if(!n&&!i)return!1;ky=i?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=ZA?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(VU(t,n),!1)};const nM=Go.define();function rM(t,e){let n=[];for(let r of t.facet($A)){let i=r(t,e);i&&n.push(i)}return n.length?t.update({effects:n,annotations:nM.of(!0)}):null}function iM(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=rM(t.state,e);n?t.dispatch(n):t.update([])}},10)}Er.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),iM(t)};Er.blur=t=>{t.observer.clearSelectionRange(),iM(t)};Er.compositionstart=Er.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};Er.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};Er.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};Ji.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let s=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],a=t.posAtDOM(l.startContainer,l.startOffset),u=t.posAtDOM(l.endContainer,l.endOffset);return Ew(t,{from:a,to:u,insert:t.state.toText(s)},null),!0}}let i;if(Oe.chrome&&Oe.android&&(i=JA.find(s=>s.inputType==e.inputType))&&(t.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let s=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>Er.compositionend(t,e),20),!1};const Bk=new Set;function KU(t){Bk.has(t)||(Bk.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const jk=["pre-wrap","normal","pre-line","break-spaces"];let Ja=!1;function Hk(){Ja=!1}class XU{constructor(e){this.lineWrapping=e,this.doc=_t.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return jk.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,a=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=n,this.charWidth=r,this.textHeight=i,this.lineLength=s,a){this.heightSamples={};for(let u=0;u0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Yd&&(Ja=!0),this.height=e)}replace(e,n,r){return Tr.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,i){let s=this,o=r.doc;for(let l=i.length-1;l>=0;l--){let{fromA:a,toA:u,fromB:c,toB:f}=i[l],d=s.lineAt(a,un.ByPosNoHeight,r.setDoc(n),0,0),h=d.to>=u?d:s.lineAt(u,un.ByPosNoHeight,r,0,0);for(f+=h.to-u,u=h.to;l>0&&d.from<=i[l-1].toA;)a=i[l-1].fromA,c=i[l-1].fromB,l--,as*2){let l=e[n-1];l.break?e.splice(--n,1,l.left,null,l.right):e.splice(--n,1,l.left,l.right),r+=1+l.break,i-=l.size}else if(s>i*2){let l=e[r];l.break?e.splice(r,1,l.left,null,l.right):e.splice(r,1,l.left,l.right),r+=2+l.break,s-=l.size}else break;else if(i=s&&o(this.lineAt(0,un.ByPos,r,i,s))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,i){return i&&i.from<=n&&i.more&&this.setMeasuredHeight(i),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Gr extends sM{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Wi(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let i=r[0];return r.length==1&&(i instanceof Gr||i instanceof tr&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof tr?i=new Gr(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):Tr.of(r)}updateHeight(e,n=0,r=!1,i){return i&&i.from<=n&&i.more?this.setMeasuredHeight(i):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class tr extends Tr{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,i=e.doc.lineAt(n+this.length).number,s=i-r+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:r,lastLine:i,perLine:o,perChar:l}}blockAt(e,n,r,i){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(n,i);if(n.lineWrapping){let u=i+(e0){let s=r[r.length-1];s instanceof tr?r[r.length-1]=new tr(s.length+i):r.push(null,new tr(i-1))}if(e>0){let s=r[0];s instanceof tr?r[0]=new tr(e+s.length):r.unshift(new tr(e-1),null)}return Tr.of(r)}decomposeLeft(e,n){n.push(new tr(e-1),null)}decomposeRight(e,n){n.push(null,new tr(this.length-e-1))}updateHeight(e,n=0,r=!1,i){let s=n+this.length;if(i&&i.from<=n+this.length&&i.more){let o=[],l=Math.max(n,i.from),a=-1;for(i.from>n&&o.push(new tr(i.from-n-1).updateHeight(e,n));l<=s&&i.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=i.heights[i.index++],d=0;f<0&&(d=-f,f=i.heights[i.index++]),a==-1?a=f:Math.abs(f-a)>=Yd&&(a=-2);let h=new Gr(c,f,d);h.outdated=!1,o.push(h),l+=c+1}l<=s&&o.push(null,new tr(s-l).updateHeight(e,l));let u=Tr.of(o);return(a<0||Math.abs(u.height-this.height)>=Yd||Math.abs(a-this.heightMetrics(e,n).perLine)>=Yd)&&(Ja=!0),qh(this,u)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class YU extends Tr{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,i){let s=r+this.left.height;return el))return u;let c=n==un.ByPosNoHeight?un.ByPosNoHeight:un.ByPos;return a?u.join(this.right.lineAt(l,c,r,o,l)):this.left.lineAt(l,c,r,i,s).join(u)}forEachLine(e,n,r,i,s,o){let l=i+this.left.height,a=s+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,n,r,l,a,o);else{let u=this.lineAt(a,un.ByPos,r,i,s);e=e&&u.from<=n&&o(u),n>u.to&&this.right.forEachLine(u.to+1,n,r,l,a,o)}}replace(e,n,r){let i=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-i,n-i,r));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of r)s.push(l);if(e>0&&Wk(s,o-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,i=r+this.break;if(e>=i)return this.right.decomposeRight(e-i,n);e2*n.size||n.size>2*e.size?Tr.of(this.break?[e,null,n]:[e,n]):(this.left=qh(this.left,e),this.right=qh(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,i){let{left:s,right:o}=this,l=n+s.length+this.break,a=null;return i&&i.from<=n+s.length&&i.more?a=s=s.updateHeight(e,n,r,i):s.updateHeight(e,n,r),i&&i.from<=l+o.length&&i.more?a=o=o.updateHeight(e,l,r,i):o.updateHeight(e,l,r),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Wk(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof tr&&(r=t[e+1])instanceof tr&&t.splice(e-1,3,new tr(n.length+1+r.length))}const JU=5;class Aw{constructor(e,n){this.pos=e,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof Gr?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Gr(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=JU)&&this.addLineDeco(i,s,o)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Gr(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new tr(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Gr)return e;let n=new Gr(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let i=this.ensureLine();i.length+=r,i.collapsed+=r,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Gr)&&!this.isCovered?this.nodes.push(new Gr(0,-1,0)):(this.writtenToc.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let d=c.getBoundingClientRect();s=Math.max(s,d.left),o=Math.min(o,d.right),l=Math.max(l,d.top),a=Math.min(u==t.parentNode?i.innerHeight:a,d.bottom)}u=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:l-(n.top+e),bottom:Math.max(l,a)-(n.top+e)}}function t7(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function n7(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class Sm{constructor(e,n,r,i){this.from=e,this.to=n,this.size=r,this.displaySize=i}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new XU(r),this.stateDeco=Kk(n),this.heightMap=Tr.empty().applyChanges(this.stateDeco,_t.empty,this.heightOracle.setDoc(n.doc),[new gi(0,0,0,n.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Qt.set(this.lineGaps.map(i=>i.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let i=r?n.head:n.anchor;if(!e.some(({from:s,to:o})=>i>=s&&i<=o)){let{from:s,to:o}=this.lineBlockAt(i);e.push(new yd(s,o))}}return this.viewports=e.sort((r,i)=>r.from-i.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Uk:new Mw(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(ec(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=Kk(this.state);let i=e.changedRanges,s=gi.extendWithRanges(i,QU(r,this.stateDeco,e?e.changes:Wn.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Hk(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||Ja)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,n));let u=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(u||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(XV)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),i=this.heightOracle,s=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?En.RTL:En.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=n.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let u=0,c=0;if(l.width&&l.height){let{scaleX:x,scaleY:C}=wA(n,l);(x>.005&&Math.abs(this.scaleX-x)>.005||C>.005&&Math.abs(this.scaleY-C)>.005)&&(this.scaleX=x,this.scaleY=C,u|=16,o=a=!0)}let f=(parseInt(r.paddingTop)||0)*this.scaleY,d=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=d)&&(this.paddingTop=f,this.paddingBottom=d,u|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,u|=16);let h=bA(this.view.contentDOM,!1).y;h!=this.scrollParent&&(this.scrollParent=h,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=CA(this.scrollParent||e.win);let g=(this.printing?n7:e7)(n,this.paddingTop),b=g.top-this.pixelViewport.top,m=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(a=!0)),!this.inView&&!this.scrollTarget&&!t7(e.dom))return 0;let w=l.width;if((this.contentDOMWidth!=w||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,u|=16),a){let x=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(x)&&(o=!0),o||i.lineWrapping&&Math.abs(w-this.contentDOMWidth)>i.charWidth){let{lineHeight:C,charWidth:T,textHeight:A}=e.docView.measureTextSize();o=C>0&&i.refresh(s,C,T,A,Math.max(5,w/T),x),o&&(e.docView.minWidth=0,u|=16)}b>0&&m>0?c=Math.max(b,m):b<0&&m<0&&(c=Math.min(b,m)),Hk();for(let C of this.viewports){let T=C.from==this.viewport.from?x:e.docView.measureVisibleLineHeights(C);this.heightMap=(o?Tr.empty().applyChanges(this.stateDeco,_t.empty,this.heightOracle,[new gi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new GU(C.from,T))}Ja&&(u|=2)}let k=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return k&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),u|=this.updateForViewport()),(u&2||k)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new yd(i.lineAt(o-r*1e3,un.ByHeight,s,0,0).from,i.lineAt(l+(1-r)*1e3,un.ByHeight,s,0,0).to);if(n){let{head:u}=n.range;if(ua.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=i.lineAt(u,un.ByPos,s,0,0),d;n.y=="center"?d=(f.top+f.bottom)/2-c/2:n.y=="start"||n.y=="nearest"&&u=l+Math.max(10,Math.min(r,250)))&&i>o-2*1e3&&s>1,o=i<<1;if(this.defaultTextDirection!=En.LTR&&!r)return[];let l=[],a=(c,f,d,h)=>{if(f-cc&&mm.from>=d.from&&m.to<=d.to&&Math.abs(m.from-c)m.fromv));if(!b){if(fw.from<=f&&w.to>=f)){let w=n.moveToLineBoundary(ce.cursor(f),!1,!0).head;w>c&&(f=w)}let m=this.gapSize(d,c,f,h),v=r||m<2e6?m:2e6;b=new Sm(c,f,m,v)}l.push(b)},u=c=>{if(c.length2e6)for(let C of e)C.from>=c.from&&C.fromc.from&&a(c.from,h,c,f),pn.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];Kt.spans(n,this.viewport.from,this.viewport.to,{span(s,o){r.push({from:s,to:o})},point(){}},20);let i=0;if(r.length!=this.visibleRanges.length)i=12;else for(let s=0;s=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||ec(this.heightMap.lineAt(e,un.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||ec(this.heightMap.lineAt(this.scaler.fromDOM(e),un.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return ec(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class yd{constructor(e,n){this.from=e,this.to=n}}function i7(t,e,n){let r=[],i=t,s=0;return Kt.spans(n,t,e,{span(){},point(o,l){o>i&&(r.push({from:i,to:o}),s+=o-i),i=l}},20),i=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let i=0;;i++){let{from:s,to:o}=e[i],l=o-s;if(r<=l)return s+r;r-=l}}function wd(t,e){let n=0;for(let{from:r,to:i}of t.ranges){if(e<=i){n+=e-r;break}n+=i-r}return n/t.total}function s7(t,e){for(let n of t)if(e(n))return n}const Uk={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function Kk(t){let e=t.facet(jp).filter(r=>typeof r!="function"),n=t.facet(Cw).filter(r=>typeof r!="function");return n.length&&e.push(Kt.join(n)),e}class Mw{constructor(e,n,r){let i=0,s=0,o=0;this.viewports=r.map(({from:l,to:a})=>{let u=n.lineAt(l,un.ByPos,e,0,0).top,c=n.lineAt(a,un.ByPos,e,0,0).bottom;return i+=c-u,{from:l,to:a,top:u,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(n.height-i);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let n=0,r=0,i=0;;n++){let s=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function ec(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Wi(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(i=>ec(i,e)):t._content)}const bd=Ue.define({combine:t=>t.join(" ")}),Sy=Ue.define({combine:t=>t.indexOf(!0)>-1}),Cy=Bo.newName(),oM=Bo.newName(),lM=Bo.newName(),aM={"&light":"."+oM,"&dark":"."+lM};function Ty(t,e,n){return new Bo(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,i=>{if(i=="&")return t;if(!n||!n[i])throw new RangeError(`Unsupported selector: ${i}`);return n[i]}):t+" "+r}})}const o7=Ty("."+Cy,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},aM),l7={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Cm=Oe.ie&&Oe.ie_version<=11;class a7{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new DV,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new c7(e),e.state.facet(Fs)&&(e.contentDOM.editContext=this.editContext.editContext)),Cm&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,i=this.selectionRange;if(r.state.facet(Fs)?r.root.activeElement!=this.dom:!wc(this.dom,i))return;let s=i.anchorNode&&r.docView.tile.nearest(i.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&i.focusNode&&xc(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Gc(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&u7(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let i=wc(this.dom,r);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&_a(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(i)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,i=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(i=!0),n==-1?{from:n,to:r}=o:(n=Math.min(o.from,n),r=Math.max(o.to,r)))}return{from:n,to:r,typeOver:i}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),i=this.selectionChanged&&wc(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new EU(this.view,e,n,r);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,i=qA(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!Gh(this.view.state.selection,n.newSel.main))&&this.view.update([]),i}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=Xk(n,e.previousSibling||e.target.previousSibling,-1),i=Xk(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:i?n.posBefore(i):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Fs)!=e.state.facet(Fs)&&(e.view.contentDOM.editContext=e.state.facet(Fs)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Xk(t,e,n){for(;e;){let r=An.get(e);if(r&&r.parent==t)return r;let i=e.parentNode;e=i!=t.dom?i:n>0?e.nextSibling:e.previousSibling}return null}function Gk(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor,1);return xc(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function u7(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Gk(t,i)}let n=null;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?Gk(t,n):null}class c7{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let i=e.state.selection.main,{anchor:s,head:o}=i,l=this.toEditorPos(r.updateRangeStart),a=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:l,drifted:!1});let u=a-l>r.text.length;l==this.from&&sthis.to&&(a=s);let c=YA(e.state.sliceDoc(l,a),r.text,(u?i.from:i.to)-l,u?"end":null);if(!c){let d=ce.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));Gh(d,i)||e.dispatch({selection:d,userEvent:"select"});return}let f={from:c.from+l,to:c.toA+l,insert:_t.of(r.text.slice(c.from,c.toB).split(` -`))};if((Oe.mac||Oe.android)&&f.from==o-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:_t.of([r.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let d=this.to-this.from+(f.to-f.from+f.insert.length);Ew(e,f,ce.single(this.toEditorPos(r.selectionStart,d),this.toEditorPos(r.selectionEnd,d)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let i=[],s=null;for(let o=this.toEditorPos(r.rangeStart),l=this.toEditorPos(r.rangeEnd);o{let i=[];for(let s of r.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),u=this.toEditorPos(s.rangeEnd);if(a{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let i=Gc(r.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,i=this.pendingContextChange;return e.changes.iterChanges((s,o,l,a,u)=>{if(r)return;let c=u.length-(o-s);if(i&&o>=i.to)if(i.from==s&&i.to==o&&i.insert.eq(u)){i=this.pendingContextChange=null,n+=c,this.to+=c;return}else i=null,this.revertPending(e.state);if(s+=n,o+=n,o<=this.from)this.from+=c,this.to+=c;else if(sthis.to||this.to-this.from+u.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),u.toString()),this.to+=c}n+=c}),i&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(i=>!i.isUserEvent("input.type")&&i.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),i=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(r,i)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to1e4*3)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Je{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(i=>i.forEach(s=>r(s,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||LV(e.parent)||document,this.viewState=new Vk(this,e.state||Ft.create(e)),e.scrollTo&&e.scrollTo.is(pd)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ka).map(i=>new vm(i));for(let i of this.plugins)i.update(this);this.observer=new a7(this),this.inputState=new OU(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Pk(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof Kn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,i,s=this.state;for(let d of e){if(d.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=d.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(d=>d.annotation(nM))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=rM(s,o),a||(l=1));let u=this.observer.delayedAndroidKey,c=null;if(u?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(Ft.phrases)!=this.state.facet(Ft.phrases))return this.setState(s);i=Uh.create(this,s,e),i.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let d of e){if(f&&(f=f.map(d.changes)),d.scrollIntoView){let{main:h}=d.state.selection,{x:p,y:g}=this.state.facet(Je.cursorScrollMargin);f=new Da(h.empty?h:ce.cursor(h.head,h.head>h.anchor?-1:1),"nearest","nearest",g,p)}for(let h of d.effects)h.is(pd)&&(f=h.value.clip(this.state))}this.viewState.update(i,f),this.bidiCache=Yh.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(Zu)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(d=>d.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(bd)!=i.state.facet(bd)&&(this.viewState.mustMeasureContent=!0),(n||r||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let d of this.state.facet(wy))try{d(i)}catch(h){pi(this.state,h,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!qA(this,c)&&u.force&&_a(this.contentDOM,u.key,u.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new Vk(this,e),this.plugins=e.facet(ka).map(r=>new vm(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Pk(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(ka),r=e.state.facet(ka);if(n!=r){let i=[];for(let s of r){let o=n.indexOf(s);if(o<0)i.push(new vm(s));else{let l=this.plugins[o];l.mustUpdate=e,i.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=e;for(let i=0;i-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,i=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(CA(r||this.win))s=-1,o=this.viewState.heightMap.height;else{let h=this.viewState.scrollAnchorAt(i);s=h.from,o=h.top}this.updateState=1;let a=this.viewState.measure();if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];a&4||([this.measureRequests,u]=[u,this.measureRequests]);let c=u.map(h=>{try{return h.read(this)}catch(p){return pi(this.state,p),qk}}),f=Uh.create(this,this.state,[]),d=!1;f.flags|=a,n?n.flags|=a:n=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),d=this.docView.update(f),d&&this.docViewUpdate());for(let h=0;h1||p<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){i=i+p,r?s<0?r.scrollTop=r.scrollHeight:r.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let l of this.state.facet(wy))l(n)}get themeClasses(){return Cy+" "+(this.state.facet(Sy)?lM:oM)+" "+this.state.facet(bd)}updateAttrs(){let e=Yk(this,jA,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Fs)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),Yk(this,Sw,n);let r=this.observer.ignore(()=>{let i=Tk(this.contentDOM,this.contentAttrs,n),s=Tk(this.dom,this.editorAttrs,e);return i||s});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let i of r.effects)if(i.is(Je.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(Zu);let e=this.state.facet(Je.cspNonce);Bo.mount(this.root,this.styleModules.concat(o7).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,r){return km(this,e,Ik(this,e,n,r))}moveByGroup(e,n){return km(this,e,Ik(this,e,n,r=>bU(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),i=this.textDirectionAt(e.from),s=r[n?r.length-1:0];return ce.cursor(s.side(n,i)+e.from,s.forward(!n,i)?1:-1)}moveToLineBoundary(e,n,r=!0){return wU(this,e,n,r)}moveVertically(e,n,r){return km(this,e,xU(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=xy(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),xy(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),s=i[ws.find(i,e-r.from,-1,n)];return this.docView.coordsAt(e,n,s.dir==En.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(FA)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>f7)return OA(e.length);let n=this.textDirectionAt(e.from),r;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==n&&(s.fresh||RA(s.isolates,r=Mk(this,e))))return s.order;r||(r=Mk(this,e));let i=VV(e.text,n,r);return this.bidiCache.push(new Yh(e.from,e.to,n,r,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{SA(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,i,s,o;return pd.of(new Da(typeof e=="number"?ce.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(i=n.x)!==null&&i!==void 0?i:"nearest",(s=n.yMargin)!==null&&s!==void 0?s:5,(o=n.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return pd.of(new Da(ce.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return ki.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ki.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=Bo.newName(),i=[bd.of(r),Zu.of(Ty(`.${r}`,e))];return n&&n.dark&&i.push(Sy.of(!0)),i}static baseTheme(e){return gw.lowest(Zu.of(Ty("."+Cy,e,aM)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),i=r&&An.get(r)||An.get(e);return((n=i==null?void 0:i.root)===null||n===void 0?void 0:n.view)||null}}Je.styleModule=Zu;Je.inputHandler=LA;Je.clipboardInputFilter=xw;Je.clipboardOutputFilter=kw;Je.scrollHandler=zA;Je.focusChangeEffect=$A;Je.perLineTextDirection=FA;Je.exceptionSink=DA;Je.updateListener=wy;Je.editable=Fs;Je.mouseSelectionStyle=_A;Je.dragMovesSelection=NA;Je.clickAddsSelectionRange=IA;Je.decorations=jp;Je.blockWrappers=HA;Je.outerDecorations=Cw;Je.atomicRanges=wf;Je.bidiIsolatedRanges=WA;Je.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}});Je.scrollMargins=VA;Je.darkTheme=Sy;Je.cspNonce=Ue.define({combine:t=>t.length?t[0]:""});Je.contentAttributes=Sw;Je.editorAttributes=jA;Je.lineWrapping=Je.contentAttributes.of({class:"cm-lineWrapping"});Je.announce=rn.define();const f7=4096,qk={};class Yh{constructor(e,n,r,i,s,o){this.from=e,this.to=n,this.dir=r,this.isolates=i,this.fresh=s,this.order=o}static update(e,n){if(n.empty&&!e.some(s=>s.fresh))return e;let r=[],i=e.length?e[e.length-1].dir:En.LTR;for(let s=Math.max(0,e.length-10);s=0;i--){let s=r[i],o=typeof s=="function"?s(t):s;o&&vw(o,n)}return n}const d7=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function h7(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let i,s,o,l;for(let a=0;ar.concat(i),[]))),n}let ko=null;const m7=4e3;function y7(t,e=d7){let n=Object.create(null),r=Object.create(null),i=(o,l)=>{let a=r[o];if(a==null)r[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,u,c)=>{var f,d;let h=n[o]||(n[o]=Object.create(null)),p=l.split(/ (?!$)/).map(m=>h7(m,e));for(let m=1;m{let k=ko={view:w,prefix:v,scope:o};return setTimeout(()=>{ko==k&&(ko=null)},m7),!0}]})}let g=p.join(" ");i(g,!1);let b=h[g]||(h[g]={preventDefault:!1,stopPropagation:!1,run:((d=(f=h._any)===null||f===void 0?void 0:f.run)===null||d===void 0?void 0:d.slice())||[]});a&&b.run.push(a),u&&(b.preventDefault=!0),c&&(b.stopPropagation=!0)};for(let o of t){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let u of l){let c=n[u]||(n[u]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let d in c)c[d].run.push(h=>f(h,Ey))}let a=o[e]||o.key;if(a)for(let u of l)s(u,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(u,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return n}let Ey=null;function v7(t,e,n,r){Ey=e;let i=RV(e),s=fV(i,0),o=dV(s)==i.length&&i!=" ",l="",a=!1,u=!1,c=!1;ko&&ko.view==n&&ko.scope==r&&(l=ko.prefix+" ",QA.indexOf(e.keyCode)<0&&(u=!0,ko=null));let f=new Set,d=b=>{if(b){for(let m of b.run)if(!f.has(m)&&(f.add(m),m(n)))return b.stopPropagation&&(c=!0),!0;b.preventDefault&&(b.stopPropagation&&(c=!0),u=!0)}return!1},h=t[r],p,g;return h&&(d(h[l+xd(i,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=jo[e.keyCode])&&p!=i?(d(h[l+xd(p,e,!0)])||e.shiftKey&&(g=Kc[e.keyCode])!=i&&g!=p&&d(h[l+xd(g,e,!1)]))&&(a=!0):o&&e.shiftKey&&d(h[l+xd(i,e,!0)])&&(a=!0),!a&&d(h._any)&&(a=!0)),u&&(a=!0),a&&c&&e.stopPropagation(),Ey=null,a}class w7 extends du{constructor(e){super(),this.content=e}toDOM(e){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(e){let n=e.firstChild?bc(e.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(e.parentNode),i=qc(n[0],r.direction!="rtl"),s=parseInt(r.lineHeight);return i.bottom-i.top>s*1.5?{left:i.left,right:i.right,top:i.top,bottom:i.top+s}:i}ignoreEvent(){return!1}}function b7(t){let e=ki.fromClass(class{constructor(n){this.view=n,this.placeholder=t?Qt.set([Qt.widget({widget:new w7(t),side:1}).range(0)]):Qt.none}get decorations(){return this.view.state.doc.length?Qt.none:this.placeholder}},{decorations:n=>n.decorations});return typeof t=="string"?[e,Je.contentAttributes.of({"aria-placeholder":t})]:e}const kd="-10000px";class cM{constructor(e,n,r,i){this.facet=n,this.createTooltipView=r,this.removeTooltipView=i,this.input=e.state.facet(n),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=r(o,s))}update(e,n){var r;let i=e.state.facet(this.facet),s=i.filter(a=>a);if(i===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=n?[]:null;for(let a=0;an[u]=a),n.length=l.length),this.input=i,this.tooltips=s,this.tooltipViews=o,!0}}function x7(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const Tm=Ue.define({combine:t=>{var e,n,r;return{position:Oe.ios?"absolute":((e=t.find(i=>i.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((n=t.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=t.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||x7}}}),Qk=new WeakMap,fM=ki.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(Tm);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new cM(t,dM,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let n=e||t.geometryChanged,r=t.state.facet(Tm);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(t,e){let n=t.create(this.view),r=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),t.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=kd,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var t,e,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(t=r.destroy)===null||t===void 0||t.call(r);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(Oe.safari){let o=s.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else n=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(t=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=Tw(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(Tm).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:s}=t,o=[];for(let l=0;l=Math.min(n.bottom,r.bottom)||f.rightMath.min(n.right,r.right)+.1)){c.style.top=kd;continue}let h=a.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,p=h?7:0,g=d.right-d.left,b=(e=Qk.get(u))!==null&&e!==void 0?e:d.bottom-d.top,m=u.offset||S7,v=this.view.textDirection==En.LTR,w=d.width>r.right-r.left?v?r.left:r.right-d.width:v?Math.max(r.left,Math.min(f.left-(h?14:0)+m.x,r.right-g)):Math.min(Math.max(r.left,f.left-g+(h?14:0)-m.x),r.right-g),k=this.above[l];!a.strictSide&&(k?f.top-b-p-m.yr.bottom)&&k==r.bottom-f.bottom>f.top-r.top&&(k=this.above[l]=!k);let x=(k?f.top-r.top:r.bottom-f.bottom)-p;if(xw&&A.topC&&(C=k?A.top-b-2-p:A.bottom+p+2);if(this.position=="absolute"?(c.style.top=(C-t.parent.top)/s+"px",Zk(c,(w-t.parent.left)/i)):(c.style.top=C/s+"px",Zk(c,w/i)),h){let A=f.left+(v?m.x:-m.x)-(w+14-7);h.style.left=A/i+"px"}u.overlap!==!0&&o.push({left:w,top:C,right:T,bottom:C+b}),c.classList.toggle("cm-tooltip-above",k),c.classList.toggle("cm-tooltip-below",!k),u.positioned&&u.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=kd}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Zk(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}const k7=Je.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),S7={x:0,y:0},dM=Ue.define({enables:[fM,k7]}),Jh=Ue.define({combine:t=>t.reduce((e,n)=>e.concat(n),[])});class Up{static create(e){return new Up(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new cM(e,Jh,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(e,n){let r=e.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(e){for(let n of this.manager.tooltipViews)n.mount&&n.mount(e);this.mounted=!0}positioned(e){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let n of this.manager.tooltipViews)(e=n.destroy)===null||e===void 0||e.call(n)}passProp(e){let n;for(let r of this.manager.tooltipViews){let i=r[e];if(i!==void 0){if(n===void 0)n=i;else if(n!==i)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const C7=dM.compute([Jh],t=>{let e=t.facet(Jh);return e.length===0?null:{pos:Math.min(...e.map(n=>n.pos)),end:Math.max(...e.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:Up.create,above:e[0].above,arrow:e.some(n=>n.arrow)}}),T7=Ue.define();class E7{constructor(e,n,r,i,s,o){this.view=e,this.source=n,this.field=r,this.locked=i,this.setHover=s,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;eo.bottom||n.xo.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),a=l&&l.dir==En.RTL?-1:1;s=n.x{if(l&&!(Array.isArray(l)&&!l.length)){let a=Array.isArray(l)?l:[l];i&&this.locked.set(a,i),e.dispatch({effects:this.setHover.of(a)})}};if(s&&"then"in s){let l=this.pending={pos:n};s.then(a=>{this.pending==l&&(this.pending=null,o(a))},a=>pi(e.state,a,"hover tooltip"))}else o(s)}get tooltip(){let e=this.view.plugin(fM),n=e?e.manager.tooltips.findIndex(r=>r.create==Up.create):-1;return n>-1?e.manager.tooltipViews[n]:null}mousemove(e){var n,r;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:s}=this;if(i.length&&!this.locked.has(i)&&s&&!A7(s.dom,e)||this.pending){let{pos:o}=i[0]||this.pending,l=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!M7(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length&&!this.locked.has(n)){let{tooltip:r}=this;r&&r.dom.contains(e.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let n=r=>{e.removeEventListener("mouseleave",n);let{active:i}=this;i.length&&!this.locked.has(i)&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Sd=4;function A7(t,e){let{left:n,right:r,top:i,bottom:s}=t.getBoundingClientRect(),o;if(o=t.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();i=Math.min(l.top,i),s=Math.max(l.bottom,s)}return e.clientX>=n-Sd&&e.clientX<=r+Sd&&e.clientY>=i-Sd&&e.clientY<=s+Sd}function M7(t,e,n,r,i,s){let o=t.scrollDOM.getBoundingClientRect(),l=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>r||o.righti||Math.min(o.bottom,l)=e&&a<=n}function R7(t,e={}){let n=rn.define(),r=new WeakMap,i=Rs.define({create(){return[]},update(o,l){let a=r.get(o);if(o.length&&(e.hideOnChange&&(l.docChanged||l.selection)?o=[]:a&&a(l)?o=[]:e.hideOn&&(o=o.filter(u=>!e.hideOn(l,u)))),l.docChanged&&o.length){let u=[];for(let c of o){let f=l.changes.mapPos(c.pos,-1,Ir.TrackDel);if(f!=null){let d=Object.assign(Object.create(null),c);d.pos=f,d.end!=null&&(d.end=l.changes.mapPos(d.end)),u.push(d)}}o=u}for(let u of l.effects)u.is(n)&&(o=u.value,a=void 0),(u.is(O7)&&!u.value||u.value==i)&&(o=[]);return o.length&&a&&r.set(o,a),o},provide:o=>Jh.from(o)});const s=ki.define(o=>new E7(o,t,i,r,n,e.hoverTime||300));return{active:i,extension:[i,s,T7.of(s),C7]}}const O7=rn.define(),eS=Ue.define({combine(t){let e,n;for(let r of t)e=e||r.topContainer,n=n||r.bottomContainer;return{topContainer:e,bottomContainer:n}}}),P7=ki.fromClass(class{constructor(t){this.input=t.state.facet(Ay),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(t));let e=t.state.facet(eS);this.top=new Cd(t,!0,e.topContainer),this.bottom=new Cd(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(t){let e=t.state.facet(eS);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Cd(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Cd(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=t.state.facet(Ay);if(n!=this.input){let r=n.filter(a=>a),i=[],s=[],o=[],l=[];for(let a of r){let u=this.specs.indexOf(a),c;u<0?(c=a(t.view),l.push(c)):(c=this.panels[u],c.update&&c.update(t)),i.push(c),(c.top?s:o).push(c)}this.specs=r,this.panels=i,this.top.sync(s),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let r of this.panels)r.update&&r.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>Je.scrollMargins.of(e=>{let n=e.plugin(t);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class Cd{constructor(e,n,r){this.view=e,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let n of this.panels)n.destroy&&e.indexOf(n)<0&&n.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let e=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;e!=n.dom;)e=tS(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=tS(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function tS(t){let e=t.nextSibling;return t.remove(),e}const Ay=Ue.define({enables:P7});class Qa extends Pl{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Qa.prototype.elementClass="";Qa.prototype.toDOM=void 0;Qa.prototype.mapMode=Ir.TrackBefore;Qa.prototype.startSide=Qa.prototype.endSide=-1;Qa.prototype.point=!0;const hM=1024;let I7=0;class Em{constructor(e,n){this.from=e,this.to=n}}class At{constructor(e={}){this.id=I7++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=zr.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}At.closedBy=new At({deserialize:t=>t.split(" ")});At.openedBy=new At({deserialize:t=>t.split(" ")});At.group=new At({deserialize:t=>t.split(" ")});At.isolate=new At({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});At.contextHash=new At({perNode:!0});At.lookAhead=new At({perNode:!0});At.mounted=new At({perNode:!0});class Sc{constructor(e,n,r,i=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=i}static get(e){return e&&e.props&&e.props[At.mounted.id]}}const N7=Object.create(null);class zr{constructor(e,n,r,i=0){this.name=e,this.props=n,this.id=r,this.flags=i}static define(e){let n=e.props&&e.props.length?Object.create(null):N7,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new zr(e.name||"",n,e.id,r);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(i)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(At.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let i of r.split(" "))n[i]=e[r];return r=>{for(let i=r.prop(At.group),s=-1;s<(i?i.length:0);s++){let o=n[s<0?r.name:i[s]];if(o)return o}}}}zr.none=new zr("",Object.create(null),0,8);class Rw{constructor(e){this.types=e;for(let n=0;n0;for(let a=this.cursor(o|Tn.IncludeAnonymous);;){let u=!1;if(a.from<=s&&a.to>=i&&(!l&&a.type.isAnonymous||n(a)!==!1)){if(a.firstChild())continue;u=!0}for(;u&&r&&(l||!a.type.isAnonymous)&&r(a),!a.nextSibling();){if(!a.parent())return;u=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Iw(zr.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new Dn(this.type,n,r,i,this.propValues),e.makeTree||((n,r,i)=>new Dn(zr.none,n,r,i)))}static build(e){return $7(e)}}Dn.empty=new Dn(zr.none,[],[],0);class Ow{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Ow(this.buffer,this.index)}}class Wo{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return zr.none}toString(){let e=[];for(let n=0;n0));a=o[a+3]);return l}slice(e,n,r){let i=this.buffer,s=new Uint16Array(n-e),o=0;for(let l=e,a=0;l=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function Jc(t,e,n,r){for(var i;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?l.length:-1;e!=u;e+=n){let c=l[e],f=a[e]+o.from,d;if(!(!(s&Tn.EnterBracketed&&c instanceof Dn&&(d=Sc.get(c))&&!d.overlay&&d.bracketed&&r>=f&&r<=f+c.length)&&!pM(i,r,f,f+c.length))){if(c instanceof Wo){if(s&Tn.ExcludeBuffers)continue;let h=c.findChild(0,c.buffer.length,n,r-f,i);if(h>-1)return new Ao(new _7(o,c,e,f),null,h)}else if(s&Tn.IncludeAnonymous||!c.type.isAnonymous||Pw(c)){let h;if(!(s&Tn.IgnoreMounts)&&(h=Sc.get(c))&&!h.overlay)return new wi(h.tree,f,e,o);let p=new wi(c,f,e,o);return s&Tn.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(n<0?c.children.length-1:0,n,r,i,s)}}}if(s&Tn.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let i;if(!(r&Tn.IgnoreOverlays)&&(i=Sc.get(this._tree))&&i.overlay){let s=e-this.from,o=r&Tn.EnterBracketed&&i.bracketed;for(let{from:l,to:a}of i.overlay)if((n>0||o?l<=s:l=s:a>s))return new wi(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function rS(t,e,n,r){let i=t.cursor(),s=[];if(!i.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=i.type.is(n),!i.nextSibling())return s}for(;;){if(r!=null&&i.type.is(r))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return r==null?s:[]}}function My(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class _7{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class Ao extends gM{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.context.start,r);return s<0?null:new Ao(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Tn.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new Ao(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Ao(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Ao(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,i=this.index+4,s=r.buffer[this.index+3];if(s>i){let o=r.buffer[this.index+1];e.push(r.slice(i,s,o)),n.push(0)}return new Dn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function mM(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;sn.from||o.to=e){let l=new wi(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(Jc(l,e,n,!1))}}return i?mM(i):r}class Ry{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Tn.EnterBracketed,e instanceof wi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:i}=this.buffer;return this.type=n||i.set.types[i.buffer[e]],this.from=r+i.buffer[e+1],this.to=r+i.buffer[e+2],!0}yield(e){return e?e instanceof wi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.buffer.start,r);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&Tn.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Tn.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Tn.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:i}=this;if(i){if(e>0){if(this.index-1)for(let s=n+e,o=e<0?-1:r._tree.children.length;s!=o;s+=e){let l=r._tree.children[s];if(this.mode&Tn.IncludeAnonymous||l instanceof Wo||!l.type.isAnonymous||Pw(l))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;n=o,r=s+1;break e}i=this.stack[--s]}for(let i=r;i=0;s--){if(s<0)return My(this._tree,e,i);let o=r[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function Pw(t){return t.children.some(e=>e instanceof Wo||!e.type.isAnonymous||Pw(e))}function $7(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=hM,reused:s=[],minRepeatType:o=r.types.length}=t,l=Array.isArray(n)?new Ow(n,n.length):n,a=r.types,u=0,c=0;function f(x,C,T,A,R,P){let{id:_,start:O,end:D,size:N}=l,ne=c,ie=u;if(N<0)if(l.next(),N==-1){let I=s[_];T.push(I),A.push(O-x);return}else if(N==-3){u=_;return}else if(N==-4){c=_;return}else throw new RangeError(`Unrecognized record size: ${N}`);let V=a[_],j,G,M=O-x;if(D-O<=i&&(G=b(l.pos-C,R))){let I=new Uint16Array(G.size-G.skip),$=l.pos-G.size,B=I.length;for(;l.pos>$;)B=m(G.start,I,B);j=new Wo(I,D-G.start,r),M=G.start-x}else{let I=l.pos-N;l.next();let $=[],B=[],Y=_>=o?_:-1,W=0,de=D;for(;l.pos>I;)Y>=0&&l.id==Y&&l.size>=0?(l.end<=de-i&&(p($,B,O,W,l.end,de,Y,ne,ie),W=$.length,de=l.end),l.next()):P>2500?d(O,I,$,B):f(O,I,$,B,Y,P+1);if(Y>=0&&W>0&&W<$.length&&p($,B,O,W,O,de,Y,ne,ie),$.reverse(),B.reverse(),Y>-1&&W>0){let le=h(V,ie);j=Iw(V,$,B,0,$.length,0,D-O,le,le)}else j=g(V,$,B,D-O,ne-D,ie)}T.push(j),A.push(M)}function d(x,C,T,A){let R=[],P=0,_=-1;for(;l.pos>C;){let{id:O,start:D,end:N,size:ne}=l;if(ne>4)l.next();else{if(_>-1&&D<_)break;_<0&&(_=N-i),R.push(O,D,N),P++,l.next()}}if(P){let O=new Uint16Array(P*4),D=R[R.length-2];for(let N=R.length-3,ne=0;N>=0;N-=3)O[ne++]=R[N],O[ne++]=R[N+1]-D,O[ne++]=R[N+2]-D,O[ne++]=ne;T.push(new Wo(O,R[2]-D,r)),A.push(D-x)}}function h(x,C){return(T,A,R)=>{let P=0,_=T.length-1,O,D;if(_>=0&&(O=T[_])instanceof Dn){if(!_&&O.type==x&&O.length==R)return O;(D=O.prop(At.lookAhead))&&(P=A[_]+O.length+D)}return g(x,T,A,R,P,C)}}function p(x,C,T,A,R,P,_,O,D){let N=[],ne=[];for(;x.length>A;)N.push(x.pop()),ne.push(C.pop()+T-R);x.push(g(r.types[_],N,ne,P-R,O-P,D)),C.push(R-T)}function g(x,C,T,A,R,P,_){if(P){let O=[At.contextHash,P];_=_?[O].concat(_):[O]}if(R>25){let O=[At.lookAhead,R];_=_?[O].concat(_):[O]}return new Dn(x,C,T,A,_)}function b(x,C){let T=l.fork(),A=0,R=0,P=0,_=T.end-i,O={size:0,start:0,skip:0};e:for(let D=T.pos-x;T.pos>D;){let N=T.size;if(T.id==C&&N>=0){O.size=A,O.start=R,O.skip=P,P+=4,A+=4,T.next();continue}let ne=T.pos-N;if(N<0||ne=o?4:0,V=T.start;for(T.next();T.pos>ne;){if(T.size<0)if(T.size==-3||T.size==-4)ie+=4;else break e;else T.id>=o&&(ie+=4);T.next()}R=V,A+=N,P+=ie}return(C<0||A==x)&&(O.size=A,O.start=R,O.skip=P),O.size>4?O:void 0}function m(x,C,T){let{id:A,start:R,end:P,size:_}=l;if(l.next(),_>=0&&A4){let D=l.pos-(_-4);for(;l.pos>D;)T=m(x,C,T)}C[--T]=O,C[--T]=P-x,C[--T]=R-x,C[--T]=A}else _==-3?u=A:_==-4&&(c=A);return T}let v=[],w=[];for(;l.pos>0;)f(t.start||0,t.bufferStart||0,v,w,-1,0);let k=(e=t.length)!==null&&e!==void 0?e:v.length?w[0]+v[0].length:0;return new Dn(a[t.topID],v.reverse(),w.reverse(),k)}const iS=new WeakMap;function Jd(t,e){if(!t.isAnonymous||e instanceof Wo||e.type!=t)return 1;let n=iS.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof Dn)){n=1;break}n+=Jd(t,r)}iS.set(e,n)}return n}function Iw(t,e,n,r,i,s,o,l,a){let u=0;for(let p=r;p=c)break;C+=T}if(w==k+1){if(C>c){let T=p[k];h(T.children,T.positions,0,T.children.length,g[k]+v);continue}f.push(p[k])}else{let T=g[w-1]+p[w-1].length-x;f.push(Iw(t,p,g,k,w,x,T,null,a))}d.push(x+v-s)}}return h(e,n,r,i,0),(l||a)(f,d,o)}class Cl{constructor(e,n,r,i,s=!1,o=!1){this.from=e,this.to=n,this.tree=r,this.offset=i,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let i=[new Cl(0,e.length,e,0,!1,r)];for(let s of n)s.to>e.length&&i.push(s);return i}static applyChanges(e,n,r=128){if(!n.length)return e;let i=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,u=0;;l++){let c=l=r)for(;o&&o.from=d.from||f<=d.to||u){let h=Math.max(d.from,a)-u,p=Math.min(d.to,f)-u;d=h>=p?null:new Cl(h,p,d.tree,d.offset+u,l>0,!!c)}if(d&&i.push(d),o.to>f)break;o=snew Em(i.from,i.to)):[new Em(0,0)]:[new Em(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let i=this.startParse(e,n,r);for(;;){let s=i.advance();if(s)return s}}}class F7{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new At({perNode:!0});let z7=0;class fi{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=z7++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof fi&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let i=new fi(r,[],null,[]);if(i.set.push(i),n)for(let s of n.set)i.set.push(s);return i}static defineModifier(e){let n=new Qh(e);return r=>r.modified.indexOf(n)>-1?r:Qh.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let B7=0;class Qh{constructor(e){this.name=e,this.instances=[],this.id=B7++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(l=>l.base==e&&j7(n,l.modified));if(r)return r;let i=[],s=new fi(e.name,i,e,n);for(let l of n)l.instances.push(s);let o=H7(n);for(let l of e.set)if(!l.modified.length)for(let a of o)i.push(Qh.get(l,a));return s}}function j7(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function H7(t){let e=[[]];for(let n=0;nr.length-n.length)}function vM(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let s=[],o=2,l=i;for(let f=0;;){if(l=="..."&&f>0&&f+3==i.length){o=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!d)throw new RangeError("Invalid path: "+i);if(s.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),f+=d[0].length,f==i.length)break;let h=i[f++];if(f==i.length&&h=="!"){o=0;break}if(h!="/")throw new RangeError("Invalid path: "+i);l=i.slice(f)}let a=s.length-1,u=s[a];if(!u)throw new RangeError("Invalid path: "+i);let c=new Qc(r,o,a>0?s.slice(0,a):null);e[u]=c.sort(e[u])}}return wM.add(e)}const wM=new At({combine(t,e){let n,r,i;for(;t||e;){if(!t||e&&t.depth>=e.depth?(i=e,e=e.next):(i=t,t=t.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let s=new Qc(i.tags,i.mode,i.context);n?n.next=s:r=s,n=s}return r}});class Qc{constructor(e,n,r,i){this.tags=e,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=i;for(let l of s)for(let a of l.set){let u=n[a.id];if(u){o=o?o+" "+u:u;break}}return o},scope:r}}function W7(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function V7(t,e,n,r=0,i=t.length){let s=new U7(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class U7{constructor(e,n,r){this.at=e,this.highlighters=n,this.span=r,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,r,i,s){let{type:o,from:l,to:a}=e;if(l>=r||a<=n)return;o.isTop&&(s=this.highlighters.filter(h=>!h.scope||h.scope(o)));let u=i,c=K7(e)||Qc.empty,f=W7(s,c.tags);if(f&&(u&&(u+=" "),u+=f,c.mode==1&&(i+=(i?" ":"")+f)),this.startSpan(Math.max(n,l),u),c.opaque)return;let d=e.tree&&e.tree.prop(At.mounted);if(d&&d.overlay){let h=e.node.enter(d.overlay[0].from+l,1),p=this.highlighters.filter(b=>!b.scope||b.scope(d.tree.type)),g=e.firstChild();for(let b=0,m=l;;b++){let v=b=w||!e.nextSibling())););if(!v||w>r)break;m=v.to+l,m>n&&(this.highlightRange(h.cursor(),Math.max(n,v.from+l),Math.min(r,m),"",p),this.startSpan(Math.min(r,m),u))}g&&e.parent()}else if(e.firstChild()){d&&(i="");do if(!(e.to<=n)){if(e.from>=r)break;this.highlightRange(e,n,r,i,s),this.startSpan(Math.min(r,e.to),u)}while(e.nextSibling());e.parent()}}}function K7(t){let e=t.type.prop(wM);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const xe=fi.define,Ed=xe(),yo=xe(),sS=xe(yo),oS=xe(yo),vo=xe(),Ad=xe(vo),Am=xe(vo),fs=xe(),ll=xe(fs),us=xe(),cs=xe(),Oy=xe(),Wu=xe(Oy),Md=xe(),Ye={comment:Ed,lineComment:xe(Ed),blockComment:xe(Ed),docComment:xe(Ed),name:yo,variableName:xe(yo),typeName:sS,tagName:xe(sS),propertyName:oS,attributeName:xe(oS),className:xe(yo),labelName:xe(yo),namespace:xe(yo),macroName:xe(yo),literal:vo,string:Ad,docString:xe(Ad),character:xe(Ad),attributeValue:xe(Ad),number:Am,integer:xe(Am),float:xe(Am),bool:xe(vo),regexp:xe(vo),escape:xe(vo),color:xe(vo),url:xe(vo),keyword:us,self:xe(us),null:xe(us),atom:xe(us),unit:xe(us),modifier:xe(us),operatorKeyword:xe(us),controlKeyword:xe(us),definitionKeyword:xe(us),moduleKeyword:xe(us),operator:cs,derefOperator:xe(cs),arithmeticOperator:xe(cs),logicOperator:xe(cs),bitwiseOperator:xe(cs),compareOperator:xe(cs),updateOperator:xe(cs),definitionOperator:xe(cs),typeOperator:xe(cs),controlOperator:xe(cs),punctuation:Oy,separator:xe(Oy),bracket:Wu,angleBracket:xe(Wu),squareBracket:xe(Wu),paren:xe(Wu),brace:xe(Wu),content:fs,heading:ll,heading1:xe(ll),heading2:xe(ll),heading3:xe(ll),heading4:xe(ll),heading5:xe(ll),heading6:xe(ll),contentSeparator:xe(fs),list:xe(fs),quote:xe(fs),emphasis:xe(fs),strong:xe(fs),link:xe(fs),monospace:xe(fs),strikethrough:xe(fs),inserted:xe(),deleted:xe(),changed:xe(),invalid:xe(),meta:Md,documentMeta:xe(Md),annotation:xe(Md),processingInstruction:xe(Md),definition:fi.defineModifier("definition"),constant:fi.defineModifier("constant"),function:fi.defineModifier("function"),standard:fi.defineModifier("standard"),local:fi.defineModifier("local"),special:fi.defineModifier("special")};for(let t in Ye){let e=Ye[t];e instanceof fi&&(e.name=t)}bM([{tag:Ye.link,class:"tok-link"},{tag:Ye.heading,class:"tok-heading"},{tag:Ye.emphasis,class:"tok-emphasis"},{tag:Ye.strong,class:"tok-strong"},{tag:Ye.keyword,class:"tok-keyword"},{tag:Ye.atom,class:"tok-atom"},{tag:Ye.bool,class:"tok-bool"},{tag:Ye.url,class:"tok-url"},{tag:Ye.labelName,class:"tok-labelName"},{tag:Ye.inserted,class:"tok-inserted"},{tag:Ye.deleted,class:"tok-deleted"},{tag:Ye.literal,class:"tok-literal"},{tag:Ye.string,class:"tok-string"},{tag:Ye.number,class:"tok-number"},{tag:[Ye.regexp,Ye.escape,Ye.special(Ye.string)],class:"tok-string2"},{tag:Ye.variableName,class:"tok-variableName"},{tag:Ye.local(Ye.variableName),class:"tok-variableName tok-local"},{tag:Ye.definition(Ye.variableName),class:"tok-variableName tok-definition"},{tag:Ye.special(Ye.variableName),class:"tok-variableName2"},{tag:Ye.definition(Ye.propertyName),class:"tok-propertyName tok-definition"},{tag:Ye.typeName,class:"tok-typeName"},{tag:Ye.namespace,class:"tok-namespace"},{tag:Ye.className,class:"tok-className"},{tag:Ye.macroName,class:"tok-macroName"},{tag:Ye.propertyName,class:"tok-propertyName"},{tag:Ye.operator,class:"tok-operator"},{tag:Ye.comment,class:"tok-comment"},{tag:Ye.meta,class:"tok-meta"},{tag:Ye.invalid,class:"tok-invalid"},{tag:Ye.punctuation,class:"tok-punctuation"}]);var Mm;const Sa=new At;function X7(t){return Ue.define({combine:t?e=>e.concat(t):void 0})}const G7=new At;class Ui{constructor(e,n,r=[],i=""){this.data=e,this.name=i,Ft.prototype.hasOwnProperty("tree")||Object.defineProperty(Ft.prototype,"tree",{get(){return Es(this)}}),this.parser=n,this.extension=[eu.of(this),Ft.languageData.of((s,o,l)=>{let a=lS(s,o,l),u=a.type.prop(Sa);if(!u)return[];let c=s.facet(u),f=a.type.prop(G7);if(f){let d=a.resolve(o-a.from,l);for(let h of f)if(h.test(d,s)){let p=s.facet(h.facet);return h.type=="replace"?p:p.concat(c)}}return c})].concat(r)}isActiveAt(e,n,r=-1){return lS(e,n,r).type.prop(Sa)==this.data}findRegions(e){let n=e.facet(eu);if((n==null?void 0:n.data)==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(s,o)=>{if(s.prop(Sa)==this.data){r.push({from:o,to:o+s.length});return}let l=s.prop(At.mounted);if(l){if(l.tree.prop(Sa)==this.data){if(l.overlay)for(let a of l.overlay)r.push({from:a.from+o,to:a.to+o});else r.push({from:o,to:o+s.length});return}else if(l.overlay){let a=r.length;if(i(l.tree,l.overlay[0].from+o),r.length>a)return}}for(let a=0;ar.isTop?n:void 0)]}),e.name)}configure(e,n){return new Zh(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Es(t){let e=t.field(Ui.state,!1);return e?e.tree:Dn.empty}class q7{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let r=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Vu=null;class ep{constructor(e,n,r=[],i,s,o,l,a){this.parser=e,this.state=n,this.fragments=r,this.tree=i,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new ep(e,n,[],Dn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new q7(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=Dn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(Cl.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Vu;Vu=this;try{return e()}finally{Vu=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=aS(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:i,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((u,c,f,d)=>a.push({fromA:u,toA:c,fromB:f,toB:d})),r=Cl.applyChanges(r,a),i=Dn.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let c=e.mapPos(u.from,1),f=e.mapPos(u.to,-1);ce.from&&(this.fragments=aS(this.fragments,i,s),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends yM{createParse(n,r,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let a=Vu;if(a){for(let u of i)a.tempSkipped.push(u);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new Dn(zr.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Vu}}function aS(t,e,n){return Cl.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class Za{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new Za(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=ep.create(e.facet(eu).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new Za(r)}}Ui.state=Rs.define({create:Za.init,update(t,e){for(let n of e.effects)if(n.is(Ui.setState))return n.value;return e.startState.facet(eu)!=e.state.facet(eu)?Za.init(e.state):t.apply(e)}});let xM=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(xM=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const Rm=typeof navigator<"u"&&(!((Mm=navigator.scheduling)===null||Mm===void 0)&&Mm.isInputPending)?()=>navigator.scheduling.isInputPending():null,Y7=ki.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(Ui.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(Ui.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=xM(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEndi+1e3,a=s.context.work(()=>Rm&&Rm()||Date.now()>o,i+(l?0:1e5));this.chunkBudget-=Date.now()-n,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Ui.setState.of(new Za(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>pi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),eu=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[Ui.state,Y7,Je.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class J7{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const Q7=Ue.define(),Nw=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function tp(t){let e=t.facet(Nw);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function np(t,e){let n="",r=t.tabSize,i=t.facet(Nw)[0];if(i==" "){for(;e>=r;)n+=" ",e-=r;i=" "}for(let s=0;s=e?Z7(t,n,e):null}class Kp{constructor(e,n={}){this.state=e,this.options=n,this.unit=tp(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:s}=this.options;return i!=null&&i>=r.from&&i<=r.to?s&&i==e?{text:"",from:e}:(n<0?i-1&&(s+=o-this.countColumn(r,r.search(/\S|$/))),s}countColumn(e,n=e.length){return zp(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:i}=this.lineAt(e,n),s=this.options.overrideIndentation;if(s){let o=s(i);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const SM=new At;function Z7(t,e,n){let r=e.resolveStack(n),i=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let s=[];for(let o=i;o&&!(o.fromr.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)r={node:s[o],next:r}}return CM(r,t,n)}function CM(t,e,n){for(let r=t;r;r=r.next){let i=tK(r.node);if(i)return i(_w.create(e,n,r))}return 0}function eK(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function tK(t){let e=t.type.prop(SM);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(At.closedBy))){let i=t.lastChild,s=i&&r.indexOf(i.name)>-1;return o=>sK(o,!0,1,void 0,s&&!eK(o)?i.from:void 0)}return t.parent==null?nK:null}function nK(){return 0}class _w extends Kp{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new _w(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(rK(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return CM(this.context.next,this.base,this.pos)}}function rK(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function iK(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let i=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=i==null||i<=s.from?s.to:Math.min(s.to,i);for(let l=n.to;;){let a=e.childAfter(l);if(!a||a==r)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let u=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+u}}l=a.to}}function sK(t,e,n,r,i){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=r&&s.slice(o,o+r.length)==r||i==t.pos+o,a=iK(t);return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*n)}function uS({except:t,units:e=1}={}){return n=>{let r=t&&t.test(n.textAfter);return n.baseIndent+(r?0:e*n.unit)}}const oK=new At;function lK(t){let e=t.firstChild,n=t.lastChild;return e&&e.tol.prop(Sa)==o.data:o?l=>l==o:void 0,this.style=bM(e.map(l=>({tag:l.tag,class:l.class||i(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=r?new Bo(r):null,this.themeType=n.themeType}static define(e,n){return new Xp(e,n||{})}}const Py=Ue.define(),aK=Ue.define({combine(t){return t.length?[t[0]]:null}});function Om(t){let e=t.facet(Py);return e.length?e:t.facet(aK)}function cS(t,e){let n=[cK],r;return t instanceof Xp&&(t.module&&n.push(Je.styleModule.of(t.module)),r=t.themeType),r?n.push(Py.computeN([Je.darkTheme],i=>i.facet(Je.darkTheme)==(r=="dark")?[t]:[])):n.push(Py.of(t)),n}class uK{constructor(e){this.markCache=Object.create(null),this.tree=Es(e.state),this.decorations=this.buildDeco(e,Om(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=Es(e.state),r=Om(e.state),i=r!=Om(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);n.length=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(n!=this.tree||e.viewportChanged||i)&&(this.tree=n,this.decorations=this.buildDeco(e.view,r),this.decoratedTo=s.to)}buildDeco(e,n){if(!n||!this.tree.length)return Qt.none;let r=new Ga;for(let{from:i,to:s}of e.visibleRanges)V7(this.tree,n,(o,l,a)=>{r.add(o,l,this.markCache[a]||(this.markCache[a]=Qt.mark({class:a})))},i,s);return r.finish()}}const cK=gw.high(ki.fromClass(uK,{decorations:t=>t.decorations})),fK=1e4,dK="()[]{}",hK=new At;function Iy(t,e,n){let r=t.prop(e<0?At.openedBy:At.closedBy);if(r)return r;if(t.name.length==1){let i=n.indexOf(t.name);if(i>-1&&i%2==(e<0?1:0))return[n[i+e]]}return null}function Ny(t){let e=t.type.prop(hK);return e?e(t.node):t}function Ca(t,e,n,r={}){let i=r.maxScanDistance||fK,s=r.brackets||dK,o=Es(t),l=o.resolveInner(e,n);for(let a=l;a;a=a.parent){let u=Iy(a.type,n,s);if(u&&a.from0?e>=c.from&&ec.from&&e<=c.to))return pK(t,e,n,a,c,u,s)}}return gK(t,e,n,o,l.type,i,s)}function pK(t,e,n,r,i,s,o){let l=r.parent,a={from:i.from,to:i.to},u=0,c=l==null?void 0:l.cursor();if(c&&(n<0?c.childBefore(r.from):c.childAfter(r.to)))do if(n<0?c.to<=r.from:c.from>=r.to){if(u==0&&s.indexOf(c.type.name)>-1&&c.from0)return null;let u={from:n<0?e-1:e,to:n>0?e+1:e},c=t.doc.iterRange(e,n>0?t.doc.length:0),f=0;for(let d=0;!c.next().done&&d<=s;){let h=c.value;n<0&&(d+=h.length);let p=e+d*n;for(let g=n>0?0:h.length-1,b=n>0?h.length:-1;g!=b;g+=n){let m=o.indexOf(h[g]);if(!(m<0||r.resolveInner(p+g,1).type!=i))if(m%2==0==n>0)f++;else{if(f==1)return{start:u,end:{from:p+g,to:p+g+1},matched:m>>1==a>>1};f--}}n>0&&(d+=h.length)}return c.done?{start:u,matched:!1}:null}const mK=Object.create(null),fS=[zr.none],dS=[],hS=Object.create(null),yK=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])yK[t]=vK(mK,e);function Pm(t,e){dS.indexOf(t)>-1||(dS.push(t),console.warn(e))}function vK(t,e){let n=[];for(let l of e.split(" ")){let a=[];for(let u of l.split(".")){let c=t[u]||Ye[u];c?typeof c=="function"?a.length?a=a.map(c):Pm(u,`Modifier ${u} used at start of tag`):a.length?Pm(u,`Tag ${u} used as modifier`):a=Array.isArray(c)?c:[c]:Pm(u,`Unknown highlighting tag ${u}`)}for(let u of a)n.push(u)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),i=r+" "+n.map(l=>l.id),s=hS[i];if(s)return s.id;let o=hS[i]=zr.define({id:fS.length,name:r,props:[vM({[r]:n})]});return fS.push(o),o.id}En.RTL,En.LTR;const wK=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=Lw(t.state,n.from);return r.line?bK(t):r.block?kK(t):!1};function Dw(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=t(e,n);return i?(r(n.update(i)),!0):!1}}const bK=Dw(TK,0),xK=Dw(TM,0),kK=Dw((t,e)=>TM(t,e,CK(e)),0);function Lw(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Uu=50;function SK(t,{open:e,close:n},r,i){let s=t.sliceDoc(r-Uu,r),o=t.sliceDoc(i,i+Uu),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,u=s.length-l;if(s.slice(u-e.length,u)==e&&o.slice(a,a+n.length)==n)return{open:{pos:r-l,margin:l&&1},close:{pos:i+a,margin:a&&1}};let c,f;i-r<=2*Uu?c=f=t.sliceDoc(r,i):(c=t.sliceDoc(r,r+Uu),f=t.sliceDoc(i-Uu,i));let d=/^\s*/.exec(c)[0].length,h=/\s*$/.exec(f)[0].length,p=f.length-h-n.length;return c.slice(d,d+e.length)==e&&f.slice(p,p+n.length)==n?{open:{pos:r+d+e.length,margin:/\s/.test(c.charAt(d+e.length))?1:0},close:{pos:i-h-n.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function CK(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),i=n.to<=r.to?r:t.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let s=e.length-1;s>=0&&e[s].to>r.from?e[s].to=i.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return e}function TM(t,e,n=e.selection.ranges){let r=n.map(s=>Lw(e,s.from).block);if(!r.every(s=>s))return null;let i=n.map((s,o)=>SK(e,r[o],s.from,s.to));if(t!=2&&!i.every(s=>s))return{changes:e.changes(n.map((s,o)=>i[o]?[]:[{from:s.from,insert:r[o].open+" "},{from:s.to,insert:" "+r[o].close}]))};if(t!=1&&i.some(s=>s)){let s=[];for(let o=0,l;oi&&(s==o||o>f.from)){i=f.from;let d=/^\s*/.exec(f.text)[0].length,h=d==f.length,p=f.text.slice(d,d+u.length)==u?d:-1;ds.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:u,empty:c,single:f}of r)(f||!c)&&s.push({from:l.from+u,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&r.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of r)if(l>=0){let u=o.from+l,c=u+a.length;o.text[c-o.from]==" "&&c++,s.push({from:u,to:c})}return{changes:s}}return null}const _y=Go.define(),EK=Go.define(),AK=Ue.define(),EM=Ue.define({combine(t){return hA(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,i)=>e(r,i)||n(r,i)})}}),AM=Rs.define({create(){return bs.empty},update(t,e){let n=e.state.facet(EM),r=e.annotation(_y);if(r){let a=Dr.fromTransaction(e,r.selection),u=r.side,c=u==0?t.undone:t.done;return a?c=rp(c,c.length,n.minDepth,a):c=OM(c,e.startState.selection),new bs(u==0?r.rest:c,u==0?c:r.rest)}let i=e.annotation(EK);if((i=="full"||i=="before")&&(t=t.isolate()),e.annotation(Kn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=Dr.fromTransaction(e),o=e.annotation(Kn.time),l=e.annotation(Kn.userEvent);return s?t=t.addChanges(s,o,l,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,l,n.newGroupDelay)),(i=="full"||i=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new bs(t.done.map(Dr.fromJSON),t.undone.map(Dr.fromJSON))}});function MK(t={}){return[AM,EM.of(t),Je.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?MM:e.inputType=="historyRedo"?Dy:null;return r?(e.preventDefault(),r(n)):!1}})]}function Gp(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let i=n.field(AM,!1);if(!i)return!1;let s=i.pop(t,n,e);return s?(r(s),!0):!1}}const MM=Gp(0,!1),Dy=Gp(1,!1),RK=Gp(0,!0),OK=Gp(1,!0);class Dr{constructor(e,n,r,i,s){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=i,this.selectionsAfter=s}setSelAfter(e){return new Dr(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new Dr(e.changes&&Wn.fromJSON(e.changes),[],e.mapped&&Ts.fromJSON(e.mapped),e.startSelection&&ce.fromJSON(e.startSelection),e.selectionsAfter.map(ce.fromJSON))}static fromTransaction(e,n){let r=mi;for(let i of e.startState.facet(AK)){let s=i(e);s.length&&(r=r.concat(s))}return!r.length&&e.changes.empty?null:new Dr(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,mi)}static selection(e){return new Dr(void 0,mi,void 0,void 0,e)}}function rp(t,e,n,r){let i=e+1>n+20?e-n-1:0,s=t.slice(i,e);return s.push(r),s}function PK(t,e){let n=[],r=!1;return t.iterChangedRanges((i,s)=>n.push(i,s)),e.iterChangedRanges((i,s,o,l)=>{for(let a=0;a=u&&o<=c&&(r=!0)}}),r}function IK(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function RM(t,e){return t.length?e.length?t.concat(e):t:e}const mi=[],NK=200;function OM(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-NK));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),rp(t,t.length-1,1e9,n.setSelAfter(r)))}else return[Dr.selection([e])]}function _K(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Im(t,e){if(!t.length)return t;let n=t.length,r=mi;for(;n;){let i=DK(t[n-1],e,r);if(i.changes&&!i.changes.empty||i.effects.length){let s=t.slice(0,n);return s[n-1]=i,s}else e=i.mapped,n--,r=i.selectionsAfter}return r.length?[Dr.selection(r)]:mi}function DK(t,e,n){let r=RM(t.selectionsAfter.length?t.selectionsAfter.map(l=>l.map(e)):mi,n);if(!t.changes)return Dr.selection(r);let i=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new Dr(i,rn.mapEffects(t.effects,e),o,t.startSelection.map(s),r)}const LK=/^(input\.type|delete)($|\.)/;class bs{constructor(e,n,r=0,i=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=i}isolate(){return this.prevTime?new bs(this.done,this.undone):this}addChanges(e,n,r,i,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!r||LK.test(r))&&(!l.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):qp(n,e))}function yr(t){return t.textDirectionAt(t.state.selection.main.head)==En.LTR}const IM=t=>PM(t,!yr(t)),NM=t=>PM(t,yr(t));function _M(t,e){return es(t,n=>n.empty?t.moveByGroup(n,e):qp(n,e))}const FK=t=>_M(t,!yr(t)),zK=t=>_M(t,yr(t));function BK(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Yp(t,e,n){let r=Es(t).resolveInner(e.head),i=n?At.closedBy:At.openedBy;for(let a=e.head;;){let u=n?r.childAfter(a):r.childBefore(a);if(!u)break;BK(t,u,i)?r=u:a=n?u.to:u.from}let s=r.type.prop(i),o,l;return s&&(o=n?Ca(t,r.from,1):Ca(t,r.to,-1))&&o.matched?l=n?o.end.to:o.end.from:l=n?r.to:r.from,ce.cursor(l,n?-1:1)}const jK=t=>es(t,e=>Yp(t.state,e,!yr(t))),HK=t=>es(t,e=>Yp(t.state,e,yr(t)));function DM(t,e){return es(t,n=>{if(!n.empty)return qp(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const LM=t=>DM(t,!1),$M=t=>DM(t,!0);function FM(t){let e=t.scrollDOM.clientHeighto.empty?t.moveVertically(o,e,n.height):qp(o,e));if(i.eq(r.selection))return!1;let s;if(n.selfScroll){let o=t.coordsAtPos(r.selection.main.head),l=t.scrollDOM.getBoundingClientRect(),a=l.top+n.marginTop,u=l.bottom-n.marginBottom;o&&o.top>a&&o.bottomzM(t,!1),Ly=t=>zM(t,!0);function qo(t,e,n){let r=t.lineBlockAt(e.head),i=t.moveToLineBoundary(e,n);if(i.head==e.head&&i.head!=(n?r.to:r.from)&&(i=t.moveToLineBoundary(e,n,!1)),!n&&i.head==r.from&&r.length){let s=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;s&&e.head!=r.from+s&&(i=ce.cursor(r.from+s))}return i}const WK=t=>es(t,e=>qo(t,e,!0)),VK=t=>es(t,e=>qo(t,e,!1)),UK=t=>es(t,e=>qo(t,e,!yr(t))),KK=t=>es(t,e=>qo(t,e,yr(t))),XK=t=>es(t,e=>ce.cursor(t.lineBlockAt(e.head).from,1)),GK=t=>es(t,e=>ce.cursor(t.lineBlockAt(e.head).to,-1));function qK(t,e,n){let r=!1,i=hu(t.selection,s=>{let o=Ca(t,s.head,-1)||Ca(t,s.head,1)||s.head>0&&Ca(t,s.head-1,1)||s.headqK(t,e);function Si(t,e,n){let r=hu(t.state.selection,i=>{i.undirectional&&i.head>=i.anchor!=e&&(i=ce.range(i.head,i.anchor));let s=n(i);return ce.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Zi(t.state,r)),!0)}function BM(t,e){return Si(t,e,n=>t.moveByChar(n,e))}const jM=t=>BM(t,!yr(t)),HM=t=>BM(t,yr(t));function WM(t,e){return Si(t,e,n=>t.moveByGroup(n,e))}const JK=t=>WM(t,!yr(t)),QK=t=>WM(t,yr(t)),ZK=t=>{let e=!yr(t);return Si(t,e,n=>Yp(t.state,n,e))},eX=t=>{let e=yr(t);return Si(t,e,n=>Yp(t.state,n,e))};function VM(t,e){return Si(t,e,n=>t.moveVertically(n,e))}const UM=t=>VM(t,!1),KM=t=>VM(t,!0);function XM(t,e){return Si(t,e,n=>t.moveVertically(n,e,FM(t).height))}const gS=t=>XM(t,!1),mS=t=>XM(t,!0),tX=t=>Si(t,!0,e=>qo(t,e,!0)),nX=t=>Si(t,!1,e=>qo(t,e,!1)),rX=t=>{let e=!yr(t);return Si(t,e,n=>qo(t,n,e))},iX=t=>{let e=yr(t);return Si(t,e,n=>qo(t,n,e))},sX=t=>Si(t,!1,e=>ce.cursor(t.lineBlockAt(e.head).from)),oX=t=>Si(t,!0,e=>ce.cursor(t.lineBlockAt(e.head).to)),yS=({state:t,dispatch:e})=>(e(Zi(t,{anchor:0})),!0),vS=({state:t,dispatch:e})=>(e(Zi(t,{anchor:t.doc.length})),!0),wS=({state:t,dispatch:e})=>(e(Zi(t,{anchor:t.selection.main.anchor,head:0})),!0),bS=({state:t,dispatch:e})=>(e(Zi(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),lX=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),aX=({state:t,dispatch:e})=>{let n=Jp(t).map(({from:r,to:i})=>ce.undirectionalRange(r,Math.min(i+1,t.doc.length)));return e(t.update({selection:ce.create(n),userEvent:"select"})),!0},uX=({state:t,dispatch:e})=>{let n=hu(t.selection,r=>{let i=Es(t),s=i.resolveStack(r.from,1);if(r.empty){let o=i.resolveStack(r.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from=r.to||l.to>r.to&&l.from<=r.from)&&o.next)return ce.undirectionalRange(l.from,l.to)}return r});return n.eq(t.selection)?!1:(e(Zi(t,n)),!0)};function GM(t,e){let{state:n}=t,r=n.selection,i=n.selection.ranges.slice();for(let s of n.selection.ranges){let o=n.doc.lineAt(s.head);if(e?o.to0)for(let l=s;;){let a=t.moveVertically(l,e);if(a.heado.to){i.some(u=>u.head==a.head)||i.push(a);break}else{if(a.head==l.head)break;l=a}}}return i.length==r.ranges.length?!1:(t.dispatch(Zi(n,ce.create(i,i.length-1))),!0)}const cX=t=>GM(t,!1),fX=t=>GM(t,!0),dX=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ce.create([n.main]):n.main.empty||(r=ce.create([ce.cursor(n.main.head)])),r?(e(Zi(t,r)),!0):!1};function bf(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,i=r.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);ao&&(n="delete.forward",a=Rd(t,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Rd(t,o,!1),l=Rd(t,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:ce.cursor(o,oi(t)))r.between(e,e,(i,s)=>{ie&&(e=n?s:i)});return e}const qM=(t,e,n)=>bf(t,r=>{let i=r.from,{state:s}=t,o=s.doc.lineAt(i),l,a;if(n&&!e&&i>o.from&&iqM(t,!1,!0),YM=t=>qM(t,!0,!1),JM=(t,e)=>bf(t,n=>{let r=n.head,{state:i}=t,s=i.doc.lineAt(r),o=i.charCategorizer(r);for(let l=null;;){if(r==(e?s.to:s.from)){r==n.head&&s.number!=(e?i.doc.lines:1)&&(r+=e?1:-1);break}let a=gr(s.text,r-s.from,e)+s.from,u=s.text.slice(Math.min(r,a)-s.from,Math.max(r,a)-s.from),c=o(u);if(l!=null&&c!=l)break;(u!=" "||r!=n.head)&&(l=c),r=a}return r}),QM=t=>JM(t,!1),hX=t=>JM(t,!0),pX=t=>bf(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headbf(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),mX=t=>bf(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:_t.of(["",""])},range:ce.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},vX=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let i=r.from,s=t.doc.lineAt(i),o=i==s.from?i-1:gr(s.text,i-s.from,!1)+s.from,l=i==s.to?i+1:gr(s.text,i-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:t.doc.slice(i,l).append(t.doc.slice(o,i))},range:ce.cursor(l)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Jp(t){let e=[],n=-1;for(let r of t.selection.ranges){let i=t.doc.lineAt(r.from),s=t.doc.lineAt(r.to);if(!r.empty&&r.to==s.from&&(s=t.doc.lineAt(r.to-1)),n>=i.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(r)}else e.push({from:i.from,to:s.to,ranges:[r]});n=s.number+1}return e}function ZM(t,e,n){if(t.readOnly)return!1;let r=[],i=[];for(let s of Jp(t)){if(n?s.to==t.doc.length:s.from==0)continue;let o=t.doc.lineAt(n?s.to+1:s.from-1),l=o.length+1;if(n){r.push({from:s.to,to:o.to},{from:s.from,insert:o.text+t.lineBreak});for(let a of s.ranges)i.push(ce.range(Math.min(t.doc.length,a.anchor+l),Math.min(t.doc.length,a.head+l)))}else{r.push({from:o.from,to:s.from},{from:s.to,insert:t.lineBreak+o.text});for(let a of s.ranges)i.push(ce.range(a.anchor-l,a.head-l))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ce.create(i,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const wX=({state:t,dispatch:e})=>ZM(t,e,!1),bX=({state:t,dispatch:e})=>ZM(t,e,!0);function eR(t,e,n){if(t.readOnly)return!1;let r=[];for(let s of Jp(t))n?r.push({from:s.from,insert:t.doc.slice(s.from,s.to)+t.lineBreak}):r.push({from:s.to,insert:t.lineBreak+t.doc.slice(s.from,s.to)});let i=t.changes(r);return e(t.update({changes:i,selection:t.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const xX=({state:t,dispatch:e})=>eR(t,e,!1),kX=({state:t,dispatch:e})=>eR(t,e,!0),SX=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Jp(e).map(({from:i,to:s})=>(i>0?i--:s{let s;if(t.lineWrapping){let o=t.lineBlockAt(i.head),l=t.coordsAtPos(i.head,i.assoc||1);l&&(s=o.bottom+t.documentTop-l.bottom+t.defaultLineHeight/2)}return t.moveVertically(i,!0,s)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function CX(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Es(t).resolveInner(e),r=n.childBefore(e),i=n.childAfter(e),s;return r&&i&&r.to<=e&&i.from>=e&&(s=r.type.prop(At.closedBy))&&s.indexOf(i.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(i.from).from&&!/\S/.test(t.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}const xS=tR(!1),TX=tR(!0);function tR(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(i=>{let{from:s,to:o}=i,l=e.doc.lineAt(s),a=!t&&s==o&&CX(e,s);t&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let u=new Kp(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=kM(u,s);for(c==null&&(c=zp(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));ol.from&&s{let i=[];for(let o=r.from;o<=r.to;){let l=t.doc.lineAt(o);l.number>n&&(r.empty||r.to>l.from)&&(e(l,i,r),n=l.number),o=l.to+1}let s=t.changes(i);return{changes:i,range:ce.range(s.mapPos(r.anchor,1),s.mapPos(r.head,1))}})}const EX=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new Kp(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),i=$w(t,(s,o,l)=>{let a=kM(r,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let u=/^\s*/.exec(s.text)[0],c=np(t,a);(u!=c||l.fromt.readOnly?!1:(e(t.update($w(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Nw)})}),{userEvent:"input.indent"})),!0),rR=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update($w(t,(n,r)=>{let i=/^\s*/.exec(n.text)[0];if(!i)return;let s=zp(i,t.tabSize),o=0,l=np(t,Math.max(0,s-tp(t)));for(;o(t.setTabFocusMode(),!0),MX=[{key:"Ctrl-b",run:IM,shift:jM,preventDefault:!0},{key:"Ctrl-f",run:NM,shift:HM},{key:"Ctrl-p",run:LM,shift:UM},{key:"Ctrl-n",run:$M,shift:KM},{key:"Ctrl-a",run:XK,shift:sX},{key:"Ctrl-e",run:GK,shift:oX},{key:"Ctrl-d",run:YM},{key:"Ctrl-h",run:$y},{key:"Ctrl-k",run:pX},{key:"Ctrl-Alt-h",run:QM},{key:"Ctrl-o",run:yX},{key:"Ctrl-t",run:vX},{key:"Ctrl-v",run:Ly}],RX=[{key:"ArrowLeft",run:IM,shift:jM,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:FK,shift:JK,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:UK,shift:rX,preventDefault:!0},{key:"ArrowRight",run:NM,shift:HM,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:zK,shift:QK,preventDefault:!0},{mac:"Cmd-ArrowRight",run:KK,shift:iX,preventDefault:!0},{key:"ArrowUp",run:LM,shift:UM,preventDefault:!0},{mac:"Cmd-ArrowUp",run:yS,shift:wS},{mac:"Ctrl-ArrowUp",run:pS,shift:gS},{key:"ArrowDown",run:$M,shift:KM,preventDefault:!0},{mac:"Cmd-ArrowDown",run:vS,shift:bS},{mac:"Ctrl-ArrowDown",run:Ly,shift:mS},{key:"PageUp",run:pS,shift:gS},{key:"PageDown",run:Ly,shift:mS},{key:"Home",run:VK,shift:nX,preventDefault:!0},{key:"Mod-Home",run:yS,shift:wS},{key:"End",run:WK,shift:tX,preventDefault:!0},{key:"Mod-End",run:vS,shift:bS},{key:"Enter",run:xS,shift:xS},{key:"Mod-a",run:lX},{key:"Backspace",run:$y,shift:$y,preventDefault:!0},{key:"Delete",run:YM,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:QM,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:hX,preventDefault:!0},{mac:"Mod-Backspace",run:gX,preventDefault:!0},{mac:"Mod-Delete",run:mX,preventDefault:!0}].concat(MX.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),OX=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:jK,shift:ZK},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:HK,shift:eX},{key:"Alt-ArrowUp",run:wX},{key:"Shift-Alt-ArrowUp",run:xX},{key:"Alt-ArrowDown",run:bX},{key:"Shift-Alt-ArrowDown",run:kX},{key:"Mod-Alt-ArrowUp",run:cX},{key:"Mod-Alt-ArrowDown",run:fX},{key:"Escape",run:dX},{key:"Mod-Enter",run:TX},{key:"Alt-l",mac:"Ctrl-l",run:aX},{key:"Mod-i",run:uX,preventDefault:!0},{key:"Mod-[",run:rR},{key:"Mod-]",run:nR},{key:"Mod-Alt-\\",run:EX},{key:"Shift-Mod-k",run:SX},{key:"Shift-Mod-\\",run:YK},{key:"Mod-/",run:wK},{key:"Alt-A",mac:"Ctrl-A",run:xK},{key:"Ctrl-m",mac:"Shift-Alt-m",run:AX}].concat(RX),PX={key:"Tab",run:nR,shift:rR};var kS={};class ip{constructor(e,n,r,i,s,o,l,a,u,c=0,f){this.p=e,this.stack=n,this.state=r,this.reducePos=i,this.pos=s,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=u,this.lookAhead=c,this.parent=f}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,r=0){let i=e.parser.context;return new ip(e,[],n,r,r,0,[],0,i?new SS(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let r=e>>19,i=e&65535,{parser:s}=this.p,o=this.reducePos=2e3&&!(!((n=this.p.parser.nodeSet.types[i])===null||n===void 0)&&n.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSizea;)this.stack.pop();this.reduceContext(i,u)}storeNode(e,n,r,i=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(n==r)return;if(this.buffer[o-2]>=n){this.buffer[o-2]=r;return}}}if(!s||this.pos==r)this.buffer.push(e,n,r,i);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>r;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>r;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,i>4&&(i-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=r,this.buffer[o+3]=i}}shift(e,n,r,i){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=i,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,i,4);else{let s=e,{parser:o}=this.p;this.pos=i;let l=o.stateFlag(s,1);!l&&(i>r||n<=o.maxNode)&&(this.reducePos=i),this.pushState(s,l?r:Math.min(r,this.reducePos)),this.shiftContext(n,r),n<=o.maxNode&&this.buffer.push(n,r,i,4)}}apply(e,n,r,i){e&65536?this.reduce(e):this.shift(e,n,r,i)}useNode(e,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(n,i),this.buffer.push(r,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(n&&e.buffer[n-4]==0&&(n-=4);n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let r=e.buffer.slice(n),i=e.bufferBase+n;for(;e&&i==e.bufferBase;)e=e.parent;return new ip(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new IX(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(r==0)return!1;if(!(r&65536))return!0;n.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let i=[];for(let s=0,o;sa&1&&l==o)||i.push(n[s],o)}n=i}let r=[];for(let i=0;i>19,i=n&65535,s=this.stack.length-r*3;if(s<0||e.getGoto(this.stack[s],i,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],r=(i,s)=>{if(!n.includes(i))return n.push(i),e.allActions(i,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-s;if(l>1){let a=o&65535,u=this.stack.length-l*3;if(u>=0&&e.getGoto(this.stack[u],a,!1)>=0)return l<<19|65536|a}}else{let l=r(o,s+1);if(l!=null)return l}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n0&&this.emitLookAhead()}}class SS{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class IX{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,r=e>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=i}}class sp{constructor(e,n,r){this.stack=e,this.pos=n,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new sp(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new sp(this.stack,this.pos,this.index)}}function Od(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let r=0,i=0;r=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),s+=a,l)break;s*=46}n?n[i++]=s:n=new e(s)}return n}class Qd{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const CS=new Qd;class NX{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=CS,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let r=this.range,i=this.rangeIndex,s=this.pos+e;for(;sr.to:s>=r.to;){if(i==this.ranges.length-1)return null;let o=this.ranges[++i];s+=o.from-r.to,r=o}return s}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,r,i;if(n>=0&&n=this.chunk2Pos&&rl.to&&(this.chunk2=this.chunk2.slice(0,l.to-r)),i=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),i}acceptToken(e,n=0){let r=n?this.resolveOffset(n,-1):this.pos;if(r==null||r=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=CS,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let r="";for(let i of this.ranges){if(i.from>=n)break;i.to>e&&(r+=this.input.read(Math.max(i.from,e),Math.min(i.to,n)))}return r}}class La{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;_X(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}La.prototype.contextual=La.prototype.fallback=La.prototype.extend=!1;La.prototype.fallback=La.prototype.extend=!1;function _X(t,e,n,r,i,s){let o=0,l=1<0){let p=t[h];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||DX(p,e.token.value,i,s))){e.acceptToken(p);break}}let c=e.next,f=0,d=t[o+2];if(e.next<0&&d>f&&t[u+d*3-3]==65535){o=t[u+d*3-1];continue e}for(;f>1,p=u+h+(h<<1),g=t[p],b=t[p+1]||65536;if(c=b)f=h+1;else{o=t[p+2],e.advance();continue e}}break}}function TS(t,e,n){for(let r=e,i;(i=t[r])!=65535;r++)if(i==n)return r-e;return-1}function DX(t,e,n,r){let i=TS(n,r,e);return i<0||TS(n,r,t)e)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(t.length,Math.max(r.from+1,e+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:t.length}}class LX{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?ES(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?ES(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(s instanceof Dn){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class $X{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new Qd)}getActions(e){let n=0,r=null,{parser:i}=e.p,{tokenizers:s}=i,o=i.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let u=0;uf.end+25&&(a=Math.max(f.lookAhead,a)),f.value!=0)){let d=n;if(f.extended>-1&&(n=this.addActions(e,f.extended,f.end,n)),n=this.addActions(e,f.value,f.end,n),!c.extend&&(r=f,n>d))break}}for(;this.actions.length>n;)this.actions.pop();return a&&e.setLookAhead(a),!r&&e.pos==this.stream.end&&(r=new Qd,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,n=this.addActions(e,r.value,r.end,n)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new Qd,{pos:r,p:i}=e;return n.start=r,n.end=Math.min(r+1,i.stream.end),n.value=r==i.stream.end?i.parser.eofTerm:0,n}updateCachedToken(e,n,r){let i=this.stream.clipPos(r.pos);if(n.token(this.stream.reset(i,e),r),e.value>-1){let{parser:s}=r.p;for(let o=0;o=0&&r.p.parser.dialect.allows(l>>1)){l&1?e.extended=l>>1:e.value=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,n,r,i){for(let s=0;se.bufferLength*4?new LX(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,r=this.stacks=[],i,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;on)r.push(l);else{if(this.advanceStack(l,r,e))continue;{i||(i=[],s=[]),i.push(l);let a=this.tokens.getMainToken(l);s.push(a.value,a.end)}}break}}if(!r.length){let o=i&&BX(i);if(o)return Ur&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw Ur&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&i){let o=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,s,r);if(o)return Ur&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(r.length>o)for(r.sort((l,a)=>a.score-l.score);r.length>o;)r.pop();r.some(l=>l.reducePos>n)&&this.recovering--}else if(r.length>1){e:for(let o=0;o500&&u.buffer.length>500)if((l.score-u.score||l.buffer.length-u.buffer.length)>0)r.splice(a--,1);else{r.splice(o--,1);continue e}}}r.length>12&&(r.sort((o,l)=>l.score-o.score),r.splice(12,r.length-12))}this.minStackPos=r[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,c=u?e.curContext.hash:0;for(let f=this.fragments.nodeAt(i);f;){let d=this.parser.nodeSet.types[f.type.id]==f.type?s.getGoto(e.state,f.type.id):-1;if(d>-1&&f.length&&(!u||(f.prop(At.contextHash)||0)==c))return e.useNode(f,d),Ur&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof Dn)||f.children.length==0||f.positions[0]>0)break;let h=f.children[0];if(h instanceof Dn&&f.positions[0]==0)f=h;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),Ur&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let u=0;ui?n.push(p):r.push(p)}return!1}advanceFully(e,n){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return AS(e,n),!0}}runRecovery(e,n,r){let i=null,s=!1;for(let o=0;o ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),Ur&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,r))))continue;let f=l.split(),d=c;for(let h=0;h<10&&f.forceReduce()&&(Ur&&console.log(d+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,r));h++)Ur&&(d=this.stackID(f)+" -> ");for(let h of l.recoverByInsert(a))Ur&&console.log(c+this.stackID(h)+" (via recover-insert)"),this.advanceFully(h,r);this.stream.end>l.pos?(u==l.pos&&(u++,a=0),l.recoverByDelete(a,u),Ur&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),AS(l,r)):(!i||i.scoree.topRules[l][1]),i=[];for(let l=0;l=0)s(c,a,l[u++]);else{let f=l[u+-c];for(let d=-c;d>0;d--)s(l[u++],a,f);u++}}}this.nodeSet=new Rw(n.map((l,a)=>zr.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:i[a],top:r.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=hM;let o=Od(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;ltypeof l=="number"?new La(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,r){let i=new FX(this,e,n,r);for(let s of this.wrappers)i=s(i,e,n,r);return i}getGoto(e,n,r=!1){let i=this.goto;if(n>=i[0])return-1;for(let s=i[n+1];;){let o=i[s++],l=o&1,a=i[s++];if(l&&r)return a;for(let u=s+(o>>1);s0}validAction(e,n){return!!this.allActions(e,r=>r==n?!0:null)}allActions(e,n){let r=this.stateSlot(e,4),i=r?n(r):void 0;for(let s=this.stateSlot(e,1);i==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Ls(this.data,s+2);else break;i=n(Ls(this.data,s+1))}return i}nextStates(e){let n=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=Ls(this.data,r+2);else break;if(!(this.data[r+2]&1)){let i=this.data[r+1];n.some((s,o)=>o&1&&s==i)||n.push(this.data[r],i)}}return n}configure(e){let n=Object.assign(Object.create(op.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=r}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let i=e.tokenizers.find(s=>s.from==r);return i?i.to:r})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,i)=>{let s=e.specializers.find(l=>l.from==r.external);if(!s)return r;let o=Object.assign(Object.assign({},r),{external:s.to});return n.specializers[i]=MS(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(r[o]=!0)}let i=null;for(let s=0;sr)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.scoret.external(n,r)<<1|e}return t.get}const jX=vM({String:Ye.string,Number:Ye.number,"True False":Ye.bool,PropertyName:Ye.propertyName,Null:Ye.null,", :":Ye.separator,"[ ]":Ye.squareBracket,"{ }":Ye.brace}),HX=op.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[jX],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),WX=()=>t=>{try{JSON.parse(t.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const n=VX(e,t.state.doc);return[{from:n,message:e.message,severity:"error",to:n}]}return[]};function VX(t,e){let n;return(n=t.message.match(/at position (\d+)/))?Math.min(+n[1],e.length):(n=t.message.match(/at line (\d+) column (\d+)/))?Math.min(e.line(+n[1]).from+ +n[2]-1,e.length):0}const UX=Zh.define({name:"json",parser:HX.configure({props:[SM.add({Object:uS({except:/^\s*\}/}),Array:uS({except:/^\s*\]/})}),oK.add({"Object Array":lK})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function RS(){return new J7(UX)}class OS{constructor(e,n,r){this.from=e,this.to=n,this.diagnostic=r}}class gl{constructor(e,n,r){this.diagnostics=e,this.panel=n,this.selected=r}static init(e,n,r){let i=r.facet(xs).markerFilter;i&&(e=i(e,r));let s=e.slice().sort((h,p)=>h.from-p.from||h.to-p.to),o=new Ga,l=[],a=0,u=r.doc.iter(),c=0,f=r.doc.length;for(let h=0;;){let p=h==s.length?null:s[h];if(!p&&!l.length)break;let g,b;if(l.length)g=a,b=l.reduce((w,k)=>Math.min(w,k.to),p&&p.from>g?p.from:1e8);else{if(g=p.from,g>f)break;b=p.to,l.push(p),h++}for(;hw.from||w.to==g))l.push(w),h++,b=Math.min(w.to,b);else{b=Math.min(w.from,b);break}}b=Math.min(b,f);let m=!1;if(l.some(w=>w.from==g&&(w.to==b||b==f))&&(m=g==b,!m&&b-g<10)){let w=g-(c+u.value.length);w>0&&(u.next(w),c=g);for(let k=g;;){if(k>=b){m=!0;break}if(!u.lineBreak&&c+u.value.length>k)break;k=c+u.value.length,c+=u.value.length,u.next()}}let v=sG(l);if(m)o.add(g,g,Qt.widget({widget:new tG(v),diagnostics:l.slice()}));else{let w=l.reduce((k,x)=>x.markClass?k+" "+x.markClass:k,"");o.add(g,b,Qt.mark({class:"cm-lintRange cm-lintRange-"+v+w,diagnostics:l.slice(),inclusiveEnd:l.some(k=>k.to>b)}))}if(a=b,a==f)break;for(let w=0;w{if(!(e&&o.diagnostics.indexOf(e)<0))if(!r)r=new OS(i,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new OS(r.from,s,r.diagnostic)}}),r}function KX(t,e){let n=e.pos,r=e.end||n,i=t.state.facet(xs).hideOn(t,n,r);if(i!=null)return i;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(Fw))||t.changes.touchesRange(s.from,Math.max(s.to,r)))}function XX(t,e){return t.field(Ki,!1)?e:e.concat(rn.appendConfig.of(aR))}function GX(t,e){return{effects:XX(t,[Fw.of(e)])}}const Fw=rn.define(),iR=rn.define(),sR=rn.define(),Ki=Rs.define({create(){return new gl(Qt.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),r=null,i=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);r=tu(n,t.selected.diagnostic,s)||tu(n,null,s)}!n.size&&i&&e.state.facet(xs).autoPanel&&(i=null),t=new gl(n,i,r)}for(let n of e.effects)if(n.is(Fw)){let r=e.state.facet(xs).autoPanel?n.value.length?lp.open:null:t.panel;t=gl.init(n.value,r,e.state)}else n.is(iR)?t=new gl(t.diagnostics,n.value?lp.open:null,t.selected):n.is(sR)&&(t=new gl(t.diagnostics,t.panel,n.value));return t},provide:t=>[Ay.from(t,e=>e.panel),Je.decorations.from(t,e=>e.diagnostics)]}),qX=Qt.mark({class:"cm-lintRange cm-lintRange-active"});function YX(t,e,n){let{diagnostics:r}=t.state.field(Ki),i,s=-1,o=-1;r.between(e-(n<0?1:0),e+(n>0?1:0),(a,u,{spec:c})=>{if(e>=a&&e<=u&&(a==u||(e>a||n>0)&&(elR(t,n,!1)))}const PS=t=>{let e=t.state.field(Ki,!1);return!e||!e.panel?!1:(t.dispatch({effects:iR.of(!1)}),!0)},QX=ki.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(xs);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let t=Date.now();if(tPromise.resolve(r(this.view))),r=>{this.view.state.doc==e.doc&&this.view.dispatch(GX(this.view.state,r.reduce((i,s)=>i.concat(s))))},r=>{pi(this.view.state,r)})}}update(t){let e=t.state.facet(xs);(t.docChanged||e!=t.startState.facet(xs)||e.needsRefresh&&e.needsRefresh(t))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function ZX(t,e,n){let r=[],i=-1;for(let s of t)s.then(o=>{r.push(o),clearTimeout(i),r.length==t.length?e(r):i=setTimeout(()=>e(r),200)},n)}const xs=Ue.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...hA(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:IS,tooltipFilter:IS,needsRefresh:(e,n)=>e?n?r=>e(r)||n(r):e:n,hideOn:(e,n)=>e?n?(r,i,s)=>e(r,i,s)||n(r,i,s):e:n,autoPanel:(e,n)=>e||n})}}});function IS(t,e){return t?e?(n,r)=>e(t(n,r),r):t:e}function eG(t,e={}){return[xs.of({source:t,config:e}),QX,aR]}function oR(t){let e=[];if(t)e:for(let{name:n}of t){for(let r=0;rs.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function lR(t,e,n){var r;let i=n?oR(e.actions):[];return gs("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},gs("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((s,o)=>{let l=!1,a=h=>{if(h.preventDefault(),l)return;l=!0;let p=tu(t.state.field(Ki).diagnostics,e);p&&s.apply(t,p.from,p.to)},{name:u}=s,c=i[o]?u.indexOf(i[o]):-1,f=c<0?u:[u.slice(0,c),gs("u",u.slice(c,c+1)),u.slice(c+1)],d=s.markClass?" "+s.markClass:"";return gs("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:a,onmousedown:a,"aria-label":` Action: ${u}${c<0?"":` (access key "${i[o]})"`}.`},f)}),e.source&&gs("div",{class:"cm-diagnosticSource"},e.source))}class tG extends du{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return gs("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class NS{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=lR(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class lp{constructor(e){this.view=e,this.items=[];let n=i=>{if(!(i.ctrlKey||i.altKey||i.metaKey)){if(i.keyCode==27)PS(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=oR(s.actions);for(let l=0;l{for(let s=0;sPS(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Ki).selected;if(!e)return-1;for(let n=0;n{for(let c of u.diagnostics){if(o.has(c))continue;o.add(c);let f=-1,d;for(let h=r;hr&&(this.items.splice(r,f-r),i=!0)),n&&d.diagnostic==n.diagnostic?d.dom.hasAttribute("aria-selected")||(d.dom.setAttribute("aria-selected","true"),s=d):d.dom.hasAttribute("aria-selected")&&d.dom.removeAttribute("aria-selected"),r++}});r({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let u=a.height/this.list.offsetHeight;l.topa.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function n(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)n();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(Ki),r=tu(n.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:sR.of(r)})}static open(e){return new lp(e)}}function nG(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(t)}')`}function Pd(t){return nG(``,'width="6" height="3"')}const rG=Je.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Pd("#f11")},".cm-lintRange-warning":{backgroundImage:Pd("orange")},".cm-lintRange-info":{backgroundImage:Pd("#999")},".cm-lintRange-hint":{backgroundImage:Pd("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function iG(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function sG(t){let e="hint",n=1;for(let r of t){let i=iG(r.severity);i>n&&(n=i,e=r.severity)}return e}const oG=R7(YX,{hideOn:KX}),aR=[Ki,Je.decorations.compute([Ki],t=>{let{selected:e,panel:n}=t.field(Ki);return!e||!n||e.from==e.to?Qt.none:Qt.set([qX.range(e.from,e.to)])}),oG,rG],lG=512*1024,_S=512*1024,uR=2e6;function aG(t,e){if(t.length<=e)return t;const n=t.lastIndexOf(` -`,e);return n>e*.5?t.slice(0,n):t.slice(0,e)}const uG=t=>t.state.doc.length>lG?[]:WX()(t);function DS(t){return Xp.define([{tag:Ye.propertyName,color:t?"#7dd3fc":"#0369a1"},{tag:Ye.string,color:t?"#86efac":"#15803d"},{tag:Ye.number,color:t?"#fcd34d":"#b45309"},{tag:Ye.bool,color:t?"#d8b4fe":"#7e22ce"},{tag:Ye.null,color:t?"#a1a1aa":"#71717a"}])}const cG=Je.theme({"&":{height:"100%",fontSize:"13px",backgroundColor:"transparent"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:"inherit",lineHeight:"1.5rem",overflow:"auto"},".cm-gutters":{display:"none"},".cm-activeLine":{backgroundColor:"transparent"},".cm-content":{caretColor:"currentColor",fontFamily:"inherit",letterSpacing:"-0.025em"},".cm-placeholder":{color:"var(--color-muted-foreground)"}});function cR({value:t,onChange:e,editable:n,lintJson:r=!0,dark:i,placeholder:s,testId:o="json-editor",className:l,onReady:a}){const u=y.useRef(null),c=y.useRef(null),f=y.useRef(e);f.current=e;const d=y.useRef(i),h=y.useRef(null),p=y.useRef(null),g=y.useRef(null),b=n??e!==void 0,m=y.useRef(b),v=y.useRef(r),w=t.length>_S,k=y.useRef(w),x=!b&&t.length>uR,C=x?aG(t,_S):t,T=y.useRef(!1),A=y.useCallback((R,P,_)=>R?[Je.updateListener.of(O=>{var D;O.docChanged&&!T.current&&((D=f.current)==null||D.call(f,O.state.doc.toString()))}),...P||!_?[]:[eG(uG,{delay:300})]]:[Ft.readOnly.of(!0),Je.editable.of(!1)],[]);return y.useEffect(()=>{const R=u.current;if(!R)return;const P=new Sl,_=new Sl,O=new Sl,D=Ft.create({doc:C,extensions:[O.of(w||!r?[]:RS()),Je.lineWrapping,MK(),uM.of([...OX,...$K,PX]),cG,P.of(cS(DS(i))),_.of(A(b,w,r)),...s?[b7(s)]:[]]}),N=new Je({state:D,parent:R});return h.current=P,p.current=_,g.current=O,a==null||a(N),c.current=N,()=>{N.destroy(),c.current=null}},[]),y.useEffect(()=>{const R=c.current;if(!R)return;const P=g.current,_=p.current,O=[];(w!==k.current||r!==v.current)&&(k.current=w,v.current=r,P&&O.push(P.reconfigure(w||!r?[]:RS())),_&&O.push(_.reconfigure(A(b,w,r))));const D=R.state.doc.toString();if(!(D===C&&O.length===0)){T.current=!0;try{R.dispatch({...D!==C?{changes:{from:0,to:R.state.doc.length,insert:C}}:{},...O.length>0?{effects:O}:{}})}finally{T.current=!1}}},[C,w,r,b,A]),y.useEffect(()=>{const R=c.current,P=p.current;!R||!P||b!==m.current&&(m.current=b,R.dispatch({effects:P.reconfigure(A(b,w,r))}))},[b,w,r,A]),y.useEffect(()=>{const R=c.current;if(!R||i===d.current)return;d.current=i;const P=h.current;P&&R.dispatch({effects:P.reconfigure(cS(DS(i)))})},[i]),E.jsxs("div",{"data-testid":o,className:Gn("flex min-h-0 flex-1 flex-col overflow-hidden font-mono",l),children:[x?E.jsx("div",{"data-testid":"large-output-preview-banner",role:"status",className:"border-b border-border bg-muted/40 px-5 py-1.5 font-sans text-xs text-muted-foreground",children:"Showing first 512 KB preview in editor — Copy and Download include the full output"}):null,E.jsx("div",{ref:u,className:"min-h-0 flex-1 overflow-hidden px-5 py-4"})]})}function fR({title:t,meta:e,actions:n,status:r,children:i}){return E.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[E.jsxs("div",{className:"flex min-h-[42px] flex-shrink-0 flex-wrap items-center justify-between gap-x-2 gap-y-1.5 border-b border-border px-3.5 py-2 max-md:gap-2 md:min-h-12 md:py-1.5 md:pr-2.5 md:pl-3.5 lg:gap-x-3 lg:pr-3 lg:pl-5",children:[E.jsxs("div",{className:"flex items-center gap-2 lg:gap-3",children:[E.jsx("span",{className:"font-mono text-[11px] font-semibold tracking-[0.18em] text-muted-foreground",children:t}),e?E.jsx("span",{"data-testid":"pane-meta",className:"text-xs tabular-nums text-muted-foreground/70",children:e}):null]}),E.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-0.5 max-md:gap-1",children:n})]}),E.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:i}),r?E.jsxs("div",{"data-testid":"pane-status",className:r.kind==="error"?"flex-shrink-0 px-3.5 pb-2 text-xs text-destructive":"flex-shrink-0 whitespace-pre-line px-3.5 pb-2 text-xs text-muted-foreground",role:"status",children:[r.message,r.action]}):null]})}const bl="inline-flex h-7 cursor-pointer items-center gap-1.5 rounded-md px-2 text-[13px] font-medium text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-40 [&_svg]:size-3.5";var Fy={exports:{}};(function(t,e){(function(){var n="We could not detect the separator.",r="Empty CSV. Please provide something.",i="Could not detect header. Ensure first row cotains your column headers.",s=[",",";"," "],o=!0,l={",":"comma",";":"semicolon"," ":"tab","|":"pipe"};function a(d){var h={},p;return s.forEach(function(g,b){var m=new RegExp(g,"g");h[g]=(d.match(m)||[]).length,p=!p||h[g]>h[p]?g:p}),p}function u(d){for(var h={},p=0;p=0;p--){var g=d[p];h[g]>0&&(g=g+"__"+h[g]--),b.unshift(g)}return b}function c(d,h){if(h||(h={}),d.length==0)throw r;var p=h.separator||a(d);if(!p)throw n;var g=[];try{o=h.trim!==!1;var g=f.parse(d,l[p])}catch(V){var b=d.lastIndexOf(` -`,V.offset),m=d.indexOf(` -`,V.offset),v=d.substring(b>=-1?b:0,m>-1?m:d.length);throw V.message+" On line "+V.line+" and column "+V.column+`. -`+v}if(h.transpose){for(var w=0,k=0;kw&&(w=g[k].length);for(var x=new Array(w),C=0;Cv&&(v=m,w=[]),w.push(M))}function x(){var M,I,$,B;return $=m,B=m,M=function(Y){return ne=","}()?"":null,M!==null?(I=R(),I!==null?M=[M,I]:(M=null,m=B)):(M=null,m=B),M!==null&&(M=function(Y,W){return W}($,M[1])),M===null&&(m=$),M}function C(){var M,I,$,B;return $=m,B=m,M=function(Y){return ne=";"}()?"":null,M!==null?(I=R(),I!==null?M=[M,I]:(M=null,m=B)):(M=null,m=B),M!==null&&(M=function(Y,W){return W}($,M[1])),M===null&&(m=$),M}function T(){var M,I,$,B;return $=m,B=m,M=function(Y){return ne="|"}()?"":null,M!==null?(I=R(),I!==null?M=[M,I]:(M=null,m=B)):(M=null,m=B),M!==null&&(M=function(Y,W){return W}($,M[1])),M===null&&(m=$),M}function A(){var M,I,$,B;return $=m,B=m,M=function(Y){return ne=" "}()?"":null,M!==null?(I=R(),I!==null?M=[M,I]:(M=null,m=B)):(M=null,m=B),M!==null&&(M=function(Y,W){return W}($,M[1])),M===null&&(m=$),M}function R(){var M,I,$,B,Y,W,de,le,ge;for(W=m,de=m,M=[],/^[\n\r]/.test(p.charAt(m))?(I=p.charAt(m),m++):(I=null,k("[\\n\\r]"));I!==null;)M.push(I),/^[\n\r]/.test(p.charAt(m))?(I=p.charAt(m),m++):(I=null,k("[\\n\\r]"));if(M!==null)if(I=P(),I!==null){if($=[],le=m,ge=m,/^[\n\r]/.test(p.charAt(m))?(Y=p.charAt(m),m++):(Y=null,k("[\\n\\r]")),Y!==null)for(B=[];Y!==null;)B.push(Y),/^[\n\r]/.test(p.charAt(m))?(Y=p.charAt(m),m++):(Y=null,k("[\\n\\r]"));else B=null;for(B!==null?(Y=P(),Y!==null?B=[B,Y]:(B=null,m=ge)):(B=null,m=ge),B!==null&&(B=function($e,ke){return ke}(le,B[1])),B===null&&(m=le);B!==null;){if($.push(B),le=m,ge=m,/^[\n\r]/.test(p.charAt(m))?(Y=p.charAt(m),m++):(Y=null,k("[\\n\\r]")),Y!==null)for(B=[];Y!==null;)B.push(Y),/^[\n\r]/.test(p.charAt(m))?(Y=p.charAt(m),m++):(Y=null,k("[\\n\\r]"));else B=null;B!==null?(Y=P(),Y!==null?B=[B,Y]:(B=null,m=ge)):(B=null,m=ge),B!==null&&(B=function($e,ke){return ke}(le,B[1])),B===null&&(m=le)}if($!==null){for(B=[],/^[\n\r]/.test(p.charAt(m))?(Y=p.charAt(m),m++):(Y=null,k("[\\n\\r]"));Y!==null;)B.push(Y),/^[\n\r]/.test(p.charAt(m))?(Y=p.charAt(m),m++):(Y=null,k("[\\n\\r]"));B!==null?M=[M,I,$,B]:(M=null,m=de)}else M=null,m=de}else M=null,m=de;else M=null,m=de;return M!==null&&(M=function($e,ke,ye){return ye.unshift(ke),ye}(W,M[1],M[2])),M===null&&(m=W),M}function P(){var M,I,$,B,Y,W,de,le,ge;if(W=m,de=m,M=_(),M!==null){for(I=[],le=m,ge=m,p.length>m?($=p.charAt(m),m++):($=null,k("any character")),$!==null?(B=function($e,ke){return ke==ne}(m,$)?"":null,B!==null?(Y=_(),Y!==null?$=[$,B,Y]:($=null,m=ge)):($=null,m=ge)):($=null,m=ge),$!==null&&($=function($e,ke,ye){return ye}(le,$[0],$[2])),$===null&&(m=le);$!==null;)I.push($),le=m,ge=m,p.length>m?($=p.charAt(m),m++):($=null,k("any character")),$!==null?(B=function($e,ke){return ke==ne}(m,$)?"":null,B!==null?(Y=_(),Y!==null?$=[$,B,Y]:($=null,m=ge)):($=null,m=ge)):($=null,m=ge),$!==null&&($=function($e,ke,ye){return ye}(le,$[0],$[2])),$===null&&(m=le);I!==null?($=function($e,ke,ye){return!!ke||ye.length}(m,M,I)?"":null,$!==null?M=[M,I,$]:(M=null,m=de)):(M=null,m=de)}else M=null,m=de;return M!==null&&(M=function($e,ke,ye){return ye.unshift(ke),ye}(W,M[0],M[1])),M===null&&(m=W),M}function _(){var M,I,$,B,Y,W;if(B=m,Y=m,p.charCodeAt(m)===34?(M='"',m++):(M=null,k('"\\""')),M!==null){for(I=[],$=O();$!==null;)I.push($),$=O();I!==null?(p.charCodeAt(m)===34?($='"',m++):($=null,k('"\\""')),$!==null?M=[M,I,$]:(M=null,m=Y)):(M=null,m=Y)}else M=null,m=Y;if(M!==null&&(M=function(de,le){return le.join("")}(B,M[1])),M===null&&(m=B),M===null){for(B=m,M=[],Y=m,W=m,/^[^\n\r]/.test(p.charAt(m))?(I=p.charAt(m),m++):(I=null,k("[^\\n\\r]")),I!==null?($=function(de,le){return le!=ne}(m,I)?"":null,$!==null?I=[I,$]:(I=null,m=W)):(I=null,m=W),I!==null&&(I=function(de,le){return le}(Y,I[0])),I===null&&(m=Y);I!==null;)M.push(I),Y=m,W=m,/^[^\n\r]/.test(p.charAt(m))?(I=p.charAt(m),m++):(I=null,k("[^\\n\\r]")),I!==null?($=function(de,le){return le!=ne}(m,I)?"":null,$!==null?I=[I,$]:(I=null,m=W)):(I=null,m=W),I!==null&&(I=function(de,le){return le}(Y,I[0])),I===null&&(m=Y);M!==null&&(M=function(de,le){return(o?le.join("").trim():le.join("")).replace(/(^")|("$)/g,"")}(B,M)),M===null&&(m=B)}return M}function O(){var M,I,$,B;return $=m,B=m,p.charCodeAt(m)===34?(M='"',m++):(M=null,k('"\\""')),M!==null?(p.charCodeAt(m)===34?(I='"',m++):(I=null,k('"\\""')),I!==null?M=[M,I]:(M=null,m=B)):(M=null,m=B),M!==null&&(M=function(Y){return'"'}()),M===null&&(m=$),M===null&&(/^[^"]/.test(p.charAt(m))?(M=p.charAt(m),m++):(M=null,k('[^"]'))),M}function D(M){M.sort();for(var I=null,$=[],B=0;B=2)try{return{ok:!0,value:JSON.parse(e)}}catch{return{ok:!1}}return{ok:!1}}function Xi(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function bG(t){return t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function xG(t){const e=(r,i,s)=>{for(const[o,l]of Object.entries(r)){const a=i?`${i}.${o}`:o;Xi(l)&&Object.keys(l).length>0?e(l,a,s):Array.isArray(l)?s[a]=l.map(n):s[a]=l}},n=r=>{if(!Xi(r))return r;const i={};return e(r,"",i),i};return Array.isArray(t)?t.map(n):Xi(t)?n(t):t}function kG(t){const e=n=>{if(!Xi(n))return n;const r={};for(const[i,s]of Object.entries(n))Array.isArray(s)&&s.length>0&&s.every(bG)?r[i]=s.join(", "):Array.isArray(s)?r[i]=s.map(e):r[i]=s;return r};return Array.isArray(t)?t.map(e):Xi(t)?e(t):t}function SG(t){const e=t.trim().toLowerCase();return e==="true"||e==="1"||e==="yes"?!0:e==="false"||e==="0"||e==="no"?!1:t}function CG(t,e,n){if(n==="string")return t;if(n==="number")return $S(t);if(n==="boolean")return SG(t);if(e.parseJSON){const r=wG(t);if(r.ok&&typeof r.value!="number")return r.value}return e.parseNumbers?$S(t):t}function TG(t,e){const n=i=>{var o;const s={};for(const l of Object.keys(i)){const a=i[l];if(typeof a!="string"){s[l]=a;continue}if(e.emptyFields==="skip"&&a==="")continue;if(e.nullLiterals==="null"&&a==="NULL"){s[l]=null;continue}const u=(o=e.columnTypes)==null?void 0:o[l],c=CG(a,e,u);s[l]=c}return s};if(Array.isArray(t))return t.map(i=>Xi(i)?n(i):i);const r={};for(const[i,s]of Object.entries(t))r[i]=Xi(s)?n(s):s;return r}const EG=/^([^.[\]]+)(?:\.(0|[1-9]\d*)|\[(0|[1-9]\d*)\])(?:\.(.+))?$/;function hR(t){const e=EG.exec(t);if(!e)return null;const n=e[1],r=e[2],i=e[3],s=e[4],o=Number(r??i);return Number.isSafeInteger(o)?{column:t,prefix:n,index:o,notation:r!==void 0?"dot":"bracket",...s!==void 0?{subKey:s}:{}}:null}function By(t){const e=new Set(t),n=new Map;for(const i of t){const s=hR(i);if(!s)continue;const o=n.get(s.prefix);o?o.push(s):n.set(s.prefix,[s])}const r=[];for(const[i,s]of n.entries()){if(e.has(i))continue;const o=s[0].subKey!==void 0,l=s[0].notation;if(s.some(h=>h.subKey!==void 0!==o||h.notation!==l))continue;const a=new Set;let u=!1;for(const h of s){const p=`${h.index}:${h.subKey??""}`;if(a.has(p)){u=!0;break}a.add(p)}if(u)continue;const c=Array.from(new Set(s.map(h=>h.index))).sort((h,p)=>h-p);if(c.length<2)continue;const f=c[0];f!==0&&f!==1||!c.every((h,p)=>h===f+p)||r.push({prefix:i,indices:c,columns:s.map(h=>h.column)})}return r}function FS(t,e){return t===void 0||t===""||e==="skip"&&t===null}function zS(t,e,n,r){const i=new Map,s=new Set,o=new Map;for(const a of n)if(a.columns.length!==0){i.set(a.columns[0],a);for(const u of a.columns)s.add(u);o.set(a.prefix,a.columns.map(u=>hR(u)).filter(u=>u!==null))}const l={};for(const a of e){const u=i.get(a);if(u){const c=o.get(u.prefix)??[];if(c.some(d=>d.subKey!==void 0)){const d=new Map;for(const p of c){const g=d.get(p.index);g?g.push(p):d.set(p.index,[p])}const h=[];for(const p of u.indices){const g=d.get(p)??[],b={};for(const m of g){if(!m.subKey)continue;const v=t[m.column];FS(v,r)||(b[m.subKey]=v)}Object.keys(b).length>0&&h.push(b)}if(h.length===0&&r==="skip")continue;l[u.prefix]=h}else{const d=new Map;for(const p of c)d.set(p.index,p.column);const h=[];for(const p of u.indices){const g=d.get(p);if(!g)continue;const b=t[g];FS(b,r)||h.push(b)}if(h.length===0&&r==="skip")continue;l[u.prefix]=h}continue}s.has(a)||Object.prototype.hasOwnProperty.call(t,a)&&(l[a]=t[a])}return l}function AG(t,e,n){if(Array.isArray(t)&&Array.isArray(e)){const r=t[0];if(!Xi(r))return e;const i=Object.keys(r),s=By(i);return s.length===0?e:e.map(o=>Xi(o)?zS(o,i,s,n):o)}if(!Array.isArray(t)&&!Array.isArray(e)){const r=Object.values(t)[0];if(!Xi(r))return e;const i=Object.keys(r),s=By(i);if(s.length===0)return e;const o={};for(const[l,a]of Object.entries(e))o[l]=Xi(a)?zS(a,i,s,n):a;return o}return e}function BS(t,e={}){const n={parseNumbers:e.parseNumbers??!0,parseJSON:e.parseJSON??!1,emptyFields:e.emptyFields??"keep",nullLiterals:e.nullLiterals??"string",columnTypes:e.columnTypes},r=t.startsWith(LS)?t.slice(LS.length):t,i=e.separator===void 0?gf(r):null,s=i?i.cleanedCsv:r;try{const o=dG(s,{...e,parseNumbers:!1,parseJSON:!1,trim:!1}),l=TG(o,n);return e.collapseIndexedArrays!==!1&&!e.transpose?AG(o,l,n.emptyFields):l}catch(o){throw new Error(dR(o))}}function MG(t,e={}){try{const n=e.flatten?kG(xG(t)):t;return pG(n,e)}catch(n){const r=dR(n);throw yG.some(i=>r.startsWith(i))?new gG(mG(r,e.flatten??!1)):new Error(r)}}function RG(t,e={}){return JSON.stringify(t,null,e.minify?void 0:2)}const Kr={separator:"auto",parseNumbers:!0,parseJSON:!0,emptyFields:"keep",nullLiterals:"string",transpose:!1,hash:!1,minify:!1,flatten:!1,collapseIndexedArrays:!0},jS=["data","items","results","records","rows"];function Cc(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function pR(t){const e=t.trim();if(e===""||!e.startsWith("{"))return[];let n;try{n=JSON.parse(e)}catch{return[]}if(!Cc(n))return[];const r=Object.keys(n),i=new Set(jS),s=[...jS.filter(l=>r.includes(l)),...r.filter(l=>!i.has(l))],o=[];for(const l of s){const a=n[l];Array.isArray(a)&&a.length>0&&a.every(u=>Cc(u))&&o.push({key:l,rowCount:a.length,unwrappedJson:JSON.stringify(a,null,2)})}return o}function zw(t){const e=t.split(/\r?\n/).map(r=>r.trim()).filter(r=>r.length>0);if(e.length<2)return null;const n=[];for(const r of e)try{const i=JSON.parse(r);if(typeof i!="object"||i===null)return null;n.push(i)}catch{return null}return n}function OG(t){const e=t.trim();if(e==="")return null;let n;try{n=JSON.parse(e)}catch{const i=zw(e);if(i===null)return null;n=i}const r=JSON.stringify(n,null,2);return e===r?{label:"Minify",nextInput:JSON.stringify(n)}:{label:"Format",nextInput:r}}function PG(t){const e=t.trim();if(e==="")return[];let n;try{n=JSON.parse(e)}catch{const o=zw(e);if(o===null)return[];n=o}let r=[];if(Array.isArray(n)){if(n.length===0||!n.every(o=>Cc(o)))return[];r=n}else if(Cc(n)){if(pR(e).length>0)return[];r=[n]}else return[];const i=new Set,s=r.slice(0,50);for(const o of s)for(const[l,a]of Object.entries(o))(Cc(a)||Array.isArray(a)&&a.length>0)&&i.add(l);return Array.from(i)}function IG(t){const e=n=>{const r=new Set;for(const i of n)i&&typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).forEach(s=>r.add(s));return r};if(Array.isArray(t))return{rows:t.length,cols:e(t).size};if(t&&typeof t=="object"){const n=Object.values(t);return{rows:n.length,cols:e(n).size}}return{rows:0,cols:0}}const HS=t=>t==="auto"?void 0:t;function NG(t){let e=!1,n=1;for(let r=0;r0;return i.rowWidths.forEach((o,l)=>{if(s&&l===i.rowWidths.length-1)return;const a=i.rows[l];o===1&&a[0]===""||o!==i.headers.length&&n.push(o0?{warnings:f}:{}}}let r;try{r=JSON.parse(e)}catch(l){const a=zw(e);if(a!==null)r=a;else return{ok:!1,error:`Invalid JSON — ${l instanceof Error?l.message:String(l)}`}}const i=HS(n.separator),s=MG(r,{separator:i,flatten:n.flatten}),o=mf(s,i);return{ok:!0,text:s,rows:o.rows.length,cols:o.headers.length}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}}function LG(){return E.jsx("svg",{"data-testid":"reading-spinner",className:"animate-spin",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,"aria-label":"Reading file",children:E.jsx("path",{d:"M21 12a9 9 0 1 1-6.2-8.56",strokeLinecap:"round"})})}function Ku({label:t,testId:e,onClick:n,disabled:r,Icon:i,keepLabelOnMobile:s=!1}){return E.jsxs("button",{type:"button","data-testid":e,"aria-label":t,disabled:r,onClick:n,title:t,className:bl,children:[i?E.jsx(i,{"aria-hidden":"true"}):null,i&&!s?E.jsx("span",{className:"hidden xl:inline",children:t}):t]})}function $G(t){const e=Math.min(t.length,65536);let n=!1,r=0;for(let i=0;i=3))return t.slice(0,i+1)}return t.slice(0,e)}function FG(t){const e=t.slice(0,3).map(r=>`.${r}`).join(", "),n=t.length-3;return n>0?`${e}, +${n} more`:e}function zG({format:t,input:e,onInputChange:n,onFile:r,onTryExample:i,onClear:s,onCopy:o,onCopySelection:l,onDownload:a,filename:u,reading:c,meta:f,error:d,notice:h,dark:p,delimiter:g,onCellCommit:b,canUndo:m=!1,canRedo:v=!1,onUndo:w,onRedo:k,onProjectedCsvChange:x,collapseIndexedArrays:C=!0,onToggleCollapseIndexedArrays:T,columnTypes:A,onChangeColumnTypes:R,flatten:P=!1,onToggleFlatten:_}){const[O,D]=y.useState(!1),[N,ne]=y.useState(!1),ie=y.useRef(0),V=y.useRef(null),j=e.trim()==="",G=t==="CSV",M=y.useMemo(()=>!G||j||g!==void 0?null:gf(e),[G,j,e,g]),I=y.useMemo(()=>{if(!G||j)return[];const ye=M?M.cleanedCsv:e,lt=$G(ye),Fe=mf(lt,g);return By(Fe.headers.map(He=>He.trim()))},[G,j,e,g,M]),$=y.useMemo(()=>G||j?[]:pR(e),[G,j,e]),B=y.useMemo(()=>G||j?[]:PG(e),[G,j,e]),Y=y.useMemo(()=>G||j?null:OG(e),[G,j,e]),W=ye=>{var lt;ye.preventDefault(),Array.from(((lt=ye.dataTransfer)==null?void 0:lt.types)??[]).includes("Files")&&(ie.current++,ne(!0))},de=()=>{ie.current=Math.max(0,ie.current-1),ie.current===0&&ne(!1)},le=ye=>{var Fe,He;ye.preventDefault(),ie.current=0,ne(!1);const lt=(He=(Fe=ye.dataTransfer)==null?void 0:Fe.files)==null?void 0:He[0];lt&&r(lt,"drop")},ge=ye=>{var Fe;if(!j||ye.defaultPrevented||ye.target instanceof HTMLTextAreaElement||ye.target instanceof HTMLInputElement)return;const lt=(Fe=ye.clipboardData)==null?void 0:Fe.getData("text/plain");lt&&(ye.preventDefault(),n(lt))},$e=G?E.jsxs("span",{"data-testid":"view-mode",role:"group","aria-label":"View mode",className:"inline-flex items-center gap-0.5 rounded-lg border border-border bg-muted/60 p-0.5",children:[E.jsxs("button",{type:"button","data-testid":"view-table","aria-pressed":!O,onClick:()=>D(!1),className:Gn("inline-flex cursor-pointer items-center gap-1 rounded-[7px] px-2 py-1 text-xs font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50 lg:px-2.5",O?"text-muted-foreground hover:text-foreground":"bg-background text-foreground shadow-sm"),children:[E.jsx(TN,{"aria-hidden":"true",className:"size-3.5 md:hidden lg:inline"}),"Table"]}),E.jsxs("button",{type:"button","data-testid":"raw-toggle","aria-pressed":O,onClick:()=>D(!0),className:Gn("inline-flex cursor-pointer items-center gap-1 rounded-[7px] px-2 py-1 text-xs font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50 lg:px-2.5",O?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[E.jsx(mb,{"aria-hidden":"true",className:"size-3.5 md:hidden lg:inline"}),"Raw"]})]}):null,ke=c&&u?E.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[E.jsx(LG,{})," ",u]}):u?f?`${u} · ${f}`:u:f;return E.jsx("div",{"data-testid":"input-pane",onDragEnter:W,onDragOver:ye=>ye.preventDefault(),onDragLeave:de,onDrop:le,onPaste:ge,"data-drag-over":N||void 0,className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:E.jsxs(fR,{title:t,meta:ke,actions:E.jsxs(E.Fragment,{children:[$e,G&&(m||v)?E.jsxs(E.Fragment,{children:[E.jsx("button",{type:"button","data-testid":"csv-undo-button","aria-label":"Undo",title:"Undo",disabled:!m,onClick:()=>w==null?void 0:w(),className:bl,children:E.jsx(IN,{"aria-hidden":"true"})}),E.jsx("button",{type:"button","data-testid":"csv-redo-button","aria-label":"Redo",title:"Redo",disabled:!v,onClick:()=>k==null?void 0:k(),className:bl,children:E.jsx(pN,{"aria-hidden":"true"})})]}):null,Y?E.jsx(Ku,{label:Y.label,testId:"json-format-toggle",onClick:()=>n(Y.nextInput),Icon:mb,keepLabelOnMobile:!0}):null,E.jsx("input",{ref:V,type:"file","data-testid":"file-input",accept:G?".csv,.tsv,.txt,text/csv,text/tab-separated-values":".json,.txt,application/json",className:"hidden",onChange:ye=>{var Fe;const lt=(Fe=ye.target.files)==null?void 0:Fe[0];lt&&r(lt,"picker"),ye.target.value=""}}),E.jsx(Ku,{label:"Upload",testId:"upload",onClick:()=>{var ye;return(ye=V.current)==null?void 0:ye.click()},Icon:kT}),E.jsx(Ku,{label:"Copy",testId:"copy-input",onClick:o,Icon:zv}),E.jsx(Ku,{label:"Clear",testId:"clear-input",onClick:s,disabled:j,Icon:Th}),E.jsx(Ku,{label:"Download",testId:"download-input",onClick:a,disabled:j,Icon:xT})]}),status:d?{kind:"error",message:d}:h?{kind:"notice",message:h}:null,children:[j?E.jsx(rV,{format:t,onIngest:n,onBrowse:()=>{var ye;return(ye=V.current)==null?void 0:ye.click()},onTryExample:i}):G?E.jsxs(E.Fragment,{children:[M?E.jsxs("div",{"data-testid":"csv-markdown-table-bar",className:"flex flex-shrink-0 flex-wrap items-center justify-between gap-1.5 border-b border-border bg-muted/30 px-3.5 py-1.5",children:[E.jsx("span",{className:"text-xs text-muted-foreground",children:M.kind==="box"?"ASCII CLI box table detected:":"Markdown pipe table detected:"}),E.jsx("button",{type:"button","data-testid":"csv-clean-markdown-pill",onClick:()=>n(M.cleanedCsv),className:"inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background px-2 py-0.5 font-mono text-xs font-medium text-foreground shadow-2xs transition-colors hover:bg-muted outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:M.kind==="box"?`Clean CLI table (${M.rows} ${M.rows===1?"row":"rows"})`:`Clean Markdown table (${M.rows} ${M.rows===1?"row":"rows"})`})]}):null,I.length>0?E.jsxs("div",{"data-testid":"csv-indexed-array-bar",className:"flex flex-shrink-0 flex-wrap items-center justify-between gap-1.5 border-b border-border bg-muted/30 px-3.5 py-1.5",children:[E.jsx("span",{className:"text-xs text-muted-foreground",children:`Indexed columns (${I.map(ye=>`${ye.prefix}[${ye.indices.length}]`).join(", ")}):`}),E.jsx("button",{type:"button","data-testid":"csv-indexed-array-pill","aria-pressed":C,onClick:()=>T==null?void 0:T(),className:Gn("inline-flex cursor-pointer items-center gap-1 rounded-md border px-2 py-0.5 font-mono text-xs font-medium shadow-2xs transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50",C?"border-border bg-background text-foreground hover:bg-muted":"border-border bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground"),children:C?"Arrays: .0, .1 → []":"Keep flat keys (.0, .1)"})]}):null,O?E.jsx("textarea",{"data-testid":"input-editor",value:e,onChange:ye=>n(ye.target.value),spellCheck:!1,className:"min-h-0 flex-1 resize-none bg-transparent px-5 py-4 font-mono text-[13px] leading-6 tracking-tight focus:outline-none"}):E.jsx(qE,{text:e,delimiter:g,testId:"input-table",dark:p,onCellCommit:b,onUndo:w,onRedo:k,onCopySelection:l,columnTypes:A,onChangeColumnTypes:R,onProjectedCsvChange:x})]}):E.jsxs(E.Fragment,{children:[$.length>0?E.jsxs("div",{"data-testid":"json-unwrap-bar",className:"flex flex-shrink-0 flex-wrap items-center gap-1.5 border-b border-border bg-muted/30 px-3.5 py-1.5",children:[E.jsx("span",{className:"text-xs text-muted-foreground",children:"Nested array detected:"}),$.map(ye=>E.jsx("button",{type:"button","data-testid":`json-unwrap-pill-${ye.key}`,onClick:()=>n(ye.unwrappedJson),className:"inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background px-2 py-0.5 font-mono text-xs font-medium text-foreground shadow-2xs transition-colors outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50",children:`Unwrap .${ye.key} (${ye.rowCount} ${ye.rowCount===1?"row":"rows"})`},ye.key))]}):null,B.length>0?E.jsxs("div",{"data-testid":"json-flatten-bar",className:"flex flex-shrink-0 flex-wrap items-center justify-between gap-1.5 border-b border-border bg-muted/30 px-3.5 py-1.5",children:[E.jsx("span",{className:"text-xs text-muted-foreground",children:`Nested keys (${B.length}):`}),E.jsx("button",{type:"button","data-testid":"json-flatten-pill","aria-pressed":P,onClick:()=>_==null?void 0:_(),className:Gn("inline-flex cursor-pointer items-center gap-1 rounded-md border px-2 py-0.5 font-mono text-xs font-medium shadow-2xs transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50",P?"border-border bg-background text-foreground hover:bg-muted":"border-border bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground"),children:`${P?"Flattened":"Flatten"} nested keys (${FG(B)})`})]}):null,E.jsx(cR,{value:e,onChange:n,dark:p,testId:"input-editor"})]}),N?E.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-3 z-10 flex items-center justify-center rounded-xl border-2 border-dashed border-primary/50 bg-background/80 backdrop-blur-sm",children:E.jsx("p",{className:"text-sm font-medium text-foreground",children:"Drop file to import"})}):null]})})}const BG=/\.(csv|tsv|txt|json|ndjson|md|log)$/i;function jG(t){return t.type.startsWith("text/")||t.type==="application/json"?!0:BG.test(t.name)}const HG=[{value:"utf-8",label:"UTF-8"},{value:"windows-1252",label:"Windows-1252"}];async function WS(t,e){const n=t.stream().getReader();let r="";try{const i=[];let s=0;for(;s<2;){const{done:u,value:c}=await n.read();if(u)break;c&&c.byteLength>0&&(i.push(c),s+=c.byteLength)}let o=null;if(i.length===1)o=i[0];else if(i.length>1){o=new Uint8Array(s);let u=0;for(const c of i)o.set(c,u),u+=c.byteLength}let l=e;e==="utf-8"&&o&&o.byteLength>=2&&(o[0]===255&&o[1]===254?l="utf-16le":o[0]===254&&o[1]===255&&(l="utf-16be"));const a=new TextDecoder(l,{fatal:!1});for(o&&(r+=a.decode(o,{stream:!0}));;){const{done:u,value:c}=await n.read();if(u)break;r+=a.decode(c,{stream:!0})}return r+a.decode()}finally{n.releaseLock()}}function gR(t){const[e,n]=y.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(t).matches);return y.useEffect(()=>{if(typeof window.matchMedia!="function")return;const r=window.matchMedia(t),i=s=>n(s.matches);return n(r.matches),r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[t]),e}const mR=[{value:"auto",label:"Auto-detect"},{value:",",label:"Comma"},{value:";",label:"Semicolon"},{value:" ",label:"Tab"},{value:"|",label:"Pipe"}];function VS(){return E.jsx("div",{className:"hidden h-5 w-px shrink-0 bg-border fit:block","aria-hidden":"true"})}function WG(t,e){var i;const r=[e.separator==="auto"?"Auto":((i=mR.find(s=>s.value===e.separator))==null?void 0:i.label)??"Auto"];return t==="csv2json"?(e.parseNumbers&&r.push("Parse numbers"),e.parseJSON&&r.push("Parse JSON"),e.emptyFields==="skip"&&r.push("Skip empty"),e.nullLiterals==="null"&&r.push("NULL→null"),e.transpose&&r.push("Transpose"),e.hash&&r.push("Hash"),e.minify&&r.push("Minify")):e.flatten&&r.push("Flatten"),r.join(" · ")}function US(){return"h-7 cursor-pointer appearance-none rounded-md border border-border bg-background py-0 pl-2.5 pr-6 text-[13px] font-medium text-foreground transition-colors outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50"}function KS(){return E.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"pointer-events-none absolute top-1/2 right-1.5 size-3.5 -translate-y-1/2 text-muted-foreground",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:E.jsx("path",{d:"m4 6 4 4 4-4",strokeLinecap:"round",strokeLinejoin:"round"})})}function XS({children:t}){return E.jsx("span",{className:"font-mono text-[11px] font-semibold tracking-[0.14em] whitespace-nowrap text-muted-foreground/70 uppercase",children:t})}function ho({label:t,checked:e,onChange:n,hint:r}){return E.jsxs("span",{className:"inline-flex items-center gap-1",children:[E.jsxs("label",{className:"flex cursor-pointer items-center gap-2 whitespace-nowrap text-[13px] text-muted-foreground transition-colors hover:text-foreground",children:[E.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":t,onClick:()=>n(!e),className:"flex h-6 shrink-0 cursor-pointer items-center rounded-full outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:E.jsx("span",{className:Gn("relative inline-flex h-[18px] w-8 items-center rounded-full border transition-colors",e?"border-primary bg-primary":"border-border bg-muted"),children:E.jsx("span",{className:Gn("pointer-events-none inline-block size-3 rounded-full bg-background shadow-sm transition-transform",e?"translate-x-[15px]":"translate-x-[2px]")})})}),E.jsx("span",{className:"select-none",children:t})]}),r?E.jsx(jy,{text:r}):null]})}function jy({text:t}){const e=y.useId(),[n,r]=y.useState(!1);return E.jsxs("span",{className:"relative inline-flex items-center",children:[E.jsx("button",{type:"button","aria-label":"What does this option do?","aria-expanded":n,"aria-describedby":e,title:"What does this option do?",onClick:()=>r(i=>!i),className:"flex h-4 w-4 cursor-pointer items-center justify-center rounded-full border border-border text-[9px] font-semibold leading-none text-muted-foreground hover:text-foreground",children:"i"}),E.jsx("span",{"data-hint":!0,id:e,hidden:!n,className:"ml-1 text-muted-foreground",children:t})]})}function VG({direction:t,options:e,onChange:n,notice:r,uploadEncoding:i,onUploadEncodingChange:s}){const[o,l]=y.useState(!1),a=y.useRef(null),u=y.useRef(null),c=gR("(min-width: 98.5rem)"),f=t==="csv2json",d=WG(t,e),h=y.useCallback(()=>{var g;l(!1),(g=a.current)==null||g.focus()},[]);y.useEffect(()=>{if(!o)return;const g=m=>{m.key==="Escape"&&h()},b=m=>{const v=u.current;v===null||!(m.target instanceof Node)||v.contains(m.target)||h()};return document.addEventListener("keydown",g),document.addEventListener("click",b),()=>{document.removeEventListener("keydown",g),document.removeEventListener("click",b)}},[o,h]);const p=E.jsxs(E.Fragment,{children:[E.jsxs("span",{className:"inline-flex items-center gap-2",children:[E.jsxs("label",{className:"flex items-center gap-2",children:[E.jsx(XS,{children:"Separator"}),E.jsxs("span",{className:"relative inline-flex",children:[E.jsx("select",{"data-testid":"opt-separator",value:e.separator,onChange:g=>n({separator:g.target.value}),className:US(),children:mR.map(g=>E.jsx("option",{value:g.value,children:g.label},g.value))}),E.jsx(KS,{})]})]}),E.jsx(jy,{text:"Auto-detect is conservative — it only picks comma, semicolon, or tab. Pipe never auto-detects because normal prose is full of pipes, so pipe-separated text must be selected explicitly."})]}),i&&s?E.jsxs(E.Fragment,{children:[E.jsx(VS,{}),E.jsxs("span",{className:"inline-flex items-center gap-2",children:[E.jsxs("label",{className:"flex items-center gap-2",children:[E.jsx(XS,{children:"Encoding"}),E.jsxs("span",{className:"relative inline-flex",children:[E.jsx("select",{"data-testid":"opt-encoding",value:i,onChange:g=>s(g.target.value),className:US(),children:HG.map(g=>E.jsx("option",{value:g.value,children:g.label},g.value))}),E.jsx(KS,{})]})]}),E.jsx(jy,{text:"Applies to file uploads and drops only — pasted or typed text is always read as UTF-8. Switch to Windows-1252 for CSVs saved by legacy Excel to fix mangled accents like ü and ö."})]})]}):null,E.jsx(VS,{}),f?E.jsxs(E.Fragment,{children:[E.jsx(ho,{label:"Parse numbers",checked:e.parseNumbers,onChange:g=>n({parseNumbers:g}),hint:"On by default — plain numbers like 5 or 19.99 become real JSON numbers; leading-zero values like 00721 and very long IDs stay strings. Uncheck to keep numeric cells as strings — booleans, null, and containers still convert while Parse JSON is on."}),E.jsx(ho,{label:"Parse JSON",checked:e.parseJSON,onChange:g=>n({parseJSON:g}),hint:"Turns null, true, false, [] and {} into real JSON values instead of strings."}),E.jsx(ho,{label:"Skip empty fields",checked:e.emptyFields==="skip",onChange:g=>n({emptyFields:g?"skip":"keep"}),hint:'Empty cells are dropped from the output instead of becoming "" — a column that is empty in every row disappears from the output and the counts.'}),E.jsx(ho,{label:"NULL as null",checked:e.nullLiterals==="null",onChange:g=>n({nullLiterals:g?"null":"string"}),hint:"The string NULL becomes JSON null. Matching is exact and case-sensitive — SQL exports write uppercase NULL; Null and nULL are untouched, and lowercase null already converts when Parse JSON is on."}),E.jsx(ho,{label:"Transpose",checked:e.transpose,onChange:g=>n({transpose:g}),hint:"Flip rows and columns — the first column becomes the header row."}),E.jsx(ho,{label:"Hash output",checked:e.hash,onChange:g=>n({hash:g}),hint:"The first column becomes the object key instead of a field."}),E.jsx(ho,{label:"Minify",checked:e.minify,onChange:g=>n({minify:g}),hint:"Remove indentation from the JSON output. Data is untouched."})]}):E.jsx(ho,{label:"Flatten nested arrays",checked:e.flatten,onChange:g=>n({flatten:g}),hint:"Explode nested arrays into extra rows with dotted keys — needed when the JSON isn't a flat table."})]});return c?E.jsx("div",{"data-testid":"options-row",className:"flex flex-shrink-0 flex-row items-center gap-5 border-t border-border bg-panel px-5 py-2.5 text-[13px] text-muted-foreground",children:E.jsxs("div",{"data-testid":"options-settings-menu",role:"group","aria-label":"Parse settings",className:"flex flex-1 flex-wrap items-center gap-x-4 gap-y-2.5",children:[p,r?E.jsxs(E.Fragment,{children:[E.jsx("div",{className:"flex-1"}),E.jsx("span",{"data-testid":"options-notice",children:r})]}):null]})}):E.jsxs("div",{"data-testid":"options-row",ref:u,className:"relative flex flex-shrink-0 flex-col border-t border-border bg-panel px-3.5 py-2 text-[13px] text-muted-foreground md:px-4",children:[E.jsxs("div",{className:"flex w-full items-center gap-2",children:[E.jsxs("button",{type:"button",ref:a,"data-testid":"options-settings-toggle","aria-expanded":o,"aria-haspopup":"true",onClick:()=>o?h():l(!0),className:"inline-flex shrink-0 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-md py-0.5 text-[13px] font-medium text-foreground outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:["Parse settings",E.jsx(tN,{"aria-hidden":"true",className:Gn("size-3.5 shrink-0 transition-transform",o&&"rotate-180")})]}),E.jsx("span",{"data-testid":"options-settings-summary",className:"min-w-0 truncate",children:d}),r?E.jsx("span",{"data-testid":"options-notice",className:"ml-auto shrink-0 text-right",children:r}):null]}),E.jsx("div",{"data-testid":"options-settings-menu",role:"group","aria-label":"Parse settings",hidden:!o,className:Gn("absolute bottom-full left-0 z-50 mb-2 w-full items-center gap-x-4 gap-y-2.5 rounded-md border border-border bg-panel p-3 shadow-md",o?"flex flex-wrap":"hidden"),children:p})]})}const UG=[{format:"json",label:"JSON",extension:"json",mime:"application/json"},{format:"jsonl",label:"JSONL",extension:"jsonl",mime:"application/x-ndjson"},{format:"sql",label:"SQL",extension:"sql",mime:"application/sql"},{format:"ts",label:"TS",extension:"ts",mime:"text/typescript"}],KG=new Set(["csv","tsv","txt","json","jsonl","sql","ts"]),XG=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Zd(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Bw(t){if(Array.isArray(t))return t.map(e=>Zd(e)?e:{value:e});if(Zd(t)){const e=Object.entries(t);return e.length===0?[]:e.every(([,n])=>Zd(n))?e.map(([n,r])=>{const i=r;return"key"in i?i:{key:n,...i}}):[t]}return[]}function yR(t){const e=new Set,n=[];for(const r of t)for(const i of Object.keys(r))e.has(i)||(e.add(i),n.push(i));return n}function GG(t){if(!t)return"data";let e=t.trim();const n=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));for(n>=0&&(e=e.slice(n+1));;){const i=e.lastIndexOf(".");if(i<=0)break;if(i===e.length-1){e=e.slice(0,i);continue}const s=e.slice(i+1).toLowerCase();if(!KG.has(s))break;e=e.slice(0,i)}const r=e.replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,"");return r.length>0?r:"data"}function _m(t){return`"${t.replace(/"/g,'""')}"`}function qG(t){const e=t.filter(n=>n!=null);return e.length===0?"TEXT":e.every(n=>typeof n=="boolean")?"BOOLEAN":e.every(n=>typeof n=="number"&&Number.isFinite(n))?e.every(n=>Number.isInteger(n))?"INTEGER":"NUMERIC":"TEXT"}function YG(t){return t==null?"NULL":typeof t=="boolean"?t?"TRUE":"FALSE":typeof t=="number"?Number.isFinite(t)?String(t):"NULL":typeof t=="string"?`'${t.replace(/'/g,"''")}'`:`'${JSON.stringify(t).replace(/'/g,"''")}'`}function JG(t){const e=t.trim();if(e==="")return"";let n;try{n=JSON.parse(e)}catch{return t}return Bw(n).map(i=>JSON.stringify(i)).join(` -`)}function QG(t,e){const n=t.trim();if(n==="")return"";let r;try{r=JSON.parse(n)}catch{return t}const i=Bw(r),s=yR(i),o=_m(GG(e));if(s.length===0)return`CREATE TABLE ${o} ();`;const l=s.map(d=>{const h=i.map(g=>g[d]),p=qG(h);return` ${_m(d)} ${p}`}),a=`CREATE TABLE ${o} ( -${l.join(`, -`)} -);`;if(i.length===0)return a;const u=s.map(_m).join(", "),c=i.map(d=>` (${s.map(p=>YG(d[p])).join(", ")})`),f=`INSERT INTO ${o} (${u}) VALUES -${c.join(`, -`)};`;return`${a} - -${f}`}function vR(t){if(t===null)return"null";if(typeof t=="string")return"string";if(typeof t=="number")return"number";if(typeof t=="boolean")return"boolean";if(Array.isArray(t)){if(t.length===0)return"unknown[]";const e=wR(Array.from(new Set(t.map(n=>vR(n)))));return e.length===1?`${e[0]}[]`:`(${e.join(" | ")})[]`}return Zd(t)?"Record":"unknown"}const GS={string:1,number:2,boolean:3,"Record":4,unknown:90,null:100};function wR(t){return[...t].sort((e,n)=>{const r=GS[e]??50,i=GS[n]??50;return r!==i?r-i:e.localeCompare(n)})}function ZG(t){return XG.test(t)?t:JSON.stringify(t)}function eq(t){const e=t.trim();if(e==="")return"";let n;try{n=JSON.parse(e)}catch{return t}const r=Bw(n),s=yR(r).map(l=>{let a=!1;const u=new Set;for(const h of r){if(!Object.prototype.hasOwnProperty.call(h,l)||h[l]===void 0){a=!0;continue}u.add(vR(h[l]))}const c=wR(Array.from(u)),f=c.length>0?c.join(" | "):"unknown",d=a?"?":"";return` ${ZG(l)}${d}: ${f};`});return`${s.length>0?`export interface DataRow { -${s.join(` -`)} -}`:"export interface DataRow {}"} - -export const data: DataRow[] = ${JSON.stringify(r,null,2)};`}function tq(t,e,n,r){const i=typeof t=="string"?t:t.text,s=typeof n=="string"||n===null?n:r??null;switch(e){case"json":return i;case"jsonl":return JG(i);case"sql":return QG(i,s);case"ts":return eq(i)}}const nq=3;function rq(t){const e=t.slice(0,nq),n=t.length-e.length;return(n>0?[...e,`+${n} more`]:e).join(` -`)}function iq({format:t,inputEmpty:e,outputText:n,error:r,meta:i,staleNotice:s,warnings:o,edited:l,editable:a,egressFormat:u="json",delimiter:c,dark:f,onCopy:d,onCopySelection:h,onProjectedCsvChange:p,onNativeCopy:g,onDownload:b,onEgressFormatChange:m,onOutputChange:v,onRevert:w,onDiscardReconvert:k}){const x=t==="JSON",C=u==="json";return E.jsx("div",{"data-testid":"output-pane","data-surface":"output",className:"flex min-h-0 min-w-0 flex-1 flex-col bg-muted/30",children:E.jsx(fR,{title:t,meta:e?null:l?E.jsxs("span",{className:"flex items-center gap-1.5",children:[E.jsx("span",{"data-testid":"edited-badge",role:"status","aria-label":"Output edited",className:"rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.08em] text-amber-700 dark:bg-amber-400/15 dark:text-amber-400",children:"Edited"}),E.jsxs("button",{type:"button","data-testid":"revert-output",onClick:w,className:bl,children:[E.jsx(yb,{"aria-hidden":"true"}),"Revert"]})]}):s?E.jsx("span",{"data-testid":"stale-notice",className:"text-xs text-amber-600 dark:text-amber-400",children:s}):i,actions:E.jsxs(E.Fragment,{children:[x?E.jsx("span",{"data-testid":"output-format-switcher",role:"group","aria-label":"Output format",className:"inline-flex items-center gap-0.5 rounded-lg border border-border bg-muted/60 p-0.5",children:UG.map(T=>{const A=u===T.format;return E.jsx("button",{type:"button","data-testid":`output-format-option-${T.format}`,"aria-pressed":A,onClick:()=>m==null?void 0:m(T.format),className:Gn("inline-flex cursor-pointer items-center rounded-[7px] px-1.5 py-0.5 font-mono text-[11px] font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50 sm:px-2 sm:py-1",A?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:T.label},T.format)})}):null,E.jsxs("button",{type:"button","data-testid":"copy-output","aria-label":"Copy",title:"Copy",onClick:d,disabled:!n,className:bl,children:[E.jsx(zv,{"aria-hidden":"true"}),E.jsx("span",{className:"hidden xl:inline",children:"Copy"})]}),E.jsxs("button",{type:"button","data-testid":"download-output","aria-label":"Download",title:"Download",onClick:b,disabled:!n,className:bl,children:[E.jsx(xT,{"aria-hidden":"true"}),E.jsx("span",{className:"hidden xl:inline",children:"Download"})]})]}),status:l?{kind:"notice",message:"Output edited — CSV and option changes aren't applied.",action:k?E.jsxs("button",{type:"button","data-testid":"discard-reconvert",onClick:k,className:bl+" ml-2",children:[E.jsx(yb,{"aria-hidden":"true"}),"Discard edits & reconvert"]}):void 0}:r?{kind:"error",message:r}:o&&o.length>0?{kind:"notice",message:rq(o)}:null,children:e?E.jsxs("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:["Your ",t," appears here."]}):n?x?E.jsx("div",{className:"flex min-h-0 flex-1 flex-col",onCopy:()=>g==null?void 0:g(),children:E.jsx(cR,{value:n,editable:a&&C&&n.length<=uR,lintJson:C,onChange:v,dark:f,testId:"output-view"})}):E.jsx(qE,{text:n,delimiter:c,testId:"output-table",dark:f,onCopySelection:h,onProjectedCsvChange:p}):r?E.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"Resolve the error to see output."}):E.jsx("div",{"data-testid":"output-converting-placeholder",className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"Converting…"})})})}function sq({phase:t,message:e,onRetry:n}){return t==="loading"?E.jsx("div",{role:"status","aria-busy":"true","data-testid":"permalink-loading",className:"mx-4 mt-3 rounded-md border border-border bg-muted px-4 py-2 text-sm text-muted-foreground",children:"Loading shared data…"}):t==="not-found"?E.jsxs("div",{role:"alert","data-testid":"permalink-notice",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-2 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[E.jsx("span",{children:"This data doesn't exist (or was deleted)."}),E.jsx("a",{href:"/",className:"font-medium underline underline-offset-2",children:"Go to the converter"})]}):t==="unsupported"?E.jsxs("div",{role:"alert","data-testid":"permalink-unsupported",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-2 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[E.jsx("span",{children:"This link's saved data can't be shown in the new converter."}),E.jsx("a",{href:"/",className:"font-medium underline underline-offset-2",children:"Go to the converter"})]}):E.jsxs("div",{role:"alert","data-testid":"permalink-notice",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-3 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[E.jsx("span",{children:e||"Couldn't load this data."}),E.jsx("button",{type:"button","data-testid":"permalink-retry",onClick:n,className:"rounded-md border border-border bg-background px-2 py-1 text-sm font-medium hover:bg-accent",children:"Retry"})]})}const jw="csvjson:recent.v1",bR=10,xR=1e5,qS=80;function oq(t){return t==="csv2json"||t==="json2csv"}function lq(t){if(!t||typeof t!="object"||Array.isArray(t))return;const e={};for(const[n,r]of Object.entries(t))(r==="string"||r==="number"||r==="boolean"||r==="auto")&&(e[n]=r);return Object.keys(e).length>0?e:void 0}function kR(t){if(typeof t!="object"||t===null)return{...Kr};const e=t,n=e.separator,r=n==="auto"||n===","||n===";"||n===" "||n==="|"?n:Kr.separator,i=e.emptyFields==="keep"||e.emptyFields==="skip"?e.emptyFields:Kr.emptyFields,s=e.nullLiterals==="string"||e.nullLiterals==="null"?e.nullLiterals:Kr.nullLiterals,o=lq(e.columnTypes);return{separator:r,parseNumbers:typeof e.parseNumbers=="boolean"?e.parseNumbers:Kr.parseNumbers,parseJSON:typeof e.parseJSON=="boolean"?e.parseJSON:Kr.parseJSON,emptyFields:i,nullLiterals:s,transpose:typeof e.transpose=="boolean"?e.transpose:Kr.transpose,hash:typeof e.hash=="boolean"?e.hash:Kr.hash,minify:typeof e.minify=="boolean"?e.minify:Kr.minify,flatten:typeof e.flatten=="boolean"?e.flatten:Kr.flatten,collapseIndexedArrays:typeof e.collapseIndexedArrays=="boolean"?e.collapseIndexedArrays:Kr.collapseIndexedArrays,...o?{columnTypes:o}:{}}}function SR(t){const n=(t.split(/\r?\n/).map(r=>r.trim()).find(r=>r.length>0)??"").replace(/\s+/g," ");return n.length<=qS?n:`${n.slice(0,qS-1)}…`}function aq(t){if(typeof t!="object"||t===null)return!1;const e=t;return!(typeof e.id!="string"||e.id.trim()===""||typeof e.createdAt!="number"||!Number.isFinite(e.createdAt)||!oq(e.direction)||typeof e.input!="string"||e.input.trim()===""||e.input.length>xR||e.filename!==null&&typeof e.filename!="string"||typeof e.rows!="number"||!Number.isInteger(e.rows)||e.rows<0||typeof e.cols!="number"||!Number.isInteger(e.cols)||e.cols<0||typeof e.preview!="string")}function uq(t){return{id:t.id,createdAt:t.createdAt,direction:t.direction,input:t.input,options:kR(t.options),filename:t.filename,rows:t.rows,cols:t.cols,preview:t.preview||SR(t.input)}}function CR(t){try{if(typeof window>"u")return;window.localStorage.setItem(jw,JSON.stringify(t))}catch{}}function cq(t){var e;return typeof((e=globalThis.crypto)==null?void 0:e.randomUUID)=="function"?globalThis.crypto.randomUUID():`snap-${t}-${Math.random().toString(36).slice(2,10)}`}function Hw(){try{if(typeof window>"u")return[];const t=window.localStorage.getItem(jw);if(t===null)return[];const e=JSON.parse(t);return Array.isArray(e)?e.filter(aq).map(uq).sort((r,i)=>i.createdAt-r.createdAt).slice(0,bR):[]}catch{return[]}}function YS(t){const e=Hw(),n=t.input.trim();if(n===""||t.input.length>xR||t.rows<=0&&t.cols<=0)return e;const r=t.createdAt??Date.now(),i=e.find(a=>a.direction===t.direction&&a.input.trim()===n),s={id:(i==null?void 0:i.id)??cq(r),createdAt:r,direction:t.direction,input:t.input,options:kR(t.options),filename:t.filename,rows:t.rows,cols:t.cols,preview:SR(t.input)},o=e.filter(a=>!(a.direction===t.direction&&a.input.trim()===n)),l=[s,...o].slice(0,bR);return CR(l),l}function fq(t){const n=Hw().filter(r=>r.id!==t);return CR(n),n}function dq(){try{if(typeof window>"u")return;window.localStorage.removeItem(jw)}catch{}}function hq(t,e=Date.now()){const n=Math.max(0,e-t),r=Math.floor(n/1e3);if(r<45)return"just now";const i=Math.floor(r/60);if(i<60)return`${i}m ago`;const s=Math.floor(i/60);if(s<24)return`${s}h ago`;const o=Math.floor(s/24);return o===1?"yesterday":o<7?`${o}d ago`:new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function pq(t){return t==="csv2json"?"CSV→JSON":"JSON→CSV"}function gq(t,e){return t>0&&e>0?`${t} rows · ${e} cols`:t>0?`${t} rows`:e>0?`${e} cols`:"0 rows"}function mq({snapshots:t,onSelect:e,onRemove:n,onClear:r}){const[i,s]=y.useState(!1),o=y.useRef(null),l=y.useRef(null),a=y.useCallback(()=>{s(!1)},[]),u=y.useRef(!1);y.useEffect(()=>{var f;u.current&&!i&&((f=l.current)==null||f.focus()),u.current=i},[i]),y.useEffect(()=>{if(!i)return;const f=h=>{h.key==="Escape"&&a()},d=h=>{const p=o.current;p===null||!(h.target instanceof Node)||p.contains(h.target)||a()};return document.addEventListener("keydown",f),document.addEventListener("click",d),()=>{document.removeEventListener("keydown",f),document.removeEventListener("click",d)}},[i,a]);const c=t.length;return E.jsxs("div",{"data-testid":"recent-history",ref:o,className:"relative max-sm:static",children:[E.jsxs("button",{type:"button","data-testid":"recent-history-toggle",ref:l,onClick:()=>s(f=>!f),"aria-expanded":i,"aria-haspopup":"dialog","aria-label":"Recent conversions",title:"Recent conversions",className:"relative inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg border border-border bg-panel px-2.5 text-xs font-medium text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[E.jsx(sN,{size:14,strokeWidth:2,"aria-hidden":"true"}),E.jsx("span",{className:"hidden sm:inline",children:"Recent"}),c>0&&E.jsx("span",{"data-testid":"recent-history-count",className:"rounded-full bg-muted px-1.5 py-px text-[10px] font-semibold tabular-nums text-foreground",children:c})]}),i&&E.jsxs("div",{"data-testid":"recent-history-popout",role:"dialog","aria-label":"Recent conversions",className:"absolute right-0 top-9 z-50 w-80 rounded-md border border-border bg-panel shadow-md max-sm:inset-x-2 max-sm:top-14 max-sm:w-auto",children:[E.jsxs("div",{className:"flex items-center justify-between border-b border-border py-1.5 pl-3 pr-1.5",children:[E.jsx("span",{className:"text-xs font-semibold tracking-tight text-foreground",children:"Recent conversions"}),E.jsxs("div",{className:"flex items-center gap-1",children:[c>0&&E.jsx("button",{type:"button","data-testid":"recent-history-clear",onClick:()=>{r()},className:"cursor-pointer rounded-md px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:"Clear history"}),E.jsx("button",{type:"button","data-testid":"recent-history-close",onClick:a,"aria-label":"Close recent conversions",className:"flex size-6 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:E.jsx(Eh,{size:14,strokeWidth:2,"aria-hidden":"true"})})]})]}),c===0?E.jsx("div",{"data-testid":"recent-history-empty",className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No recent conversions saved on this device yet."}):E.jsx("div",{className:"max-h-96 divide-y divide-border overflow-y-auto",children:t.map(f=>E.jsxs("div",{className:"flex items-start justify-between gap-1 px-2 py-2 transition-colors hover:bg-muted/50",children:[E.jsxs("button",{type:"button","data-testid":`recent-history-item-${f.id}`,onClick:()=>{e(f),a()},className:"flex min-w-0 flex-1 cursor-pointer flex-col items-start text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/50 rounded-sm px-1 py-0.5",children:[E.jsxs("div",{className:"mb-1 flex w-full items-center gap-1.5",children:[E.jsx("span",{className:"rounded-full border border-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:pq(f.direction)}),E.jsx("span",{className:"text-[11px] text-muted-foreground",children:gq(f.rows,f.cols)}),E.jsx("span",{className:"ml-auto text-[11px] text-muted-foreground",children:hq(f.createdAt)})]}),E.jsx("span",{className:"w-full truncate font-mono text-xs text-foreground",children:f.filename??f.preview})]}),E.jsx("button",{type:"button","data-testid":`recent-history-delete-${f.id}`,onClick:d=>{d.stopPropagation(),n(f.id)},"aria-label":`Delete recent snapshot ${f.filename??f.preview}`,title:"Delete snapshot",className:"mt-0.5 flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:E.jsx(Th,{size:13,strokeWidth:2,"aria-hidden":"true"})})]},f.id))})]})]})}const Hy=20,Wy=80,JS=50;function Dm(t){return Math.min(Wy,Math.max(Hy,t))}function yq({layout:t,split:e,onSplitChange:n,left:r,right:i,children:s}){const o=y.useRef(null),[l,a]=y.useState(!1),u=t==="stacked";y.useEffect(()=>{if(!l)return;const f=h=>{var b;const p=(b=o.current)==null?void 0:b.getBoundingClientRect();if(!p||p.width===0||p.height===0)return;const g=u?(h.clientY-p.top)/p.height:(h.clientX-p.left)/p.width;n(Dm(g*100))},d=()=>a(!1);return window.addEventListener("pointermove",f),window.addEventListener("pointerup",d),window.addEventListener("pointercancel",d),()=>{window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",d)}},[l,u,n]);const c=f=>{const d=f.shiftKey?5:1;switch(f.key){case"ArrowLeft":case"ArrowUp":f.preventDefault(),n(Dm(e-d));break;case"ArrowRight":case"ArrowDown":f.preventDefault(),n(Dm(e+d));break;case"Home":f.preventDefault(),n(Hy);break;case"End":f.preventDefault(),n(Wy);break;case"Enter":case" ":f.preventDefault(),n(JS);break}};return E.jsxs("div",{ref:o,className:Gn("relative flex min-h-0 flex-1","flex-col md:flex-row",l&&"select-none"),children:[E.jsx("div",{"data-testid":"pane-left",style:{"--split":`${e}%`},className:Gn("flex min-h-0 min-w-0 flex-col overflow-hidden border-border bg-panel max-md:min-h-[280px] max-md:max-h-[360px]","h-[var(--split)] border-b","md:h-auto md:w-[var(--split)] md:border-b-0 md:border-r"),children:r}),E.jsxs("div",{"data-testid":"seam",role:"separator",tabIndex:0,"aria-orientation":u?"horizontal":"vertical","aria-valuenow":Math.round(e),"aria-valuemin":Hy,"aria-valuemax":Wy,"aria-label":"Resize panes",title:"Drag to resize · double-click to reset",onPointerDown:f=>{var d,h;f.target instanceof Element&&f.target.closest("button")||(f.preventDefault(),(h=(d=f.currentTarget).setPointerCapture)==null||h.call(d,f.pointerId),a(!0))},onPointerUp:()=>a(!1),onDoubleClick:()=>n(JS),onKeyDown:c,style:{"--split":`${e}%`,touchAction:"none"},className:Gn("relative z-10 flex h-9 flex-shrink-0 items-center justify-center border-b border-border bg-muted/20 cursor-row-resize","md:absolute md:top-0 md:right-auto md:bottom-0 md:left-[var(--split)] md:h-auto md:w-0 md:border-b-0 md:bg-transparent md:cursor-col-resize"),children:[E.jsx("div",{className:Gn("absolute","inset-0","md:inset-auto md:top-0 md:right-auto md:bottom-0 md:-left-1.5 md:h-auto md:w-3")}),s?E.jsx("div",{className:"relative z-10 md:absolute md:left-1/2 md:top-1/2 md:-translate-x-1/2 md:-translate-y-1/2",children:s}):null]}),E.jsx("div",{"data-testid":"pane-right",className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-panel max-md:min-h-[240px] max-md:max-h-[340px]",children:i})]})}function vq({theme:t}){return t==="dark"?E.jsx(SN,{size:15,strokeWidth:2,"aria-hidden":"true"}):E.jsx(dN,{size:15,strokeWidth:2,"aria-hidden":"true"})}function wq({theme:t,onToggleTheme:e,slot:n}){return E.jsxs("header",{"data-testid":"topbar",className:"relative flex h-14 flex-shrink-0 items-center gap-3 border-b border-border bg-panel px-5",children:[E.jsxs("div",{className:"flex items-baseline gap-2",children:[E.jsx("span",{className:"text-[15px] font-semibold tracking-tight text-foreground whitespace-nowrap",children:"csvjson"}),E.jsx("span",{className:"hidden text-[13px] font-medium text-muted-foreground sm:inline",children:"CSV → JSON converter"})]}),E.jsx("div",{className:"flex-1"}),E.jsx("div",{"data-testid":"topbar-slot",children:n}),E.jsx("button",{type:"button","data-testid":"theme-toggle",onClick:e,"aria-label":t==="dark"?"Switch to light mode":"Switch to dark mode",title:t==="dark"?"Switch to light mode":"Switch to dark mode",className:"inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border bg-panel text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:E.jsx(vq,{theme:t})})]})}function bq(t){return[...t].sort((e,n)=>n.id-e.id)}const TR=[{id:22,date:"2026-10-20",tag:"new",title:"Column visibility picker and Apply view to output",summary:"Use the new Columns menu in any data table to hide or restore columns without touching your raw input. When a search filter, sort order, or column subset is active, toggle Apply view to output to project that exact table view into the converted output, Copy, and Download."},{id:21,date:"2026-10-20",tag:"new",title:"Paste Markdown & CLI box tables directly into CSV → JSON",summary:"Paste GitHub/ChatGPT Markdown pipe tables or psql/MySQL ASCII box tables directly into CSV → JSON: divider rows, outer pipes, and (N rows) footers are stripped automatically, with a one-click Clean table action to normalize the raw CSV in place."},{id:20,date:"2026-10-20",tag:"new",title:"One-click nested JSON flattening in JSON → CSV",summary:"When JSON → CSV input contains nested objects or arrays, a contextual Flatten nested keys pill appears above the editor to expand deep objects into dotted CSV column headers (like user.profile.name) and join scalar arrays in one click."},{id:19,date:"2026-10-20",tag:"new",title:"Pin per-column types in the CSV grid",summary:"Select any column in the CSV table to pin its JSON output type to String, Number, Boolean, or Auto — keeping postal codes and IDs as strings or coercing yes/no/1/0 columns to booleans without changing global parse settings."},{id:18,date:"2026-10-20",tag:"new",title:"Live spreadsheet selection aggregates in the table toolbar",summary:"Select any range of cells, rows, or columns in the data table to see instant cell, distinct, and empty counts alongside numeric Sum, Avg, Min, and Max aggregates. Range selections also expose one-click Copy as CSV right from the toolbar."},{id:17,date:"2026-10-20",tag:"new",title:"Export CSV as JSONL, SQL INSERTs, or TypeScript",summary:"Switch the CSV → JSON output header between JSON, JSONL, SQL, and TS to generate newline-delimited records, CREATE TABLE and INSERT statements with inferred types, or a typed TypeScript DataRow interface and array ready to copy or download."},{id:16,date:"2026-10-20",tag:"new",title:"Restore recent conversions from the top bar",summary:"The new Recent menu in the top bar saves up to 10 valid conversions locally on your device so you can jump back to an earlier dataset in one click. Fresh page loads still start on a clean empty dropzone."},{id:15,date:"2026-10-18",tag:"improvement",title:"Options fold into a Parse settings menu",summary:"On narrower screens the converter's options bar no longer wraps onto extra lines — it collapses to a single Parse settings line showing your active options, with the full control set in a drop-up above it. Small screens lose the accordion that squeezed the panes."},{id:14,date:"2026-10-17",tag:"improvement",title:"Polished mobile stacked panes and collapsible options bar",summary:"Small screens now stack the input and output panes with an in-flow direction switch and compact icon actions so nothing overlaps. The options bar collapses into a one-tap summary on phones while keeping every setting a tap away."},{id:13,date:"2026-10-15",tag:"fix",title:"Faster large CSV uploads without page freezes",summary:"Uploading large CSV files now converts in a single pass without freezing the tab or flashing a false error state, previews multi-megabyte JSON outputs smoothly while keeping full Copy and Download, and decodes UTF-16 CSV exports automatically."},{id:12,date:"2026-10-15",tag:"improvement",title:"Table undo, header rename, and smarter JSON input",summary:"Undo or redo CSV table edits, double-click any column header to rename it in place, and collapse .0, .1 indexed columns into JSON arrays. JSON → CSV now formats or minifies JSON in one click, unwraps nested record arrays, parses JSONL, and previews pipe-delimited output accurately."},{id:11,date:"2026-10-03",tag:"improvement",title:"The switch names the direction",summary:"The ⇄ switch now labels the active conversion, and legacy /json2csv links land you in JSON → CSV mode again — it never left."},{id:10,date:"2026-09-08",tag:"new",title:"Delete rows and columns from the table",summary:"Select rows or columns in the input table and delete them by button or the Delete key — the raw CSV updates and reconverts in place, with at least one column always kept. Selected column headers are also readable again in both themes."},{id:9,date:"2026-09-08",tag:"new",title:"Spreadsheet-grade data table",summary:"The rebuilt data table adds drag-to-select ranges, Shift+Arrow range extension, fill, and spreadsheet-style cell editing — with copy/paste always producing clean CSV."},{id:8,date:"2026-09-07",tag:"new",title:"Search, sort, and select in the data table",summary:"The CSV table now has a search bar with a live row count, click-to-sort columns, and row selection with copy-as-CSV — on both the input and output tables."},{id:7,date:"2026-09-07",tag:"fix",title:"No more layout flash on load",summary:"The converter now renders side-by-side immediately on desktop, instead of stacking the panes and snapping into columns as the page loads."},{id:6,date:"2026-09-07",tag:"new",title:"Introducing the changelog",summary:"This changelog keeps you posted on what's new — recent updates appear here with an unseen dot when you come back. Feel free to vote on what you find useful."},{id:5,date:"2026-09-05",tag:"improvement",title:"Icons match the design",summary:"Action buttons, view toggle, and the empty state now use the same crisp icon set as the rest of the interface."},{id:4,date:"2026-09-05",tag:"new",title:"Edit the JSON output in place",summary:"The output pane is now an editor. Hand edits survive until you reconvert; revert and discard keep you safe."},{id:3,date:"2026-09-05",tag:"fix",title:"Pastes land where they belong",summary:"Paste anywhere on the page and your data routes to the input — including pastes over the read-only output pane."},{id:2,date:"2026-09-04",tag:"improvement",title:"A calmer empty state",summary:"Empty panes now open on a compact paste field with a Choose file button, so starting is obvious on any screen."},{id:1,date:"2026-09-04",tag:"improvement",title:"Smarter number handling",summary:"Numbers convert sensibly out of the box: leading-zero values like 00721 and very long IDs stay strings so nothing gets silently mangled."}],xq=864e5;function QS(t){return Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())}function kq(t,e=Date.now()){const n=new Date(`${t}T00:00:00Z`),r=new Date(e),i=Math.round((QS(r)-QS(n))/xq);if(i<=0)return"today";if(i===1)return"yesterday";if(i<7)return`${i} days ago`;const s=n.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:"UTC"});return n.getUTCFullYear()===r.getUTCFullYear()?s:`${s}, ${n.getUTCFullYear()}`}const ER="csvjson:changelog.v1",eh=Math.max(...TR.map(t=>t.id),0),Sq=bq(TR);function Cq(t){if(typeof t!="object"||t===null)return!1;const e=t;if(e.lastSeenId!==null&&typeof e.lastSeenId!="number"||typeof e.votes!="object"||e.votes===null)return!1;for(const[n,r]of Object.entries(e.votes))if(!/^\d+$/.test(n)||r!==1&&r!==-1)return!1;return!(e.clientId!==void 0&&!Tq(e.clientId)||e.pendingIds!==void 0&&(!Array.isArray(e.pendingIds)||e.pendingIds.some(n=>typeof n!="number"||!Number.isInteger(n)||n<1)))}function Tq(t){return typeof t=="string"&&/^[0-9a-fA-F-]{8,64}$/.test(t)}function AR(t){return t===void 0?[]:[...new Set(t)].filter(e=>e>=1&&e<=eh).sort((e,n)=>e-n)}function ZS(t,e,n){const r=AR(t.pendingIds),i=n?[...new Set([...r,e])].sort((s,o)=>s-o):r.filter(s=>s!==e);return{...t,pendingIds:i}}function Eq(){try{const t=window.localStorage.getItem(ER);if(t===null)return{lastSeenId:null,votes:{}};const e=JSON.parse(t);return Cq(e)?{...e,pendingIds:AR(e.pendingIds)}:{lastSeenId:null,votes:{}}}catch{return{lastSeenId:null,votes:{}}}}function Aq(t){try{window.localStorage.setItem(ER,JSON.stringify(t))}catch{}}function Mq(){var n,r,i;if(typeof((n=globalThis.crypto)==null?void 0:n.randomUUID)=="function")return globalThis.crypto.randomUUID();const t=(i=(r=globalThis.crypto)==null?void 0:r.getRandomValues)==null?void 0:i.call(r,new Uint8Array(16));if(t===void 0)throw new Error("no secure randomness available");t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=Array.from(t,s=>s.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}async function Rq(t,e,n){try{return(await fetch("/api/changelog-vote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:t,entryId:e,vote:n})})).ok?"ok":"failed"}catch{return"failed"}}function eC(t){return["flex h-6 w-7 cursor-pointer items-center justify-center rounded-md transition-colors",t?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"].join(" ")}function Oq({entry:t,vote:e,queued:n,inFlight:r,onVote:i}){return E.jsxs("article",{className:"px-3 py-2.5","data-testid":`changelog-entry-${t.id}`,children:[E.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[t.tag!==void 0&&E.jsx("span",{className:"rounded-full border border-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:t.tag}),E.jsx("span",{className:"text-[11px] text-muted-foreground",children:kq(t.date)})]}),E.jsx("h3",{className:"text-xs font-semibold text-foreground",children:t.title}),E.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:t.summary}),E.jsxs("div",{className:"mt-1.5 flex gap-1",children:[E.jsx("button",{type:"button","data-testid":`changelog-up-${t.id}`,onClick:()=>i(t.id,1),"aria-pressed":e===1,"aria-label":`Upvote: ${t.title}`,title:"Good change",className:eC(e===1),children:E.jsx(RN,{size:13,strokeWidth:2,"aria-hidden":"true"})}),E.jsx("button",{type:"button","data-testid":`changelog-down-${t.id}`,onClick:()=>i(t.id,-1),"aria-pressed":e===-1,"aria-label":`Downvote: ${t.title}`,title:"Not for me",className:eC(e===-1),children:E.jsx(AN,{size:13,strokeWidth:2,"aria-hidden":"true"})})]}),n&&!r&&E.jsx("p",{"data-testid":`changelog-queued-${t.id}`,role:"status",className:"mt-1.5 rounded-sm border border-dashed border-border px-2 py-1 text-[11px] text-muted-foreground",children:"Vote queued — it will retry on your next interaction."})]})}function Pq(){const[t,e]=y.useState(Eq),[n,r]=y.useState(!1),i=y.useRef(t),s=y.useCallback(x=>{Aq(x),i.current=x,e(x)},[]),[o,l]=y.useState(()=>new Set),a=y.useRef(new Set),u=y.useRef(null),c=y.useRef(null),f=y.useRef(new Map),d=t.lastSeenId!==null&&eh>t.lastSeenId,h=y.useCallback((x,C)=>{l(T=>{const A=new Set(T);return C?A.add(x):A.delete(x),A})},[]),p=y.useCallback((x,C,T,A)=>{const R=(f.current.get(x)??0)+1;f.current.set(x,R),a.current.add(x),A&&h(x,!0),Rq(T,x,C).then(P=>{f.current.get(x)===R&&(a.current.delete(x),P==="ok"&&(LI({entry_id:x,vote:C}),s(ZS(i.current,x,!1))),A&&h(x,!1))})},[s,h]),g=y.useCallback(x=>{const{clientId:C,pendingIds:T,votes:A}=i.current,R=T??[];if(R.length!==0&&C!==void 0)for(const P of R){if(P===x||a.current.has(P))continue;const _=A[P];_!==void 0&&p(P,_,C,!1)}},[p]),b=(x,C)=>{if(t.votes[x]===C){g();return}const T=t.clientId??Mq();s(ZS({...t,votes:{...t.votes,[x]:C},clientId:T},x,!0)),p(x,C,T,!0),g(x)},m=()=>{r(!0),DI(),t.lastSeenId!==eh&&s({...t,lastSeenId:eh}),g()},v=y.useCallback(()=>{r(!1)},[]),w=y.useRef(!1);y.useEffect(()=>{var x;w.current&&!n&&((x=c.current)==null||x.focus()),w.current=n},[n]);const k=y.useRef(!1);return y.useEffect(()=>{k.current||(k.current=!0,g())},[g]),y.useEffect(()=>{if(!n)return;const x=T=>{T.key==="Escape"&&v()},C=T=>{const A=u.current;A===null||!(T.target instanceof Node)||A.contains(T.target)||v()};return document.addEventListener("keydown",x),document.addEventListener("click",C),()=>{document.removeEventListener("keydown",x),document.removeEventListener("click",C)}},[n,v]),E.jsxs("div",{"data-testid":"changelog",ref:u,className:"relative max-sm:static",children:[E.jsxs("button",{type:"button","data-testid":"changelog-toggle",ref:c,onClick:()=>n?v():m(),"aria-expanded":n,"aria-haspopup":"dialog","aria-label":"Changelog",title:"What's new",className:"relative inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border bg-panel text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[E.jsx(mN,{size:15,strokeWidth:2,"aria-hidden":"true"}),d&&E.jsx("span",{"data-testid":"changelog-dot","aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-foreground"})]}),n&&E.jsxs("div",{"data-testid":"changelog-popout",role:"dialog","aria-label":"Changelog",className:"absolute right-0 top-9 z-50 w-80 rounded-md border border-border bg-panel shadow-md max-sm:inset-x-2 max-sm:top-14 max-sm:w-auto",children:[E.jsxs("div",{className:"flex items-center justify-between border-b border-border py-1.5 pl-3 pr-1.5",children:[E.jsx("span",{className:"text-xs font-semibold tracking-tight text-foreground",children:"What's new"}),E.jsx("button",{type:"button","data-testid":"changelog-close",onClick:v,"aria-label":"Close changelog",className:"flex size-6 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:E.jsx(Eh,{size:14,strokeWidth:2,"aria-hidden":"true"})})]}),E.jsx("div",{className:"max-h-96 divide-y divide-border overflow-y-auto",children:Sq.map(x=>{var C;return E.jsx(Oq,{entry:x,vote:t.votes[x.id],queued:((C=t.pendingIds)==null?void 0:C.includes(x.id))??!1,inFlight:o.has(x.id),onVote:b},x.id)})})]})]})}function Iq(t,e){const[n,r]=y.useState(t);return y.useEffect(()=>{const i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}const Nq={},_q=["csv2json","json2csv","json_validator","json_beautifier","sql2json","csvjson2json","datajanitor"],Dq=["csv2json","json2csv","csvjson2json"];function Lq(t){return Dq.includes(t)}const $q=/^[0-9a-f]{32}$/i,Fq=/^\/([a-z0-9_]+)\/([0-9a-f]{32})\/?$/i,Lm=Nq,zq=((Lm==null?void 0:Lm.VITE_S3_DATA_URL)??"https://csvjson.s3.us-east-2.amazonaws.com/data/").replace(/\/*$/,"/");function Bq(t){const e=Fq.exec(t);if(!e)return null;const n=e[1].toLowerCase();return _q.includes(n)?{tool:n,id:e[2].toLowerCase()}:null}class Vy extends Error{constructor(){super("This data doesn't exist (or was deleted)"),this.name="PermalinkNotFoundError"}}class $m extends Error{constructor(e,n){super(e,n),this.name="PermalinkFetchError"}}const Fm={csv:(t,e)=>{t.direction="csv2json",t.input=ap(e)},json:(t,e)=>{t.input=ap(e),t.direction="json2csv"},parseNumbers:(t,e)=>{const n=ra(e);n!==void 0&&(t.options.parseNumbers=n)},parseJSON:(t,e)=>{const n=ra(e);n!==void 0&&(t.options.parseJSON=n)},transpose:(t,e)=>{const n=ra(e);n!==void 0&&(t.options.transpose=n)},"output-array":(t,e)=>{const n=ra(e);n!==void 0&&(t.options.hash=!n)},"output-hash":(t,e)=>{const n=ra(e);n!==void 0&&(t.options.hash=n)},flatten:(t,e)=>{const n=ra(e);n!==void 0&&(t.options.flatten=n)},output_csvjson_variant:()=>{}};function ap(t){return typeof t=="string"?t:typeof t=="number"?String(t):""}function tC(t){return typeof t=="string"&&t.trim()!==""}function ra(t){if(t===!0||t==="true")return!0;if(t===!1||t==="false")return!1}function jq(t){return t===null||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(e=>typeof e=="string"||typeof e=="boolean")}function Hq(t){var i;if(!jq(t))return null;const e=tC(t.csv),n=tC(t.json);if(!e&&!n)return null;const r={direction:e?"csv2json":"json2csv",input:"",options:{}};for(const[s,o]of Object.entries(t))(i=Fm[s])==null||i.call(Fm,r,o);return r.input=ap(e?t.csv:t.json),r}async function Wq(t){if(!$q.test(t))throw new Vy;let e;try{e=await fetch(`${zq}${t}`,{mode:"cors"})}catch(r){throw new $m("Network error while loading this data",{cause:r})}if(e.status===403||e.status===404)throw new Vy;if(!e.ok)throw new $m(`Unexpected response while loading this data (HTTP ${e.status})`);let n;try{const r=await e.text();if(r.trim()==="")throw new Error("empty body");n=JSON.parse(r)}catch{throw new $m("Stored data for this link is malformed")}return n}function Vq(t){const e=y.useMemo(()=>t&&Lq(t.tool)?t.id:null,[t]),[n,r]=y.useState(0),[i,s]=y.useState(e?"loading":"idle"),[o,l]=y.useState(null),[a,u]=y.useState("");return y.useEffect(()=>{if(!e)return;let c=!1;return Wq(e).then(f=>{if(c)return;const d=Hq(f);d?(l(d),s("hydrated")):s("unsupported")}).catch(f=>{c||(f instanceof Vy?s("not-found"):(u(f instanceof Error?f.message:"Couldn't load this data"),s("error")))}),()=>{c=!0}},[e,n]),{phase:i,hydrated:o,message:a,retry:()=>{i==="error"&&(s("loading"),r(c=>c+1))}}}async function nC(t){try{if(typeof navigator<"u"&&navigator.clipboard)return await navigator.clipboard.writeText(t),!0}catch{}try{const e=document.createElement("textarea");e.value=t,e.setAttribute("readonly",""),e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select();const n=document.execCommand("copy");return e.remove(),n}catch{return!1}}const Uq="\uFEFF";function Kq(t,e){return e?Uq+t:t}function Xq(t,e,n){const r=Kq(t,n);return new Blob([r],{type:`${e};charset=utf-8`})}const Gq=new Set(["csv","tsv","json","jsonl","sql","ts","txt"]);function qq(t){let e=t;for(;;){const n=e.lastIndexOf(".");if(n<=0)break;if(n===e.length-1){e=e.slice(0,n);continue}if(!Gq.has(e.slice(n+1).toLowerCase()))break;e=e.slice(0,n)}return e}function Yq(t,e,n="json"){const r=e==="csv2json"?n:"csv";return t?`${qq(t)}.${r}`:`data.${r}`}function Jq(t,e="json"){if(t==="json2csv")return"text/csv";switch(e){case"json":return"application/json";case"jsonl":return"application/x-ndjson";case"sql":return"application/sql";case"ts":return"text/typescript"}}function rC(t,e,{mime:n="text/plain",bom:r=!1}={}){const i=Xq(t,n,r),s=URL.createObjectURL(i),o=document.createElement("a");return o.href=s,o.download=e,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(s),0),e}function Qq(t){if(!(t instanceof HTMLElement))return!1;if(t.isContentEditable)return!0;const e=t.tagName;return e==="INPUT"||e==="TEXTAREA"?!0:t.closest('[contenteditable="true"]')!==null}const Zq=`album,year,US_peak_chart_post -The White Stripes,1999, -De Stijl,2000, -White Blood Cells,2001,61 -Elephant,2003,6 -Get Behind Me Satan,2005,3 -Icky Thump,2007,2`,eY=`[ - { - "album": "Elephant", - "year": 2003, - "label": "XL Recordings" - }, - { - "album": "Icky Thump", - "year": 2007, - "label": "XL Recordings" - } -]`,MR="csvjson-theme";function tY(){try{const t=localStorage.getItem(MR);return t==="dark"||t==="light"?t:null}catch{return null}}function nY(){try{if(typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}catch{}return"light"}function rY(){return tY()??nY()}function iY(t){try{localStorage.setItem(MR,t)}catch{}}function sY(t){return new URLSearchParams(t).get("direction")==="json2csv"?"json2csv":"csv2json"}const iC=2*1024*1024,oY=150,lY=1e3,aY=2e3,uY=2e3;function cY(t,e){return t===0?null:e>0?`${t} rows · ${e} cols`:`${t} rows`}function sC(t){try{return JSON.parse(t),!0}catch{return!1}}function fY(){var Bt;const[t,e]=y.useState(rY);y.useEffect(()=>{document.documentElement.classList.toggle("dark",t==="dark")},[t]);const n=()=>e(J=>{const Me=J==="dark"?"light":"dark";return iY(Me),Me}),[r,i]=y.useState(()=>typeof window>"u"?"csv2json":sY(window.location.search)),[s,o]=y.useState(()=>il("")),l=s.present,[a,u]=y.useState(Kr),[c,f]=y.useState("json"),[d,h]=y.useState(50),[p,g]=y.useState(null),[b,m]=y.useState(!1),[v,w]=y.useState(null),[k,x]=y.useState("utf-8"),[C,T]=y.useState(Hw),[A,R]=y.useState(null),[P,_]=y.useState(null),O=y.useRef({direction:r,options:a,input:l,resultOk:!0}),D=y.useRef(null);D.current||(D.current=VI({settleMs:aY,minWindowMs:uY,isValid:(J,Me)=>{const ze=O.current;return Me===ze.input?ze.resultOk:fo(J==="csv_to_json"?"csv2json":"json2csv",Me,ze.options).ok}}));const N=D.current;y.useEffect(()=>()=>N.cancel(),[N]);const ie=gR("(min-width: 48rem)")?"side-by-side":"stacked",V=r==="csv2json",j=V?"CSV":"JSON",G=V?"JSON":"CSV",M=l.trim()==="",I=l.length>iC?lY:oY,$=Iq(l,M?0:I),B=y.useRef(null),Y=y.useRef(null),de=l!==""&&((Bt=B.current)==null?void 0:Bt.text)===l?l:$,le=V&&A!==null&&de.trim()!==""?A:de,ge=y.useMemo(()=>typeof window>"u"?null:Bq(window.location.pathname),[]),$e=Vq(ge),ke=y.useMemo(()=>fo(r,le,a),[r,le,a]);O.current={direction:r,options:a,input:de,resultOk:ke.ok},y.useEffect(()=>{const J=Y.current;!J||J.text!==de||(Y.current=null,N.discrete(J.direction,J.via,J.text))},[de,ke,N]);const[ye,lt]=y.useState(null);y.useEffect(()=>{de.trim()!==""&&ke.ok&<(ke.text)},[ke,de]),y.useEffect(()=>{de.trim()!==""&&(!ke.ok||ke.rows<=0&&ke.cols<=0||T(YS({direction:r,input:de,options:a,filename:p,rows:ke.rows,cols:ke.cols})))},[r,de,p,a,ke]);const Fe=de.trim()!==""&&ke.ok?ke.text:ye,[He,be]=y.useState(!1),[Rt,me]=y.useState(null),Se=He?Rt:Fe,Pe=y.useMemo(()=>{if(!V||Se===null||c==="json")return Se;const J=He&&Rt!==null&&sC(Rt)?Rt:Fe;return J===null?null:tq(J,c,a,p)},[V,Se,c,He,Rt,Fe,a,p]),Xe=V&&c==="json"&&!M&&Pe!==null&&(He||ke.ok),rt=y.useCallback(J=>{if(J===Fe){be(!1),me(null);return}be(!0),me(J)},[Fe]),_e=y.useCallback(()=>{const J=V&&A!==null&&l.trim()!==""?A:l,Me=fo(r,J,a);Me.ok&<(Me.text),be(!1),me(null)},[V,r,l,a,A]),yt=y.useCallback(J=>{o(Me=>V?nk(Me,J):il(J))},[V]),We=V&&s.past.length>0,it=V&&s.future.length>0,pe=y.useCallback(()=>{if(!V||s.past.length===0)return;const J=F9(s);w(null),o(J),N.edit("csv_to_json",J.present)},[V,s,N]),at=y.useCallback(()=>{if(!V||s.future.length===0)return;const J=z9(s);w(null),o(J),N.edit("csv_to_json",J.present)},[V,s,N]),dt=y.useCallback(J=>{w(null),B.current=null,i(J.direction),u({...J.options}),g(J.filename),be(!1),me(null),o(Me=>J.direction==="csv2json"&&r==="csv2json"?nk(Me,J.input):il(J.input)),T(YS({direction:J.direction,input:J.input,options:J.options,filename:J.filename,rows:J.rows,cols:J.cols}))},[r]),Ge=y.useCallback(J=>{T(fq(J))},[]),on=y.useCallback(()=>{dq(),T([])},[]),vt=()=>{const J=r==="csv2json"?"json2csv":"csv2json";if(He){const Me=Rt??"",ze=sC(Me)?Me:l;o(il(ze)),i(J),be(!1),me(null),ze.trim()!==""&&(O.current={direction:J,options:a,input:ze,resultOk:fo(J,ze,a).ok},N.discrete(J==="csv2json"?"csv_to_json":"json_to_csv","flip",ze));return}if(i(J),M)o(il(""));else{const Me=fo(r,l,a),ze=Me.ok?Me.text:l;o(il(ze)),ze.trim()!==""&&(O.current={direction:J,options:a,input:ze,resultOk:fo(J,ze,a).ok},N.discrete(J==="csv2json"?"csv_to_json":"json_to_csv","flip",ze))}},Be=$e.hydrated;y.useEffect(()=>{if(Be===null)return;const J={...O.current.options,...Be.options};O.current={direction:Be.direction,options:J,input:Be.input,resultOk:fo(Be.direction,Be.input,J).ok},i(Be.direction),o(il(Be.input)),u(Me=>({...Me,...Be.options})),be(!1),me(null),_I(),N.discrete(Be.direction==="csv2json"?"csv_to_json":"json_to_csv","permalink",Be.input)},[Be,N]);const ht=async(J,Me)=>{if(!jG(J)){w(`Can't read "${J.name}" as text — drop a ${V?".csv / .tsv":".json"} file.`);return}w(null),m(!0);try{const ze=await WS(J,k);B.current={file:J,source:Me,text:ze},Y.current={direction:V?"csv_to_json":"json_to_csv",via:Me==="drop"?"drag":"file",text:ze},yt(ze),g(J.name),m(!1)}catch{m(!1),w(`Couldn't read "${J.name}".`)}},Gt=async J=>{const Me=k;x(J);const ze=B.current;if(!(!ze||l!==ze.text)){m(!0);try{const It=await WS(ze.file,J);B.current={...ze,text:It},Y.current={direction:V?"csv_to_json":"json_to_csv",via:ze.source==="drop"?"drag":"file",text:It},o(Yt=>({...Yt,present:It})),m(!1)}catch{m(!1),x(Me),w(`Couldn't read "${ze.file.name}".`)}}},Zt=y.useCallback(J=>{w(null),J.trim()===""&&u(Me=>{if(!Me.columnTypes)return Me;const ze={...Me};return delete ze.columnTypes,ze}),yt(J),N.edit(V?"csv_to_json":"json_to_csv",J)},[yt,V,N]);y.useEffect(()=>{const J=Me=>{var It;const ze=(It=Me.clipboardData)==null?void 0:It.getData("text/plain");!ze||Qq(Me.target)||(Me.preventDefault(),Me.stopPropagation(),g(null),Zt(ze))};return document.addEventListener("paste",J,!0),()=>document.removeEventListener("paste",J,!0)},[Zt]);const Bn=ke.ok?cY(ke.rows,ke.cols):null,Yn=!ke.ok&&ye?"Last valid result — input has errors":null,Ht=ke.ok&&ke.warnings&&ke.warnings.length>0?ke.warnings:null,jn=l.length>iC,zt=V?"csv_to_json":"json_to_csv",Ln=V?c:"csv",Br=()=>{tl({via:"copy",format:V?"csv":"json",pane:"input",direction:zt}),nC(l)},$t=!V&&P!==null?P:Pe,et=()=>{tl({via:"copy",format:Ln,pane:"output",direction:zt}),$t&&nC($t)},ft=()=>{tl({via:"download",format:V?"csv":"json",pane:"input",direction:zt}),rC(l,p??(V?"data.csv":"data.json"),{mime:V?"text/csv":"application/json",bom:V})},Wt=()=>{tl({via:"download",format:Ln,pane:"output",direction:zt}),rC($t??"",Yq(p,V?"csv2json":"json2csv",c),{mime:Jq(V?"csv2json":"json2csv",c),bom:!V})},qt=y.useCallback(()=>{tl({via:"copy",format:"csv",pane:"input",direction:zt})},[zt]),ln=y.useCallback(()=>{tl({via:"copy",format:"csv",pane:"output",direction:zt})},[zt]),kn=y.useCallback(()=>{tl({via:"copy",format:Ln,pane:"output",direction:zt})},[Ln,zt]),Jn=E.jsx(zG,{format:j,input:l,onInputChange:Zt,onCellCommit:Zt,onFile:ht,onTryExample:()=>{w(null);const J=V?Zq:eY;O.current={direction:r,options:a,input:J,resultOk:fo(r,J,a).ok},yt(J),N.discrete(zt,"example",J)},onClear:()=>{yt(""),g(null),u(J=>{if(!J.columnTypes)return J;const Me={...J};return delete Me.columnTypes,Me}),be(!1),me(null),N.cancel()},onCopy:Br,onCopySelection:qt,onProjectedCsvChange:R,onDownload:ft,canUndo:We,canRedo:it,onUndo:pe,onRedo:at,collapseIndexedArrays:a.collapseIndexedArrays??!0,onToggleCollapseIndexedArrays:()=>u(J=>({...J,collapseIndexedArrays:!(J.collapseIndexedArrays??!0)})),columnTypes:a.columnTypes??{},onChangeColumnTypes:J=>u(Me=>{const ze={...Me};return Object.keys(J).length>0?ze.columnTypes=J:delete ze.columnTypes,ze}),flatten:a.flatten,onToggleFlatten:()=>u(J=>({...J,flatten:!J.flatten})),filename:p,reading:b,meta:Bn,error:null,notice:v,delimiter:a.separator==="auto"?void 0:a.separator,dark:t==="dark"}),gt=E.jsx(iq,{format:G,inputEmpty:M,outputText:Pe,error:ke.ok?null:ke.error,meta:Bn,staleNotice:Yn,warnings:Ht,edited:He,editable:Xe,egressFormat:c,delimiter:a.separator==="auto"?void 0:a.separator,dark:t==="dark",onCopy:et,onCopySelection:ln,onProjectedCsvChange:_,onNativeCopy:kn,onDownload:Wt,onEgressFormatChange:f,onOutputChange:rt,onRevert:_e,onDiscardReconvert:_e});return E.jsxs("div",{className:"flex min-h-svh flex-col bg-background text-foreground",children:[E.jsx("h1",{className:"sr-only",children:"CSV to JSON and JSON to CSV converter"}),E.jsxs("div",{className:"flex min-h-svh flex-col md:h-svh md:min-h-0",children:[E.jsx(v_,{}),E.jsx(wq,{theme:t,onToggleTheme:n,slot:E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx(mq,{snapshots:C,onSelect:dt,onRemove:Ge,onClear:on}),E.jsx(Pq,{}),E.jsx(S_,{})]})}),ge&&($e.phase==="loading"||$e.phase==="not-found"||$e.phase==="unsupported"||$e.phase==="error")?E.jsx(sq,{phase:$e.phase,message:$e.phase==="error"?$e.message:void 0,onRetry:$e.retry}):null,E.jsx(yq,{layout:ie,split:d,onSplitChange:h,left:Jn,right:gt,children:E.jsx(p_,{direction:r,onFlip:vt})}),E.jsx(VG,{direction:r,options:a,onChange:J=>u(Me=>({...Me,...J})),uploadEncoding:k,onUploadEncodingChange:Gt,notice:jn?"Large file — converting on pause":null})]}),E.jsx(m_,{})]})}vT(document.getElementById("root")).render(E.jsx(y.StrictMode,{children:E.jsx(fY,{})}));document.getElementById("root").removeAttribute("inert");II();NI();export{d6 as C,Vn as R,$4 as T,wa as a,u$ as b,OI as c,ia as i,L4 as m,y as r,ii as s}; diff --git a/app/dist/assets/index-CqiPq7HB.js b/app/dist/assets/index-CqiPq7HB.js new file mode 100644 index 0000000..d9d08f3 --- /dev/null +++ b/app/dist/assets/index-CqiPq7HB.js @@ -0,0 +1,313 @@ +var uO=Object.defineProperty;var cO=(t,e,n)=>e in t?uO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var kt=(t,e,n)=>cO(t,typeof e!="symbol"?e+"":e,n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var Co=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function es(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var fC={exports:{}},cp={},dC={exports:{}},At={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var ef=Symbol.for("react.element"),fO=Symbol.for("react.portal"),dO=Symbol.for("react.fragment"),hO=Symbol.for("react.strict_mode"),pO=Symbol.for("react.profiler"),gO=Symbol.for("react.provider"),mO=Symbol.for("react.context"),yO=Symbol.for("react.forward_ref"),vO=Symbol.for("react.suspense"),wO=Symbol.for("react.memo"),bO=Symbol.for("react.lazy"),c1=Symbol.iterator;function xO(t){return t===null||typeof t!="object"?null:(t=c1&&t[c1]||t["@@iterator"],typeof t=="function"?t:null)}var hC={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},pC=Object.assign,gC={};function su(t,e,n){this.props=t,this.context=e,this.refs=gC,this.updater=n||hC}su.prototype.isReactComponent={};su.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};su.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function mC(){}mC.prototype=su.prototype;function qy(t,e,n){this.props=t,this.context=e,this.refs=gC,this.updater=n||hC}var Yy=qy.prototype=new mC;Yy.constructor=qy;pC(Yy,su.prototype);Yy.isPureReactComponent=!0;var f1=Array.isArray,yC=Object.prototype.hasOwnProperty,Jy={current:null},vC={key:!0,ref:!0,__self:!0,__source:!0};function wC(t,e,n){var r,i={},s=null,o=null;if(e!=null)for(r in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)yC.call(e,r)&&!vC.hasOwnProperty(r)&&(i[r]=e[r]);var l=arguments.length-2;if(l===1)i.children=n;else if(1>>1,P=H[N];if(0>>1;Ni(W,R))yei(ee,W)?(H[N]=ee,H[ye]=R,N=ye):(H[N]=W,H[q]=R,N=q);else if(yei(ee,R))H[N]=ee,H[ye]=R,N=ye;else break e}}return X}function i(H,X){var R=H.sortIndex-X.sortIndex;return R!==0?R:H.id-X.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var a=[],u=[],c=1,f=null,d=3,h=!1,p=!1,g=!1,b=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(H){for(var X=n(u);X!==null;){if(X.callback===null)r(u);else if(X.startTime<=H)r(u),X.sortIndex=X.expirationTime,e(a,X);else break;X=n(u)}}function k(H){if(g=!1,w(H),!p)if(n(a)!==null)p=!0,ie(x);else{var X=n(u);X!==null&&se(k,X.startTime-H)}}function x(H,X){p=!1,g&&(g=!1,m(A),A=-1),h=!0;var R=d;try{for(w(X),f=n(a);f!==null&&(!(f.expirationTime>X)||H&&!D());){var N=f.callback;if(typeof N=="function"){f.callback=null,d=f.priorityLevel;var P=N(f.expirationTime<=X);X=t.unstable_now(),typeof P=="function"?f.callback=P:f===n(a)&&r(a),w(X)}else r(a);f=n(a)}if(f!==null)var B=!0;else{var q=n(u);q!==null&&se(k,q.startTime-X),B=!1}return B}finally{f=null,d=R,h=!1}}var C=!1,T=null,A=-1,M=5,I=-1;function D(){return!(t.unstable_now()-IH||125N?(H.sortIndex=R,e(u,H),n(a)===null&&H===n(u)&&(g?(m(A),A=-1):g=!0,se(k,R-N))):(H.sortIndex=P,e(a,H),p||h||(p=!0,ie(x))),H},t.unstable_shouldYield=D,t.unstable_wrapCallback=function(H){var X=d;return function(){var R=d;d=X;try{return H.apply(this,arguments)}finally{d=R}}}})(CC);SC.exports=CC;var IO=SC.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var NO=y,si=IO;function he(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Wm=Object.prototype.hasOwnProperty,_O=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,h1={},p1={};function DO(t){return Wm.call(p1,t)?!0:Wm.call(h1,t)?!1:_O.test(t)?p1[t]=!0:(h1[t]=!0,!1)}function LO(t,e,n,r){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function $O(t,e,n,r){if(e===null||typeof e>"u"||LO(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Pr(t,e,n,r,i,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}var lr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){lr[t]=new Pr(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];lr[e]=new Pr(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){lr[t]=new Pr(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){lr[t]=new Pr(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){lr[t]=new Pr(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){lr[t]=new Pr(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){lr[t]=new Pr(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){lr[t]=new Pr(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){lr[t]=new Pr(t,5,!1,t.toLowerCase(),null,!1,!1)});var Zy=/[\-:]([a-z])/g;function ev(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Zy,ev);lr[e]=new Pr(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Zy,ev);lr[e]=new Pr(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Zy,ev);lr[e]=new Pr(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){lr[t]=new Pr(t,1,!1,t.toLowerCase(),null,!1,!1)});lr.xlinkHref=new Pr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){lr[t]=new Pr(t,1,!1,t.toLowerCase(),null,!0,!0)});function tv(t,e,n,r){var i=lr.hasOwnProperty(e)?lr[e]:null;(i!==null?i.type!==0:r||!(2l||i[o]!==s[l]){var a=` +`+i[o].replace(" at new "," at ");return t.displayName&&a.includes("")&&(a=a.replace("",t.displayName)),a}while(1<=o&&0<=l);break}}}finally{wg=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Gu(t):""}function FO(t){switch(t.tag){case 5:return Gu(t.type);case 16:return Gu("Lazy");case 13:return Gu("Suspense");case 19:return Gu("SuspenseList");case 0:case 2:case 15:return t=bg(t.type,!1),t;case 11:return t=bg(t.type.render,!1),t;case 1:return t=bg(t.type,!0),t;default:return""}}function Xm(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case ca:return"Fragment";case ua:return"Portal";case Vm:return"Profiler";case nv:return"StrictMode";case Um:return"Suspense";case Km:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case AC:return(t.displayName||"Context")+".Consumer";case EC:return(t._context.displayName||"Context")+".Provider";case rv:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case iv:return e=t.displayName||null,e!==null?e:Xm(t.type)||"Memo";case mo:e=t._payload,t=t._init;try{return Xm(t(e))}catch{}}return null}function zO(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Xm(e);case 8:return e===nv?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Fo(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function RC(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function BO(t){var e=RC(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,s=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Ff(t){t._valueTracker||(t._valueTracker=BO(t))}function OC(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=RC(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function nh(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Gm(t,e){var n=e.checked;return Cn({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function m1(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=Fo(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function PC(t,e){e=e.checked,e!=null&&tv(t,"checked",e,!1)}function qm(t,e){PC(t,e);var n=Fo(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Ym(t,e.type,n):e.hasOwnProperty("defaultValue")&&Ym(t,e.type,Fo(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function y1(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Ym(t,e,n){(e!=="number"||nh(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var qu=Array.isArray;function Aa(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=zf.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function Ac(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var rc={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},jO=["Webkit","ms","Moz","O"];Object.keys(rc).forEach(function(t){jO.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),rc[e]=rc[t]})});function DC(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||rc.hasOwnProperty(t)&&rc[t]?(""+e).trim():e+"px"}function LC(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=DC(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,i):t[n]=i}}var HO=Cn({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Zm(t,e){if(e){if(HO[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(he(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(he(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(he(61))}if(e.style!=null&&typeof e.style!="object")throw Error(he(62))}}function e0(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var t0=null;function sv(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var n0=null,Ma=null,Ra=null;function b1(t){if(t=rf(t)){if(typeof n0!="function")throw Error(he(280));var e=t.stateNode;e&&(e=gp(e),n0(t.stateNode,t.type,e))}}function $C(t){Ma?Ra?Ra.push(t):Ra=[t]:Ma=t}function FC(){if(Ma){var t=Ma,e=Ra;if(Ra=Ma=null,b1(t),e)for(t=0;t>>=0,t===0?32:31-(ZO(t)/eP|0)|0}var Bf=64,jf=4194304;function Yu(t){switch(t&-t){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: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 t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function oh(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,s=t.pingedLanes,o=n&268435455;if(o!==0){var l=o&~i;l!==0?r=Yu(l):(s&=o,s!==0&&(r=Yu(s)))}else o=n&~i,o!==0?r=Yu(o):s!==0&&(r=Yu(s));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if(r&4&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0n;n++)e.push(t);return e}function tf(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Yi(e),t[e]=n}function iP(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=sc),R1=" ",O1=!1;function i2(t,e){switch(t){case"keyup":return IP.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function s2(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var fa=!1;function _P(t,e){switch(t){case"compositionend":return s2(e);case"keypress":return e.which!==32?null:(O1=!0,R1);case"textInput":return t=e.data,t===R1&&O1?null:t;default:return null}}function DP(t,e){if(fa)return t==="compositionend"||!hv&&i2(t,e)?(t=n2(),Dd=cv=To=null,fa=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=_1(n)}}function u2(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?u2(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function c2(){for(var t=window,e=nh();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=nh(t.document)}return e}function pv(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function VP(t){var e=c2(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&u2(n.ownerDocument.documentElement,n)){if(r!==null&&pv(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!t.extend&&s>r&&(i=r,r=s,s=i),i=D1(n,s);var o=D1(n,r);i&&o&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),s>r?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,da=null,a0=null,lc=null,u0=!1;function L1(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;u0||da==null||da!==nh(r)||(r=da,"selectionStart"in r&&pv(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),lc&&Nc(lc,r)||(lc=r,r=uh(a0,"onSelect"),0ga||(t.current=g0[ga],g0[ga]=null,ga--)}function fn(t,e){ga++,g0[ga]=t.current,t.current=e}var zo={},wr=Ko(zo),zr=Ko(!1),Al=zo;function ja(t,e){var n=t.type.contextTypes;if(!n)return zo;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=e[s];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function Br(t){return t=t.childContextTypes,t!=null}function fh(){gn(zr),gn(wr)}function W1(t,e,n){if(wr.current!==zo)throw Error(he(168));fn(wr,e),fn(zr,n)}function w2(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(he(108,zO(t)||"Unknown",i));return Cn({},n,r)}function dh(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||zo,Al=wr.current,fn(wr,t),fn(zr,zr.current),!0}function V1(t,e,n){var r=t.stateNode;if(!r)throw Error(he(169));n?(t=w2(t,e,Al),r.__reactInternalMemoizedMergedChildContext=t,gn(zr),gn(wr),fn(wr,t)):gn(zr),fn(zr,n)}var Ds=null,mp=!1,_g=!1;function b2(t){Ds===null?Ds=[t]:Ds.push(t)}function nI(t){mp=!0,b2(t)}function Xo(){if(!_g&&Ds!==null){_g=!0;var t=0,e=qt;try{var n=Ds;for(qt=1;t>=o,i-=o,Bs=1<<32-Yi(e)+i|n<A?(M=T,T=null):M=T.sibling;var I=d(m,T,w[A],k);if(I===null){T===null&&(T=M);break}t&&T&&I.alternate===null&&e(m,T),v=s(I,v,A),C===null?x=I:C.sibling=I,C=I,T=M}if(A===w.length)return n(m,T),wn&&ul(m,A),x;if(T===null){for(;AA?(M=T,T=null):M=T.sibling;var D=d(m,T,I.value,k);if(D===null){T===null&&(T=M);break}t&&T&&D.alternate===null&&e(m,T),v=s(D,v,A),C===null?x=D:C.sibling=D,C=D,T=M}if(I.done)return n(m,T),wn&&ul(m,A),x;if(T===null){for(;!I.done;A++,I=w.next())I=f(m,I.value,k),I!==null&&(v=s(I,v,A),C===null?x=I:C.sibling=I,C=I);return wn&&ul(m,A),x}for(T=r(m,T);!I.done;A++,I=w.next())I=h(T,m,A,I.value,k),I!==null&&(t&&I.alternate!==null&&T.delete(I.key===null?A:I.key),v=s(I,v,A),C===null?x=I:C.sibling=I,C=I);return t&&T.forEach(function(O){return e(m,O)}),wn&&ul(m,A),x}function b(m,v,w,k){if(typeof w=="object"&&w!==null&&w.type===ca&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case $f:e:{for(var x=w.key,C=v;C!==null;){if(C.key===x){if(x=w.type,x===ca){if(C.tag===7){n(m,C.sibling),v=i(C,w.props.children),v.return=m,m=v;break e}}else if(C.elementType===x||typeof x=="object"&&x!==null&&x.$$typeof===mo&&X1(x)===C.type){n(m,C.sibling),v=i(C,w.props),v.ref=Nu(m,C,w),v.return=m,m=v;break e}n(m,C);break}else e(m,C);C=C.sibling}w.type===ca?(v=Cl(w.props.children,m.mode,k,w.key),v.return=m,m=v):(k=Wd(w.type,w.key,w.props,null,m.mode,k),k.ref=Nu(m,v,w),k.return=m,m=k)}return o(m);case ua:e:{for(C=w.key;v!==null;){if(v.key===C)if(v.tag===4&&v.stateNode.containerInfo===w.containerInfo&&v.stateNode.implementation===w.implementation){n(m,v.sibling),v=i(v,w.children||[]),v.return=m,m=v;break e}else{n(m,v);break}else e(m,v);v=v.sibling}v=Hg(w,m.mode,k),v.return=m,m=v}return o(m);case mo:return C=w._init,b(m,v,C(w._payload),k)}if(qu(w))return p(m,v,w,k);if(Mu(w))return g(m,v,w,k);Gf(m,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,v!==null&&v.tag===6?(n(m,v.sibling),v=i(v,w),v.return=m,m=v):(n(m,v),v=jg(w,m.mode,k),v.return=m,m=v),o(m)):n(m,v)}return b}var Wa=C2(!0),T2=C2(!1),gh=Ko(null),mh=null,va=null,vv=null;function wv(){vv=va=mh=null}function bv(t){var e=gh.current;gn(gh),t._currentValue=e}function v0(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function Pa(t,e){mh=t,vv=va=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&($r=!0),t.firstContext=null)}function Ci(t){var e=t._currentValue;if(vv!==t)if(t={context:t,memoizedValue:e,next:null},va===null){if(mh===null)throw Error(he(308));va=t,mh.dependencies={lanes:0,firstContext:t}}else va=va.next=t;return e}var wl=null;function xv(t){wl===null?wl=[t]:wl.push(t)}function E2(t,e,n,r){var i=e.interleaved;return i===null?(n.next=n,xv(e)):(n.next=i.next,i.next=n),e.interleaved=n,Xs(t,r)}function Xs(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var yo=!1;function kv(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function A2(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Ws(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function No(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,Dt&2){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,Xs(t,n)}return i=r.interleaved,i===null?(e.next=e,xv(r)):(e.next=i.next,i.next=e),r.interleaved=e,Xs(t,n)}function $d(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,lv(t,n)}}function G1(t,e){var n=t.updateQueue,r=t.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?i=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?i=s=e:s=s.next=e}else i=s=e;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function yh(t,e,n,r){var i=t.updateQueue;yo=!1;var s=i.firstBaseUpdate,o=i.lastBaseUpdate,l=i.shared.pending;if(l!==null){i.shared.pending=null;var a=l,u=a.next;a.next=null,o===null?s=u:o.next=u,o=a;var c=t.alternate;c!==null&&(c=c.updateQueue,l=c.lastBaseUpdate,l!==o&&(l===null?c.firstBaseUpdate=u:l.next=u,c.lastBaseUpdate=a))}if(s!==null){var f=i.baseState;o=0,c=u=a=null,l=s;do{var d=l.lane,h=l.eventTime;if((r&d)===d){c!==null&&(c=c.next={eventTime:h,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var p=t,g=l;switch(d=e,h=n,g.tag){case 1:if(p=g.payload,typeof p=="function"){f=p.call(h,f,d);break e}f=p;break e;case 3:p.flags=p.flags&-65537|128;case 0:if(p=g.payload,d=typeof p=="function"?p.call(h,f,d):p,d==null)break e;f=Cn({},f,d);break e;case 2:yo=!0}}l.callback!==null&&l.lane!==0&&(t.flags|=64,d=i.effects,d===null?i.effects=[l]:d.push(l))}else h={eventTime:h,lane:d,tag:l.tag,payload:l.payload,callback:l.callback,next:null},c===null?(u=c=h,a=f):c=c.next=h,o|=d;if(l=l.next,l===null){if(l=i.shared.pending,l===null)break;d=l,l=d.next,d.next=null,i.lastBaseUpdate=d,i.shared.pending=null}}while(!0);if(c===null&&(a=f),i.baseState=a,i.firstBaseUpdate=u,i.lastBaseUpdate=c,e=i.shared.interleaved,e!==null){i=e;do o|=i.lane,i=i.next;while(i!==e)}else s===null&&(i.shared.lanes=0);Ol|=o,t.lanes=o,t.memoizedState=f}}function q1(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;en?n:4,t(!0);var r=Lg.transition;Lg.transition={};try{t(!1),e()}finally{qt=n,Lg.transition=r}}function V2(){return Ti().memoizedState}function oI(t,e,n){var r=Do(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},U2(t))K2(e,n);else if(n=E2(t,e,n,r),n!==null){var i=Ar();Ji(n,t,r,i),X2(n,e,r)}}function lI(t,e,n){var r=Do(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(U2(t))K2(e,i);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,l=s(o,n);if(i.hasEagerState=!0,i.eagerState=l,Qi(l,o)){var a=e.interleaved;a===null?(i.next=i,xv(e)):(i.next=a.next,a.next=i),e.interleaved=i;return}}catch{}finally{}n=E2(t,e,i,r),n!==null&&(i=Ar(),Ji(n,t,r,i),X2(n,e,r))}}function U2(t){var e=t.alternate;return t===Sn||e!==null&&e===Sn}function K2(t,e){ac=wh=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function X2(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,lv(t,n)}}var bh={readContext:Ci,useCallback:dr,useContext:dr,useEffect:dr,useImperativeHandle:dr,useInsertionEffect:dr,useLayoutEffect:dr,useMemo:dr,useReducer:dr,useRef:dr,useState:dr,useDebugValue:dr,useDeferredValue:dr,useTransition:dr,useMutableSource:dr,useSyncExternalStore:dr,useId:dr,unstable_isNewReconciler:!1},aI={readContext:Ci,useCallback:function(t,e){return hs().memoizedState=[t,e===void 0?null:e],t},useContext:Ci,useEffect:J1,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,zd(4194308,4,z2.bind(null,e,t),n)},useLayoutEffect:function(t,e){return zd(4194308,4,t,e)},useInsertionEffect:function(t,e){return zd(4,2,t,e)},useMemo:function(t,e){var n=hs();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=hs();return e=n!==void 0?n(e):e,r.memoizedState=r.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},r.queue=t,t=t.dispatch=oI.bind(null,Sn,t),[r.memoizedState,t]},useRef:function(t){var e=hs();return t={current:t},e.memoizedState=t},useState:Y1,useDebugValue:Ov,useDeferredValue:function(t){return hs().memoizedState=t},useTransition:function(){var t=Y1(!1),e=t[0];return t=sI.bind(null,t[1]),hs().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=Sn,i=hs();if(wn){if(n===void 0)throw Error(he(407));n=n()}else{if(n=e(),Zn===null)throw Error(he(349));Rl&30||P2(r,e,n)}i.memoizedState=n;var s={value:n,getSnapshot:e};return i.queue=s,J1(N2.bind(null,r,s,t),[t]),r.flags|=2048,jc(9,I2.bind(null,r,s,n,e),void 0,null),n},useId:function(){var t=hs(),e=Zn.identifierPrefix;if(wn){var n=js,r=Bs;n=(r&~(1<<32-Yi(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=zc++,0<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=o.createElement(n,{is:r.is}):(t=o.createElement(n),n==="select"&&(o=t,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):t=o.createElementNS(t,n),t[ps]=e,t[Lc]=r,rT(t,e,!1,!1),e.stateNode=t;e:{switch(o=e0(n,r),n){case"dialog":hn("cancel",t),hn("close",t),i=r;break;case"iframe":case"object":case"embed":hn("load",t),i=r;break;case"video":case"audio":for(i=0;iKa&&(e.flags|=128,r=!0,_u(s,!1),e.lanes=4194304)}else{if(!r)if(t=vh(o),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),_u(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!wn)return hr(e),null}else 2*$n()-s.renderingStartTime>Ka&&n!==1073741824&&(e.flags|=128,r=!0,_u(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(n=s.last,n!==null?n.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=$n(),e.sibling=null,n=kn.current,fn(kn,r?n&1|2:n&1),e):(hr(e),null);case 22:case 23:return Lv(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Jr&1073741824&&(hr(e),e.subtreeFlags&6&&(e.flags|=8192)):hr(e),null;case 24:return null;case 25:return null}throw Error(he(156,e.tag))}function mI(t,e){switch(mv(e),e.tag){case 1:return Br(e.type)&&fh(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Va(),gn(zr),gn(wr),Tv(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return Cv(e),null;case 13:if(gn(kn),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(he(340));Ha()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return gn(kn),null;case 4:return Va(),null;case 10:return bv(e.type._context),null;case 22:case 23:return Lv(),null;case 24:return null;default:return null}}var Yf=!1,yr=!1,yI=typeof WeakSet=="function"?WeakSet:Set,_e=null;function wa(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){An(t,e,r)}else n.current=null}function A0(t,e,n){try{n()}catch(r){An(t,e,r)}}var ab=!1;function vI(t,e){if(c0=lh,t=c2(),pv(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,l=-1,a=-1,u=0,c=0,f=t,d=null;t:for(;;){for(var h;f!==n||i!==0&&f.nodeType!==3||(l=o+i),f!==s||r!==0&&f.nodeType!==3||(a=o+r),f.nodeType===3&&(o+=f.nodeValue.length),(h=f.firstChild)!==null;)d=f,f=h;for(;;){if(f===t)break t;if(d===n&&++u===i&&(l=o),d===s&&++c===r&&(a=o),(h=f.nextSibling)!==null)break;f=d,d=f.parentNode}f=h}n=l===-1||a===-1?null:{start:l,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(f0={focusedElem:t,selectionRange:n},lh=!1,_e=e;_e!==null;)if(e=_e,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,_e=t;else for(;_e!==null;){e=_e;try{var p=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(p!==null){var g=p.memoizedProps,b=p.memoizedState,m=e.stateNode,v=m.getSnapshotBeforeUpdate(e.elementType===e.type?g:Bi(e.type,g),b);m.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var w=e.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(he(163))}}catch(k){An(e,e.return,k)}if(t=e.sibling,t!==null){t.return=e.return,_e=t;break}_e=e.return}return p=ab,ab=!1,p}function uc(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var s=i.destroy;i.destroy=void 0,s!==void 0&&A0(e,n,s)}i=i.next}while(i!==r)}}function wp(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function M0(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function oT(t){var e=t.alternate;e!==null&&(t.alternate=null,oT(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[ps],delete e[Lc],delete e[p0],delete e[eI],delete e[tI])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function lT(t){return t.tag===5||t.tag===3||t.tag===4}function ub(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||lT(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function R0(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=ch));else if(r!==4&&(t=t.child,t!==null))for(R0(t,e,n),t=t.sibling;t!==null;)R0(t,e,n),t=t.sibling}function O0(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(O0(t,e,n),t=t.sibling;t!==null;)O0(t,e,n),t=t.sibling}var nr=null,ji=!1;function oo(t,e,n){for(n=n.child;n!==null;)aT(t,e,n),n=n.sibling}function aT(t,e,n){if(Ss&&typeof Ss.onCommitFiberUnmount=="function")try{Ss.onCommitFiberUnmount(fp,n)}catch{}switch(n.tag){case 5:yr||wa(n,e);case 6:var r=nr,i=ji;nr=null,oo(t,e,n),nr=r,ji=i,nr!==null&&(ji?(t=nr,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):nr.removeChild(n.stateNode));break;case 18:nr!==null&&(ji?(t=nr,n=n.stateNode,t.nodeType===8?Ng(t.parentNode,n):t.nodeType===1&&Ng(t,n),Pc(t)):Ng(nr,n.stateNode));break;case 4:r=nr,i=ji,nr=n.stateNode.containerInfo,ji=!0,oo(t,e,n),nr=r,ji=i;break;case 0:case 11:case 14:case 15:if(!yr&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&A0(n,e,o),i=i.next}while(i!==r)}oo(t,e,n);break;case 1:if(!yr&&(wa(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){An(n,e,l)}oo(t,e,n);break;case 21:oo(t,e,n);break;case 22:n.mode&1?(yr=(r=yr)||n.memoizedState!==null,oo(t,e,n),yr=r):oo(t,e,n);break;default:oo(t,e,n)}}function cb(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new yI),e.forEach(function(r){var i=AI.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function $i(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=$n()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*bI(r/1960))-r,10t?16:t,Eo===null)var r=!1;else{if(t=Eo,Eo=null,Sh=0,Dt&6)throw Error(he(331));var i=Dt;for(Dt|=4,_e=t.current;_e!==null;){var s=_e,o=s.child;if(_e.flags&16){var l=s.deletions;if(l!==null){for(var a=0;a$n()-_v?Sl(t,0):Nv|=n),jr(t,e)}function mT(t,e){e===0&&(t.mode&1?(e=jf,jf<<=1,!(jf&130023424)&&(jf=4194304)):e=1);var n=Ar();t=Xs(t,e),t!==null&&(tf(t,e,n),jr(t,n))}function EI(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),mT(t,n)}function AI(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,i=t.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(he(314))}r!==null&&r.delete(e),mT(t,n)}var yT;yT=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||zr.current)$r=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return $r=!1,pI(t,e,n);$r=!!(t.flags&131072)}else $r=!1,wn&&e.flags&1048576&&x2(e,ph,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;Bd(t,e),t=e.pendingProps;var i=ja(e,wr.current);Pa(e,n),i=Av(null,e,r,t,i,n);var s=Mv();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Br(r)?(s=!0,dh(e)):s=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,kv(e),i.updater=vp,e.stateNode=i,i._reactInternals=e,b0(e,r,t,n),e=S0(null,e,r,!0,s,n)):(e.tag=0,wn&&s&&gv(e),Tr(null,e,i,n),e=e.child),e;case 16:r=e.elementType;e:{switch(Bd(t,e),t=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=RI(r),t=Bi(r,t),i){case 0:e=k0(null,e,r,t,n);break e;case 1:e=sb(null,e,r,t,n);break e;case 11:e=rb(null,e,r,t,n);break e;case 14:e=ib(null,e,r,Bi(r.type,t),n);break e}throw Error(he(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Bi(r,i),k0(t,e,r,i,n);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Bi(r,i),sb(t,e,r,i,n);case 3:e:{if(eT(e),t===null)throw Error(he(387));r=e.pendingProps,s=e.memoizedState,i=s.element,A2(t,e),yh(e,r,null,n);var o=e.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){i=Ua(Error(he(423)),e),e=ob(t,e,r,n,i);break e}else if(r!==i){i=Ua(Error(he(424)),e),e=ob(t,e,r,n,i);break e}else for(ri=Io(e.stateNode.containerInfo.firstChild),ii=e,wn=!0,Hi=null,n=T2(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ha(),r===i){e=Gs(t,e,n);break e}Tr(t,e,r,n)}e=e.child}return e;case 5:return M2(e),t===null&&y0(e),r=e.type,i=e.pendingProps,s=t!==null?t.memoizedProps:null,o=i.children,d0(r,i)?o=null:s!==null&&d0(r,s)&&(e.flags|=32),Z2(t,e),Tr(t,e,o,n),e.child;case 6:return t===null&&y0(e),null;case 13:return tT(t,e,n);case 4:return Sv(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Wa(e,null,r,n):Tr(t,e,r,n),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Bi(r,i),rb(t,e,r,i,n);case 7:return Tr(t,e,e.pendingProps,n),e.child;case 8:return Tr(t,e,e.pendingProps.children,n),e.child;case 12:return Tr(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,s=e.memoizedProps,o=i.value,fn(gh,r._currentValue),r._currentValue=o,s!==null)if(Qi(s.value,o)){if(s.children===i.children&&!zr.current){e=Gs(t,e,n);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var l=s.dependencies;if(l!==null){o=s.child;for(var a=l.firstContext;a!==null;){if(a.context===r){if(s.tag===1){a=Ws(-1,n&-n),a.tag=2;var u=s.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?a.next=a:(a.next=c.next,c.next=a),u.pending=a}}s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),v0(s.return,n,e),l.lanes|=n;break}a=a.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(he(341));o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),v0(o,n,e),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===e){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}Tr(t,e,i.children,n),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,Pa(e,n),i=Ci(i),r=r(i),e.flags|=1,Tr(t,e,r,n),e.child;case 14:return r=e.type,i=Bi(r,e.pendingProps),i=Bi(r.type,i),ib(t,e,r,i,n);case 15:return J2(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Bi(r,i),Bd(t,e),e.tag=1,Br(r)?(t=!0,dh(e)):t=!1,Pa(e,n),G2(e,r,i),b0(e,r,i,n),S0(null,e,r,!0,t,n);case 19:return nT(t,e,n);case 22:return Q2(t,e,n)}throw Error(he(156,e.tag))};function vT(t,e){return UC(t,e)}function MI(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function mi(t,e,n,r){return new MI(t,e,n,r)}function Fv(t){return t=t.prototype,!(!t||!t.isReactComponent)}function RI(t){if(typeof t=="function")return Fv(t)?1:0;if(t!=null){if(t=t.$$typeof,t===rv)return 11;if(t===iv)return 14}return 2}function Lo(t,e){var n=t.alternate;return n===null?(n=mi(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function Wd(t,e,n,r,i,s){var o=2;if(r=t,typeof t=="function")Fv(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case ca:return Cl(n.children,i,s,e);case nv:o=8,i|=8;break;case Vm:return t=mi(12,n,e,i|2),t.elementType=Vm,t.lanes=s,t;case Um:return t=mi(13,n,e,i),t.elementType=Um,t.lanes=s,t;case Km:return t=mi(19,n,e,i),t.elementType=Km,t.lanes=s,t;case MC:return xp(n,i,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case EC:o=10;break e;case AC:o=9;break e;case rv:o=11;break e;case iv:o=14;break e;case mo:o=16,r=null;break e}throw Error(he(130,t==null?t:typeof t,""))}return e=mi(o,n,e,i),e.elementType=t,e.type=r,e.lanes=s,e}function Cl(t,e,n,r){return t=mi(7,t,r,e),t.lanes=n,t}function xp(t,e,n,r){return t=mi(22,t,r,e),t.elementType=MC,t.lanes=n,t.stateNode={isHidden:!1},t}function jg(t,e,n){return t=mi(6,t,null,e),t.lanes=n,t}function Hg(t,e,n){return e=mi(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function OI(t,e,n,r,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=kg(0),this.expirationTimes=kg(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=kg(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function zv(t,e,n,r,i,s,o,l,a){return t=new OI(t,e,n,l,a),e===1?(e=1,s===!0&&(e|=8)):e=0,s=mi(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},kv(s),t}function PI(t,e,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(kT)}catch(t){console.error(t)}}kT(),kC.exports=oi;var LI=kC.exports,ST,vb=LI;ST=vb.createRoot,vb.hydrateRoot;function CT(){return""}function $I(){return/^G-[A-Z0-9]+$/.test(CT())}function FI(){const t=window.gtag;typeof t=="function"&&$I()&&t("config",CT(),{send_page_view:!1})}function zI(){var t,e;(t=window.gtag)==null||t.call(window,"event","page_view",{page_path:window.location.pathname,page_location:window.location.href}),(e=window.plausible)==null||e.call(window,"pageview")}function BI(){var t,e;(t=window.gtag)==null||t.call(window,"event","permalink_view"),(e=window.plausible)==null||e.call(window,"Permalink View")}function jI(){var t,e;(t=window.gtag)==null||t.call(window,"event","changelog_open"),(e=window.plausible)==null||e.call(window,"Changelog Open")}function HI(t){var e,n;(e=window.gtag)==null||e.call(window,"event","changelog_vote",{...t}),(n=window.plausible)==null||n.call(window,"Changelog Vote",{props:{...t}})}function WI(t){return t.charAt(0).toUpperCase()+t.slice(1)}function Ep(t,e){var n,r;(n=window.gtag)==null||n.call(window,"event",t,{...e}),(r=window.plausible)==null||r.call(window,WI(t),{props:{...e}})}function VI(t){Ep("input",t)}function UI(t){Ep("conversion",t)}function nl(t){const e={via:t.via,format:t.format,...t.pane!==void 0?{pane:t.pane}:{},...t.direction!==void 0?{direction:t.direction}:{}};Ep("export",e)}function KI(t){Ep("feedback",t)}function XI(t){return new TextEncoder().encode(t).length}function GI(t){return t<10*1024?"<10KB":t<100*1024?"10-100KB":t<1024*1024?"100KB-1MB":">1MB"}function qI(t){let e=2166136261;for(let n=0;n>>0).toString(36)}function YI(t={}){const e=t.settleMs??2e3,n=t.minWindowMs??2e3,r=t.now??(()=>Date.now()),i=t.isValid??(()=>!0);let s=null,o,l=null,a=0,u=null,c=0;function f(h){if(h.text.trim()==="")return!1;const p=XI(h.text),g=GI(p),b=i(h.direction,h.text),m=`${h.direction}:${h.input}:${p}:${qI(h.text)}`,v=r();return m!==l&&(a===0||v-a>=n)&&(l=m,a=v,VI({direction:h.direction,input:h.input,size:g,valid:b})),!b||m===u||c!==0&&v-c{o=void 0,s&&f(s)},e)}return{edit(h,p){s={direction:h,input:"paste",text:p},d()},discrete(h,p,g){s={direction:h,input:p,text:g},d(),f(s)},cancel(){s=null,l=null,u=null,o&&(clearTimeout(o),o=void 0)}}}/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const TT=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const JI=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const QI=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const wb=t=>{const e=QI(t);return e.charAt(0).toUpperCase()+e.slice(1)};/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var Wg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ZI=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1},eN=y.createContext({}),tN=()=>y.useContext(eN),nN=y.forwardRef(({color:t,size:e,strokeWidth:n,absoluteStrokeWidth:r,className:i="",children:s,iconNode:o,...l},a)=>{const{size:u=24,strokeWidth:c=2,absoluteStrokeWidth:f=!1,color:d="currentColor",className:h=""}=tN()??{},p=r??f?Number(n??c)*24/Number(e??u):n??c;return y.createElement("svg",{ref:a,...Wg,width:e??u??Wg.width,height:e??u??Wg.height,stroke:t??d,strokeWidth:p,className:TT("lucide",h,i),...!s&&!ZI(l)&&{"aria-hidden":"true"},...l},[...o.map(([g,b])=>y.createElement(g,b)),...Array.isArray(s)?s:[s]])});/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pn=(t,e)=>{const n=y.forwardRef(({className:r,...i},s)=>y.createElement(nN,{ref:s,iconNode:e,className:TT(`lucide-${JI(wb(t))}`,`lucide-${t}`,r),...i}));return n.displayName=wb(t),n};/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const rN=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],iN=Pn("arrow-left-right",rN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const sN=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],bb=Pn("braces",sN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const oN=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],lN=Pn("chevron-down",oN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const aN=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]],uN=Pn("clipboard",aN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const cN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],fN=Pn("clock",cN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const dN=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],hN=Pn("columns-3",dN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const pN=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Wv=Pn("copy",pN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const gN=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],ET=Pn("download",gN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const mN=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]],AT=Pn("file-up",mN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const yN=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],vN=Pn("moon",yN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const wN=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],bN=Pn("redo-2",wN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const xN=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],kN=Pn("rotate-ccw-clock",xN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const SN=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],xb=Pn("rotate-ccw",SN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const CN=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],TN=Pn("search",CN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const EN=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],AN=Pn("sparkles",EN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const MN=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],RN=Pn("sun",MN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ON=[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]],PN=Pn("table",ON);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const IN=[["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}],["path",{d:"M17 14V2",key:"8ymqnk"}]],NN=Pn("thumbs-down",IN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _N=[["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}],["path",{d:"M7 10v12",key:"1qc93n"}]],DN=Pn("thumbs-up",_N);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const LN=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Eh=Pn("trash",LN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $N=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],FN=Pn("undo-2",$N);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zN=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ah=Pn("x",zN);function MT(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e{const e=WN(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{const l=o.split(Vv);return l[0]===""&&l.length!==1&&l.shift(),RT(l,e)||HN(o)},getConflictingClassGroupIds:(o,l)=>{const a=n[o]||[];return l&&r[o]?[...a,...r[o]]:a}}},RT=(t,e)=>{var o;if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),i=r?RT(t.slice(1),r):void 0;if(i)return i;if(e.validators.length===0)return;const s=t.join(Vv);return(o=e.validators.find(({validator:l})=>l(s)))==null?void 0:o.classGroupId},kb=/^\[(.+)\]$/,HN=t=>{if(kb.test(t)){const e=kb.exec(t)[1],n=e==null?void 0:e.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},WN=t=>{const{theme:e,prefix:n}=t,r={nextPart:new Map,validators:[]};return UN(Object.entries(t.classGroups),n).forEach(([s,o])=>{D0(o,r,s,e)}),r},D0=(t,e,n,r)=>{t.forEach(i=>{if(typeof i=="string"){const s=i===""?e:Sb(e,i);s.classGroupId=n;return}if(typeof i=="function"){if(VN(i)){D0(i(r),e,n,r);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([s,o])=>{D0(o,Sb(e,s),n,r)})})},Sb=(t,e)=>{let n=t;return e.split(Vv).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},VN=t=>t.isThemeGetter,UN=(t,e)=>e?t.map(([n,r])=>{const i=r.map(s=>typeof s=="string"?e+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,l])=>[e+o,l])):s);return[n,i]}):t,KN=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,r=new Map;const i=(s,o)=>{n.set(s,o),e++,e>t&&(e=0,r=n,n=new Map)};return{get(s){let o=n.get(s);if(o!==void 0)return o;if((o=r.get(s))!==void 0)return i(s,o),o},set(s,o){n.has(s)?n.set(s,o):i(s,o)}}},OT="!",XN=t=>{const{separator:e,experimentalParseClassName:n}=t,r=e.length===1,i=e[0],s=e.length,o=l=>{const a=[];let u=0,c=0,f;for(let b=0;bc?f-c:void 0;return{modifiers:a,hasImportantModifier:h,baseClassName:p,maybePostfixModifierPosition:g}};return n?l=>n({className:l,parseClassName:o}):o},GN=t=>{if(t.length<=1)return t;const e=[];let n=[];return t.forEach(r=>{r[0]==="["?(e.push(...n.sort(),r),n=[]):n.push(r)}),e.push(...n.sort()),e},qN=t=>({cache:KN(t.cacheSize),parseClassName:XN(t),...jN(t)}),YN=/\s+/,JN=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=e,s=[],o=t.trim().split(YN);let l="";for(let a=o.length-1;a>=0;a-=1){const u=o[a],{modifiers:c,hasImportantModifier:f,baseClassName:d,maybePostfixModifierPosition:h}=n(u);let p=!!h,g=r(p?d.substring(0,h):d);if(!g){if(!p){l=u+(l.length>0?" "+l:l);continue}if(g=r(d),!g){l=u+(l.length>0?" "+l:l);continue}p=!1}const b=GN(c).join(":"),m=f?b+OT:b,v=m+g;if(s.includes(v))continue;s.push(v);const w=i(g,p);for(let k=0;k0?" "+l:l)}return l};function QN(){let t=0,e,n,r="";for(;t{if(typeof t=="string")return t;let e,n="";for(let r=0;rf(c),t());return n=qN(u),r=n.cache.get,i=n.cache.set,s=l,l(a)}function l(a){const u=r(a);if(u)return u;const c=JN(a,n);return i(a,c),c}return function(){return s(QN.apply(null,arguments))}}const dn=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},IT=/^\[(?:([a-z-]+):)?(.+)\]$/i,e_=/^\d+\/\d+$/,t_=new Set(["px","full","screen"]),n_=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,r_=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,i_=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,s_=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,o_=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Is=t=>Na(t)||t_.has(t)||e_.test(t),lo=t=>au(t,"length",p_),Na=t=>!!t&&!Number.isNaN(Number(t)),Vg=t=>au(t,"number",Na),Lu=t=>!!t&&Number.isInteger(Number(t)),l_=t=>t.endsWith("%")&&Na(t.slice(0,-1)),vt=t=>IT.test(t),ao=t=>n_.test(t),a_=new Set(["length","size","percentage"]),u_=t=>au(t,a_,NT),c_=t=>au(t,"position",NT),f_=new Set(["image","url"]),d_=t=>au(t,f_,m_),h_=t=>au(t,"",g_),$u=()=>!0,au=(t,e,n)=>{const r=IT.exec(t);return r?r[1]?typeof e=="string"?r[1]===e:e.has(r[1]):n(r[2]):!1},p_=t=>r_.test(t)&&!i_.test(t),NT=()=>!1,g_=t=>s_.test(t),m_=t=>o_.test(t),y_=()=>{const t=dn("colors"),e=dn("spacing"),n=dn("blur"),r=dn("brightness"),i=dn("borderColor"),s=dn("borderRadius"),o=dn("borderSpacing"),l=dn("borderWidth"),a=dn("contrast"),u=dn("grayscale"),c=dn("hueRotate"),f=dn("invert"),d=dn("gap"),h=dn("gradientColorStops"),p=dn("gradientColorStopPositions"),g=dn("inset"),b=dn("margin"),m=dn("opacity"),v=dn("padding"),w=dn("saturate"),k=dn("scale"),x=dn("sepia"),C=dn("skew"),T=dn("space"),A=dn("translate"),M=()=>["auto","contain","none"],I=()=>["auto","hidden","clip","visible","scroll"],D=()=>["auto",vt,e],O=()=>[vt,e],L=()=>["",Is,lo],_=()=>["auto",Na,vt],re=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ie=()=>["solid","dashed","dotted","double","none"],se=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],H=()=>["start","end","center","between","around","evenly","stretch"],X=()=>["","0",vt],R=()=>["auto","avoid","all","avoid-page","page","left","right","column"],N=()=>[Na,vt];return{cacheSize:500,separator:":",theme:{colors:[$u],spacing:[Is,lo],blur:["none","",ao,vt],brightness:N(),borderColor:[t],borderRadius:["none","","full",ao,vt],borderSpacing:O(),borderWidth:L(),contrast:N(),grayscale:X(),hueRotate:N(),invert:X(),gap:O(),gradientColorStops:[t],gradientColorStopPositions:[l_,lo],inset:D(),margin:D(),opacity:N(),padding:O(),saturate:N(),scale:N(),sepia:X(),skew:N(),space:O(),translate:O()},classGroups:{aspect:[{aspect:["auto","square","video",vt]}],container:["container"],columns:[{columns:[ao]}],"break-after":[{"break-after":R()}],"break-before":[{"break-before":R()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...re(),vt]}],overflow:[{overflow:I()}],"overflow-x":[{"overflow-x":I()}],"overflow-y":[{"overflow-y":I()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[g]}],"inset-x":[{"inset-x":[g]}],"inset-y":[{"inset-y":[g]}],start:[{start:[g]}],end:[{end:[g]}],top:[{top:[g]}],right:[{right:[g]}],bottom:[{bottom:[g]}],left:[{left:[g]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Lu,vt]}],basis:[{basis:D()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",vt]}],grow:[{grow:X()}],shrink:[{shrink:X()}],order:[{order:["first","last","none",Lu,vt]}],"grid-cols":[{"grid-cols":[$u]}],"col-start-end":[{col:["auto",{span:["full",Lu,vt]},vt]}],"col-start":[{"col-start":_()}],"col-end":[{"col-end":_()}],"grid-rows":[{"grid-rows":[$u]}],"row-start-end":[{row:["auto",{span:[Lu,vt]},vt]}],"row-start":[{"row-start":_()}],"row-end":[{"row-end":_()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",vt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",vt]}],gap:[{gap:[d]}],"gap-x":[{"gap-x":[d]}],"gap-y":[{"gap-y":[d]}],"justify-content":[{justify:["normal",...H()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...H(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...H(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[v]}],px:[{px:[v]}],py:[{py:[v]}],ps:[{ps:[v]}],pe:[{pe:[v]}],pt:[{pt:[v]}],pr:[{pr:[v]}],pb:[{pb:[v]}],pl:[{pl:[v]}],m:[{m:[b]}],mx:[{mx:[b]}],my:[{my:[b]}],ms:[{ms:[b]}],me:[{me:[b]}],mt:[{mt:[b]}],mr:[{mr:[b]}],mb:[{mb:[b]}],ml:[{ml:[b]}],"space-x":[{"space-x":[T]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[T]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",vt,e]}],"min-w":[{"min-w":[vt,e,"min","max","fit"]}],"max-w":[{"max-w":[vt,e,"none","full","min","max","fit","prose",{screen:[ao]},ao]}],h:[{h:[vt,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[vt,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[vt,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[vt,e,"auto","min","max","fit"]}],"font-size":[{text:["base",ao,lo]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Vg]}],"font-family":[{font:[$u]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",vt]}],"line-clamp":[{"line-clamp":["none",Na,Vg]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Is,vt]}],"list-image":[{"list-image":["none",vt]}],"list-style-type":[{list:["none","disc","decimal",vt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[m]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[m]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ie(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Is,lo]}],"underline-offset":[{"underline-offset":["auto",Is,vt]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:O()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",vt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",vt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[m]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...re(),c_]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",u_]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},d_]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[p]}],"gradient-via-pos":[{via:[p]}],"gradient-to-pos":[{to:[p]}],"gradient-from":[{from:[h]}],"gradient-via":[{via:[h]}],"gradient-to":[{to:[h]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[m]}],"border-style":[{border:[...ie(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[m]}],"divide-style":[{divide:ie()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...ie()]}],"outline-offset":[{"outline-offset":[Is,vt]}],"outline-w":[{outline:[Is,lo]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:L()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[m]}],"ring-offset-w":[{"ring-offset":[Is,lo]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",ao,h_]}],"shadow-color":[{shadow:[$u]}],opacity:[{opacity:[m]}],"mix-blend":[{"mix-blend":[...se(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":se()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[a]}],"drop-shadow":[{"drop-shadow":["","none",ao,vt]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[c]}],invert:[{invert:[f]}],saturate:[{saturate:[w]}],sepia:[{sepia:[x]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[a]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[c]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[m]}],"backdrop-saturate":[{"backdrop-saturate":[w]}],"backdrop-sepia":[{"backdrop-sepia":[x]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",vt]}],duration:[{duration:N()}],ease:[{ease:["linear","in","out","in-out",vt]}],delay:[{delay:N()}],animate:[{animate:["none","spin","ping","pulse","bounce",vt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[k]}],"scale-x":[{"scale-x":[k]}],"scale-y":[{"scale-y":[k]}],rotate:[{rotate:[Lu,vt]}],"translate-x":[{"translate-x":[A]}],"translate-y":[{"translate-y":[A]}],"skew-x":[{"skew-x":[C]}],"skew-y":[{"skew-y":[C]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",vt]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",vt]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":O()}],"scroll-mx":[{"scroll-mx":O()}],"scroll-my":[{"scroll-my":O()}],"scroll-ms":[{"scroll-ms":O()}],"scroll-me":[{"scroll-me":O()}],"scroll-mt":[{"scroll-mt":O()}],"scroll-mr":[{"scroll-mr":O()}],"scroll-mb":[{"scroll-mb":O()}],"scroll-ml":[{"scroll-ml":O()}],"scroll-p":[{"scroll-p":O()}],"scroll-px":[{"scroll-px":O()}],"scroll-py":[{"scroll-py":O()}],"scroll-ps":[{"scroll-ps":O()}],"scroll-pe":[{"scroll-pe":O()}],"scroll-pt":[{"scroll-pt":O()}],"scroll-pr":[{"scroll-pr":O()}],"scroll-pb":[{"scroll-pb":O()}],"scroll-pl":[{"scroll-pl":O()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",vt]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[Is,lo,Vg]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},v_=ZN(y_);function Un(...t){return v_(BN(t))}function Ug(t){return t==="csv2json"?"CSV → JSON":"JSON → CSV"}function w_({flipped:t}){return E.jsx(iN,{size:18,strokeWidth:2,"aria-hidden":"true",className:Un("transition-transform duration-300",t&&"rotate-180")})}function b_({direction:t,onFlip:e}){return E.jsxs("button",{type:"button","data-testid":"divider-switch",onClick:e,onMouseDown:n=>n.stopPropagation(),onDoubleClick:n=>n.stopPropagation(),title:`Switch direction (currently ${Ug(t)})`,"aria-label":`Switch conversion direction (currently ${Ug(t)})`,className:"flex h-9 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-full border border-border bg-background px-3 text-xs font-medium text-muted-foreground shadow-sm transition-colors hover:border-muted-foreground/50 hover:text-foreground md:h-8 md:gap-1 md:px-2.5 md:text-[11px]",children:[E.jsx(w_,{flipped:t==="json2csv"}),E.jsx("span",{"data-testid":"divider-switch-label",children:Ug(t)})]})}const _T=[{question:"How does it work?",answer:"Paste CSV or JSON into the left pane and the conversion runs as you type — no upload, no submit button. Flip the direction with the switch between the panes to convert JSON back to CSV, then copy the result or download it as a file. The converter understands quoted fields, embedded separators, and Unicode."},{question:"What do the options do?",answer:"Separator picks the delimiter — auto-detect covers comma, semicolon, and tab. Parse numbers is on by default with smart semantics — plain numbers like 5 or 19.99 become real JSON numbers, while leading-zero values like 00721 and very long IDs stay strings; uncheck it to keep numeric cells as strings — booleans, null, and containers still convert while Parse JSON is on. Parse JSON converts null, true, false, [] and {} cells into real JSON values instead of strings. Transpose flips rows and columns; Hash output makes the first column the object key; Minify removes indentation from JSON output. On the JSON to CSV side, Flatten explodes nested arrays into extra rows with dotted keys."},{question:"TSV vs CSV — what changes?",answer:"Only the delimiter: TSV separates cells with tabs, CSV with commas. Anything you can paste from Excel or Google Sheets is tab-separated, and auto-detect picks that up — or choose Tab in the separator menu. Quoting rules only apply to comma and semicolon output; TSV rarely needs them."},{question:"Does my data ever leave the browser?",answer:"No. The conversion runs entirely in your browser — nothing is uploaded, nothing is stored, nothing is logged. Files you open are read locally in the page, there is no account and no server processing. The site's analytics never see your data: Plausible counts visits cookieless, and the Google tag is a standard conversion-measurement tag that uses the page URL, referrer, and a first-party conversion cookie to measure ad performance. Your files and converted output never leave the browser. When you send feedback, we store your vote and anything you choose to write — nothing else."}],x_={"@context":"https://schema.org","@type":"FAQPage",mainEntity:_T.map(t=>({"@type":"Question",name:t.question,acceptedAnswer:{"@type":"Answer",text:t.answer}}))};function k_(){const[t,e]=y.useState(!1),n=y.useId();return E.jsxs("section",{"data-testid":"faq","aria-label":"How it works and frequently asked questions",className:"flex-shrink-0 border-t border-border bg-panel px-4",children:[E.jsxs("button",{type:"button","data-testid":"faq-toggle","aria-expanded":t,"aria-controls":n,onClick:()=>e(r=>!r),className:"flex w-full cursor-pointer items-center gap-1.5 py-2 text-[12.5px] text-muted-foreground hover:text-foreground",children:[E.jsx("span",{"aria-hidden":"true",className:"w-3 text-center",children:t?"▾":"▸"}),"How it works & FAQ"]}),E.jsx("div",{id:n,"data-testid":"faq-content",hidden:!t,className:"max-w-3xl pb-4 text-[13px] leading-relaxed text-muted-foreground",children:_T.map(r=>E.jsxs("div",{className:"mb-3 last:mb-0",children:[E.jsx("h2",{className:"mb-0.5 text-[11px] font-semibold uppercase tracking-[0.1em] text-foreground",children:r.question}),E.jsx("p",{children:r.answer})]},r.question))}),E.jsx("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(x_)}})]})}const S_="https://github.com/FlatFilers/csvjson-app/discussions/163";function C_(){return E.jsx("div",{"data-testid":"feedback-banner",className:"flex flex-shrink-0 items-center justify-center border-b border-border bg-muted px-3 py-1.5 text-xs text-muted-foreground sm:px-4 sm:text-sm",children:E.jsxs("p",{className:"text-center",children:["Enjoy a cleaner, simpler CSVJSON."," ",E.jsx("a",{"data-testid":"feedback-link",href:S_,target:"_blank",rel:"noopener noreferrer",className:"rounded-sm font-medium text-foreground underline decoration-border underline-offset-2 transition-colors hover:decoration-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:"Leave feedback or ask for features here"}),"."]})})}const DT="csvjson:feedback.v1",T_=[{value:"wrong_output",label:"The conversion is wrong"},{value:"hard_to_use",label:"Hard to use"},{value:"missing_feature",label:"Missing a feature"},{value:"slower",label:"Slower than the old site"},{value:"looks_worse",label:"Looks worse"},{value:"other",label:"Other"}];function E_(t){if(typeof t!="object"||t===null)return!1;const e=t;return typeof e.clientId=="string"&&e.clientId.length<=64&&(e.vote===1||e.vote===-1)&&(typeof e.reasonCode=="string"||e.reasonCode===null)&&(typeof e.reasonText=="string"||e.reasonText===null)&&typeof e.pending=="boolean"}function Cb(){try{const t=window.localStorage.getItem(DT);if(t===null)return null;const e=JSON.parse(t);return E_(e)?e:null}catch{return null}}function Tb(t){try{window.localStorage.setItem(DT,JSON.stringify(t))}catch{}}function Eb(){var n,r,i;if(typeof((n=globalThis.crypto)==null?void 0:n.randomUUID)=="function")return globalThis.crypto.randomUUID();const t=(i=(r=globalThis.crypto)==null?void 0:r.getRandomValues)==null?void 0:i.call(r,new Uint8Array(16));if(t===void 0)throw new Error("no secure randomness available");t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=Array.from(t,s=>s.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}function A_(t){const e=window.location.pathname;return t.vote===1?{clientId:t.clientId,vote:1,path:e}:{clientId:t.clientId,vote:-1,reasonCode:t.reasonCode,reasonText:t.reasonText,path:e}}async function M_(t){try{return(await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(A_(t))})).ok?"ok":"failed"}catch{return"failed"}}function Ab(t){return["flex h-7 w-7 cursor-pointer items-center justify-center rounded-md transition-colors",t?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"].join(" ")}function R_(){const[t,e]=y.useState(Cb),[n,r]=y.useState(!1),[i,s]=y.useState(null),[o,l]=y.useState(""),[a,u]=y.useState(!1),[c,f]=y.useState(!1),d=y.useRef(null),h=y.useRef(0),p=y.useCallback((x,C)=>{const T={...x,pending:C==="failed"};Tb(T),e(T),C==="ok"?KI({vote:x.vote,with_reason:x.reasonCode!==null}):u(!1)},[]),g=y.useCallback((x,C)=>{const T=++h.current;C&&f(!0),M_(x).then(A=>{h.current===T&&(p(x,A),A==="ok"&&u(!0))}).finally(()=>{C&&h.current===T&&f(!1)})},[p]),b=x=>{const C={...x,pending:!0};Tb(C),e(C),g(C,!0)},m=y.useRef(!1);y.useEffect(()=>{if(m.current)return;m.current=!0;const x=Cb();x!=null&&x.pending&&g(x,!1)},[g]),y.useEffect(()=>{if(!a)return;const x=setTimeout(()=>u(!1),3e3);return()=>clearTimeout(x)},[a]),y.useEffect(()=>{if(!n)return;const x=T=>{T.key==="Escape"&&r(!1)},C=T=>{const A=d.current;A===null||!(T.target instanceof Node)||A.contains(T.target)||r(!1)};return document.addEventListener("keydown",x),document.addEventListener("mousedown",C),()=>{document.removeEventListener("keydown",x),document.removeEventListener("mousedown",C)}},[n]);const v=()=>{if((t==null?void 0:t.vote)===1&&!t.pending){u(!0);return}b({clientId:(t==null?void 0:t.clientId)??Eb(),vote:1,reasonCode:null,reasonText:null})},w=()=>{if(n){r(!1);return}s(null),l(""),r(!0)},k=()=>{if(i===null)return;const x=o.trim();b({clientId:(t==null?void 0:t.clientId)??Eb(),vote:-1,reasonCode:i,reasonText:x===""?null:x}),r(!1)};return E.jsxs("div",{"data-testid":"feedback-vote",ref:d,className:"relative flex items-center gap-1 max-sm:static",children:[E.jsx("button",{type:"button","data-testid":"feedback-up",onClick:v,"aria-pressed":(t==null?void 0:t.vote)===1,"aria-label":"Helpful — send an upvote",title:"Helpful",className:Ab((t==null?void 0:t.vote)===1),children:E.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[E.jsx("path",{d:"M7 10v12"}),E.jsx("path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"})]})}),E.jsx("button",{type:"button","data-testid":"feedback-down",onClick:w,"aria-pressed":(t==null?void 0:t.vote)===-1,"aria-haspopup":"dialog","aria-expanded":n,"aria-label":"Not helpful — send a downvote",title:"Not helpful",className:Ab((t==null?void 0:t.vote)===-1),children:E.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[E.jsx("path",{d:"M17 14V2"}),E.jsx("path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"})]})}),a&&E.jsx("span",{"data-testid":"feedback-thanks",className:"text-xs text-muted-foreground",children:"Thanks for the feedback!"}),(t==null?void 0:t.pending)&&!c&&E.jsx("span",{"data-testid":"feedback-pending",role:"status",className:"max-w-44 text-right text-xs text-muted-foreground sm:max-w-none",children:"Feedback couldn't send — your vote is kept on this device and will send automatically once the service is back."}),n&&E.jsxs("div",{"data-testid":"feedback-popover",role:"dialog","aria-label":"What went wrong?",className:"absolute right-0 top-9 z-50 w-72 rounded-md border border-border bg-panel p-3 shadow-md max-sm:inset-x-2 max-sm:top-14 max-sm:w-auto",children:[E.jsx("p",{className:"mb-2 text-xs font-medium text-foreground",children:"What went wrong?"}),E.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:T_.map(x=>E.jsx("button",{type:"button","data-testid":`feedback-reason-${x.value}`,"aria-pressed":i===x.value,onClick:()=>s(x.value),className:["cursor-pointer rounded-sm border px-2 py-0.5 text-xs transition-colors",i===x.value?"border-foreground bg-foreground text-panel":"border-border text-muted-foreground hover:border-foreground hover:text-foreground"].join(" "),children:x.label},x.value))}),E.jsx("textarea",{"data-testid":"feedback-text",value:o,maxLength:500,rows:2,onChange:x=>l(x.target.value),placeholder:"Anything more? (optional)",className:"mb-2 w-full resize-none rounded-sm border border-border bg-panel px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/60 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring"}),E.jsxs("div",{className:"flex items-center justify-end gap-2",children:[E.jsxs("span",{className:"text-[10px] text-muted-foreground/70",children:[o.length,"/500"]}),E.jsx("button",{type:"button","data-testid":"feedback-submit",onClick:k,disabled:i===null,className:"cursor-pointer rounded-sm border border-border px-2.5 py-1 text-xs font-medium text-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50",children:"Send"})]})]})]})}function LT(t="This should not happen"){throw new Error(t)}function ei(t,e="Assertion failed"){if(!t)return LT(e)}function Wc(t,e){return LT(e??"Hell froze over")}function O_(t,e){try{return t()}catch{return e}}const Mb=Object.prototype.hasOwnProperty;function Xa(t,e){let n,r;if(t===e)return!0;if(t&&e&&(n=t.constructor)===e.constructor){if(n===Date)return t.getTime()===e.getTime();if(n===RegExp)return t.toString()===e.toString();if(n===Array){if((r=t.length)===e.length)for(;r--&&Xa(t[r],e[r]););return r===-1}if(!n||typeof t=="object"){r=0;for(n in t)if(Mb.call(t,n)&&++r&&!Mb.call(e,n)||!(n in e)||!Xa(t[n],e[n]))return!1;return Object.keys(e).length===r}}return t!==t&&e!==e}var P_=Object.prototype,I_=P_.hasOwnProperty;function N_(t,e){return t!=null&&I_.call(t,e)}var __=N_,D_=Array.isArray,Ms=D_,L_=typeof Co=="object"&&Co&&Co.Object===Object&&Co,$T=L_,$_=$T,F_=typeof self=="object"&&self&&self.Object===Object&&self,z_=$_||F_||Function("return this")(),Rs=z_,B_=Rs,j_=B_.Symbol,of=j_,Rb=of,FT=Object.prototype,H_=FT.hasOwnProperty,W_=FT.toString,Fu=Rb?Rb.toStringTag:void 0;function V_(t){var e=H_.call(t,Fu),n=t[Fu];try{t[Fu]=void 0;var r=!0}catch{}var i=W_.call(t);return r&&(e?t[Fu]=n:delete t[Fu]),i}var U_=V_,K_=Object.prototype,X_=K_.toString;function G_(t){return X_.call(t)}var q_=G_,Ob=of,Y_=U_,J_=q_,Q_="[object Null]",Z_="[object Undefined]",Pb=Ob?Ob.toStringTag:void 0;function eD(t){return t==null?t===void 0?Z_:Q_:Pb&&Pb in Object(t)?Y_(t):J_(t)}var lf=eD;function tD(t){return t!=null&&typeof t=="object"}var af=tD,nD=lf,rD=af,iD="[object Symbol]";function sD(t){return typeof t=="symbol"||rD(t)&&nD(t)==iD}var Ap=sD,oD=Ms,lD=Ap,aD=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,uD=/^\w*$/;function cD(t,e){if(oD(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||lD(t)?!0:uD.test(t)||!aD.test(t)||e!=null&&t in Object(e)}var Uv=cD;function fD(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var zl=fD,dD=lf,hD=zl,pD="[object AsyncFunction]",gD="[object Function]",mD="[object GeneratorFunction]",yD="[object Proxy]";function vD(t){if(!hD(t))return!1;var e=dD(t);return e==gD||e==mD||e==pD||e==yD}var zT=vD,wD=Rs,bD=wD["__core-js_shared__"],xD=bD,Kg=xD,Ib=function(){var t=/[^.]+$/.exec(Kg&&Kg.keys&&Kg.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function kD(t){return!!Ib&&Ib in t}var SD=kD,CD=Function.prototype,TD=CD.toString;function ED(t){if(t!=null){try{return TD.call(t)}catch{}try{return t+""}catch{}}return""}var BT=ED,AD=zT,MD=SD,RD=zl,OD=BT,PD=/[\\^$.*+?()[\]{}|]/g,ID=/^\[object .+?Constructor\]$/,ND=Function.prototype,_D=Object.prototype,DD=ND.toString,LD=_D.hasOwnProperty,$D=RegExp("^"+DD.call(LD).replace(PD,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function FD(t){if(!RD(t)||MD(t))return!1;var e=AD(t)?$D:ID;return e.test(OD(t))}var zD=FD;function BD(t,e){return t==null?void 0:t[e]}var jD=BD,HD=zD,WD=jD;function VD(t,e){var n=WD(t,e);return HD(n)?n:void 0}var Bl=VD,UD=Bl,KD=UD(Object,"create"),Mp=KD,Nb=Mp;function XD(){this.__data__=Nb?Nb(null):{},this.size=0}var GD=XD;function qD(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var YD=qD,JD=Mp,QD="__lodash_hash_undefined__",ZD=Object.prototype,eL=ZD.hasOwnProperty;function tL(t){var e=this.__data__;if(JD){var n=e[t];return n===QD?void 0:n}return eL.call(e,t)?e[t]:void 0}var nL=tL,rL=Mp,iL=Object.prototype,sL=iL.hasOwnProperty;function oL(t){var e=this.__data__;return rL?e[t]!==void 0:sL.call(e,t)}var lL=oL,aL=Mp,uL="__lodash_hash_undefined__";function cL(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=aL&&e===void 0?uL:e,this}var fL=cL,dL=GD,hL=YD,pL=nL,gL=lL,mL=fL;function uu(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e-1}var NL=IL,_L=Rp;function DL(t,e){var n=this.__data__,r=_L(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}var LL=DL,$L=wL,FL=AL,zL=OL,BL=NL,jL=LL;function cu(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e-1&&t%1==0&&t-1&&t%1==0&&t<=Z3}var Qv=e$,t$=Ap;function n$(t){if(typeof t=="string"||t$(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}var Ip=n$,r$=WT,i$=Yv,s$=Ms,o$=Jv,l$=Qv,a$=Ip;function u$(t,e,n){e=r$(e,t);for(var r=-1,i=e.length,s=!1;++r[r[0]+e,r[1]+e]);return new _s(n)}add(e){const n=typeof e=="number"?[e,e+1]:e,r=m$([...this.items,n]);return new _s(r)}remove(e){const n=[...this.items],r=typeof e=="number"?e:e[0],i=typeof e=="number"?e+1:e[1];for(const[s,o]of n.entries()){const[l,a]=o;if(l<=i&&r<=a){const u=[];l=r&&ejb??(jb=new _s([]))),kt(_s,"fromSingleSelection",e=>_s.empty().add(e));let Pt=_s;function y$(t){var e=Object.create(null);return function(n){return e[n]===void 0&&(e[n]=t(n)),e[n]}}var v$=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,Xg=y$(function(t){return v$.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),w$=function(){const e=Array.prototype.slice.call(arguments).filter(Boolean),n={},r=[];e.forEach(s=>{(s?s.split(" "):[]).forEach(l=>{if(l.startsWith("atm_")){const[,a]=l.split("_");n[a]=l}else r.push(l)})});const i=[];for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&i.push(n[s]);return i.push(...r),i.join(" ")},Hb=w$,b$=t=>t.toUpperCase()===t,x$=t=>e=>t.indexOf(e)===-1,KT=(t,e)=>{const n={};return Object.keys(t).filter(x$(e)).forEach(r=>{n[r]=t[r]}),n};function k$(t,e,n){const r=KT(e,n);if(!t){const i=typeof Xg=="function"?{default:Xg}:Xg;Object.keys(r).forEach(s=>{i.default(s)||delete r[s]})}return r}var S$=(t,e)=>{};function C$(t){let e="";return n=>{const r=(s,o)=>{const{as:l=t,class:a=e}=s,u=n.propsAsIs===void 0?!(typeof l=="string"&&l.indexOf("-")===-1&&!b$(l[0])):n.propsAsIs,c=k$(u,s,["as","class"]);c.ref=o,c.className=n.atomic?Hb(n.class,c.className||a):Hb(c.className||a,n.class);const{vars:f}=n;if(f){const d={};for(const g in f){const b=f[g],m=b[0],v=b[1]||"",w=typeof m=="function"?m(s):m;S$(w,n.name),d[`--${g}`]=`${w}${v}`}const h=c.style||{},p=Object.keys(h);p.length>0&&p.forEach(g=>{d[g]=h[g]}),c.style=d}return t.__linaria&&t!==l?(c.as=l,Kn.createElement(t,c)):Kn.createElement(l,c)},i=Kn.forwardRef?Kn.forwardRef(r):s=>{const o=KT(s,["innerRef"]);return r(o,s.innerRef)};return i.displayName=n.name,i.__linaria={className:n.class||e,extends:t},i}}var ai=C$;const T$=ai("div")({name:"ImageOverlayEditorStyle",class:"gdg-i2iowwq",propsAsIs:!1});var XT={},Np={},ew={},Gg={},qg={exports:{}},Yg,Wb;function E$(){if(Wb)return Yg;Wb=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Yg=t,Yg}var Jg,Vb;function A$(){if(Vb)return Jg;Vb=1;var t=E$();function e(){}function n(){}return n.resetWarningCache=e,Jg=function(){function r(o,l,a,u,c,f){if(f!==t){var d=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw d.name="Invariant Violation",d}}r.isRequired=r;function i(){return r}var s={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:i,element:r,elementType:r,instanceOf:i,node:r,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:n,resetWarningCache:e};return s.PropTypes=s,s},Jg}var Ub;function M$(){return Ub||(Ub=1,qg.exports=A$()()),qg.exports}var Kb;function R$(){return Kb||(Kb=1,function(t){(function(e,n){n(t,y,M$())})(Co,function(e,n,r){Object.defineProperty(e,"__esModule",{value:!0}),e.setHasSupportToCaptureOption=p;var i=o(n),s=o(r);function o(v){return v&&v.__esModule?v:{default:v}}var l=Object.assign||function(v){for(var w=1;w=0||Object.prototype.hasOwnProperty.call(v,x)&&(k[x]=v[x]);return k}function u(v,w){if(!(v instanceof w))throw new TypeError("Cannot call a class as a function")}var c=function(){function v(w,k){for(var x=0;x0&&arguments[0]!==void 0?arguments[0]:{capture:!0};return h?v:v.capture}function b(v){if("touches"in v){var w=v.touches[0],k=w.pageX,x=w.pageY;return{x:k,y:x}}var C=v.screenX,T=v.screenY;return{x:C,y:T}}var m=function(v){d(w,v);function w(){var k;u(this,w);for(var x=arguments.length,C=Array(x),T=0;TC&&this.props.onSwipeRight(1,x),this.movePosition.deltaY<-C?this.props.onSwipeUp(1,x):this.movePosition.deltaY>C&&this.props.onSwipeDown(1,x)),this.moveStart=null,this.moving=!1,this.movePosition=null}},{key:"_setSwiperRef",value:function(x){this.swiper=x,this.props.innerRef(x)}},{key:"render",value:function(){var x=this.props;x.tagName;var C=x.className,T=x.style,A=x.children;x.allowMouseEvents,x.onSwipeUp,x.onSwipeDown,x.onSwipeLeft,x.onSwipeRight,x.onSwipeStart,x.onSwipeMove,x.onSwipeEnd,x.innerRef,x.tolerance;var M=a(x,["tagName","className","style","children","allowMouseEvents","onSwipeUp","onSwipeDown","onSwipeLeft","onSwipeRight","onSwipeStart","onSwipeMove","onSwipeEnd","innerRef","tolerance"]);return i.default.createElement(this.props.tagName,l({ref:this._setSwiperRef,onMouseDown:this._onMouseDown,onTouchStart:this._handleSwipeStart,onTouchEnd:this._handleSwipeEnd,className:C,style:T},M),A)}}]),w}(n.Component);m.displayName="ReactSwipe",m.propTypes={tagName:s.default.string,className:s.default.string,style:s.default.object,children:s.default.node,allowMouseEvents:s.default.bool,onSwipeUp:s.default.func,onSwipeDown:s.default.func,onSwipeLeft:s.default.func,onSwipeRight:s.default.func,onSwipeStart:s.default.func,onSwipeMove:s.default.func,onSwipeEnd:s.default.func,innerRef:s.default.func,tolerance:s.default.number.isRequired},m.defaultProps={tagName:"div",allowMouseEvents:!1,onSwipeUp:function(){},onSwipeDown:function(){},onSwipeLeft:function(){},onSwipeRight:function(){},onSwipeStart:function(){},onSwipeMove:function(){},onSwipeEnd:function(){},innerRef:function(){},tolerance:0},e.default=m})}(Gg)),Gg}(function(t){(function(e,n){n(t,R$())})(Co,function(e,n){Object.defineProperty(e,"__esModule",{value:!0});var r=i(n);function i(s){return s&&s.__esModule?s:{default:s}}e.default=r.default})})(ew);var uf={},GT={exports:{}};/*! + Copyright (c) 2018 Jed Watson. + Licensed under the MIT License (MIT), see + http://jedwatson.github.io/classnames +*/(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var s="",o=0;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Oh(t){return Oh=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Oh(t)}function pr(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var X$=function(e){return e.hasOwnProperty("key")},tw=function(t){W$(n,t);var e=V$(n);function n(r){var i;return B$(this,n),i=e.call(this,r),pr(Cr(i),"itemsWrapperRef",void 0),pr(Cr(i),"itemsListRef",void 0),pr(Cr(i),"thumbsRef",void 0),pr(Cr(i),"setItemsWrapperRef",function(s){i.itemsWrapperRef=s}),pr(Cr(i),"setItemsListRef",function(s){i.itemsListRef=s}),pr(Cr(i),"setThumbsRef",function(s,o){i.thumbsRef||(i.thumbsRef=[]),i.thumbsRef[o]=s}),pr(Cr(i),"updateSizes",function(){if(!(!i.props.children||!i.itemsWrapperRef||!i.thumbsRef)){var s=Fi.Children.count(i.props.children),o=i.itemsWrapperRef.clientWidth,l=i.props.thumbWidth?i.props.thumbWidth:(0,$$.outerWidth)(i.thumbsRef[0]),a=Math.floor(o/l),u=a0&&(o=0),u===f&&o<0&&(o=0);var d=i.itemsWrapperRef.clientWidth,h=u+100/(d/o);return i.itemsListRef&&["WebkitTransform","MozTransform","MsTransform","OTransform","transform","msTransform"].forEach(function(p){i.itemsListRef.style[p]=(0,Xb.default)(h,"%",i.props.axis)}),!0}),pr(Cr(i),"slideRight",function(s){i.moveTo(i.state.firstItem-(typeof s=="number"?s:1))}),pr(Cr(i),"slideLeft",function(s){i.moveTo(i.state.firstItem+(typeof s=="number"?s:1))}),pr(Cr(i),"moveTo",function(s){s=s<0?0:s,s=s>=i.state.lastPosition?i.state.lastPosition:s,i.setState({firstItem:s})}),i.state={selectedItem:r.selectedItem,swiping:!1,showArrows:!1,firstItem:0,visibleItems:0,lastPosition:0},i}return H$(n,[{key:"componentDidMount",value:function(){this.setupThumbs()}},{key:"componentDidUpdate",value:function(i){this.props.selectedItem!==this.state.selectedItem&&this.setState({selectedItem:this.props.selectedItem,firstItem:this.getFirstItem(this.props.selectedItem)}),this.props.children!==i.children&&this.updateSizes()}},{key:"componentWillUnmount",value:function(){this.destroyThumbs()}},{key:"setupThumbs",value:function(){(0,ed.default)().addEventListener("resize",this.updateSizes),(0,ed.default)().addEventListener("DOMContentLoaded",this.updateSizes),this.updateSizes()}},{key:"destroyThumbs",value:function(){(0,ed.default)().removeEventListener("resize",this.updateSizes),(0,ed.default)().removeEventListener("DOMContentLoaded",this.updateSizes)}},{key:"getFirstItem",value:function(i){var s=i;return i>=this.state.lastPosition&&(s=this.state.lastPosition),i1,o=this.state.showArrows&&this.state.firstItem>0,l=this.state.showArrows&&this.state.firstItemo);if(l)return s<0?e.centerMode&&e.centerSlidePercentage&&e.axis==="horizontal"?r.itemListStyle=(0,ws.setPosition)(-(o+2)*e.centerSlidePercentage-(100-e.centerSlidePercentage)/2,e.axis):r.itemListStyle=(0,ws.setPosition)(-(o+2)*100,e.axis):s>o&&(r.itemListStyle=(0,ws.setPosition)(0,e.axis)),r;var a=(0,ws.getPosition)(i,e),u=(0,rF.default)(a,"%",e.axis),c=e.transitionTime+"ms";return r.itemListStyle={WebkitTransform:u,msTransform:u,OTransform:u,transform:u},n.swiping||(r.itemListStyle=pl(pl({},r.itemListStyle),{},{WebkitTransitionDuration:c,MozTransitionDuration:c,OTransitionDuration:c,transitionDuration:c,msTransitionDuration:c})),r};vs.slideAnimationHandler=oF;var lF=function(e,n,r,i){var s={},o=n.axis==="horizontal",l=YT.Children.count(n.children),a=0,u=(0,ws.getPosition)(r.selectedItem,n),c=n.infiniteLoop?(0,ws.getPosition)(l-1,n)-100:(0,ws.getPosition)(l-1,n),f=o?e.x:e.y,d=f;u===a&&f>0&&(d=0),u===c&&f<0&&(d=0);var h=u+100/(r.itemSize/d),p=Math.abs(f)>n.swipeScrollTolerance;return n.infiniteLoop&&p&&(r.selectedItem===0&&h>-100?h-=l*100:r.selectedItem===l-1&&h<-l*100&&(h+=l*100)),(!n.preventMovementUntilSwipeScrollTolerance||p||r.swipeMovementStarted)&&(r.swipeMovementStarted||i({swipeMovementStarted:!0}),s.itemListStyle=(0,ws.setPosition)(h,n.axis)),p&&!r.cancelClick&&i({cancelClick:!0}),s};vs.slideSwipeAnimationHandler=lF;var aF=function(e,n){var r=(0,ws.getPosition)(n.selectedItem,e),i=(0,ws.setPosition)(r,e.axis);return{itemListStyle:i}};vs.slideStopSwipingHandler=aF;var uF=function(e,n){var r=e.transitionTime+"ms",i="ease-in-out",s={position:"absolute",display:"block",zIndex:-2,minHeight:"100%",opacity:0,top:0,right:0,left:0,bottom:0,transitionTimingFunction:i,msTransitionTimingFunction:i,MozTransitionTimingFunction:i,WebkitTransitionTimingFunction:i,OTransitionTimingFunction:i};return n.swiping||(s=pl(pl({},s),{},{WebkitTransitionDuration:r,MozTransitionDuration:r,OTransitionDuration:r,transitionDuration:r,msTransitionDuration:r})),{slideStyle:s,selectedStyle:pl(pl({},s),{},{opacity:1,position:"relative"}),prevStyle:pl({},s)}};vs.fadeAnimationHandler=uF;Object.defineProperty(Np,"__esModule",{value:!0});Np.default=void 0;var Xt=dF(y),cF=df(ew),Ls=df(uf),fF=df(cf),td=df(Lp),nd=df(ff),Zu=ni,Ph=vs;function df(t){return t&&t.__esModule?t:{default:t}}function JT(){if(typeof WeakMap!="function")return null;var t=new WeakMap;return JT=function(){return t},t}function dF(t){if(t&&t.__esModule)return t;if(t===null||hc(t)!=="object"&&typeof t!="function")return{default:t};var e=JT();if(e&&e.has(t))return e.get(t);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=r?Object.getOwnPropertyDescriptor(t,i):null;s&&(s.get||s.set)?Object.defineProperty(n,i,s):n[i]=t[i]}return n.default=t,e&&e.set(t,n),n}function hc(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?hc=function(n){return typeof n}:hc=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},hc(t)}function z0(){return z0=Object.assign||function(t){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Ih(t){return Ih=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Ih(t)}function St(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var nw=function(t){mF(n,t);var e=yF(n);function n(r){var i;hF(this,n),i=e.call(this,r),St(Tt(i),"thumbsRef",void 0),St(Tt(i),"carouselWrapperRef",void 0),St(Tt(i),"listRef",void 0),St(Tt(i),"itemsRef",void 0),St(Tt(i),"timer",void 0),St(Tt(i),"animationHandler",void 0),St(Tt(i),"setThumbsRef",function(o){i.thumbsRef=o}),St(Tt(i),"setCarouselWrapperRef",function(o){i.carouselWrapperRef=o}),St(Tt(i),"setListRef",function(o){i.listRef=o}),St(Tt(i),"setItemsRef",function(o,l){i.itemsRef||(i.itemsRef=[]),i.itemsRef[l]=o}),St(Tt(i),"autoPlay",function(){Xt.Children.count(i.props.children)<=1||(i.clearAutoPlay(),i.props.autoPlay&&(i.timer=setTimeout(function(){i.increment()},i.props.interval)))}),St(Tt(i),"clearAutoPlay",function(){i.timer&&clearTimeout(i.timer)}),St(Tt(i),"resetAutoPlay",function(){i.clearAutoPlay(),i.autoPlay()}),St(Tt(i),"stopOnHover",function(){i.setState({isMouseEntered:!0},i.clearAutoPlay)}),St(Tt(i),"startOnLeave",function(){i.setState({isMouseEntered:!1},i.autoPlay)}),St(Tt(i),"isFocusWithinTheCarousel",function(){return i.carouselWrapperRef?!!((0,td.default)().activeElement===i.carouselWrapperRef||i.carouselWrapperRef.contains((0,td.default)().activeElement)):!1}),St(Tt(i),"navigateWithKeyboard",function(o){if(i.isFocusWithinTheCarousel()){var l=i.props.axis,a=l==="horizontal",u={ArrowUp:38,ArrowRight:39,ArrowDown:40,ArrowLeft:37},c=a?u.ArrowRight:u.ArrowDown,f=a?u.ArrowLeft:u.ArrowUp;c===o.keyCode?i.increment():f===o.keyCode&&i.decrement()}}),St(Tt(i),"updateSizes",function(){if(!(!i.state.initialized||!i.itemsRef||i.itemsRef.length===0)){var o=i.props.axis==="horizontal",l=i.itemsRef[0];if(l){var a=o?l.clientWidth:l.clientHeight;i.setState({itemSize:a}),i.thumbsRef&&i.thumbsRef.updateSizes()}}}),St(Tt(i),"setMountState",function(){i.setState({hasMount:!0}),i.updateSizes()}),St(Tt(i),"handleClickItem",function(o,l){if(Xt.Children.count(i.props.children)!==0){if(i.state.cancelClick){i.setState({cancelClick:!1});return}i.props.onClickItem(o,l),o!==i.state.selectedItem&&i.setState({selectedItem:o})}}),St(Tt(i),"handleOnChange",function(o,l){Xt.Children.count(i.props.children)<=1||i.props.onChange(o,l)}),St(Tt(i),"handleClickThumb",function(o,l){i.props.onClickThumb(o,l),i.moveTo(o)}),St(Tt(i),"onSwipeStart",function(o){i.setState({swiping:!0}),i.props.onSwipeStart(o)}),St(Tt(i),"onSwipeEnd",function(o){i.setState({swiping:!1,cancelClick:!1,swipeMovementStarted:!1}),i.props.onSwipeEnd(o),i.clearAutoPlay(),i.state.autoPlay&&i.autoPlay()}),St(Tt(i),"onSwipeMove",function(o,l){i.props.onSwipeMove(l);var a=i.props.swipeAnimationHandler(o,i.props,i.state,i.setState.bind(Tt(i)));return i.setState(zi({},a)),!!Object.keys(a).length}),St(Tt(i),"decrement",function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;i.moveTo(i.state.selectedItem-(typeof o=="number"?o:1))}),St(Tt(i),"increment",function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;i.moveTo(i.state.selectedItem+(typeof o=="number"?o:1))}),St(Tt(i),"moveTo",function(o){if(typeof o=="number"){var l=Xt.Children.count(i.props.children)-1;o<0&&(o=i.props.infiniteLoop?l:0),o>l&&(o=i.props.infiniteLoop?0:l),i.selectItem({selectedItem:o}),i.state.autoPlay&&i.state.isMouseEntered===!1&&i.resetAutoPlay()}}),St(Tt(i),"onClickNext",function(){i.increment(1)}),St(Tt(i),"onClickPrev",function(){i.decrement(1)}),St(Tt(i),"onSwipeForward",function(){i.increment(1),i.props.emulateTouch&&i.setState({cancelClick:!0})}),St(Tt(i),"onSwipeBackwards",function(){i.decrement(1),i.props.emulateTouch&&i.setState({cancelClick:!0})}),St(Tt(i),"changeItem",function(o){return function(l){(!(0,Zu.isKeyboardEvent)(l)||l.key==="Enter")&&i.moveTo(o)}}),St(Tt(i),"selectItem",function(o){i.setState(zi({previousItem:i.state.selectedItem},o),function(){i.setState(i.animationHandler(i.props,i.state))}),i.handleOnChange(o.selectedItem,Xt.Children.toArray(i.props.children)[o.selectedItem])}),St(Tt(i),"getInitialImage",function(){var o=i.props.selectedItem,l=i.itemsRef&&i.itemsRef[o],a=l&&l.getElementsByTagName("img")||[];return a[0]}),St(Tt(i),"getVariableItemHeight",function(o){var l=i.itemsRef&&i.itemsRef[o];if(i.state.hasMount&&l&&l.children.length){var a=l.children[0].getElementsByTagName("img")||[];if(a.length>0){var u=a[0];if(!u.complete){var c=function h(){i.forceUpdate(),u.removeEventListener("load",h)};u.addEventListener("load",c)}}var f=a[0]||l.children[0],d=f.clientHeight;return d>0?d:null}return null});var s={initialized:!1,previousItem:r.selectedItem,selectedItem:r.selectedItem,hasMount:!1,isMouseEntered:!1,autoPlay:r.autoPlay,swiping:!1,swipeMovementStarted:!1,cancelClick:!1,itemSize:1,itemListStyle:{},slideStyle:{},selectedStyle:{},prevStyle:{}};return i.animationHandler=typeof r.animationHandler=="function"&&r.animationHandler||r.animationHandler==="fade"&&Ph.fadeAnimationHandler||Ph.slideAnimationHandler,i.state=zi(zi({},s),i.animationHandler(r,s)),i}return gF(n,[{key:"componentDidMount",value:function(){this.props.children&&this.setupCarousel()}},{key:"componentDidUpdate",value:function(i,s){!i.children&&this.props.children&&!this.state.initialized&&this.setupCarousel(),!i.autoFocus&&this.props.autoFocus&&this.forceFocus(),s.swiping&&!this.state.swiping&&this.setState(zi({},this.props.stopSwipingHandler(this.props,this.state))),(i.selectedItem!==this.props.selectedItem||i.centerMode!==this.props.centerMode)&&(this.updateSizes(),this.moveTo(this.props.selectedItem)),i.autoPlay!==this.props.autoPlay&&(this.props.autoPlay?this.setupAutoPlay():this.destroyAutoPlay(),this.setState({autoPlay:this.props.autoPlay}))}},{key:"componentWillUnmount",value:function(){this.destroyCarousel()}},{key:"setupCarousel",value:function(){var i=this;this.bindEvents(),this.state.autoPlay&&Xt.Children.count(this.props.children)>1&&this.setupAutoPlay(),this.props.autoFocus&&this.forceFocus(),this.setState({initialized:!0},function(){var s=i.getInitialImage();s&&!s.complete?s.addEventListener("load",i.setMountState):i.setMountState()})}},{key:"destroyCarousel",value:function(){this.state.initialized&&(this.unbindEvents(),this.destroyAutoPlay())}},{key:"setupAutoPlay",value:function(){this.autoPlay();var i=this.carouselWrapperRef;this.props.stopOnHover&&i&&(i.addEventListener("mouseenter",this.stopOnHover),i.addEventListener("mouseleave",this.startOnLeave))}},{key:"destroyAutoPlay",value:function(){this.clearAutoPlay();var i=this.carouselWrapperRef;this.props.stopOnHover&&i&&(i.removeEventListener("mouseenter",this.stopOnHover),i.removeEventListener("mouseleave",this.startOnLeave))}},{key:"bindEvents",value:function(){(0,nd.default)().addEventListener("resize",this.updateSizes),(0,nd.default)().addEventListener("DOMContentLoaded",this.updateSizes),this.props.useKeyboardArrows&&(0,td.default)().addEventListener("keydown",this.navigateWithKeyboard)}},{key:"unbindEvents",value:function(){(0,nd.default)().removeEventListener("resize",this.updateSizes),(0,nd.default)().removeEventListener("DOMContentLoaded",this.updateSizes);var i=this.getInitialImage();i&&i.removeEventListener("load",this.setMountState),this.props.useKeyboardArrows&&(0,td.default)().removeEventListener("keydown",this.navigateWithKeyboard)}},{key:"forceFocus",value:function(){var i;(i=this.carouselWrapperRef)===null||i===void 0||i.focus()}},{key:"renderItems",value:function(i){var s=this;return this.props.children?Xt.Children.map(this.props.children,function(o,l){var a=l===s.state.selectedItem,u=l===s.state.previousItem,c=a&&s.state.selectedStyle||u&&s.state.prevStyle||s.state.slideStyle||{};s.props.centerMode&&s.props.axis==="horizontal"&&(c=zi(zi({},c),{},{minWidth:s.props.centerSlidePercentage+"%"})),s.state.swiping&&s.state.swipeMovementStarted&&(c=zi(zi({},c),{},{pointerEvents:"none"}));var f={ref:function(h){return s.setItemsRef(h,l)},key:"itemKey"+l+(i?"clone":""),className:Ls.default.ITEM(!0,l===s.state.selectedItem,l===s.state.previousItem),onClick:s.handleClickItem.bind(s,l,o),style:c};return Xt.default.createElement("li",f,s.props.renderItem(o,{isSelected:l===s.state.selectedItem,isPrevious:l===s.state.previousItem}))}):[]}},{key:"renderControls",value:function(){var i=this,s=this.props,o=s.showIndicators,l=s.labels,a=s.renderIndicator,u=s.children;return o?Xt.default.createElement("ul",{className:"control-dots"},Xt.Children.map(u,function(c,f){return a&&a(i.changeItem(f),f===i.state.selectedItem,f,l.item)})):null}},{key:"renderStatus",value:function(){return this.props.showStatus?Xt.default.createElement("p",{className:"carousel-status"},this.props.statusFormatter(this.state.selectedItem+1,Xt.Children.count(this.props.children))):null}},{key:"renderThumbs",value:function(){return!this.props.showThumbs||!this.props.children||Xt.Children.count(this.props.children)===0?null:Xt.default.createElement(fF.default,{ref:this.setThumbsRef,onSelectItem:this.handleClickThumb,selectedItem:this.state.selectedItem,transitionTime:this.props.transitionTime,thumbWidth:this.props.thumbWidth,labels:this.props.labels,emulateTouch:this.props.emulateTouch},this.props.renderThumbs(this.props.children))}},{key:"render",value:function(){var i=this;if(!this.props.children||Xt.Children.count(this.props.children)===0)return null;var s=this.props.swipeable&&Xt.Children.count(this.props.children)>1,o=this.props.axis==="horizontal",l=this.props.showArrows&&Xt.Children.count(this.props.children)>1,a=l&&(this.state.selectedItem>0||this.props.infiniteLoop)||!1,u=l&&(this.state.selectedItem=e||T<0||f&&A>=s}function m(){var C=Qg();if(b(C))return v(C);l=setTimeout(m,g(C))}function v(C){return l=void 0,d&&r?h(C):(r=i=void 0,o)}function w(){l!==void 0&&clearTimeout(l),u=0,r=a=i=l=void 0}function k(){return l===void 0?o:v(Qg())}function x(){var C=Qg(),T=b(C);if(r=arguments,i=this,a=C,T){if(l===void 0)return p(a);if(f)return clearTimeout(l),l=setTimeout(m,e),h(a)}return l===void 0&&(l=setTimeout(m,e)),o}return x.cancel=w,x.flush=k,x}var QT=HF;const ZT=es(QT);function rr(t,e,n,r,i=!1){const s=y.useRef();s.current=e,y.useEffect(()=>{if(n===null||n.addEventListener===void 0)return;const o=n,l=a=>{var u;(u=s.current)==null||u.call(o,a)};return o.addEventListener(t,l,{passive:r,capture:i}),()=>{o.removeEventListener(t,l,{capture:i})}},[t,n,r,i])}function na(t,e){return t===void 0?void 0:e}const WF=Math.PI;function Zb(t){return t*WF/180}const eE=(t,e,n)=>({x1:t-n/2,y1:e-n/2,x2:t+n/2,y2:e+n/2}),tE=(t,e,n,r,i)=>{switch(t){case"left":return Math.floor(e)+r+i/2;case"center":return Math.floor(e+n/2);case"right":return Math.floor(e+n)-r-i/2}},nE=(t,e,n)=>Math.min(t,e-n*2),rE=(t,e,n)=>n.x1<=t&&t<=n.x2&&n.y1<=e&&e<=n.y2,iw=t=>{const e=t.fgColor??"currentColor";return y.createElement("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},y.createElement("path",{d:"M12.7073 7.05029C7.87391 11.8837 10.4544 9.30322 6.03024 13.7273C5.77392 13.9836 5.58981 14.3071 5.50189 14.6587L4.52521 18.5655C4.38789 19.1148 4.88543 19.6123 5.43472 19.475L9.34146 18.4983C9.69313 18.4104 10.0143 18.2286 10.2706 17.9722L16.9499 11.2929",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}),y.createElement("path",{d:"M20.4854 4.92901L19.0712 3.5148C18.2901 2.73375 17.0238 2.73375 16.2428 3.5148L14.475 5.28257C15.5326 7.71912 16.4736 8.6278 18.7176 9.52521L20.4854 7.75744C21.2665 6.97639 21.2665 5.71006 20.4854 4.92901Z",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}))},VF=t=>{const e=t.fgColor??"currentColor";return y.createElement("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},y.createElement("path",{d:"M19 6L10.3802 17L5.34071 11.8758",vectorEffect:"non-scaling-stroke",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))};function UF(t,e,n){const[r,i]=y.useState(t),s=y.useRef(!0);y.useEffect(()=>()=>{s.current=!1},[]);const o=y.useRef(ZT(l=>{s.current&&i(l)},n));return y.useLayoutEffect(()=>{s.current&&o.current(()=>t())},e),r}const KF="֑-߿יִ-﷽ﹰ-ﻼ",XF="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",GF=new RegExp("^[^"+XF+"]*["+KF+"]");function sw(t){return GF.test(t)?"rtl":"not-rtl"}let rd;function j0(){if(typeof document>"u")return 0;if(rd!==void 0)return rd;const t=document.createElement("p");t.style.width="100%",t.style.height="200px";const e=document.createElement("div");e.id="testScrollbar",e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.style.width="200px",e.style.height="150px",e.style.overflow="hidden",e.append(t),document.body.append(e);const n=t.offsetWidth;e.style.overflow="scroll";let r=t.offsetWidth;return n===r&&(r=e.clientWidth),e.remove(),rd=n-r,rd}const il=Symbol();function qF(t){const e=y.useRef([il,t]);e.current[1]!==t&&(e.current[0]=t),e.current[1]=t;const[n,r]=y.useState(t),[,i]=y.useState(),s=y.useCallback(l=>{const a=e.current[0];a!==il&&(l=typeof l=="function"?l(a):l,l===a)||(a!==il&&i({}),r(u=>typeof l=="function"?l(a===il?u:a):l),e.current[0]=il)},[]),o=y.useCallback(()=>{e.current[0]=il,i({})},[]);return[e.current[0]===il?n:e.current[0],s,o]}function iE(t){if(t.length===0)return"";let e=0,n=0;for(const r of t){if(n+=r.length,n>1e4)break;e++}return t.slice(0,e).join(", ")}function YF(t){const e=y.useRef(t);return Xa(t,e.current)||(e.current=t),e.current}const JF=t=>{const{urls:e,canWrite:n,onEditClick:r,renderImage:i}=t,s=e.filter(l=>l!=="");if(s.length===0)return null;const o=s.length>1;return y.createElement(T$,{"data-testid":"GDG-default-image-overlay-editor"},y.createElement(XT.Carousel,{showArrows:o,showThumbs:!1,swipeable:o,emulateTouch:o,infiniteLoop:o},s.map(l=>{const a=(i==null?void 0:i(l))??y.createElement("img",{draggable:!1,src:l});return y.createElement("div",{className:"gdg-centering-container",key:l},a)})),n&&r&&y.createElement("button",{className:"gdg-edit-icon",onClick:r},y.createElement(iw,null)))};function sE(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let jl=sE();function QF(t){jl=t}const oE=/[&<>"']/,ZF=new RegExp(oE.source,"g"),lE=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,e4=new RegExp(lE.source,"g"),t4={"&":"&","<":"<",">":">",'"':""","'":"'"},ex=t=>t4[t];function gr(t,e){if(e){if(oE.test(t))return t.replace(ZF,ex)}else if(lE.test(t))return t.replace(e4,ex);return t}const n4=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function aE(t){return t.replace(n4,(e,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const r4=/(^|[^\[])\^/g;function ln(t,e){t=typeof t=="string"?t:t.source,e=e||"";const n={replace:(r,i)=>(i=i.source||i,i=i.replace(r4,"$1"),t=t.replace(r,i),n),getRegex:()=>new RegExp(t,e)};return n}const i4=/[^\w:]/g,s4=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function tx(t,e,n){if(t){let r;try{r=decodeURIComponent(aE(n)).replace(i4,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}e&&!s4.test(n)&&(n=u4(e,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const id={},o4=/^[^:]+:\/*[^/]*$/,l4=/^([^:]+:)[\s\S]*$/,a4=/^([^:]+:\/*[^/]*)[\s\S]*$/;function u4(t,e){id[" "+t]||(o4.test(t)?id[" "+t]=t+"/":id[" "+t]=Vd(t,"/",!0)),t=id[" "+t];const n=t.indexOf(":")===-1;return e.substring(0,2)==="//"?n?e:t.replace(l4,"$1")+e:e.charAt(0)==="/"?n?e:t.replace(a4,"$1")+e:t+e}const Nh={exec:function(){}};function nx(t,e){const n=t.replace(/\|/g,(s,o,l)=>{let a=!1,u=o;for(;--u>=0&&l[u]==="\\";)a=!a;return a?"|":" |"}),r=n.split(/ \|/);let i=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>e)r.splice(e);else for(;r.length1;)e&1&&(n+=t),e>>=1,t+=t;return n+t}function ix(t,e,n,r){const i=e.href,s=e.title?gr(e.title):null,o=t[1].replace(/\\([\[\]])/g,"$1");if(t[0].charAt(0)!=="!"){r.state.inLink=!0;const l={type:"link",raw:n,href:i,title:s,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,l}return{type:"image",raw:n,href:i,title:s,text:gr(o)}}function d4(t,e){const n=t.match(/^(\s+)(?:```)/);if(n===null)return e;const r=n[1];return e.split(` +`).map(i=>{const s=i.match(/^\s+/);if(s===null)return i;const[o]=s;return o.length>=r.length?i.slice(r.length):i}).join(` +`)}class ow{constructor(e){this.options=e||jl}space(e){const n=this.rules.block.newline.exec(e);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(e){const n=this.rules.block.code.exec(e);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Vd(r,` +`)}}}fences(e){const n=this.rules.block.fences.exec(e);if(n){const r=n[0],i=d4(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:i}}}heading(e){const n=this.rules.block.heading.exec(e);if(n){let r=n[2].trim();if(/#$/.test(r)){const i=Vd(r,"#");(this.options.pedantic||!i||/ $/.test(i))&&(r=i.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(e){const n=this.rules.block.hr.exec(e);if(n)return{type:"hr",raw:n[0]}}blockquote(e){const n=this.rules.block.blockquote.exec(e);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),i=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=i,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(e){let n=this.rules.block.list.exec(e);if(n){let r,i,s,o,l,a,u,c,f,d,h,p,g=n[1].trim();const b=g.length>1,m={type:"list",raw:"",ordered:b,start:b?+g.slice(0,-1):"",loose:!1,items:[]};g=b?`\\d{1,9}\\${g.slice(-1)}`:`\\${g}`,this.options.pedantic&&(g=b?g:"[*+-]");const v=new RegExp(`^( {0,3}${g})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;e&&(p=!1,!(!(n=v.exec(e))||this.rules.block.hr.test(e)));){if(r=n[0],e=e.substring(r.length),c=n[2].split(` +`,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),f=e.split(` +`,1)[0],this.options.pedantic?(o=2,h=c.trimLeft()):(o=n[2].search(/[^ ]/),o=o>4?1:o,h=c.slice(o),o+=n[1].length),a=!1,!c&&/^ *$/.test(f)&&(r+=f+` +`,e=e.substring(f.length+1),p=!0),!p){const k=new RegExp(`^ {0,${Math.min(3,o-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),x=new RegExp(`^ {0,${Math.min(3,o-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),C=new RegExp(`^ {0,${Math.min(3,o-1)}}(?:\`\`\`|~~~)`),T=new RegExp(`^ {0,${Math.min(3,o-1)}}#`);for(;e&&(d=e.split(` +`,1)[0],f=d,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(C.test(f)||T.test(f)||k.test(f)||x.test(e)));){if(f.search(/[^ ]/)>=o||!f.trim())h+=` +`+f.slice(o);else{if(a||c.search(/[^ ]/)>=4||C.test(c)||T.test(c)||x.test(c))break;h+=` +`+f}!a&&!f.trim()&&(a=!0),r+=d+` +`,e=e.substring(d.length+1),c=f.slice(o)}}m.loose||(u?m.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(i=/^\[[ xX]\] /.exec(h),i&&(s=i[0]!=="[ ] ",h=h.replace(/^\[[ xX]\] +/,""))),m.items.push({type:"list_item",raw:r,task:!!i,checked:s,loose:!1,text:h}),m.raw+=r}m.items[m.items.length-1].raw=r.trimRight(),m.items[m.items.length-1].text=h.trimRight(),m.raw=m.raw.trimRight();const w=m.items.length;for(l=0;lC.type==="space"),x=k.length>0&&k.some(C=>/\n.*\n/.test(C.raw));m.loose=x}if(m.loose)for(l=0;l$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:i,title:s}}}table(e){const n=this.rules.block.table.exec(e);if(n){const r={type:"table",header:nx(n[1]).map(i=>({text:i})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(` +`):[]};if(r.header.length===r.align.length){r.raw=n[0];let i=r.align.length,s,o,l,a;for(s=0;s({text:u}));for(i=r.header.length,o=0;o/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):gr(n[0]):n[0]}}link(e){const n=this.rules.inline.link.exec(e);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^$/.test(r))return;const o=Vd(r.slice(0,-1),"\\");if((r.length-o.length)%2===0)return}else{const o=c4(n[2],"()");if(o>-1){const a=(n[0].indexOf("!")===0?5:4)+n[1].length+o;n[2]=n[2].substring(0,o),n[0]=n[0].substring(0,a).trim(),n[3]=""}}let i=n[2],s="";if(this.options.pedantic){const o=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);o&&(i=o[1],s=o[3])}else s=n[3]?n[3].slice(1,-1):"";return i=i.trim(),/^$/.test(r)?i=i.slice(1):i=i.slice(1,-1)),ix(n,{href:i&&i.replace(this.rules.inline._escapes,"$1"),title:s&&s.replace(this.rules.inline._escapes,"$1")},n[0],this.lexer)}}reflink(e,n){let r;if((r=this.rules.inline.reflink.exec(e))||(r=this.rules.inline.nolink.exec(e))){let i=(r[2]||r[1]).replace(/\s+/g," ");if(i=n[i.toLowerCase()],!i){const s=r[0].charAt(0);return{type:"text",raw:s,text:s}}return ix(r,i,r[0],this.lexer)}}emStrong(e,n,r=""){let i=this.rules.inline.emStrong.lDelim.exec(e);if(!i||i[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=i[1]||i[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const o=i[0].length-1;let l,a,u=o,c=0;const f=i[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*e.length+o);(i=f.exec(n))!=null;){if(l=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!l)continue;if(a=l.length,i[3]||i[4]){u+=a;continue}else if((i[5]||i[6])&&o%3&&!((o+a)%3)){c+=a;continue}if(u-=a,u>0)continue;a=Math.min(a,a+u+c);const d=e.slice(0,o+i.index+(i[0].length-l.length)+a);if(Math.min(o,a)%2){const p=d.slice(1,-1);return{type:"em",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}const h=d.slice(2,-2);return{type:"strong",raw:d,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(e){const n=this.rules.inline.code.exec(e);if(n){let r=n[2].replace(/\n/g," ");const i=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return i&&s&&(r=r.substring(1,r.length-1)),r=gr(r,!0),{type:"codespan",raw:n[0],text:r}}}br(e){const n=this.rules.inline.br.exec(e);if(n)return{type:"br",raw:n[0]}}del(e){const n=this.rules.inline.del.exec(e);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(e,n){const r=this.rules.inline.autolink.exec(e);if(r){let i,s;return r[2]==="@"?(i=gr(this.options.mangle?n(r[1]):r[1]),s="mailto:"+i):(i=gr(r[1]),s=i),{type:"link",raw:r[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}url(e,n){let r;if(r=this.rules.inline.url.exec(e)){let i,s;if(r[2]==="@")i=gr(this.options.mangle?n(r[0]):r[0]),s="mailto:"+i;else{let o;do o=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(o!==r[0]);i=gr(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e,n){const r=this.rules.inline.text.exec(e);if(r){let i;return this.lexer.state.inRawBlock?i=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):gr(r[0]):r[0]:i=gr(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:i}}}}const Je={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Nh,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Je._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/;Je._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;Je.def=ln(Je.def).replace("label",Je._label).replace("title",Je._title).getRegex();Je.bullet=/(?:[*+-]|\d{1,9}[.)])/;Je.listItemStart=ln(/^( *)(bull) */).replace("bull",Je.bullet).getRegex();Je.list=ln(Je.list).replace(/bull/g,Je.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Je.def.source+")").getRegex();Je._tag="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|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";Je._comment=/|$)/;Je.html=ln(Je.html,"i").replace("comment",Je._comment).replace("tag",Je._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();Je.paragraph=ln(Je._paragraph).replace("hr",Je.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Je._tag).getRegex();Je.blockquote=ln(Je.blockquote).replace("paragraph",Je.paragraph).getRegex();Je.normal={...Je};Je.gfm={...Je.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"};Je.gfm.table=ln(Je.gfm.table).replace("hr",Je.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Je._tag).getRegex();Je.gfm.paragraph=ln(Je._paragraph).replace("hr",Je.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Je.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Je._tag).getRegex();Je.pedantic={...Je.normal,html:ln(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Je._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Nh,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ln(Je.normal._paragraph).replace("hr",Je.hr).replace("heading",` *#{1,6} *[^ +]`).replace("lheading",Je.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const De={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Nh,tag:"^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Nh,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\?@\\[\\]`^{|}~";De.punctuation=ln(De.punctuation).replace(/punctuation/g,De._punctuation).getRegex();De.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;De.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g;De._comment=ln(Je._comment).replace("(?:-->|$)","-->").getRegex();De.emStrong.lDelim=ln(De.emStrong.lDelim).replace(/punct/g,De._punctuation).getRegex();De.emStrong.rDelimAst=ln(De.emStrong.rDelimAst,"g").replace(/punct/g,De._punctuation).getRegex();De.emStrong.rDelimUnd=ln(De.emStrong.rDelimUnd,"g").replace(/punct/g,De._punctuation).getRegex();De._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;De._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;De._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;De.autolink=ln(De.autolink).replace("scheme",De._scheme).replace("email",De._email).getRegex();De._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;De.tag=ln(De.tag).replace("comment",De._comment).replace("attribute",De._attribute).getRegex();De._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;De._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;De._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;De.link=ln(De.link).replace("label",De._label).replace("href",De._href).replace("title",De._title).getRegex();De.reflink=ln(De.reflink).replace("label",De._label).replace("ref",Je._label).getRegex();De.nolink=ln(De.nolink).replace("ref",Je._label).getRegex();De.reflinkSearch=ln(De.reflinkSearch,"g").replace("reflink",De.reflink).replace("nolink",De.nolink).getRegex();De.normal={...De};De.pedantic={...De.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:ln(/^!?\[(label)\]\((.*?)\)/).replace("label",De._label).getRegex(),reflink:ln(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",De._label).getRegex()};De.gfm={...De.normal,escape:ln(De.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\.5&&(r="x"+r.toString(16)),e+="&#"+r+";";return e}class Bo{constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||jl,this.options.tokenizer=this.options.tokenizer||new ow,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:Je.normal,inline:De.normal};this.options.pedantic?(n.block=Je.pedantic,n.inline=De.pedantic):this.options.gfm&&(n.block=Je.gfm,this.options.breaks?n.inline=De.breaks:n.inline=De.gfm),this.tokenizer.rules=n}static get rules(){return{block:Je,inline:De}}static lex(e,n){return new Bo(n).lex(e)}static lexInline(e,n){return new Bo(n).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,` +`),this.blockTokens(e,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(e,n=[]){this.options.pedantic?e=e.replace(/\t/g," ").replace(/^ +$/gm,""):e=e.replace(/^( *)(\t+)/gm,(l,a,u)=>a+" ".repeat(u.length));let r,i,s,o;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(l=>(r=l.call({lexer:this},e,n))?(e=e.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=` +`:n.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=` +`+r.raw,i.text+=` +`+r.text,this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=` +`+r.raw,i.text+=` +`+r.raw,this.inlineQueue[this.inlineQueue.length-1].src=i.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),n.push(r);continue}if(s=e,this.options.extensions&&this.options.extensions.startBlock){let l=1/0;const a=e.slice(1);let u;this.options.extensions.startBlock.forEach(function(c){u=c.call({lexer:this},a),typeof u=="number"&&u>=0&&(l=Math.min(l,u))}),l<1/0&&l>=0&&(s=e.substring(0,l+1))}if(this.state.top&&(r=this.tokenizer.paragraph(s))){i=n[n.length-1],o&&i.type==="paragraph"?(i.raw+=` +`+r.raw,i.text+=` +`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r),o=s.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&i.type==="text"?(i.raw+=` +`+r.raw,i.text+=` +`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r);continue}if(e){const l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let r,i,s,o=e,l,a,u;if(this.tokens.links){const c=Object.keys(this.tokens.links);if(c.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(o))!=null;)c.includes(l[0].slice(l[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,l.index)+"["+rx("a",l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(l=this.tokenizer.rules.inline.blockSkip.exec(o))!=null;)o=o.slice(0,l.index)+"["+rx("a",l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(l=this.tokenizer.rules.inline.escapedEmSt.exec(o))!=null;)o=o.slice(0,l.index+l[0].length-2)+"++"+o.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;e;)if(a||(u=""),a=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(c=>(r=c.call({lexer:this},e,n))?(e=e.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&r.type==="text"&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length),i=n[n.length-1],i&&r.type==="text"&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(e,o,u)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(e,sx)){e=e.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e,sx))){e=e.substring(r.raw.length),n.push(r);continue}if(s=e,this.options.extensions&&this.options.extensions.startInline){let c=1/0;const f=e.slice(1);let d;this.options.extensions.startInline.forEach(function(h){d=h.call({lexer:this},f),typeof d=="number"&&d>=0&&(c=Math.min(c,d))}),c<1/0&&c>=0&&(s=e.substring(0,c+1))}if(r=this.tokenizer.inlineText(s,h4)){e=e.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=r.raw.slice(-1)),a=!0,i=n[n.length-1],i&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(e){const c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return n}}class lw{constructor(e){this.options=e||jl}code(e,n,r){const i=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(e,i);s!=null&&s!==e&&(r=!0,e=s)}return e=e.replace(/\n$/,"")+` +`,i?'
    '+(r?e:gr(e,!0))+`
    +`:"
    "+(r?e:gr(e,!0))+`
    +`}blockquote(e){return`
    +${e}
    +`}html(e){return e}heading(e,n,r,i){if(this.options.headerIds){const s=this.options.headerPrefix+i.slug(r);return`${e} +`}return`${e} +`}hr(){return this.options.xhtml?`
    +`:`
    +`}list(e,n,r){const i=n?"ol":"ul",s=n&&r!==1?' start="'+r+'"':"";return"<"+i+s+`> +`+e+" +`}listitem(e){return`
  • ${e}
  • +`}checkbox(e){return" "}paragraph(e){return`

    ${e}

    +`}table(e,n){return n&&(n=`${n}`),` + +`+e+` +`+n+`
    +`}tablerow(e){return` +${e} +`}tablecell(e,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+e+` +`}strong(e){return`${e}`}em(e){return`${e}`}codespan(e){return`${e}`}br(){return this.options.xhtml?"
    ":"
    "}del(e){return`${e}`}link(e,n,r){if(e=tx(this.options.sanitize,this.options.baseUrl,e),e===null)return r;let i='
    ",i}image(e,n,r){if(e=tx(this.options.sanitize,this.options.baseUrl,e),e===null)return r;let i=`${r}":">",i}text(e){return e}}class uE{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,n,r){return""+r}image(e,n,r){return""+r}br(){return""}}class cE{constructor(){this.seen={}}serialize(e){return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(e,n){let r=e,i=0;if(this.seen.hasOwnProperty(r)){i=this.seen[e];do i++,r=e+"-"+i;while(this.seen.hasOwnProperty(r))}return n||(this.seen[e]=i,this.seen[r]=0),r}slug(e,n={}){const r=this.serialize(e);return this.getNextSafeSlug(r,n.dryrun)}}let hf=class H0{constructor(e){this.options=e||jl,this.options.renderer=this.options.renderer||new lw,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new uE,this.slugger=new cE}static parse(e,n){return new H0(n).parse(e)}static parseInline(e,n){return new H0(n).parseInline(e)}parse(e,n=!0){let r="",i,s,o,l,a,u,c,f,d,h,p,g,b,m,v,w,k,x,C;const T=e.length;for(i=0;i0&&v.tokens[0].type==="paragraph"?(v.tokens[0].text=x+" "+v.tokens[0].text,v.tokens[0].tokens&&v.tokens[0].tokens.length>0&&v.tokens[0].tokens[0].type==="text"&&(v.tokens[0].tokens[0].text=x+" "+v.tokens[0].tokens[0].text)):v.tokens.unshift({type:"text",text:x}):m+=x),m+=this.parse(v.tokens,b),d+=this.renderer.listitem(m,k,w);r+=this.renderer.list(d,p,g);continue}case"html":{r+=this.renderer.html(h.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(h.tokens));continue}case"text":{for(d=h.tokens?this.parseInline(h.tokens):h.text;i+1{if(r.message+=` +Please report this to https://github.com/markedjs/marked.`,t){const i="

    An error occurred:

    "+gr(r.message+"",!0)+"
    ";if(e)return Promise.resolve(i);if(n){n(null,i);return}return i}if(e)return Promise.reject(r);if(n){n(r);return}throw r}}function fE(t,e){return(n,r,i)=>{typeof r=="function"&&(i=r,r=null);const s={...r};r={...et.defaults,...s};const o=p4(r.silent,r.async,i);if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(f4(r),r.hooks&&(r.hooks.options=r),i){const l=r.highlight;let a;try{r.hooks&&(n=r.hooks.preprocess(n)),a=t(n,r)}catch(f){return o(f)}const u=function(f){let d;if(!f)try{r.walkTokens&&et.walkTokens(a,r.walkTokens),d=e(a,r),r.hooks&&(d=r.hooks.postprocess(d))}catch(h){f=h}return r.highlight=l,f?o(f):i(null,d)};if(!l||l.length<3||(delete r.highlight,!a.length))return u();let c=0;et.walkTokens(a,function(f){f.type==="code"&&(c++,setTimeout(()=>{l(f.text,f.lang,function(d,h){if(d)return u(d);h!=null&&h!==f.text&&(f.text=h,f.escaped=!0),c--,c===0&&u()})},0))}),c===0&&u();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(l=>t(l,r)).then(l=>r.walkTokens?Promise.all(et.walkTokens(l,r.walkTokens)).then(()=>l):l).then(l=>e(l,r)).then(l=>r.hooks?r.hooks.postprocess(l):l).catch(o);try{r.hooks&&(n=r.hooks.preprocess(n));const l=t(n,r);r.walkTokens&&et.walkTokens(l,r.walkTokens);let a=e(l,r);return r.hooks&&(a=r.hooks.postprocess(a)),a}catch(l){return o(l)}}}function et(t,e,n){return fE(Bo.lex,hf.parse)(t,e,n)}et.options=et.setOptions=function(t){return et.defaults={...et.defaults,...t},QF(et.defaults),et};et.getDefaults=sE;et.defaults=jl;et.use=function(...t){const e=et.defaults.extensions||{renderers:{},childTokens:{}};t.forEach(n=>{const r={...n};if(r.async=et.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if(i.renderer){const s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let l=i.renderer.apply(this,o);return l===!1&&(l=s.apply(this,o)),l}:e.renderers[i.name]=i.renderer}if(i.tokenizer){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");e[i.level]?e[i.level].unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){const i=et.defaults.renderer||new lw;for(const s in n.renderer){const o=i[s];i[s]=(...l)=>{let a=n.renderer[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.renderer=i}if(n.tokenizer){const i=et.defaults.tokenizer||new ow;for(const s in n.tokenizer){const o=i[s];i[s]=(...l)=>{let a=n.tokenizer[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.tokenizer=i}if(n.hooks){const i=et.defaults.hooks||new _h;for(const s in n.hooks){const o=i[s];_h.passThroughHooks.has(s)?i[s]=l=>{if(et.defaults.async)return Promise.resolve(n.hooks[s].call(i,l)).then(u=>o.call(i,u));const a=n.hooks[s].call(i,l);return o.call(i,a)}:i[s]=(...l)=>{let a=n.hooks[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.hooks=i}if(n.walkTokens){const i=et.defaults.walkTokens;r.walkTokens=function(s){let o=[];return o.push(n.walkTokens.call(this,s)),i&&(o=o.concat(i.call(this,s))),o}}et.setOptions(r)})};et.walkTokens=function(t,e){let n=[];for(const r of t)switch(n=n.concat(e.call(et,r)),r.type){case"table":{for(const i of r.header)n=n.concat(et.walkTokens(i.tokens,e));for(const i of r.rows)for(const s of i)n=n.concat(et.walkTokens(s.tokens,e));break}case"list":{n=n.concat(et.walkTokens(r.items,e));break}default:et.defaults.extensions&&et.defaults.extensions.childTokens&&et.defaults.extensions.childTokens[r.type]?et.defaults.extensions.childTokens[r.type].forEach(function(i){n=n.concat(et.walkTokens(r[i],e))}):r.tokens&&(n=n.concat(et.walkTokens(r.tokens,e)))}return n};et.parseInline=fE(Bo.lexInline,hf.parseInline);et.Parser=hf;et.parser=hf.parse;et.Renderer=lw;et.TextRenderer=uE;et.Lexer=Bo;et.lexer=Bo.lex;et.Tokenizer=ow;et.Slugger=cE;et.Hooks=_h;et.parse=et;et.options;et.setOptions;et.use;et.walkTokens;et.parseInline;hf.parse;Bo.lex;const g4=ai("div")({name:"MarkdownContainer",class:"gdg-mnuv029",propsAsIs:!1});class m4 extends Kn.PureComponent{constructor(){super(...arguments);kt(this,"targetElement",null);kt(this,"containerRefHook",n=>{this.targetElement=n,this.renderMarkdownIntoDiv()})}renderMarkdownIntoDiv(){const{targetElement:n,props:r}=this;if(n===null)return;const{contents:i,createNode:s}=r,o=et(i),l=document.createRange();l.selectNodeContents(n),l.deleteContents();let a=s==null?void 0:s(o);if(a===void 0){const c=document.createElement("template");c.innerHTML=o,a=c.content}n.append(a);const u=n.getElementsByTagName("a");for(const c of u)c.target="_blank",c.rel="noreferrer noopener"}render(){return this.renderMarkdownIntoDiv(),Kn.createElement(g4,{ref:this.containerRefHook})}}const y4=ai("textarea")({name:"InputBox",class:"gdg-izpuzkl",propsAsIs:!1}),v4=ai("div")({name:"ShadowBox",class:"gdg-s69h75o",propsAsIs:!1}),w4=ai("div")({name:"GrowingEntryStyle",class:"gdg-g1y0xocz",propsAsIs:!1});let ox=0;const $p=t=>{const{placeholder:e,value:n,onKeyDown:r,highlight:i,altNewline:s,validatedSelection:o,...l}=t,{onChange:a,className:u}=l,c=y.useRef(null),f=n??"";ei(a!==void 0,"GrowingEntry must be a controlled input area");const[d]=y.useState(()=>"input-box-"+(ox=(ox+1)%1e7));y.useEffect(()=>{const p=c.current;if(p===null||p.disabled)return;const g=f.toString().length;p.focus(),p.setSelectionRange(i?0:g,g)},[]),y.useLayoutEffect(()=>{var p;if(o!==void 0){const g=typeof o=="number"?[o,null]:o;(p=c.current)==null||p.setSelectionRange(g[0],g[1])}},[o]);const h=y.useCallback(p=>{p.key==="Enter"&&p.shiftKey&&s===!0||r==null||r(p)},[s,r]);return y.createElement(w4,{className:"gdg-growing-entry"},y.createElement(v4,{className:u},f+` +`),y.createElement(y4,{...l,className:(u??"")+" gdg-input",id:d,ref:c,onKeyDown:h,value:f,placeholder:e,dir:"auto"}))},Zg={};let co=null;function b4(){const t=document.createElement("div");return t.style.opacity="0",t.style.pointerEvents="none",t.style.position="fixed",document.body.append(t),t}function W0(t){const e=t.toLowerCase().trim();if(Zg[e]!==void 0)return Zg[e];co=co||b4(),co.style.color="#000",co.style.color=e;const n=getComputedStyle(co).color;co.style.color="#fff",co.style.color=e;const r=getComputedStyle(co).color;if(r!==n)return[0,0,0,1];let i=r.replace(/[^\d.,]/g,"").split(",").map(Number.parseFloat);return i.length<4&&i.push(1),i=i.map(s=>Number.isNaN(s)?0:s),Zg[e]=i,i}function Il(t,e){const[n,r,i]=W0(t);return`rgba(${n}, ${r}, ${i}, ${e})`}const lx=new Map;function ax(t,e){const n=`${t}-${e}`,r=lx.get(n);if(r!==void 0)return r;const i=ti(t,e);return lx.set(n,i),i}function ti(t,e){if(e===void 0)return t;const[n,r,i,s]=W0(t);if(s===1)return t;const[o,l,a,u]=W0(e),c=s+u*(1-s),f=(s*n+u*o*(1-s))/c,d=(s*r+u*l*(1-s))/c,h=(s*i+u*a*(1-s))/c;return`rgba(${f}, ${d}, ${h}, ${c})`}var la=new Map,ka=new Map,V0=new Map;function x4(){la.clear(),V0.clear(),ka.clear()}function k4(t,e,n,r,i){var s,o,l;let a=0,u={};for(let f of t)a+=(s=n.get(f))!=null?s:i,u[f]=((o=u[f])!=null?o:0)+1;let c=e-a;for(let f of Object.keys(u)){let d=u[f],h=(l=n.get(f))!=null?l:i,p=h*d/a,g=c*p*r/d,b=h+g;n.set(f,b)}}function S4(t,e){var n;let r=new Map,i=0;for(let u of"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890,.-+=?"){let c=t.measureText(u).width;r.set(u,c),i+=c}let s=i/r.size,o=3,l=(e/s+o)/(o+1),a=r.keys();for(let u of a)r.set(u,((n=r.get(u))!=null?n:s)*l);return r}function pc(t,e,n,r){var i,s;let o=ka.get(n);if(r&&o!==void 0&&o.count>2e4){let u=V0.get(n);if(u===void 0&&(u=S4(t,o.size),V0.set(n,u)),o.count>5e5){let f=0;for(let d of e)f+=(i=u.get(d))!=null?i:o.size;return f*1.01}let c=t.measureText(e);return k4(e,c.width,u,Math.max(.05,1-o.count/2e5),o.size),ka.set(n,{count:o.count+e.length,size:o.size}),c.width}let l=t.measureText(e),a=l.width/e.length;if(((s=o==null?void 0:o.count)!=null?s:0)>2e4)return l.width;if(o===void 0)ka.set(n,{count:e.length,size:a});else{let u=a-o.size,c=e.length/(o.count+e.length),f=o.size+u*c;ka.set(n,{count:o.count+e.length,size:f})}return l.width}function C4(t,e,n,r,i,s,o,l){if(e.length<=1)return e.length;if(in;){let c=e.lastIndexOf(" ",a-1);c>0?a=c:a--,u=pc(t,e.slice(0,Math.max(0,a)),r,o)}if(e[a]!==" "){let c=0;c=e.lastIndexOf(" ",a),c>0&&(a=c)}return a}function T4(t,e,n,r,i,s){let o=`${e}_${n}_${r}px`,l=la.get(o);if(l!==void 0)return l;if(r<=0)return[];let a=[],u=e.split(` +`),c=ka.get(n),f=c===void 0?e.length:r/c.size*1.5,d=i&&c!==void 0&&c.count>2e4;for(let h of u){let p=pc(t,h.slice(0,Math.max(0,f)),n,d),g=Math.min(h.length,f);if(p<=r)a.push(h);else{for(;p>r;){let b=C4(t,h,r,n,p,g,d),m=h.slice(0,Math.max(0,b));h=h.slice(m.length),a.push(m),p=pc(t,h.slice(0,Math.max(0,f)),n,d),g=Math.min(h.length,f)}p>0&&a.push(h)}}return a=a.map((h,p)=>p===0?h.trimEnd():h.trim()),la.set(o,a),la.size>500&&la.delete(la.keys().next().value),a}function E4(t,e){return Kn.useMemo(()=>t.map((n,r)=>({group:n.group,grow:n.grow,hasMenu:n.hasMenu,icon:n.icon,id:n.id,menuIcon:n.menuIcon,overlayIcon:n.overlayIcon,sourceIndex:r,sticky:r=s.x&&n=s.y&&r=e.span[0]&&n.current.cell[0]<=e.span[1]}function dE(t,e){const[n,r]=t;return n>=e.x&&n=e.y&&ro)return!1;if(e.span===void 0)return l>=r&&l<=i;const[u,c]=e.span;return u>=r&&u<=i||c>=r&&u<=i||ui}function R4(t,e,n,r){let i=0;if(n.current===void 0)return i;const s=n.current.range;(r||s.height*s.width>1)&&ux(t,e,s)&&i++;for(const o of n.current.rangeStack)ux(t,e,o)&&i++;return i}function pE(t,e){let n=t;if(e!==void 0){let r=[...t];const i=n[e.src];e.src>e.dest?(r.splice(e.src,1),r.splice(e.dest,0,i)):(r.splice(e.dest+1,0,i),r.splice(e.src,1)),r=r.map((s,o)=>({...s,sticky:t[o].sticky})),n=r}return n}function Ga(t,e){let n=0;const r=pE(t,e);for(let i=0;i0)for(const u of o)n-=u.width;let l=e,a=i??0;for(;a<=n&&l=f)return g}const d=s-u,h=t-(a??0);if(typeof o=="number"){const p=Math.floor((h-c)/o)+l;return p>=d?void 0:p}else{let p=c;for(let g=l;g"u";async function N4(){var t;I4||((t=document==null?void 0:document.fonts)==null?void 0:t.ready)===void 0||(await document.fonts.ready,Ud=0,mc={},x4())}N4();function gE(t,e,n,r){return`${t}_${r??(e==null?void 0:e.font)}_${n}`}function pf(t,e,n,r="middle"){const i=gE(t,e,r,n);let s=mc[i];return s===void 0&&(s=e.measureText(t),mc[i]=s,Ud++),Ud>1e4&&(mc={},Ud=0),s}function _4(t,e){const n=gE(t,void 0,"middle",e);return mc[n]}function Js(t,e){return typeof e!="string"&&(e=e.baseFontFull),D4(t,e)}function cx(t,e){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ";t.save(),t.textBaseline=e;const r=t.measureText(n);return t.restore(),r}const fx=[];function D4(t,e){for(const s of fx)if(s.key===e)return s.val;const n=cx(t,"alphabetic"),i=-(cx(t,"middle").actualBoundingBoxDescent-n.actualBoundingBoxDescent)+n.actualBoundingBoxAscent/2;return fx.push({key:e,val:i}),i}function L4(t,e,n,r,i,s){const{ctx:o,rect:l,theme:a}=t;let u=Number.MAX_SAFE_INTEGER;const c=500;if(e!==void 0&&(u=n-e,un&&(t=t.slice(0,n)),t}function F4(t,e,n,r,i,s,o,l,a,u){const c=l.baseFontFull,f=T4(t,e,c,i-l.cellHorizontalPadding*2,u??!1),d=yE(t,c),h=l.lineHeight*d,p=d+h*(f.length-1),g=p+l.cellVerticalPadding>s;g&&(t.save(),t.rect(n,r,i,s),t.clip());const b=r+s/2-p/2;let m=Math.max(r+l.cellVerticalPadding,b);for(const v of f)if(mE(t,v,n,m,i,d,o,l,a),m+=h,m>r+s)break;g&&t.restore()}function Fs(t,e,n,r,i){const{ctx:s,rect:o,theme:l}=t,{x:a,y:u,width:c,height:f}=o;r=r??!1,r||(e=$4(e,c));const d=Js(s,l),h=sw(e)==="rtl";if(n===void 0&&h&&(n="right"),h&&(s.direction="rtl"),e.length>0){let p=!1;n==="right"?(s.textAlign="right",p=!0):n!==void 0&&n!=="left"&&(s.textAlign=n,p=!0),r?F4(s,e,a,u,c,f,d,l,n,i):mE(s,e,a,u,c,f,d,l,n),p&&(s.textAlign="start"),h&&(s.direction="inherit")}}function Ts(t,e,n,r,i,s){typeof s=="number"&&(s={tl:s,tr:s,br:s,bl:s}),s={tl:Math.max(0,Math.min(s.tl,i/2,r/2)),tr:Math.max(0,Math.min(s.tr,i/2,r/2)),bl:Math.max(0,Math.min(s.bl,i/2,r/2)),br:Math.max(0,Math.min(s.br,i/2,r/2))},t.moveTo(e+s.tl,n),t.arcTo(e+r,n,e+r,n+s.tr,s.tr),t.arcTo(e+r,n+i,e+r-s.br,n+i,s.br),t.arcTo(e,n+i,e,n+i-s.bl,s.bl),t.arcTo(e,n,e+s.tl,n,s.tl)}function z4(t,e,n){t.arc(e,n-1.25*3.5,1.25,0,2*Math.PI,!1),t.arc(e,n,1.25,0,2*Math.PI,!1),t.arc(e,n+1.25*3.5,1.25,0,2*Math.PI,!1)}function B4(t,e,n){const r=function(l,a){const u=a.x-l.x,c=a.y-l.y,f=Math.sqrt(u*u+c*c),d=u/f,h=c/f;return{x:u,y:a.y-l.y,len:f,nx:d,ny:h,ang:Math.atan2(h,d)}};let i;const s=e.length;let o=e[s-1];for(let l=0;l1?1:d),g=1,b=!1;h<0?p<0?p=Math.PI+p:(p=Math.PI-p,g=-1,b=!0):p>0&&(g=-1,b=!0),i=a.radius!==void 0?a.radius:n;const m=p/2;let v=Math.abs(Math.cos(m)*i/Math.sin(m)),w;v>Math.min(c.len/2,f.len/2)?(v=Math.min(c.len/2,f.len/2),w=Math.abs(v*Math.sin(m)/Math.cos(m))):w=i;let k=a.x+f.nx*v,x=a.y+f.ny*v;k+=-f.ny*w*g,x+=f.nx*w*g,t.arc(k,x,w,c.ang+Math.PI/2*g,f.ang-Math.PI/2*g,b),o=a,a=u}t.closePath()}function K0(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p){const g={x:0,y:s+u,width:0,height:0};if(t>=h.length||e>=c||e<-2||t<0)return g;const b=s-i;if(t>=f){const m=o>t?-1:1,v=Ga(h);g.x+=v+a;for(let w=o;w!==t;w+=m)g.x+=h[m===1?w:w-1].width*m}else for(let m=0;m0&&Vc(h[m-1].group,v)&&h[m-1].sticky===w;){const x=h[m-1];g.x-=x.width,g.width+=x.width,m--}let k=t;for(;k+1n&&(g.width=n-g.x)}}else if(e>=c-d){let m=c-e;for(g.y=r;m>0;){const v=e+m-1;g.height=typeof p=="number"?p:p(v),g.y-=g.height,m--}g.height+=1}else{const m=l>e?-1:1;if(typeof p=="number"){const v=e-l;g.y+=v*p}else for(let v=l;v!==e;v+=m)g.y+=p(v)*m;g.height=(typeof p=="number"?p:p(e))+1}return g}const aw=1<<21;function Vi(t,e){return(e+2)*aw+t}function vE(t){return t%aw}function uw(t){return Math.floor(t/aw)-2}function cw(t){const e=vE(t),n=uw(t);return[e,n]}class wE{constructor(){kt(this,"visibleWindow",{x:0,y:0,width:0,height:0});kt(this,"freezeCols",0);kt(this,"freezeRows",[]);kt(this,"isInWindow",e=>{const n=vE(e),r=uw(e),i=this.visibleWindow,s=n>=i.x&&n<=i.x+i.width||n=i.y&&r<=i.y+i.height||this.freezeRows.includes(r);return s&&o})}setWindow(e,n,r){this.visibleWindow.x===e.x&&this.visibleWindow.y===e.y&&this.visibleWindow.width===e.width&&this.visibleWindow.height===e.height&&this.freezeCols===n&&Xa(this.freezeRows,r)||(this.visibleWindow=e,this.freezeCols=n,this.freezeRows=r,this.clearOutOfWindow())}}class j4 extends wE{constructor(){super(...arguments);kt(this,"cache",new Map);kt(this,"setValue",(n,r)=>{this.cache.set(Vi(n[0],n[1]),r)});kt(this,"getValue",n=>this.cache.get(Vi(n[0],n[1])));kt(this,"clearOutOfWindow",()=>{for(const[n]of this.cache.entries())this.isInWindow(n)||this.cache.delete(n)})}}class yc{constructor(e=[]){kt(this,"cells");this.cells=new Set(e.map(n=>Vi(n[0],n[1])))}add(e){this.cells.add(Vi(e[0],e[1]))}has(e){return e===void 0?!1:this.cells.has(Vi(e[0],e[1]))}remove(e){this.cells.delete(Vi(e[0],e[1]))}clear(){this.cells.clear()}get size(){return this.cells.size}hasHeader(){for(const e of this.cells)if(uw(e)<0)return!0;return!1}hasItemInRectangle(e){for(let n=e.y;n{const h=V4(t,d[r],e,a);return u=Math.max(u,h),h});if(c.length>5&&l){u=0;let d=0;for(const p of c)d+=p;const h=d/c.length;for(let p=0;p=h*2?c[p]=0:u=Math.max(u,c[p])}u=Math.max(u,t.measureText(n.title).width+16+(n.icon===void 0?0:28));const f=Math.max(Math.ceil(s),Math.min(Math.floor(o),Math.ceil(u)));return{...n,width:f}}function U4(t,e,n,r,i,s,o,l,a){const u=y.useRef(e),c=y.useRef(n),f=y.useRef(o);u.current=e,c.current=n,f.current=o;const[d,h]=y.useMemo(()=>{if(typeof window>"u")return[null,null];const v=document.createElement("canvas");return v.style.display="none",v.style.opacity="0",v.style.position="fixed",[v,v.getContext("2d",{alpha:!1})]},[]);y.useLayoutEffect(()=>(d&&document.documentElement.append(d),()=>{d==null||d.remove()}),[d]);const p=y.useRef({}),g=y.useRef(),[b,m]=y.useState();return y.useLayoutEffect(()=>{const v=c.current;if(v===void 0||t.every(Zf))return;let w=Math.max(1,10-Math.floor(t.length/1e4)),k=0;w1&&(w--,k=1);const x={x:0,y:0,width:t.length,height:Math.min(u.current,w)},C={x:0,y:u.current-1,width:t.length,height:1};(async()=>{const A=v(x,a.signal),M=k>0?v(C,a.signal):void 0;let I;typeof A=="object"?I=A:I=await Bb(A),M!==void 0&&(typeof M=="object"?I=[...I,...M]:I=[...I,...await Bb(M)]),g.current=t,m(I)})()},[a.signal,t]),y.useMemo(()=>{let w=t.every(Zf)?t:h===null?t.map(T=>Zf(T)?T:{...T,width:X0}):(h.font=f.current.baseFontFull,t.map((T,A)=>{if(Zf(T))return T;if(p.current[T.id]!==void 0)return{...T,width:p.current[T.id]};if(b===void 0||g.current!==t||T.id===void 0)return{...T,width:X0};const M=kE(h,o,T,A,b,i,s,!0,l);return p.current[T.id]=M.width,M})),k=0,x=0;const C=[];for(const[T,A]of w.entries())k+=A.width,A.grow!==void 0&&A.grow>0&&(x+=A.grow,C.push(T));if(k0){const T=[...w],A=r-k;let M=A;for(let I=0;I0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=Promise.allSettled(n.map(a=>{if(a=X4(a),a in dx)return;dx[a]=!0;const u=a.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${a}"]${c}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":K4,u||(f.as="script"),f.crossOrigin="",f.href=a,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((d,h)=>{f.addEventListener("load",d),f.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${a}`)))})}))}function s(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return i.then(o=>{for(const l of o||[])l.status==="rejected"&&s(l.reason);return e().catch(s)})};function G4(t,e,n){return t===t&&(n!==void 0&&(t=t<=n?t:n),e!==void 0&&(t=t>=e?t:e)),t}var q4=G4,Y4=q4,em=rw;function J4(t,e,n){return n===void 0&&(n=e,e=void 0),n!==void 0&&(n=em(n),n=n===n?n:0),e!==void 0&&(e=em(e),e=e===e?e:0),Y4(em(t),e,n)}var Q4=J4;const Wi=es(Q4);var Z4="__lodash_hash_undefined__";function e5(t){return this.__data__.set(t,Z4),this}var t5=e5;function n5(t){return this.__data__.has(t)}var r5=n5,i5=Gv,s5=t5,o5=r5;function Dh(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new i5;++e-1}var b5=w5;function x5(t,e,n){for(var r=-1,i=t==null?0:t.length;++r=j5){var u=e?null:z5(t);if(u)return B5(u);o=!1,i=F5,a=new D5}else a=e?[]:l;e:for(;++r0&&n(l)?e>1?ME(l,e-1,n,r,i):Z5(i,l):r||(i[i.length]=l)}return i}var tz=ME,nz=tz;function rz(t){var e=t==null?0:t.length;return e?nz(t,1):[]}var iz=rz;const gx=es(iz);var sz=Math.ceil,oz=Math.max;function lz(t,e,n,r){for(var i=-1,s=oz(sz((e-t)/(n||1)),0),o=Array(s);s--;)o[r?s:++i]=t,t+=n;return o}var az=lz,uz=zT,cz=Qv;function fz(t){return t!=null&&cz(t.length)&&!uz(t)}var dw=fz,dz=Kv,hz=dw,pz=Jv,gz=zl;function mz(t,e,n){if(!gz(n))return!1;var r=typeof e;return(r=="number"?hz(n)&&pz(e,n.length):r=="string"&&e in n)?dz(n[e],t):!1}var yz=mz,vz=rw,mx=1/0,wz=17976931348623157e292;function bz(t){if(!t)return t===0?t:0;if(t=vz(t),t===mx||t===-mx){var e=t<0?-1:1;return e*wz}return t===t?t:0}var xz=bz,kz=az,Sz=yz,nm=xz;function Cz(t){return function(e,n,r){return r&&typeof r!="number"&&Sz(e,n,r)&&(n=r=void 0),e=nm(e),n===void 0?(n=e,e=0):n=nm(n),r=r===void 0?e{g.drawImage(b,0,0,f,f)}).finally(()=>{this.inFlight--,this.inFlight===0&&this.onSettled()})}else a<1&&(r.globalAlpha=a),r.drawImage(h,0,0,f,f,i,s,o,o),a<1&&(r.globalAlpha=1)}}function RE(t){if(t.length===0)return;let e;for(const n of t)e=Math.min(e??n.y,n.y)}function Fp(t,e,n,r,i,s,o,l,a){l=l??e;let u=e,c=t;const f=r-s;let d=!1;for(;ul&&a(u,c,h,!1,o&&c===r-1)===!0){d=!0;break}u+=h,c++}if(!d){u=n;for(let h=0;h!h.sticky))==null?void 0:d.sourceIndex)??0;if(a>f){const h=Math.max(l,f);let p=e,g=r;for(let b=s.sourceIndex-1;b>=h;b--)p-=o[b].width,g+=o[b].width;for(let b=s.sourceIndex+1;b<=a;b++)g+=o[b].width;c={x:p,y:n,width:g,height:i}}if(f>l){const h=Math.min(a,f-1);let p=e,g=r;for(let b=s.sourceIndex-1;b>=l;b--)p-=o[b].width,g+=o[b].width;for(let b=s.sourceIndex+1;b<=h;b++)g+=o[b].width;u={x:p,y:n,width:g,height:i}}return[u,c]}function Pz(t,e,n,r){if(r==="any")return IE(t,{x:e,y:n,width:1,height:1});if(r==="vertical"&&(e=t.x),r==="horizontal"&&(n=t.y),dE([e,n],t))return;const i=e-t.x,s=t.x+t.width-e,o=n-t.y+1,l=t.y+t.height-n,a=Math.min(r==="vertical"?Number.MAX_SAFE_INTEGER:i,r==="vertical"?Number.MAX_SAFE_INTEGER:s,r==="horizontal"?Number.MAX_SAFE_INTEGER:o,r==="horizontal"?Number.MAX_SAFE_INTEGER:l);return a===l?{x:t.x,y:t.y+t.height,width:t.width,height:n-t.y-t.height+1}:a===o?{x:t.x,y:n,width:t.width,height:t.y-n}:a===s?{x:t.x+t.width,y:t.y,width:e-t.x-t.width+1,height:t.height}:{x:e,y:t.y,width:t.x-e,height:t.height}}function Lh(t,e,n,r,i,s,o,l){return t<=i+o&&i<=t+n&&e<=s+l&&s<=e+r}function zp(t,e,n){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height}function IE(t,e){const n=Math.min(t.x,e.x),r=Math.min(t.y,e.y),i=Math.max(t.x+t.width,e.x+e.width)-n,s=Math.max(t.y+t.height,e.y+e.height)-r;return{x:n,y:r,width:i,height:s}}function Iz(t,e){return t.x<=e.x&&t.y<=e.y&&t.x+t.width>=e.x+e.width&&t.y+t.height>=e.y+e.height}function Nz(t,e,n,r){if(t.x>e||t.y>n||t.x<0&&t.y<0&&t.x+t.width>e&&t.y+t.height>n)return;if(t.x>=0&&t.y>=0&&t.x+t.width<=e&&t.y+t.height<=n)return t;const i=-4,s=-4,o=e+4,l=n+4,a=i-t.x,u=t.x+t.width-o,c=s-t.y,f=t.y+t.height-l,d=a>0?t.x+Math.floor(a/r)*r:t.x,h=u>0?t.x+t.width-Math.floor(u/r)*r:t.x+t.width,p=c>0?t.y+Math.floor(c/r)*r:t.y,g=f>0?t.y+t.height-Math.floor(f/r)*r:t.y+t.height;return{x:d,y:p,width:h-d,height:g-p}}function _z(t,e,n,r,i){const[s,o,l,a]=e,[u,c,f,d]=i,{x:h,y:p,width:g,height:b}=t,m=[];if(g<=0||b<=0)return m;const v=h+g,w=p+b,k=hl,T=p+b>a,A=h>=s&&hs&&v<=l||hl,M=p>=o&&po&&w<=a||pa;if(A&&M){const D=Math.max(h,s),O=Math.max(p,o),L=Math.min(v,l),_=Math.min(w,a);m.push({rect:{x:D,y:O,width:L-D,height:_-O},clip:{x:u,y:c,width:f-u+1,height:d-c+1}})}if(k&&x){const D=h,O=p,L=Math.min(v,s),_=Math.min(w,o);m.push({rect:{x:D,y:O,width:L-D,height:_-O},clip:{x:0,y:0,width:u+1,height:c+1}})}if(x&&A){const D=Math.max(h,s),O=p,L=Math.min(v,l),_=Math.min(w,o);m.push({rect:{x:D,y:O,width:L-D,height:_-O},clip:{x:u,y:0,width:f-u+1,height:c+1}})}if(x&&C){const D=Math.max(h,l),O=p,L=v,_=Math.min(w,o);m.push({rect:{x:D,y:O,width:L-D,height:_-O},clip:{x:f,y:0,width:n-f+1,height:c+1}})}if(k&&M){const D=h,O=Math.max(p,o),L=Math.min(v,s),_=Math.min(w,a);m.push({rect:{x:D,y:O,width:L-D,height:_-O},clip:{x:0,y:c,width:u+1,height:d-c+1}})}if(C&&M){const D=Math.max(h,l),O=Math.max(p,o),L=v,_=Math.min(w,a);m.push({rect:{x:D,y:O,width:L-D,height:_-O},clip:{x:f,y:c,width:n-f+1,height:d-c+1}})}if(k&&T){const D=h,O=Math.max(p,a),L=Math.min(v,s),_=w;m.push({rect:{x:D,y:O,width:L-D,height:_-O},clip:{x:0,y:d,width:u+1,height:r-d+1}})}if(T&&A){const D=Math.max(h,s),O=Math.max(p,a),L=Math.min(v,l),_=w;m.push({rect:{x:D,y:O,width:L-D,height:_-O},clip:{x:u,y:d,width:f-u+1,height:r-d+1}})}if(C&&T){const D=Math.max(h,l),O=Math.max(p,a),L=v,_=w;m.push({rect:{x:D,y:O,width:L-D,height:_-O},clip:{x:f,y:d,width:n-f+1,height:r-d+1}})}return m}const Dz={kind:Ae.Loading,allowOverlay:!1};function yx(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,g,b,m,v,w,k,x,C,T,A,M,I,D,O,L,_,re,ie,se,H){let X=(w==null?void 0:w.size)??Number.MAX_SAFE_INTEGER;const R=performance.now();let N=L.baseFontFull;t.font=N;const P={ctx:t},B=[0,0],q=b>0?Hl(a,b,u):0;let W,ye;const ee=RE(v);return Go(e,l,s,o,i,(me,Le,Ue,ze,Mt)=>{const tt=Math.max(0,ze-Le),Be=Le+tt,ue=i+1,It=me.width-tt,be=r-i-1;if(v.length>0){let $e=!1;for(let nt=0;nt{t.save(),t.beginPath(),t.rect(Be,ue,It,be),t.clip()},Y=k.columns.hasIndex(me.sourceIndex),Se=f(me.group??"").overrideTheme,Ie=me.themeOverride===void 0&&Se===void 0?L:$o(L,Se,me.themeOverride),Ce=Ie.baseFontFull;Ce!==N&&(N=Ce,t.font=Ce),xe();let xt;return Fp(Mt,Ue,r,a,u,b,m,ee,($e,nt,ge,ot,rt)=>{var Zt,Tn,er;if(nt<0||(B[0]=me.sourceIndex,B[1]=nt,w!==void 0&&!w.has(B)))return;if(v.length>0){let pt=!1;for(let Wt=0;Wtmt.span!==void 0&&pt>=mt.span[0]&&pt<=mt.span[1]);Hn&&!p&&g?bn=0:Hn&&g&&(bn=Math.max(bn,1)),Yn&&bn++,Hn||(Ke&&bn++,Y&&!rt&&bn++);const Wr=mt.kind===Ae.Protected?jt.bgCellMedium:jt.bgCell;let Ht;if((ot||Wr!==L.bgCell)&&(Ht=ti(Wr,Ht)),bn>0||an){an&&(Ht=ti(jt.bgHeader,Ht));for(let pt=0;ptH&&!mn){const pt=jt.baseFontFull;pt!==N&&(t.font=pt,N=pt),xt=NE(t,mt,me.sourceIndex,nt,We,Lt,it,$e,dt,ge,bn>0,jt,Ht??jt.bgCell,T,A,(Qt==null?void 0:Qt.hoverAmount)??0,I,O,R,D,xt,_,re,ie,se)}return Qe&&t.restore(),mt.style==="faded"&&(t.globalAlpha=1),X--,Yt&&(t.restore(),(er=xt==null?void 0:xt.deprep)==null||er.call(xt,P),xt=void 0,xe(),N=Ce,t.font=Ce),X<=0}),t.restore(),X<=0}),W}const zu=[0,0],Bu={x:0,y:0,width:0,height:0},rm=[void 0,()=>{}];let G0=!1;function Lz(){G0=!0}function NE(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,g,b,m,v,w,k,x,C,T,A){var re,ie;let M,I;b!==void 0&&b[0][0]===n&&b[0][1]===r&&(M=b[1][0],I=b[1][1]);let D;zu[0]=n,zu[1]=r,Bu.x=o,Bu.y=l,Bu.width=a,Bu.height=u,rm[0]=C.getValue(zu),rm[1]=se=>C.setValue(zu,se),G0=!1;const O={ctx:t,theme:f,col:n,row:r,cell:e,rect:Bu,highlighted:c,cellFillColor:d,hoverAmount:g,frameTime:v,hoverX:M,drawState:rm,hoverY:I,imageLoader:h,spriteManager:p,hyperWrapping:m,overrideCursor:M!==void 0?A:void 0,requestAnimationFrame:Lz},L=L4(O,e.lastUpdated,v,k,i,s),_=T(e);if(_!==void 0){(k==null?void 0:k.renderer)!==_&&((re=k==null?void 0:k.deprep)==null||re.call(k,O),k=void 0);const se=(ie=_.drawPrep)==null?void 0:ie.call(_,O,k);w!==void 0&&!xa(O.cell)?w(O,()=>_.draw(O,e)):_.draw(O,e),D=se===void 0?void 0:{deprep:se==null?void 0:se.deprep,fillStyle:se==null?void 0:se.fillStyle,font:se==null?void 0:se.font,renderer:_}}return(L||G0)&&(x==null||x(zu)),D}function hw(t,e,n,r,i,s,o,l,a=-20,u=-20,c=32,f="center",d="square"){const h=Math.floor(i+o/2),p=d==="circle"?1e4:e.roundingRadius??4;let g=nE(c,o,e.cellVerticalPadding),b=g/2;const m=tE(f,r,s,e.cellHorizontalPadding,g),v=eE(m,h,g),w=rE(r+a,i+u,v);switch(n){case!0:{t.beginPath(),Ts(t,m-g/2,h-g/2,g,g,p),d==="circle"&&(b*=.8,g*=.8),t.fillStyle=l?e.accentColor:e.textMedium,t.fill(),t.beginPath(),t.moveTo(m-b+g/4.23,h-b+g/1.97),t.lineTo(m-b+g/2.42,h-b+g/1.44),t.lineTo(m-b+g/1.29,h-b+g/3.25),t.strokeStyle=e.bgCell,t.lineJoin="round",t.lineCap="round",t.lineWidth=1.9,t.stroke();break}case Mh:case!1:{t.beginPath(),Ts(t,m-g/2+.5,h-g/2+.5,g-1,g-1,p),t.lineWidth=1,t.strokeStyle=w?e.textDark:e.textMedium,t.stroke();break}case Zv:{t.beginPath(),Ts(t,m-g/2,h-g/2,g,g,p),t.fillStyle=w?e.textMedium:e.textLight,t.fill(),d==="circle"&&(b*=.8,g*=.8),t.beginPath(),t.moveTo(m-g/3,h),t.lineTo(m+g/3,h),t.strokeStyle=e.bgCell,t.lineCap="round",t.lineWidth=1.9,t.stroke();break}default:Wc()}}function $z(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,g,b,m,v){const w=o+l;if(w<=0)return;t.fillStyle=f.bgHeader,t.fillRect(0,0,i,w);const[k,x]=(r==null?void 0:r[0])??[],C=f.headerFontFull;t.font=C,Go(e,0,s,0,w,(T,A,M,I)=>{var P;if(b!==void 0&&!b.has([T.sourceIndex,-1]))return;const D=Math.max(0,I-A);t.save(),t.beginPath(),t.rect(A+D,l,T.width-D,o),t.clip();const O=g(T.group??"").overrideTheme,L=T.themeOverride===void 0&&O===void 0?f:$o(f,O,T.themeOverride);L.bgHeader!==f.bgHeader&&(t.fillStyle=L.bgHeader,t.fill()),L!==f&&(t.font=L.baseFontFull);const _=c.columns.hasIndex(T.sourceIndex),re=a!==void 0||u,ie=!re&&x===-1&&k===T.sourceIndex,se=re?0:((P=h.find(B=>B.item[0]===T.sourceIndex&&B.item[1]===-1))==null?void 0:P.hoverAmount)??0,H=(c==null?void 0:c.current)!==void 0&&c.current.cell[0]===T.sourceIndex,X=_?L.accentColor:H?L.bgHeaderHasFocus:L.bgHeader,R=n?l:0,N=T.sourceIndex===0?0:1;_?(t.fillStyle=X,t.fillRect(A+N,R,T.width-N,o)):(H||se>0)&&(t.beginPath(),t.rect(A+N,R,T.width-N,o),H&&(t.fillStyle=L.bgHeaderHasFocus,t.fill()),se>0&&(t.globalAlpha=se,t.fillStyle=L.bgHeaderHovered,t.fill(),t.globalAlpha=1)),LE(t,A,R,T.width,o,T,_,L,ie,H,se,d,m,v),t.restore()}),n&&Fz(t,e,i,s,l,r,f,d,h,p,g,b)}function Fz(t,e,n,r,i,s,o,l,a,u,c,f){const[h,p]=(s==null?void 0:s[0])??[];let g=0;OE(e,n,r,i,(b,m,v,w,k,x)=>{if(f!==void 0&&!f.hasItemInRectangle({x:b[0],y:-2,width:b[1]-b[0]+1,height:1}))return;t.save(),t.beginPath(),t.rect(v,w,k,x),t.clip();const C=c(m),T=(C==null?void 0:C.overrideTheme)===void 0?o:$o(o,C.overrideTheme),A=p===-2&&h!==void 0&&h>=b[0]&&h<=b[1],M=A?T.bgHeaderHovered:T.bgHeader;if(M!==o.bgHeader&&(t.fillStyle=M,t.fill()),t.fillStyle=T.textGroupHeader??T.textHeader,C!==void 0){let I=v;if(C.icon!==void 0&&(l.drawSprite(C.icon,"normal",t,I+8,(i-20)/2,20,T),I+=26),t.fillText(C.name,I+8,i/2+Js(t,o.headerFontFull)),C.actions!==void 0&&A){const D=DE({x:v,y:w,width:k,height:x},C.actions);t.beginPath();const O=D[0].x-10,L=v+k-O;t.rect(O,0,L,i);const _=t.createLinearGradient(O,0,O+L,0),re=Il(M,0);_.addColorStop(0,re),_.addColorStop(10/L,M),_.addColorStop(1,M),t.fillStyle=_,t.fill(),t.globalAlpha=.6;const[ie,se]=(s==null?void 0:s[1])??[-1,-1];for(let H=0;H35){const k=d?35:r-35,x=d?35*.7:r-35*.7,C=k/r,T=x/r,A=t.createLinearGradient(e,0,e+r,0),M=Il(g,0);A.addColorStop(d?1:0,g),A.addColorStop(C,g),A.addColorStop(T,M),A.addColorStop(d?0:1,M),t.fillStyle=A}else t.fillStyle=g;if(d&&(t.textAlign="right"),t.fillText(s.title,v,n+i/2+Js(t,l.headerFontFull)),d&&(t.textAlign="left"),b&&s.hasMenu===!0)if(s.menuIcon===void 0||s.menuIcon===Rh.Triangle){t.beginPath();const w=h.x+h.width/2-5.5,k=h.y+h.height/2-3;B4(t,[{x:w,y:k},{x:w+11,y:k},{x:w+5.5,y:k+6}],1),t.fillStyle=g,t.fill()}else if(s.menuIcon===Rh.Dots){t.beginPath();const w=h.x+h.width/2,k=h.y+h.height/2;z4(t,w,k),t.fillStyle=g,t.fill()}else{const w=h.x+(h.width-l.headerIconSize)/2,k=h.y+(h.height-l.headerIconSize)/2;c.drawSprite(s.menuIcon,"normal",t,w,k,l.headerIconSize,l)}}function LE(t,e,n,r,i,s,o,l,a,u,c,f,d,h){const p=sw(s.title)==="rtl",g=_E(e,n,r,i,p);d!==void 0?d({ctx:t,theme:l,rect:{x:e,y:n,width:r,height:i},column:s,columnIndex:s.sourceIndex,isSelected:o,hoverAmount:c,isHovered:a,hasSelectedCell:u,spriteManager:f,menuBounds:g},()=>vx(t,e,n,r,i,s,o,l,a,c,f,h,p,g)):vx(t,e,n,r,i,s,o,l,a,c,f,h,p,g)}var zz=Bl,Bz=function(){try{var t=zz(Object,"defineProperty");return t({},"",{}),t}catch{}}(),jz=Bz,wx=jz;function Hz(t,e,n){e=="__proto__"&&wx?wx(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var Wz=Hz;function Vz(t,e,n,r){for(var i=-1,s=t==null?0:t.length;++il))return!1;var u=s.get(t),c=s.get(e);if(u&&c)return u==e&&c==t;var f=-1,d=!0,h=n&Jj?new Xj:void 0;for(s.set(t,e),s.set(e,t);++f{if(k!==e[e.length-1])return;x+=k.width;const M=Math.max(x,T);M>r||(t.save(),t.beginPath(),t.rect(M,s+1,1e4,i-s-1),t.clip(),Fp(A,C,i,u,c,p,g,w,(I,D,O,L)=>{if(!L&&b.length>0&&!b.some(H=>Lh(x,I,1e4,O,H.x,H.y,H.width,H.height)))return;const _=d.hasIndex(D),re=h.hasIndex(D);t.beginPath();const ie=f==null?void 0:f(D),se=ie===void 0?v:$o(v,ie);se.bgCell!==v.bgCell&&(t.fillStyle=se.bgCell,t.fillRect(x,I,1e4,O)),re&&(t.fillStyle=se.bgHeader,t.fillRect(x,I,1e4,O)),_&&(t.fillStyle=se.accentLight,t.fillRect(x,I,1e4,O))}),t.restore())})}function HW(t,e,n,r,i,s,o,l,a){let u=!1;for(const p of e)if(!p.sticky){u=o(p.sourceIndex);break}const c=a.horizontalBorderColor??a.borderColor,f=a.borderColor,d=u?Ga(e):0;let h;if(d!==0&&(h=ax(f,a.bgCell),t.beginPath(),t.moveTo(d+.5,0),t.lineTo(d+.5,r),t.strokeStyle=h,t.stroke()),i>0){const p=f===c&&h!==void 0?h:ax(c,a.bgCell),g=Hl(s,i,l);t.beginPath(),t.moveTo(0,r-g+.5),t.lineTo(n,r-g+.5),t.strokeStyle=p,t.stroke()}}const XE=(t,e,n)=>{let r=0,i=e,s=0,o=n;if(t!==void 0&&t.length>0){r=Number.MAX_SAFE_INTEGER,s=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER,o=Number.MIN_SAFE_INTEGER;for(const l of t)r=Math.min(r,l.x-1),i=Math.max(i,l.x+l.width+1),s=Math.min(s,l.y-1),o=Math.max(o,l.y+l.height+1)}return{minX:r,maxX:i,minY:s,maxY:o}};function WW(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p){var O;const g=p.bgCell,{minX:b,maxX:m,minY:v,maxY:w}=XE(l,s,o),k=[],x=o-Hl(h,d,u);let C=a,T=n,A=0;for(;C+i=v&&L<=w-1){const re=c==null?void 0:c(T),ie=re==null?void 0:re.bgCell;ie!==void 0&&ie!==g&&T>=h-d&&k.push({x:b,y:L,w:m-b,h:_,color:ie})}C+=_,T0)for(let L=0;L=b&&re<=m&&f(L+1)&&k.push({x:re,y:A,w:_.width,h:I,color:ie}),M+=_.width}if(k.length===0)return;let D;t.beginPath();for(let L=k.length-1;L>=0;L--){const _=k[L];D===void 0?D=_.color:_.color!==D&&(t.fillStyle=D,t.fill(),t.beginPath(),D=_.color),t.rect(_.x,_.y,_.w,_.h)}D!==void 0&&(t.fillStyle=D,t.fill()),t.beginPath()}function zx(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,g,b,m=!1){if(a!==void 0){t.beginPath(),t.save(),t.rect(0,0,s,o);for(const O of a)t.rect(O.x+1,O.y+1,O.width-1,O.height-1);t.clip("evenodd")}const v=b.horizontalBorderColor??b.borderColor,w=b.borderColor,{minX:k,maxX:x,minY:C,maxY:T}=XE(l,s,o),A=[];t.beginPath();let M=.5;for(let O=0;O=k&&_<=x&&h(O+1)&&A.push({x1:_,y1:Math.max(u,C),x2:_,y2:Math.min(o,T),color:w})}let I=o+.5;for(let O=g-p;O=C&&re<=T-1){const ie=d==null?void 0:d(L);A.push({x1:k,y1:re,x2:x,y2:re,color:(ie==null?void 0:ie.horizontalBorderColor)??(ie==null?void 0:ie.borderColor)??v})}O+=f(L),L++}}const D=BW(A,O=>O.color);for(const O of Object.keys(D)){t.strokeStyle=O;for(const L of D[O])t.moveTo(L.x1,L.y1),t.lineTo(L.x2,L.y2);t.stroke(),t.beginPath()}a!==void 0&&t.restore()}function VW(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,g,b,m,v){const w=[];t.imageSmoothingEnabled=!1;const k=Math.min(i.cellYOffset,o),x=Math.max(i.cellYOffset,o);let C=0;if(typeof m=="number")C+=(x-k)*m;else for(let _=k;_i.cellYOffset&&(C=-C),C+=a-i.translateY;const T=Math.min(i.cellXOffset,s),A=Math.max(i.cellXOffset,s);let M=0;for(let _=T;_i.cellXOffset&&(M=-M),M+=l-i.translateX;const I=Ga(b);if(M!==0&&C!==0)return{regions:[]};const D=u>0?Hl(d,u,m):0,O=c-I-Math.abs(M),L=f-h-D-Math.abs(C)-1;if(O>150&&L>150){const _={sx:0,sy:0,sw:c*p,sh:f*p,dx:0,dy:0,dw:c*p,dh:f*p};if(C>0?(_.sy=(h+1)*p,_.sh=L*p,_.dy=(C+h+1)*p,_.dh=L*p,w.push({x:0,y:h,width:c,height:C+1})):C<0&&(_.sy=(-C+h+1)*p,_.sh=L*p,_.dy=(h+1)*p,_.dh=L*p,w.push({x:0,y:f+C-D,width:c,height:-C+D})),M>0?(_.sx=I*p,_.sw=O*p,_.dx=(M+I)*p,_.dw=O*p,w.push({x:I-1,y:0,width:M+2,height:f})):M<0&&(_.sx=(I-M)*p,_.sw=O*p,_.dx=I*p,_.dw=O*p,w.push({x:c+M,y:0,width:-M,height:f})),t.setTransform(1,0,0,1,0,0),v){if(I>0&&M!==0&&C===0&&(r===void 0||(n==null?void 0:n[1])!==!1)){const re=I*p,ie=f*p;t.drawImage(e,0,0,re,ie,0,0,re,ie)}if(D>0&&M===0&&C!==0&&(r===void 0||(n==null?void 0:n[0])!==!1)){const re=(f-D)*p,ie=c*p,se=D*p;t.drawImage(e,0,re,ie,se,0,re,ie,se)}}t.drawImage(e,_.sx,_.sy,_.sw,_.sh,_.dx,_.dy,_.dw,_.dh),t.scale(p,p)}return t.imageSmoothingEnabled=!0,{regions:w}}function UW(t,e,n,r,i,s,o,l,a,u){const c=[];return e!==t.cellXOffset||n!==t.cellYOffset||r!==t.translateX||i!==t.translateY||Go(a,n,r,i,l,(f,d,h,p)=>{if(f.sourceIndex===u){const g=Math.max(d,p)+1;return c.push({x:g,y:0,width:s-g,height:o}),!0}}),c}function KW(t,e){if(e===void 0||t.width!==e.width||t.height!==e.height||t.theme!==e.theme||t.headerHeight!==e.headerHeight||t.rowHeight!==e.rowHeight||t.rows!==e.rows||t.freezeColumns!==e.freezeColumns||t.getRowThemeOverride!==e.getRowThemeOverride||t.isFocused!==e.isFocused||t.isResizing!==e.isResizing||t.verticalBorder!==e.verticalBorder||t.getCellContent!==e.getCellContent||t.highlightRegions!==e.highlightRegions||t.selection!==e.selection||t.dragAndDropState!==e.dragAndDropState||t.prelightCells!==e.prelightCells||t.touchMode!==e.touchMode||t.maxScaleFactor!==e.maxScaleFactor)return!1;if(t.mappedColumns!==e.mappedColumns){if(t.mappedColumns.length>100||t.mappedColumns.length!==e.mappedColumns.length)return!1;let n;for(let r=0;rT.style!=="no-outline");if(b===void 0||b.length===0)return;const m=Ga(l),v=Hl(h,d,f),w=[a,0,l.length,h-d],k=[m,0,e,n-v],x=b.map(T=>{const A=T.range,M=T.style??"dashed";return _z(A,w,e,n,k).map(I=>{const D=I.rect,O=K0(D.x,D.y,e,n,c,u+c,r,i,s,o,h,a,d,l,f),L=D.width===1&&D.height===1?O:K0(D.x+D.width-1,D.y+D.height-1,e,n,c,u+c,r,i,s,o,h,a,d,l,f);return D.x+D.width>=l.length&&(L.width-=1),D.y+D.height>=h&&(L.height-=1),{color:T.color,style:M,clip:I.clip,rect:Nz({x:O.x,y:O.y,width:L.x+L.width-O.x,height:L.y+L.height-O.y},e,n,8)}})}),C=()=>{t.lineWidth=1;let T=!1;for(const A of x)for(const M of A)if((M==null?void 0:M.rect)!==void 0&&Lh(0,0,e,n,M.rect.x,M.rect.y,M.rect.width,M.rect.height)){const I=T,D=!Iz(M.clip,M.rect);D&&(t.save(),t.rect(M.clip.x,M.clip.y,M.clip.width,M.clip.height),t.clip()),M.style==="dashed"&&!T?(t.setLineDash([5,3]),T=!0):(M.style==="solid"||M.style==="solid-outline")&&T&&(t.setLineDash([]),T=!1),t.strokeStyle=M.style==="solid-outline"?ti(ti(M.color,g.borderColor),g.bgCell):Il(M.color,1),t.strokeRect(M.rect.x+.5,M.rect.y+.5,M.rect.width-1,M.rect.height-1),D&&(t.restore(),T=I)}T&&t.setLineDash([])};return C(),C}function jx(t,e,n,r,i){t.beginPath(),t.moveTo(e,n),t.lineTo(e,r),t.lineWidth=2,t.strokeStyle=i,t.stroke(),t.globalAlpha=1}function om(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,g,b){if(c.current===void 0)return;const m=c.current.range,v=c.current.cell,w=[m.x+m.width-1,m.y+m.height-1];if(v[1]>=b&&w[1]>=b||!o.some(_=>_.sourceIndex===v[0]||_.sourceIndex===w[0]))return;const[x,C]=c.current.cell,T=d(c.current.cell),A=T.span??[x,x],M=C>=b-h,I=h>0&&!M?Hl(b,h,f)-1:0,D=w[1];let O;if(Go(o,r,i,s,u,(_,re,ie,se,H)=>{if(_.sticky&&x>_.sourceIndex)return;const X=_.sourceIndexA[1],N=_.sourceIndex===w[0];if(!(!N&&(X||R)))return Fp(H,ie,n,b,f,h,p,void 0,(P,B,q)=>{if(B!==C&&B!==D)return;let W=re,ye=_.width;if(T.span!==void 0){const me=PE(T.span,re,P,_.width,q,_,l),Le=_.sticky?me[0]:me[1];Le!==void 0&&(W=Le.x,ye=Le.width)}return B===D&&N&&g&&(O=()=>{var me;se>W&&!_.sticky&&(t.beginPath(),t.rect(se,0,e-se,n),t.clip()),t.beginPath(),t.rect(W+ye-4,P+q-4,4,4),t.fillStyle=((me=_.themeOverride)==null?void 0:me.accentColor)??a.accentColor,t.fill()}),O!==void 0}),O!==void 0}),O===void 0)return;const L=()=>{t.save(),t.beginPath(),t.rect(0,u,e,n-u-I),t.clip(),O==null||O(),t.restore()};return L(),L}function XW(t,e,n,r,i,s,o,l,a){a===void 0||a.size===0||(t.beginPath(),OE(e,n,s,r,(u,c,f,d,h,p)=>{a.hasItemInRectangle({x:u[0],y:-2,width:u[1]-u[0]+1,height:1})&&t.rect(f,d,h,p)}),Go(e,l,s,o,i,(u,c,f,d)=>{const h=Math.max(0,d-c),p=c+h+1,g=u.width-h-1;a.has([u.sourceIndex,-1])&&t.rect(p,r,g,i-r)}),t.clip())}function GW(t,e,n,r,i,s,o,l,a,u){let c=0;return Go(t,s,r,i,n,(f,d,h,p,g)=>(Fp(g,h,e,o,l,a,u,void 0,(b,m,v,w)=>{w||(c=Math.max(m,c))}),!0)),c}function Hx(t,e){var Qe;const{canvasCtx:n,headerCanvasCtx:r,width:i,height:s,cellXOffset:o,cellYOffset:l,translateX:a,translateY:u,mappedColumns:c,enableGroups:f,freezeColumns:d,dragAndDropState:h,theme:p,drawFocus:g,headerHeight:b,groupHeaderHeight:m,disabledRows:v,rowHeight:w,verticalBorder:k,overrideCursor:x,isResizing:C,selection:T,fillHandle:A,freezeTrailingRows:M,rows:I,getCellContent:D,getGroupDetails:O,getRowThemeOverride:L,isFocused:_,drawHeaderCallback:re,prelightCells:ie,drawCellCallback:se,highlightRegions:H,resizeCol:X,imageLoader:R,lastBlitData:N,hoverValues:P,hyperWrapping:B,hoverInfo:q,spriteManager:W,maxScaleFactor:ye,hasAppendRow:ee,touchMode:me,enqueue:Le,renderStateProvider:Ue,getCellRenderer:ze,renderStrategy:Mt,bufferACtx:tt,bufferBCtx:Be,damage:ue,minimumCellWidth:It}=t;if(i===0||s===0)return;const be=Mt==="double-buffer",xe=Math.min(ye,Math.ceil(window.devicePixelRatio??1)),Y=Mt!=="direct"&&KW(t,e),Se=n.canvas;(Se.width!==i*xe||Se.height!==s*xe)&&(Se.width=i*xe,Se.height=s*xe,Se.style.width=i+"px",Se.style.height=s+"px");const Ie=r.canvas,Ce=f?m+b:b,xt=Ce+1;(Ie.width!==i*xe||Ie.height!==xt*xe)&&(Ie.width=i*xe,Ie.height=xt*xe,Ie.style.width=i+"px",Ie.style.height=xt+"px");const $e=tt.canvas,nt=Be.canvas;be&&($e.width!==i*xe||$e.height!==s*xe)&&($e.width=i*xe,$e.height=s*xe,N.current!==void 0&&(N.current.aBufferScroll=void 0)),be&&(nt.width!==i*xe||nt.height!==s*xe)&&(nt.width=i*xe,nt.height=s*xe,N.current!==void 0&&(N.current.bBufferScroll=void 0));const ge=N.current;if(Y===!0&&o===(ge==null?void 0:ge.cellXOffset)&&l===(ge==null?void 0:ge.cellYOffset)&&a===(ge==null?void 0:ge.translateX)&&u===(ge==null?void 0:ge.translateY))return;let ot=null;be&&(ot=n);const rt=r;let Ke;be?ue!==void 0?Ke=(ge==null?void 0:ge.lastBuffer)==="b"?Be:tt:Ke=(ge==null?void 0:ge.lastBuffer)==="b"?tt:Be:Ke=n;const an=Ke.canvas,mt=be?an===$e?nt:$e:Se,it=typeof w=="number"?()=>w:w;rt.save(),Ke.save(),rt.beginPath(),Ke.beginPath(),rt.textBaseline="middle",Ke.textBaseline="middle",xe!==1&&(rt.scale(xe,xe),Ke.scale(xe,xe));const dt=U0(c,o,i,h,a);let Yt=[];const mn=g&&((Qe=T.current)==null?void 0:Qe.cell[1])===l&&u===0;let qn=!1;if(H!==void 0){for(const We of H)if(We.style!=="no-outline"&&We.range.y===l&&u===0){qn=!0;break}}const Jt=()=>{$z(rt,dt,f,q,i,a,b,m,h,C,T,p,W,P,k,O,ue,re,me),zx(rt,dt,l,a,u,i,s,void 0,void 0,m,Ce,it,L,k,M,I,p,!0),rt.beginPath(),rt.moveTo(0,xt-.5),rt.lineTo(i,xt-.5),rt.strokeStyle=ti(p.headerBottomBorderColor??p.horizontalBorderColor??p.borderColor,p.bgHeader),rt.stroke(),qn&&Bx(rt,i,s,o,l,a,u,c,d,b,m,w,M,I,H,p),mn&&om(rt,i,s,l,a,u,dt,c,p,Ce,T,it,D,M,ee,A,I)};if(ue!==void 0){const We=dt[dt.length-1].sourceIndex+1,Lt=ue.hasItemInRegion([{x:o,y:-2,width:We,height:2},{x:o,y:l,width:We,height:300},{x:0,y:l,width:d,height:300},{x:0,y:-2,width:d,height:2},{x:o,y:I-M,width:We,height:M,when:M>0}]),Qt=Zt=>{yx(Zt,dt,c,s,Ce,a,u,l,I,it,D,O,L,v,_,g,M,ee,Yt,ue,T,ie,H,R,W,P,q,se,B,p,Le,Ue,ze,x,It);const Tn=T.current;A&&g&&Tn!==void 0&&ue.has(hE(Tn.range))&&om(Zt,i,s,l,a,u,dt,c,p,Ce,T,it,D,M,ee,A,I)};Lt&&(Qt(Ke),ot!==null&&(ot.save(),ot.scale(xe,xe),ot.textBaseline="middle",Qt(ot),ot.restore()),ue.hasHeader()&&(XW(rt,dt,i,m,Ce,a,u,l,ue),Jt())),Ke.restore(),rt.restore();return}if((Y!==!0||o!==(ge==null?void 0:ge.cellXOffset)||a!==(ge==null?void 0:ge.translateX)||mn!==(ge==null?void 0:ge.mustDrawFocusOnHeader)||qn!==(ge==null?void 0:ge.mustDrawHighlightRingsOnHeader))&&Jt(),Y===!0){ei(mt!==void 0&&ge!==void 0);const{regions:We}=VW(Ke,mt,mt===$e?ge.aBufferScroll:ge.bBufferScroll,mt===$e?ge.bBufferScroll:ge.aBufferScroll,ge,o,l,a,u,M,i,s,I,Ce,xe,c,dt,w,be);Yt=We}else Y!==!1&&(ei(ge!==void 0),Yt=UW(ge,o,l,a,u,i,s,Ce,dt,Y));HW(Ke,dt,i,s,M,I,k,it,p);const jt=Bx(Ke,i,s,o,l,a,u,c,d,b,m,w,M,I,H,p),Hn=g?om(Ke,i,s,l,a,u,dt,c,p,Ce,T,it,D,M,ee,A,I):void 0;if(Ke.fillStyle=p.bgCell,Yt.length>0){Ke.beginPath();for(const We of Yt)Ke.rect(We.x,We.y,We.width,We.height);Ke.clip(),Ke.fill(),Ke.beginPath()}else Ke.fillRect(0,0,i,s);const bn=yx(Ke,dt,c,s,Ce,a,u,l,I,it,D,O,L,v,_,g,M,ee,Yt,ue,T,ie,H,R,W,P,q,se,B,p,Le,Ue,ze,x,It);jW(Ke,dt,c,i,s,Ce,a,u,l,I,it,L,T.rows,v,M,ee,Yt,ue,p),WW(Ke,dt,l,a,u,i,s,Yt,Ce,it,L,k,M,I,p),zx(Ke,dt,l,a,u,i,s,Yt,bn,m,Ce,it,L,k,M,I,p),jt==null||jt(),Hn==null||Hn(),C&&Go(dt,0,a,0,Ce,(We,Lt)=>We.sourceIndex===X?(jx(rt,Lt+We.width,0,Ce+1,ti(p.resizeIndicatorColor??p.accentLight,p.bgHeader)),jx(Ke,Lt+We.width,Ce,s,ti(p.resizeIndicatorColor??p.accentLight,p.bgCell)),!0):!1),ot!==null&&(ot.fillStyle=p.bgCell,ot.fillRect(0,0,i,s),ot.drawImage(Ke.canvas,0,0));const Yn=GW(dt,s,Ce,a,u,l,I,it,M,ee);R==null||R.setWindow({x:o,y:l,width:dt.length,height:Yn-l},d,Array.from({length:M},(We,Lt)=>I-1-Lt));const Wr=ge!==void 0&&(o!==ge.cellXOffset||a!==ge.translateX),Ht=ge!==void 0&&(l!==ge.cellYOffset||u!==ge.translateY);N.current={cellXOffset:o,cellYOffset:l,translateX:a,translateY:u,mustDrawFocusOnHeader:mn,mustDrawHighlightRingsOnHeader:qn,lastBuffer:be?an===$e?"a":"b":void 0,aBufferScroll:an===$e?[Wr,Ht]:ge==null?void 0:ge.aBufferScroll,bBufferScroll:an===nt?[Wr,Ht]:ge==null?void 0:ge.bBufferScroll},Ke.restore(),rt.restore()}const qW=80;function YW(t){const e=t-1;return e*e*e+1}class JW{constructor(e){kt(this,"callback");kt(this,"currentHoveredItem");kt(this,"leavingItems",[]);kt(this,"lastAnimationTime");kt(this,"addToLeavingItems",e=>{this.leavingItems.some(r=>gc(r.item,e.item))||this.leavingItems.push(e)});kt(this,"removeFromLeavingItems",e=>{const n=this.leavingItems.find(r=>gc(r.item,e));return this.leavingItems=this.leavingItems.filter(r=>r!==n),(n==null?void 0:n.hoverAmount)??0});kt(this,"cleanUpLeavingElements",()=>{this.leavingItems=this.leavingItems.filter(e=>e.hoverAmount>0)});kt(this,"shouldStep",()=>{const e=this.leavingItems.length>0,n=this.currentHoveredItem!==void 0&&this.currentHoveredItem.hoverAmount<1;return e||n});kt(this,"getAnimatingItems",()=>this.currentHoveredItem!==void 0?[...this.leavingItems,this.currentHoveredItem]:this.leavingItems.map(e=>({...e,hoverAmount:YW(e.hoverAmount)})));kt(this,"step",e=>{if(this.lastAnimationTime===void 0)this.lastAnimationTime=e;else{const r=(e-this.lastAnimationTime)/qW;for(const s of this.leavingItems)s.hoverAmount=Wi(s.hoverAmount-r,0,1);this.currentHoveredItem!==void 0&&(this.currentHoveredItem.hoverAmount=Wi(this.currentHoveredItem.hoverAmount+r,0,1));const i=this.getAnimatingItems();this.callback(i),this.cleanUpLeavingElements()}this.shouldStep()?(this.lastAnimationTime=e,window.requestAnimationFrame(this.step)):this.lastAnimationTime=void 0});kt(this,"setHovered",e=>{var n;if(!gc((n=this.currentHoveredItem)==null?void 0:n.item,e)){if(this.currentHoveredItem!==void 0&&this.addToLeavingItems(this.currentHoveredItem),e!==void 0){const r=this.removeFromLeavingItems(e);this.currentHoveredItem={item:e,hoverAmount:r}}else this.currentHoveredItem=void 0;this.lastAnimationTime===void 0&&window.requestAnimationFrame(this.step)}});this.callback=e}}class QW{constructor(e){kt(this,"fn");kt(this,"val");this.fn=e}get value(){return this.val??(this.val=this.fn())}}function gw(t){return new QW(t)}const ZW=gw(()=>window.navigator.userAgent.includes("Firefox")),zh=gw(()=>window.navigator.userAgent.includes("Mac OS")&&window.navigator.userAgent.includes("Safari")&&!window.navigator.userAgent.includes("Chrome")),Bh=gw(()=>window.navigator.platform.toLowerCase().startsWith("mac"));function e6(t){const e=y.useRef([]),n=y.useRef(0),r=y.useRef(t);r.current=t;const i=y.useCallback(()=>{const s=()=>window.requestAnimationFrame(o),o=()=>{const l=e.current.map(cw);e.current=[],r.current(new yc(l)),e.current.length>0?n.current++:n.current=0};window.requestAnimationFrame(n.current>600?s:o)},[]);return y.useCallback(s=>{e.current.length===0&&i();const o=Vi(s[0],s[1]);e.current.includes(o)||e.current.push(o)},[i])}const go="header",Zr="group-header",jh="out-of-bounds";var Sa;(function(t){t[t.Start=-2]="Start",t[t.StartPadding=-1]="StartPadding",t[t.Center=0]="Center",t[t.EndPadding=1]="EndPadding",t[t.End=2]="End"})(Sa||(Sa={}));function GE(t,e){return t===e?!0:(t==null?void 0:t.kind)==="out-of-bounds"?(t==null?void 0:t.kind)===(e==null?void 0:e.kind)&&(t==null?void 0:t.location[0])===(e==null?void 0:e.location[0])&&(t==null?void 0:t.location[1])===(e==null?void 0:e.location[1])&&(t==null?void 0:t.region[0])===(e==null?void 0:e.region[0])&&(t==null?void 0:t.region[1])===(e==null?void 0:e.region[1]):(t==null?void 0:t.kind)===(e==null?void 0:e.kind)&&(t==null?void 0:t.location[0])===(e==null?void 0:e.location[0])&&(t==null?void 0:t.location[1])===(e==null?void 0:e.location[1])}const Wx=6,t6=(t,e)=>{if(t.kind===Ae.Custom)return t.copyData;const n=e==null?void 0:e(t);return(n==null?void 0:n.getAccessibilityString(t))??""},n6=(t,e)=>{const{width:n,height:r,accessibilityHeight:i,columns:s,cellXOffset:o,cellYOffset:l,headerHeight:a,fillHandle:u=!1,groupHeaderHeight:c,rowHeight:f,rows:d,getCellContent:h,getRowThemeOverride:p,onHeaderMenuClick:g,enableGroups:b,isFilling:m,onCanvasFocused:v,onCanvasBlur:w,isFocused:k,selection:x,freezeColumns:C,onContextMenu:T,freezeTrailingRows:A,fixedShadowX:M=!0,fixedShadowY:I=!0,drawFocusRing:D,onMouseDown:O,onMouseUp:L,onMouseMoveRaw:_,onMouseMove:re,onItemHovered:ie,dragAndDropState:se,firstColAccessible:H,onKeyDown:X,onKeyUp:R,highlightRegions:N,canvasRef:P,onDragStart:B,onDragEnd:q,eventTargetRef:W,isResizing:ye,resizeColumn:ee,isDragging:me,isDraggable:Le=!1,allowResize:Ue,disabledRows:ze,hasAppendRow:Mt,getGroupDetails:tt,theme:Be,prelightCells:ue,headerIcons:It,verticalBorder:be,drawCell:xe,drawHeader:Y,onCellFocused:Se,onDragOverCell:Ie,onDrop:Ce,onDragLeave:xt,imageWindowLoader:$e,smoothScrollX:nt=!1,smoothScrollY:ge=!1,experimental:ot,getCellRenderer:rt}=t,Ke=t.translateX??0,an=t.translateY??0,mt=Math.max(C,Math.min(s.length-1,o)),it=y.useRef(null),dt=$e,Yt=y.useRef(),[mn,qn]=y.useState(!1),Jt=y.useRef([]),jt=y.useRef(),[Hn,bn]=y.useState(),[Yn,Wr]=y.useState(),Ht=y.useRef(null),[Qe,We]=y.useState(),[Lt,Qt]=y.useState(!1),Zt=y.useRef(Lt);Zt.current=Lt;const Tn=y.useMemo(()=>new Oz(It,()=>{ui.current=void 0,z.current()}),[It]),er=b?c+a:a,pt=y.useRef(-1),Wt=((ot==null?void 0:ot.enableFirefoxRescaling)??!1)&&ZW.value,Rt=((ot==null?void 0:ot.enableSafariRescaling)??!1)&&zh.value;y.useLayoutEffect(()=>{window.devicePixelRatio===1||!Wt&&!Rt||(pt.current!==-1&&qn(!0),window.clearTimeout(pt.current),pt.current=window.setTimeout(()=>{qn(!1),pt.current=-1},200))},[l,mt,Ke,an,Wt,Rt]);const Ft=E4(s,C),tn=M?Ga(Ft,se):0,Vt=y.useCallback((j,ae,Te)=>{const we=j.getBoundingClientRect();if(ae>=Ft.length||Te>=d)return;const fe=we.width/n,Pe=K0(ae,Te,n,r,c,er,mt,l,Ke,an,d,C,A,Ft,f);return fe!==1&&(Pe.x*=fe,Pe.y*=fe,Pe.width*=fe,Pe.height*=fe),Pe.x+=we.x,Pe.y+=we.y,Pe},[n,r,c,er,mt,l,Ke,an,d,C,A,Ft,f]),Ut=y.useCallback((j,ae,Te,we)=>{const fe=j.getBoundingClientRect(),Pe=fe.width/n,at=(ae-fe.left)/Pe,ut=(Te-fe.top)/Pe,Re=5,$t=U0(Ft,mt,n,void 0,Ke);let je=0,Bt=0;we instanceof MouseEvent&&(je=we.button,Bt=we.buttons);const ht=O4(at,$t,Ke),Ct=P4(ut,r,b,a,c,d,f,l,an,A),In=(we==null?void 0:we.shiftKey)===!0,yt=(we==null?void 0:we.ctrlKey)===!0,En=(we==null?void 0:we.metaKey)===!0,ci=we!==void 0&&!(we instanceof MouseEvent)||(we==null?void 0:we.pointerType)==="touch",vn=[at<0?-1:nn||ut>r){const Nt=at>n?1:at<0?-1:0,Nn=ut>r?1:ut<0?-1:0;let Xr=Nt*2,is=Nn*2;Nt===0&&(Xr=ht===-1?Sa.EndPadding:Sa.Center),Nn===0&&(is=Ct===void 0?Sa.EndPadding:Sa.Center);let Ni=!1;if(ht===-1&&Ct===-1){const Qo=Vt(j,Ft.length-1,-1);ei(Qo!==void 0),Ni=aen&&atr&&ut=0?(Nn=!0,Nt=Vt(j,Xr,Ct),ei(Nt!==void 0),Kr={kind:b&&Ct===-2?Zr:go,location:[Xr,Ct],bounds:Nt,group:Ft[Xr].group??"",isEdge:Nn,shiftKey:In,ctrlKey:yt,metaKey:En,isTouch:ci,localEventX:ae-Nt.x,localEventY:Te-Nt.y,button:je,buttons:Bt,scrollEdge:vn}):Kr={kind:b&&Ct===-2?Zr:go,group:Ft[ht].group??"",location:[ht,Ct],bounds:Nt,isEdge:Nn,shiftKey:In,ctrlKey:yt,metaKey:En,isTouch:ci,localEventX:ae-Nt.x,localEventY:Te-Nt.y,button:je,buttons:Bt,scrollEdge:vn}}else{const Nt=Vt(j,ht,Ct);ei(Nt!==void 0);const Nn=Nt!==void 0&&Nt.x+Nt.width-ae{}),lt=y.useRef(Hn);lt.current=Hn;const[Jn,Vr]=y.useMemo(()=>{const j=document.createElement("canvas"),ae=document.createElement("canvas");return j.style.display="none",j.style.opacity="0",j.style.position="fixed",ae.style.display="none",ae.style.opacity="0",ae.style.position="fixed",[j.getContext("2d",{alpha:!1}),ae.getContext("2d",{alpha:!1})]},[]);y.useLayoutEffect(()=>{if(!(Jn===null||Vr===null))return document.documentElement.append(Jn.canvas),document.documentElement.append(Vr.canvas),()=>{Jn.canvas.remove(),Vr.canvas.remove()}},[Jn,Vr]);const rs=y.useMemo(()=>new j4,[]),Wl=Wt&&mn?1:Rt&&mn?2:5,Vl=(ot==null?void 0:ot.disableMinimumCellWidth)===!0?1:10,ui=y.useRef(),Qs=y.useRef(null),Zs=y.useRef(null),eo=y.useCallback(()=>{var at;const j=it.current,ae=Ht.current;if(j===null||ae===null||(Qs.current===null&&(Qs.current=j.getContext("2d",{alpha:!1}),j.width=0,j.height=0),Zs.current===null&&(Zs.current=ae.getContext("2d",{alpha:!1}),ae.width=0,ae.height=0),Qs.current===null||Zs.current===null||Jn===null||Vr===null))return;let Te=!1;const we=ut=>{Te=!0,We(ut)},fe=ui.current,Pe={headerCanvasCtx:Zs.current,canvasCtx:Qs.current,bufferACtx:Jn,bufferBCtx:Vr,width:n,height:r,cellXOffset:mt,cellYOffset:l,translateX:Math.round(Ke),translateY:Math.round(an),mappedColumns:Ft,enableGroups:b,freezeColumns:C,dragAndDropState:se,theme:Be,headerHeight:a,groupHeaderHeight:c,disabledRows:ze??Pt.empty(),rowHeight:f,verticalBorder:be,isResizing:ye,resizeCol:ee,isFocused:k,selection:x,fillHandle:u,drawCellCallback:xe,hasAppendRow:Mt,overrideCursor:we,maxScaleFactor:Wl,freezeTrailingRows:A,rows:d,drawFocus:D,getCellContent:h,getGroupDetails:tt??(ut=>({name:ut})),getRowThemeOverride:p,drawHeaderCallback:Y,prelightCells:ue,highlightRegions:N,imageLoader:dt,lastBlitData:jt,damage:Yt.current,hoverValues:Jt.current,hoverInfo:lt.current,spriteManager:Tn,scrolling:mn,hyperWrapping:(ot==null?void 0:ot.hyperWrapping)??!1,touchMode:Lt,enqueue:st.current,renderStateProvider:rs,renderStrategy:(ot==null?void 0:ot.renderStrategy)??(zh.value?"double-buffer":"single-buffer"),getCellRenderer:rt,minimumCellWidth:Vl};Pe.damage===void 0?(ui.current=Pe,Hx(Pe,fe)):Hx(Pe,void 0),!Te&&(Pe.damage===void 0||Pe.damage.has((at=lt==null?void 0:lt.current)==null?void 0:at[0]))&&We(void 0)},[Jn,Vr,n,r,mt,l,Ke,an,Ft,b,C,se,Be,a,c,ze,f,be,ye,Mt,ee,k,x,u,A,d,D,Wl,h,tt,p,xe,Y,ue,N,dt,Tn,mn,ot==null?void 0:ot.hyperWrapping,ot==null?void 0:ot.renderStrategy,Lt,rs,rt,Vl]),z=y.useRef(eo);y.useLayoutEffect(()=>{eo(),z.current=eo},[eo]),y.useLayoutEffect(()=>{(async()=>{var ae;((ae=document==null?void 0:document.fonts)==null?void 0:ae.ready)!==void 0&&(await document.fonts.ready,ui.current=void 0,z.current())})()},[]);const oe=y.useCallback(j=>{Yt.current=j,z.current(),Yt.current=void 0},[]),Q=e6(oe);st.current=Q;const pe=y.useCallback(j=>{oe(new yc(j.map(ae=>ae.cell)))},[oe]);dt.setCallback(oe);const[ve,gt]=y.useState(!1),[Fe,ct]=J??[],ft=Fe!==void 0&&ct===-1,Kt=Fe!==void 0&&ct===-2;let nn=!1,zn=!1,rn=Qe;if(rn===void 0&&Fe!==void 0&&ct!==void 0&&ct>-1&&ct({contain:"strict",display:"block",cursor:xr}),[xr]),Mi=y.useRef("default"),Ri=W==null?void 0:W.current;Ri!=null&&Mi.current!==to.cursor&&(Ri.style.cursor=Mi.current=to.cursor);const ar=y.useCallback((j,ae,Te,we)=>{if(tt===void 0)return;const fe=tt(j);if(fe.actions!==void 0){const Pe=DE(ae,fe.actions);for(const[at,ut]of Pe.entries())if(zp(ut,Te+ae.x,we+ut.y))return fe.actions[at]}},[tt]),Oi=y.useCallback((j,ae,Te,we)=>{const fe=s[ae];if(!me&&!ye&&fe.hasMenu===!0&&!(Yn??!1)){const Pe=Vt(j,ae,-1);ei(Pe!==void 0);const at=_E(Pe.x,Pe.y,Pe.width,Pe.height,sw(fe.title)==="rtl");if(Te>at.x&&Teat.y&&we{const ae=it.current,Te=W==null?void 0:W.current;if(ae===null||j.target!==ae&&j.target!==Te)return;vu.current=!0;let we,fe;if(j instanceof MouseEvent?(we=j.clientX,fe=j.clientY):(we=j.touches[0].clientX,fe=j.touches[0].clientY),j.target===Te&&Te!==null){const at=Te.getBoundingClientRect();if(we>at.right||fe>at.bottom)return}const Pe=Ut(ae,we,fe,j);no.current=Pe.location,Pe.isTouch&&(yu.current=Date.now()),Zt.current!==Pe.isTouch&&Qt(Pe.isTouch),!(Pe.kind===go&&Oi(ae,Pe.location[0],we,fe)!==void 0)&&(Pe.kind===Zr&&ar(Pe.group,Pe.bounds,Pe.localEventX,Pe.localEventY)!==void 0||(O==null||O(Pe),!Pe.isTouch&&Le!==!0&&Le!==Pe.kind&&Pe.button<3&&Pe.button!==1&&j.preventDefault()))},[W,Le,Ut,ar,Oi,O]);rr("touchstart",kr,window,!1),rr("mousedown",kr,window,!1);const Ul=y.useRef(0),wu=y.useCallback(j=>{var Bt,ht;const ae=Ul.current;Ul.current=Date.now();const Te=it.current;if(vu.current=!1,L===void 0||Te===null)return;const we=W==null?void 0:W.current,fe=j.target!==Te&&j.target!==we;let Pe,at,ut=!0;if(j instanceof MouseEvent){if(Pe=j.clientX,at=j.clientY,ut=j.button<3,j.pointerType==="touch")return}else Pe=j.changedTouches[0].clientX,at=j.changedTouches[0].clientY;let Re=Ut(Te,Pe,at,j);Re.isTouch&&yu.current!==0&&Date.now()-yu.current>500&&(Re={...Re,isLongTouch:!0}),ae!==0&&Date.now()-ae<(Re.isTouch?1e3:500)&&(Re={...Re,isDoubleClick:!0}),Zt.current!==Re.isTouch&&Qt(Re.isTouch),!fe&&j.cancelable&&ut&&j.preventDefault();const[$t]=Re.location,je=Oi(Te,$t,Pe,at);if(Re.kind===go&&je!==void 0){(Re.button!==0||((Bt=no.current)==null?void 0:Bt[0])!==$t||((ht=no.current)==null?void 0:ht[1])!==-1)&&L(Re,!0);return}else if(Re.kind===Zr){const Ct=ar(Re.group,Re.bounds,Re.localEventX,Re.localEventY);if(Ct!==void 0){Re.button===0&&Ct.onClick(Re);return}}L(Re,fe)},[L,W,Ut,Oi,ar]);rr("mouseup",wu,window,!1),rr("touchend",wu,window,!1);const xf=y.useCallback(j=>{var je,Bt;const ae=it.current;if(ae===null)return;const Te=W==null?void 0:W.current,we=j.target!==ae&&j.target!==Te;let fe,Pe,at=!0;j instanceof MouseEvent?(fe=j.clientX,Pe=j.clientY,at=j.button<3):(fe=j.changedTouches[0].clientX,Pe=j.changedTouches[0].clientY);const ut=Ut(ae,fe,Pe,j);Zt.current!==ut.isTouch&&Qt(ut.isTouch),!we&&j.cancelable&&at&&j.preventDefault();const[Re]=ut.location,$t=Oi(ae,Re,fe,Pe);if(ut.kind===go&&$t!==void 0)ut.button===0&&((je=no.current)==null?void 0:je[0])===Re&&((Bt=no.current)==null?void 0:Bt[1])===-1&&(g==null||g(Re,$t));else if(ut.kind===Zr){const ht=ar(ut.group,ut.bounds,ut.localEventX,ut.localEventY);ht!==void 0&&ut.button===0&&ht.onClick(ut)}},[W,Ut,Oi,g,ar]);rr("click",xf,window,!1);const eg=y.useCallback(j=>{const ae=it.current,Te=W==null?void 0:W.current;if(ae===null||j.target!==ae&&j.target!==Te||T===void 0)return;const we=Ut(ae,j.clientX,j.clientY,j);T(we,()=>{j.cancelable&&j.preventDefault()})},[W,Ut,T]);rr("contextmenu",eg,(W==null?void 0:W.current)??null,!1);const kf=y.useCallback(j=>{Yt.current=new yc(j.map(ae=>ae.item)),Jt.current=j,z.current(),Yt.current=void 0},[]),Pi=y.useMemo(()=>new JW(kf),[kf]),Ps=y.useRef(Pi);Ps.current=Pi,y.useLayoutEffect(()=>{const j=Ps.current;if(J===void 0||J[1]<0){j.setHovered(J);return}const ae=h(J,!0),Te=rt(ae),we=Te===void 0&&ae.kind===Ae.Custom||(Te==null?void 0:Te.needsHover)!==void 0&&(typeof Te.needsHover=="boolean"?Te.needsHover:Te.needsHover(ae));j.setHovered(we?J:void 0)},[h,rt,J]);const Ur=y.useRef(),K=y.useCallback(j=>{var ut;const ae=it.current;if(ae===null)return;const Te=W==null?void 0:W.current,we=j.target!==ae&&j.target!==Te,fe=Ut(ae,j.clientX,j.clientY,j);if(fe.kind!=="out-of-bounds"&&we&&!vu.current&&!fe.isTouch)return;const Pe=(Re,$t)=>{bn(je=>je===Re||(je==null?void 0:je[0][0])===(Re==null?void 0:Re[0][0])&&(je==null?void 0:je[0][1])===(Re==null?void 0:Re[0][1])&&((je==null?void 0:je[1][0])===(Re==null?void 0:Re[1][0])&&(je==null?void 0:je[1][1])===(Re==null?void 0:Re[1][1])||!$t)?je:Re)};if(!GE(fe,Ur.current))We(void 0),ie==null||ie(fe),Pe(fe.kind===jh?void 0:[fe.location,[fe.localEventX,fe.localEventY]],!0),Ur.current=fe;else if(fe.kind==="cell"||fe.kind===go||fe.kind===Zr){let Re=!1,$t=!0;if(fe.kind==="cell"){const Bt=h(fe.location);$t=((ut=rt(Bt))==null?void 0:ut.needsHoverPosition)??Bt.kind===Ae.Custom,Re=$t}else fe.kind===Zr&&(Re=!0);const je=[fe.location,[fe.localEventX,fe.localEventY]];Pe(je,$t),lt.current=je,Re&&oe(new yc([fe.location]))}const at=fe.location[0]>=(H?0:1);Wr(fe.kind===go&&fe.isEdge&&at&&Ue===!0),gt(fe.kind==="cell"&&fe.isFillHandle),_==null||_(j),re(fe)},[W,Ut,H,Ue,_,re,ie,h,rt,oe]);rr("mousemove",K,window,!0);const yn=y.useCallback(j=>{const ae=it.current;if(ae===null)return;let Te,we;x.current!==void 0&&(Te=Vt(ae,x.current.cell[0],x.current.cell[1]),we=x.current.cell),X==null||X({bounds:Te,stopPropagation:()=>j.stopPropagation(),preventDefault:()=>j.preventDefault(),cancel:()=>{},ctrlKey:j.ctrlKey,metaKey:j.metaKey,shiftKey:j.shiftKey,altKey:j.altKey,key:j.key,keyCode:j.keyCode,rawEvent:j,location:we})},[X,x,Vt]),Jo=y.useCallback(j=>{const ae=it.current;if(ae===null)return;let Te,we;x.current!==void 0&&(Te=Vt(ae,x.current.cell[0],x.current.cell[1]),we=x.current.cell),R==null||R({bounds:Te,stopPropagation:()=>j.stopPropagation(),preventDefault:()=>j.preventDefault(),cancel:()=>{},ctrlKey:j.ctrlKey,metaKey:j.metaKey,shiftKey:j.shiftKey,altKey:j.altKey,key:j.key,keyCode:j.keyCode,rawEvent:j,location:we})},[R,x,Vt]),tg=y.useCallback(j=>{it.current=j,P!==void 0&&(P.current=j)},[P]),Sf=y.useCallback(j=>{const ae=it.current;if(ae===null||Le===!1||ye){j.preventDefault();return}let Te,we;const fe=Ut(ae,j.clientX,j.clientY);if(Le!==!0&&fe.kind!==Le){j.preventDefault();return}const Pe=(Bt,ht)=>{Te=Bt,we=ht};let at,ut,Re;const $t=(Bt,ht,Ct)=>{at=Bt,ut=ht,Re=Ct};let je=!1;if(B==null||B({...fe,setData:Pe,setDragImage:$t,preventDefault:()=>je=!0,defaultPrevented:()=>je}),!je&&Te!==void 0&&we!==void 0&&j.dataTransfer!==null)if(j.dataTransfer.setData(Te,we),j.dataTransfer.effectAllowed="copyLink",at!==void 0&&ut!==void 0&&Re!==void 0)j.dataTransfer.setDragImage(at,ut,Re);else{const[Bt,ht]=fe.location;if(ht!==void 0){const Ct=document.createElement("canvas"),In=Vt(ae,Bt,ht);ei(In!==void 0);const yt=Math.ceil(window.devicePixelRatio??1);Ct.width=In.width*yt,Ct.height=In.height*yt;const En=Ct.getContext("2d");En!==null&&(En.scale(yt,yt),En.textBaseline="middle",ht===-1?(En.font=Be.headerFontFull,En.fillStyle=Be.bgHeader,En.fillRect(0,0,Ct.width,Ct.height),LE(En,0,0,In.width,In.height,Ft[Bt],!1,Be,!1,!1,0,Tn,Y,!1)):(En.font=Be.baseFontFull,En.fillStyle=Be.bgCell,En.fillRect(0,0,Ct.width,Ct.height),NE(En,h([Bt,ht]),0,ht,!1,!1,0,0,In.width,In.height,!1,Be,Be.bgCell,dt,Tn,1,void 0,!1,0,void 0,void 0,void 0,rs,rt,()=>{}))),Ct.style.left="-100%",Ct.style.position="absolute",Ct.style.width=`${In.width}px`,Ct.style.height=`${In.height}px`,document.body.append(Ct),j.dataTransfer.setDragImage(Ct,In.width/2,In.height/2),window.setTimeout(()=>{Ct.remove()},0)}}else j.preventDefault()},[Le,ye,Ut,B,Vt,Be,Ft,Tn,Y,h,dt,rs,rt]);rr("dragstart",Sf,(W==null?void 0:W.current)??null,!1,!1);const bu=y.useRef(),ng=y.useCallback(j=>{const ae=it.current;if(Ce!==void 0&&j.preventDefault(),ae===null||Ie===void 0)return;const Te=Ut(ae,j.clientX,j.clientY),[we,fe]=Te.location,Pe=we-(H?0:1),[at,ut]=bu.current??[];(at!==Pe||ut!==fe)&&(bu.current=[Pe,fe],Ie([Pe,fe],j.dataTransfer))},[H,Ut,Ie,Ce]);rr("dragover",ng,(W==null?void 0:W.current)??null,!1,!1);const Xw=y.useCallback(()=>{bu.current=void 0,q==null||q()},[q]);rr("dragend",Xw,(W==null?void 0:W.current)??null,!1,!1);const Z=y.useCallback(j=>{const ae=it.current;if(ae===null||Ce===void 0)return;j.preventDefault();const Te=Ut(ae,j.clientX,j.clientY),[we,fe]=Te.location,Pe=we-(H?0:1);Ce([Pe,fe],j.dataTransfer)},[H,Ut,Ce]);rr("drop",Z,(W==null?void 0:W.current)??null,!1,!1);const ur=y.useCallback(()=>{xt==null||xt()},[xt]);rr("dragleave",ur,(W==null?void 0:W.current)??null,!1,!1);const Bn=y.useRef(x);Bn.current=x;const Kl=y.useRef(null),xu=y.useCallback(j=>{var ae;it.current===null||!it.current.contains(document.activeElement)||(j===null&&Bn.current.current!==void 0?(ae=P==null?void 0:P.current)==null||ae.focus({preventScroll:!0}):j!==null&&j.focus({preventScroll:!0}),Kl.current=j)},[P]);y.useImperativeHandle(e,()=>({focus:()=>{var ae;const j=Kl.current;j===null||!document.contains(j)?(ae=P==null?void 0:P.current)==null||ae.focus({preventScroll:!0}):j.focus({preventScroll:!0})},getBounds:(j,ae)=>{if(!(P===void 0||P.current===null))return Vt(P.current,j??0,ae??-1)},damage:pe}),[P,pe,Vt]);const ro=y.useRef(),Ir=UF(()=>{var ut,Re,$t;if(n<50||(ot==null?void 0:ot.disableAccessibilityTree)===!0)return null;let j=U0(Ft,mt,n,se,Ke);const ae=H?0:-1;!H&&((ut=j[0])==null?void 0:ut.sourceIndex)===0&&(j=j.slice(1));const[Te,we]=((Re=x.current)==null?void 0:Re.cell)??[],fe=($t=x.current)==null?void 0:$t.range,Pe=j.map(je=>je.sourceIndex),at=gl(l,Math.min(d,l+i));return Te!==void 0&&we!==void 0&&!(Pe.includes(Te)&&at.includes(we))&&xu(null),y.createElement("table",{key:"access-tree",role:"grid","aria-rowcount":d+1,"aria-multiselectable":"true","aria-colcount":Ft.length+ae},y.createElement("thead",{role:"rowgroup"},y.createElement("tr",{role:"row","aria-rowindex":1},j.map(je=>y.createElement("th",{role:"columnheader","aria-selected":x.columns.hasIndex(je.sourceIndex),"aria-colindex":je.sourceIndex+1+ae,tabIndex:-1,onFocus:Bt=>{if(Bt.target!==Kl.current)return Se==null?void 0:Se([je.sourceIndex,-1])},key:je.sourceIndex},je.title)))),y.createElement("tbody",{role:"rowgroup"},at.map(je=>y.createElement("tr",{role:"row","aria-selected":x.rows.hasIndex(je),key:je,"aria-rowindex":je+2},j.map(Bt=>{const ht=Bt.sourceIndex,Ct=Vi(ht,je),In=Te===ht&&we===je,yt=fe!==void 0&&ht>=fe.x&&ht=fe.y&&je{const Kr=P==null?void 0:P.current;if(Kr!=null)return X==null?void 0:X({bounds:Vt(Kr,ht,je),cancel:()=>{},preventDefault:()=>{},stopPropagation:()=>{},ctrlKey:!1,key:"Enter",keyCode:13,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:ci})},onFocusCapture:Kr=>{var Nt,Nn;if(!(Kr.target===Kl.current||((Nt=ro.current)==null?void 0:Nt[0])===ht&&((Nn=ro.current)==null?void 0:Nn[1])===je))return ro.current=ci,Se==null?void 0:Se(ci)},ref:In?xu:void 0,tabIndex:-1},t6(vn,rt))})))))},[n,Ft,mt,se,Ke,d,l,i,x,xu,h,P,X,Vt,Se],200),Ii=C===0||!M?0:mt>C?1:Wi(-Ke/100,0,1),rg=-l*32+an,Xl=I?Wi(-rg/100,0,1):0,ig=y.useMemo(()=>{if(!Ii&&!Xl)return null;const j={position:"absolute",top:0,left:tn,width:n-tn,height:r,opacity:Ii,pointerEvents:"none",transition:nt?void 0:"opacity 0.2s",boxShadow:"inset 13px 0 10px -13px rgba(0, 0, 0, 0.2)"},ae={position:"absolute",top:er,left:0,width:n,height:r,opacity:Xl,pointerEvents:"none",transition:ge?void 0:"opacity 0.2s",boxShadow:"inset 0 13px 10px -13px rgba(0, 0, 0, 0.2)"};return y.createElement(y.Fragment,null,Ii>0&&y.createElement("div",{id:"shadow-x",style:j}),Xl>0&&y.createElement("div",{id:"shadow-y",style:ae}))},[Ii,Xl,tn,n,nt,er,r,ge]),sg=y.useMemo(()=>({position:"absolute",top:0,left:0}),[]);return y.createElement(y.Fragment,null,y.createElement("canvas",{"data-testid":"data-grid-canvas",tabIndex:0,onKeyDown:yn,onKeyUp:Jo,onFocus:v,onBlur:w,ref:tg,style:to},Ir),y.createElement("canvas",{ref:Ht,style:sg}),ig)},r6=y.memo(y.forwardRef(n6));function ju(t,e,n,r){return Wi(Math.round(e-(t.growOffset??0)),Math.ceil(n),Math.floor(r))}const i6=t=>{const[e,n]=y.useState(),[r,i]=y.useState(),[s,o]=y.useState(),[l,a]=y.useState(),[u,c]=y.useState(!1),[f,d]=y.useState(),[h,p]=y.useState(),[g,b]=y.useState(),[m,v]=y.useState(!1),[w,k]=y.useState(),{onHeaderMenuClick:x,getCellContent:C,onColumnMoved:T,onColumnResize:A,onColumnResizeStart:M,onColumnResizeEnd:I,gridRef:D,maxColumnWidth:O,minColumnWidth:L,onRowMoved:_,lockColumns:re,onColumnProposeMove:ie,onMouseDown:se,onMouseUp:H,onItemHovered:X,onDragStart:R,canvasRef:N}=t,P=(A??I??M)!==void 0,{columns:B,selection:q}=t,W=q.columns,ye=y.useCallback(be=>{const[xe,Y]=be.location;s!==void 0&&l!==xe&&xe>=re?(c(!0),a(xe)):h!==void 0&&Y!==void 0?(v(!0),b(Math.max(0,Y))):r===void 0&&!u&&!m&&(X==null||X(be))},[s,h,l,X,re,r,u,m]),ee=T!==void 0,me=y.useCallback(be=>{var xe;if(be.button===0){const[Y,Se]=be.location;if(be.kind==="out-of-bounds"&&be.isEdge&&P){const Ie=(xe=D==null?void 0:D.current)==null?void 0:xe.getBounds(B.length-1,-1);Ie!==void 0&&(n(Ie.x),i(B.length-1))}else if(be.kind==="header"&&Y>=re){const Ie=N==null?void 0:N.current;if(be.isEdge&&P&&Ie){n(be.bounds.x),i(Y);const xt=Ie.getBoundingClientRect().width/Ie.offsetWidth,$e=be.bounds.width/xt;M==null||M(B[Y],$e,Y,$e+(B[Y].growOffset??0))}else be.kind==="header"&&ee&&(d(be.bounds.x),o(Y))}else be.kind==="cell"&&re>0&&Y===0&&Se!==void 0&&_!==void 0&&(k(be.bounds.y),p(Se))}se==null||se(be)},[se,P,re,_,D,B,ee,M,N]),Le=y.useCallback((be,xe)=>{u||m||x==null||x(be,xe)},[u,m,x]),Ue=y.useRef(-1),ze=y.useCallback(()=>{Ue.current=-1,p(void 0),b(void 0),k(void 0),v(!1),o(void 0),a(void 0),d(void 0),c(!1),i(void 0),n(void 0)},[]),Mt=y.useCallback((be,xe)=>{if(be.button===0){if(r!==void 0){if((W==null?void 0:W.hasIndex(r))===!0)for(const Se of W){if(Se===r)continue;const Ie=B[Se],Ce=ju(Ie,Ue.current,L,O);A==null||A(Ie,Ce,Se,Ce+(Ie.growOffset??0))}const Y=ju(B[r],Ue.current,L,O);if(I==null||I(B[r],Y,r,Y+(B[r].growOffset??0)),W.hasIndex(r))for(const Se of W){if(Se===r)continue;const Ie=B[Se],Ce=ju(Ie,Ue.current,L,O);I==null||I(Ie,Ce,Se,Ce+(Ie.growOffset??0))}}ze(),s!==void 0&&l!==void 0&&(T==null||T(s,l)),h!==void 0&&g!==void 0&&(_==null||_(h,g))}H==null||H(be,xe)},[H,r,s,l,h,g,W,I,B,L,O,A,T,_,ze]),tt=y.useMemo(()=>{if(!(s===void 0||l===void 0)&&s!==l&&(ie==null?void 0:ie(s,l))!==!1)return{src:s,dest:l}},[s,l,ie]),Be=y.useCallback(be=>{const xe=N==null?void 0:N.current;if(s!==void 0&&f!==void 0)Math.abs(be.clientX-f)>20&&c(!0);else if(h!==void 0&&w!==void 0)Math.abs(be.clientY-w)>20&&v(!0);else if(r!==void 0&&e!==void 0&&xe){const Se=xe.getBoundingClientRect().width/xe.offsetWidth,Ie=(be.clientX-e)/Se,Ce=B[r],xt=ju(Ce,Ie,L,O);if(A==null||A(Ce,xt,r,xt+(Ce.growOffset??0)),Ue.current=Ie,(W==null?void 0:W.first())===r)for(const $e of W){if($e===r)continue;const nt=B[$e],ge=ju(nt,Ue.current,L,O);A==null||A(nt,ge,$e,ge+(nt.growOffset??0))}}},[s,f,h,w,r,e,B,L,O,A,W,N]),ue=y.useCallback((be,xe)=>{if(h===void 0||g===void 0)return C(be,xe);let[Y,Se]=be;return Se===g?Se=h:(Se>g&&(Se-=1),Se>=h&&(Se+=1)),C([Y,Se],xe)},[h,g,C]),It=y.useCallback(be=>{R==null||R(be),be.defaultPrevented()||ze()},[ze,R]);return y.createElement(r6,{accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,columns:t.columns,disabledRows:t.disabledRows,drawFocusRing:t.drawFocusRing,drawHeader:t.drawHeader,drawCell:t.drawCell,enableGroups:t.enableGroups,eventTargetRef:t.eventTargetRef,experimental:t.experimental,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,headerIcons:t.headerIcons,height:t.height,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,resizeColumn:r,isDraggable:t.isDraggable,isFilling:t.isFilling,isFocused:t.isFocused,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDrop:t.onDrop,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseMove:t.onMouseMove,prelightCells:t.prelightCells,rowHeight:t.rowHeight,rows:t.rows,selection:t.selection,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,verticalBorder:t.verticalBorder,width:t.width,getCellContent:ue,isResizing:r!==void 0,onHeaderMenuClick:Le,isDragging:u,onItemHovered:ye,onDragStart:It,onMouseDown:me,allowResize:P,onMouseUp:Mt,dragAndDropState:tt,onMouseMoveRaw:Be,ref:D})};function s6(t){const e=y.useRef(null),[n,r]=y.useState({width:t==null?void 0:t[0],height:t==null?void 0:t[1]});return y.useLayoutEffect(()=>{const i=o=>{for(const l of o){const{width:a,height:u}=l&&l.contentRect||{};r(c=>c.width===a&&c.height===u?c:{width:a,height:u})}},s=new window.ResizeObserver(i);return e.current&&s.observe(e.current,void 0),()=>{s.disconnect()}},[e.current]),{ref:e,...n}}const o6=(t,e,n)=>{const r=y.useRef(null),i=y.useRef(null),s=y.useRef(null),o=y.useRef(0),l=y.useRef(e);l.current=e;const a=n.current;y.useEffect(()=>{const u=()=>{var d,h;if(i.current===!1&&a!==null){const p=[a.scrollLeft,a.scrollTop];if(((d=s.current)==null?void 0:d[0])===p[0]&&((h=s.current)==null?void 0:h[1])===p[1])if(o.current>10){s.current=null,i.current=null;return}else o.current++;else o.current=0,l.current(p[0],p[1]),s.current=p;r.current=window.setTimeout(u,8.333333333333334)}},c=()=>{i.current=!0,s.current=null,r.current!==null&&(window.clearTimeout(r.current),r.current=null)},f=d=>{d.touches.length===0&&(i.current=!1,o.current=0,r.current=window.setTimeout(u,8.333333333333334))};if(t&&a!==null){const d=a;return d.addEventListener("touchstart",c),d.addEventListener("touchend",f),()=>{d.removeEventListener("touchstart",c),d.removeEventListener("touchend",f),r.current!==null&&window.clearTimeout(r.current)}}},[t,a])},l6=()=>t=>t.isSafari?"scroll":"auto",a6=ai("div")({name:"ScrollRegionStyle",class:"gdg-s1dgczr6",propsAsIs:!1,vars:{"s1dgczr6-0":[l6()]}});function u6(t){const[e,n]=y.useState(!1),r=typeof window>"u"?null:window,i=y.useRef(0);return rr("touchstart",y.useCallback(()=>{window.clearTimeout(i.current),n(!0)},[]),r,!0,!1),rr("touchend",y.useCallback(s=>{s.touches.length===0&&(i.current=window.setTimeout(()=>n(!1),t))},[t]),r,!0,!1),e}const c6=t=>{var B,q;const{children:e,clientHeight:n,scrollHeight:r,scrollWidth:i,update:s,draggable:o,className:l,preventDiagonalScrolling:a=!1,paddingBottom:u=0,paddingRight:c=0,rightElement:f,rightElementProps:d,kineticScrollPerfHack:h=!1,scrollRef:p,initialSize:g}=t,b=[],m=(d==null?void 0:d.sticky)??!1,v=(d==null?void 0:d.fill)??!1,w=y.useRef(0),k=y.useRef(0),x=y.useRef(null),C=typeof window>"u"?1:window.devicePixelRatio,T=y.useRef({scrollLeft:0,scrollTop:0,lockDirection:void 0}),A=y.useRef(null),M=u6(200),[I,D]=y.useState(!0),O=y.useRef(0);y.useLayoutEffect(()=>{if(!I||M||T.current.lockDirection===void 0)return;const W=x.current;if(W===null)return;const[ye,ee]=T.current.lockDirection;ye!==void 0?W.scrollLeft=ye:ee!==void 0&&(W.scrollTop=ee),T.current.lockDirection=void 0},[M,I]);const L=y.useCallback((W,ye)=>{var xe;const ee=x.current;if(ee===null)return;ye=ye??ee.scrollTop,W=W??ee.scrollLeft;const me=T.current.scrollTop,Le=T.current.scrollLeft,Ue=W-Le,ze=ye-me;M&&Ue!==0&&ze!==0&&(Math.abs(Ue)>3||Math.abs(ze)>3)&&a&&T.current.lockDirection===void 0&&(T.current.lockDirection=Math.abs(Ue)0&&(Math.abs(It)>2e3||ue===0||ue===be)&&r>ee.scrollHeight+5){const Y=ue/be,Se=(r-Be)*Y;w.current=Se-ue}Mt!==void 0&&(window.clearTimeout(O.current),D(!1),O.current=window.setTimeout(()=>D(!0),200)),s({x:W,y:ue+w.current,width:tt-c,height:Be-u,paddingRight:((xe=A.current)==null?void 0:xe.clientWidth)??0})},[u,c,r,s,a,M]);o6(h&&zh.value,L,x);const _=y.useRef(L);_.current=L;const re=y.useRef(),ie=y.useRef(!1);y.useLayoutEffect(()=>{ie.current?L():ie.current=!0},[L,u,c]);const se=y.useCallback(W=>{x.current=W,p!==void 0&&(p.current=W)},[p]);let H=0,X=0;for(b.push(y.createElement("div",{key:H++,style:{width:i,height:0}}));X_.current(),0),re.current={width:N,height:P}),(N??0)===0||(P??0)===0?y.createElement("div",{ref:R}):y.createElement("div",{ref:R},y.createElement(a6,{isSafari:zh.value},y.createElement("div",{className:"dvn-underlay"},e),y.createElement("div",{ref:se,style:re.current,draggable:o,onDragStart:W=>{o||(W.stopPropagation(),W.preventDefault())},className:"dvn-scroller "+(l??""),onScroll:()=>L()},y.createElement("div",{className:"dvn-scroll-inner"+(f===void 0?" dvn-hidden":"")},y.createElement("div",{className:"dvn-stack"},b),f!==void 0&&y.createElement(y.Fragment,null,!v&&y.createElement("div",{className:"dvn-spacer"}),y.createElement("div",{ref:A,style:{height:P,maxHeight:n-Math.ceil(C%1),position:"sticky",top:0,paddingLeft:1,marginBottom:-40,marginRight:c,flexGrow:v?1:void 0,right:m?c??0:void 0,pointerEvents:"auto"}},f))))))},f6=t=>{const{columns:e,rows:n,rowHeight:r,headerHeight:i,groupHeaderHeight:s,enableGroups:o,freezeColumns:l,experimental:a,nonGrowWidth:u,clientSize:c,className:f,onVisibleRegionChanged:d,scrollRef:h,preventDiagonalScrolling:p,rightElement:g,rightElementProps:b,overscrollX:m,overscrollY:v,initialSize:w,smoothScrollX:k=!1,smoothScrollY:x=!1,isDraggable:C}=t,{paddingRight:T,paddingBottom:A}=a??{},[M,I]=c,D=y.useRef(),O=y.useRef(),L=y.useRef(),_=y.useRef(),re=u+Math.max(0,m??0);let ie=o?i+s:i;if(typeof r=="number")ie+=n*r;else for(let R=0;R{var ze,Mt;if(se.current===void 0)return;const R={...se.current};let N=0,P=R.x<0?-R.x:0,B=0,q=0;R.x=R.x<0?0:R.x;let W=0;for(let tt=0;tt=Be+tt.width)N+=tt.width,q++,B++;else if(R.x>Be)N+=tt.width,k?P+=Be-R.x:q++,B++;else if(R.x+R.width>Be)N+=tt.width,B++;else break}let ye=0,ee=0,me=0;if(typeof r=="number")x?(ee=Math.floor(R.y/r),ye=ee*r-R.y):ee=Math.ceil(R.y/r),me=Math.ceil(R.height/r)+ee,ye<0&&me++;else{let tt=0;for(let Be=0;Be=tt+ue)tt+=ue,ee++,me++;else if(R.y>It)tt+=ue,x?ye+=It-R.y:ee++,me++;else if(R.y+R.height>ue/2+tt)tt+=ue,me++;else break}}const Le={x:q,y:ee,width:B-q,height:me-ee},Ue=D.current;(Ue===void 0||Ue.y!==Le.y||Ue.x!==Le.x||Ue.height!==Le.height||Ue.width!==Le.width||O.current!==P||L.current!==ye||R.width!==((ze=_.current)==null?void 0:ze[0])||R.height!==((Mt=_.current)==null?void 0:Mt[1]))&&(d==null||d({x:q,y:ee,width:B-q,height:me-ee},R.width,R.height,R.paddingRight??0,P,ye),D.current=Le,O.current=P,L.current=ye,_.current=[R.width,R.height])},[e,r,n,d,l,k,x]),X=y.useCallback(R=>{se.current=R,H()},[H]);return y.useEffect(()=>{H()},[H]),y.createElement(c6,{scrollRef:h,className:f,kineticScrollPerfHack:a==null?void 0:a.kineticScrollPerfHack,preventDiagonalScrolling:p,draggable:C===!0||typeof C=="string",scrollWidth:re+(T??0),scrollHeight:ie+(A??0),clientHeight:I,rightElement:g,paddingBottom:A,paddingRight:T,rightElementProps:b,update:X,initialSize:w},y.createElement(i6,{eventTargetRef:h,width:M,height:I,accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,columns:t.columns,disabledRows:t.disabledRows,enableGroups:t.enableGroups,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellContent:t.getCellContent,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,isFilling:t.isFilling,isFocused:t.isFocused,lockColumns:t.lockColumns,maxColumnWidth:t.maxColumnWidth,minColumnWidth:t.minColumnWidth,onHeaderMenuClick:t.onHeaderMenuClick,onMouseMove:t.onMouseMove,prelightCells:t.prelightCells,rowHeight:t.rowHeight,rows:t.rows,selection:t.selection,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,onColumnProposeMove:t.onColumnProposeMove,verticalBorder:t.verticalBorder,drawFocusRing:t.drawFocusRing,drawHeader:t.drawHeader,drawCell:t.drawCell,experimental:t.experimental,gridRef:t.gridRef,headerIcons:t.headerIcons,isDraggable:t.isDraggable,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onColumnMoved:t.onColumnMoved,onColumnResize:t.onColumnResize,onColumnResizeEnd:t.onColumnResizeEnd,onColumnResizeStart:t.onColumnResizeStart,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDragStart:t.onDragStart,onDrop:t.onDrop,onItemHovered:t.onItemHovered,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onRowMoved:t.onRowMoved,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY}))},d6=ai("div")({name:"SearchWrapper",class:"gdg-seveqep",propsAsIs:!1}),h6=y.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},y.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 244l144-144 144 144M256 120v292"})),p6=y.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},y.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 268l144 144 144-144M256 392V100"})),g6=y.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},y.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"32",d:"M368 368L144 144M368 144L144 368"})),m6=10,y6=t=>{const{canvasRef:e,cellYOffset:n,rows:r,columns:i,searchInputRef:s,searchValue:o,searchResults:l,onSearchValueChange:a,getCellsForSelection:u,onSearchResultsChanged:c,showSearch:f=!1,onSearchClose:d}=t,[h]=y.useState(()=>"search-box-"+Math.round(Math.random()*1e3)),[p,g]=y.useState(""),b=o??p,m=y.useCallback(N=>{g(N),a==null||a(N)},[a]),[v,w]=y.useState(),k=y.useRef(v);k.current=v,y.useEffect(()=>{l!==void 0&&(l.length>0?w(N=>({rowsSearched:r,results:l.length,selectedIndex:(N==null?void 0:N.selectedIndex)??-1})):w(void 0))},[r,l]);const x=y.useRef();x.current===void 0&&(x.current=new AbortController);const C=y.useRef(),[T,A]=y.useState([]),M=l??T,I=y.useCallback(()=>{C.current!==void 0&&(window.cancelAnimationFrame(C.current),C.current=void 0,x.current.abort())},[]),D=y.useRef(n);D.current=n;const O=y.useCallback(N=>{const P=new RegExp(N.replace(/([$()*+.?[\\\]^{|}-])/g,"\\$1"),"i");let B=D.current,q=Math.min(10,r),W=0;w(void 0),A([]);const ye=[],ee=async()=>{var be;if(u===void 0)return;const me=performance.now(),Le=r-W;let Ue=u({x:0,y:B,width:i.length,height:Math.min(q,Le,r-B)},x.current.signal);typeof Ue=="function"&&(Ue=await Ue());let ze=!1;for(const[xe,Y]of Ue.entries())for(const[Se,Ie]of Y.entries()){let Ce;switch(Ie.kind){case Ae.Text:case Ae.Number:Ce=Ie.displayData;break;case Ae.Uri:case Ae.Markdown:Ce=Ie.data;break;case Ae.Boolean:Ce=typeof Ie.data=="boolean"?Ie.data.toString():void 0;break;case Ae.Image:case Ae.Bubble:Ce=Ie.data.join("🐳");break;case Ae.Custom:Ce=Ie.copyData;break}Ce!==void 0&&P.test(Ce)&&(ye.push([Se,xe+B]),ze=!0)}const Mt=performance.now();ze&&A([...ye]),W+=Ue.length,ei(W<=r);const tt=((be=k.current)==null?void 0:be.selectedIndex)??-1;w({results:ye.length,rowsSearched:W,selectedIndex:tt}),c==null||c(ye,tt),B+q>=r?B=0:B+=q;const Be=Mt-me,ue=Math.max(Be,1),It=m6/ue;q=Math.ceil(q*It),W{var N;d==null||d(),w(void 0),A([]),c==null||c([],-1),I(),(N=e==null?void 0:e.current)==null||N.focus()},[I,e,d,c]),_=y.useCallback(N=>{m(N.target.value),l===void 0&&(N.target.value===""?(w(void 0),A([]),I()):O(N.target.value))},[O,I,m,l]);y.useEffect(()=>{f&&s.current!==null&&(m(""),s.current.focus({preventScroll:!0}))},[f,s,m]);const re=y.useCallback(N=>{var B;if((B=N==null?void 0:N.stopPropagation)==null||B.call(N),v===void 0)return;const P=(v.selectedIndex+1)%v.results;w({...v,selectedIndex:P}),c==null||c(M,P)},[v,c,M]),ie=y.useCallback(N=>{var B;if((B=N==null?void 0:N.stopPropagation)==null||B.call(N),v===void 0)return;let P=(v.selectedIndex-1)%v.results;P<0&&(P+=v.results),w({...v,selectedIndex:P}),c==null||c(M,P)},[c,M,v]),se=y.useCallback(N=>{(N.ctrlKey||N.metaKey)&&N.nativeEvent.code==="KeyF"||N.key==="Escape"?(L(),N.stopPropagation(),N.preventDefault()):N.key==="Enter"&&(N.shiftKey?ie():re())},[L,re,ie]);y.useEffect(()=>()=>{I()},[I]);const[H,X]=y.useState(!1);y.useEffect(()=>{if(f)X(!0);else{const N=setTimeout(()=>X(!1),150);return()=>clearTimeout(N)}},[f]);const R=y.useMemo(()=>{if(!f&&!H)return null;let N;v!==void 0&&(N=v.results>=1e3?"over 1000":`${v.results} result${v.results!==1?"s":""}`,v.selectedIndex>=0&&(N=`${v.selectedIndex+1} of ${N}`));const P=W=>{W.stopPropagation()},q={width:`${Math.floor(((v==null?void 0:v.rowsSearched)??0)/r*100)}%`};return y.createElement(d6,{className:f?"":"out",onMouseDown:P,onMouseMove:P,onMouseUp:P,onClick:P},y.createElement("div",{className:"gdg-search-bar-inner"},y.createElement("input",{id:h,"aria-hidden":!f,"data-testid":"search-input",ref:s,onChange:_,value:b,tabIndex:f?void 0:-1,onKeyDownCapture:se}),y.createElement("button",{"aria-label":"Previous Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:ie,disabled:((v==null?void 0:v.results)??0)===0},h6),y.createElement("button",{"aria-label":"Next Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:re,disabled:((v==null?void 0:v.results)??0)===0},p6),d!==void 0&&y.createElement("button",{"aria-label":"Close Search","aria-hidden":!f,"data-testid":"search-close-button",tabIndex:f?void 0:-1,onClick:L},g6)),v!==void 0?y.createElement(y.Fragment,null,y.createElement("div",{className:"gdg-search-status"},y.createElement("div",{"data-testid":"search-result-area"},N)),y.createElement("div",{className:"gdg-search-progress",style:q})):y.createElement("div",{className:"gdg-search-status"},y.createElement("label",{htmlFor:h},"Type to search")))},[f,H,v,r,h,s,_,b,se,ie,re,d,L]);return y.createElement(y.Fragment,null,y.createElement(f6,{prelightCells:M,accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,className:t.className,clientSize:t.clientSize,columns:t.columns,disabledRows:t.disabledRows,enableGroups:t.enableGroups,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,nonGrowWidth:t.nonGrowWidth,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellContent:t.getCellContent,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,initialSize:t.initialSize,isFilling:t.isFilling,isFocused:t.isFocused,lockColumns:t.lockColumns,maxColumnWidth:t.maxColumnWidth,minColumnWidth:t.minColumnWidth,onHeaderMenuClick:t.onHeaderMenuClick,onMouseMove:t.onMouseMove,onVisibleRegionChanged:t.onVisibleRegionChanged,overscrollX:t.overscrollX,overscrollY:t.overscrollY,preventDiagonalScrolling:t.preventDiagonalScrolling,rightElement:t.rightElement,rightElementProps:t.rightElementProps,rowHeight:t.rowHeight,rows:t.rows,scrollRef:t.scrollRef,selection:t.selection,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,verticalBorder:t.verticalBorder,onColumnProposeMove:t.onColumnProposeMove,drawFocusRing:t.drawFocusRing,drawCell:t.drawCell,drawHeader:t.drawHeader,experimental:t.experimental,gridRef:t.gridRef,headerIcons:t.headerIcons,isDraggable:t.isDraggable,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onColumnMoved:t.onColumnMoved,onColumnResize:t.onColumnResize,onColumnResizeEnd:t.onColumnResizeEnd,onColumnResizeStart:t.onColumnResizeStart,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDragStart:t.onDragStart,onDrop:t.onDrop,onItemHovered:t.onItemHovered,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onRowMoved:t.onRowMoved,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY}),R)};class v6 extends y.PureComponent{constructor(){super(...arguments);kt(this,"wrapperRef",y.createRef());kt(this,"clickOutside",n=>{if(!(this.props.isOutsideClick&&!this.props.isOutsideClick(n))&&this.wrapperRef.current!==null&&!this.wrapperRef.current.contains(n.target)){let r=n.target;for(;r!==null;){if(r.classList.contains("click-outside-ignore"))return;r=r.parentElement}this.props.onClickOutside()}})}componentDidMount(){document.addEventListener("touchend",this.clickOutside,!0),document.addEventListener("mousedown",this.clickOutside,!0),document.addEventListener("contextmenu",this.clickOutside,!0)}componentWillUnmount(){document.removeEventListener("touchend",this.clickOutside,!0),document.removeEventListener("mousedown",this.clickOutside,!0),document.removeEventListener("contextmenu",this.clickOutside,!0)}render(){const{onClickOutside:n,isOutsideClick:r,...i}=this.props;return y.createElement("div",{...i,ref:this.wrapperRef},this.props.children)}}const w6=()=>t=>Math.max(16,t.targetHeight-10),b6=ai("input")({name:"RenameInput",class:"gdg-r17m35ur",propsAsIs:!1,vars:{"r17m35ur-0":[w6(),"px"]}}),x6=t=>{const{bounds:e,group:n,onClose:r,canvasBounds:i,onFinish:s}=t,[o,l]=Kn.useState(n);return Kn.createElement(v6,{style:{position:"absolute",left:e.x-i.left+1,top:e.y-i.top,width:e.width-2,height:e.height},className:"gdg-c1tqibwd",onClickOutside:r},Kn.createElement(b6,{targetHeight:e.height,"data-testid":"group-rename-input",value:o,onBlur:r,onFocus:a=>a.target.setSelectionRange(0,o.length),onChange:a=>l(a.target.value),onKeyDown:a=>{a.key==="Enter"?s(o):a.key==="Escape"&&r()},autoFocus:!0}))};function k6(t,e){return t===void 0?!1:t.length>1&&t.startsWith("_")?Number.parseInt(t.slice(1))===e.keyCode:t.length===1&&t>="a"&&t<="z"?t.toUpperCase().codePointAt(0)===e.keyCode:t===e.key}function wt(t,e,n){const r=qE(t,e);return r&&(n.didMatch=!0),r}function qE(t,e){if(t.length===0)return!1;if(t.includes("|")){const a=t.split("|");for(const u of a)if(qE(u,e))return!0;return!1}let n=!1,r=!1,i=!1,s=!1;const o=t.split("+"),l=o.pop();if(!k6(l,e))return!1;if(o[0]==="any")return!0;for(const a of o)switch(a){case"ctrl":n=!0;break;case"shift":r=!0;break;case"alt":i=!0;break;case"meta":s=!0;break;case"primary":Bh.value?s=!0:n=!0;break}return e.altKey===i&&e.ctrlKey===n&&e.shiftKey===r&&e.metaKey===s}function S6(t,e,n,r,i,s){const o=Kn.useCallback((u,c,f,d)=>{var v;(s==="cell"||s==="multi-cell")&&u!==void 0&&(u={...u,range:{x:u.cell[0],y:u.cell[1],width:1,height:1}});const h=n==="mixed"&&(f||d==="drag"),p=r==="mixed"&&h,g=i==="mixed"&&h;let b={current:u===void 0?void 0:{...u,rangeStack:d==="drag"?((v=t.current)==null?void 0:v.rangeStack)??[]:[]},columns:p?t.columns:Pt.empty(),rows:g?t.rows:Pt.empty()};f&&(s==="multi-rect"||s==="multi-cell")&&b.current!==void 0&&t.current!==void 0&&(b={...b,current:{...b.current,rangeStack:[...t.current.rangeStack,t.current.range]}}),e(b,c)},[r,t,n,s,i,e]),l=Kn.useCallback((u,c,f)=>{u=u??t.rows,c!==void 0&&(u=u.add(c));let d;if(i==="exclusive"&&u.length>0)d={current:void 0,columns:Pt.empty(),rows:u};else{const h=f&&n==="mixed",p=f&&r==="mixed";d={current:h?t.current:void 0,columns:p?t.columns:Pt.empty(),rows:u}}e(d,!1)},[r,t,n,i,e]),a=Kn.useCallback((u,c,f)=>{u=u??t.columns,c!==void 0&&(u=u.add(c));let d;if(r==="exclusive"&&u.length>0)d={current:void 0,rows:Pt.empty(),columns:u};else{const h=f&&n==="mixed",p=f&&i==="mixed";d={current:h?t.current:void 0,rows:p?t.rows:Pt.empty(),columns:u}}e(d,!1)},[r,t,n,i,e]);return[o,l,a]}function C6(t,e,n,r,i){const s=y.useCallback(u=>{if(t===!0){const c=[];for(let f=u.y;f=i?d.push({kind:Ae.Loading,allowOverlay:!1}):d.push(e([h,f]));c.push(d)}return c}return(t==null?void 0:t(u,r.signal))??[]},[r.signal,e,t,i]),o=t!==void 0?s:void 0,l=y.useCallback(u=>{if(o===void 0)return[];const c={...u,x:u.x-n};if(c.x<0){c.x=0,c.width--;const f=o(c,r.signal);return typeof f=="function"?async()=>(await f()).map(d=>[{kind:Ae.Loading,allowOverlay:!1},...d]):f.map(d=>[{kind:Ae.Loading,allowOverlay:!1},...d])}return o(c,r.signal)},[r.signal,o,n]);return[t!==void 0?l:void 0,o]}function T6(t){if(t.copyData!==void 0)return{formatted:t.copyData,rawValue:t.copyData,format:"string"};switch(t.kind){case Ae.Boolean:return{formatted:t.data===!0?"TRUE":t.data===!1?"FALSE":t.data===Zv?"INDETERMINATE":"",rawValue:t.data,format:"boolean"};case Ae.Custom:return{formatted:t.copyData,rawValue:t.copyData,format:"string"};case Ae.Image:case Ae.Bubble:return{formatted:t.data,rawValue:t.data,format:"string-array"};case Ae.Drilldown:return{formatted:t.data.map(e=>e.text),rawValue:t.data.map(e=>e.text),format:"string-array"};case Ae.Text:return{formatted:t.displayData??t.data,rawValue:t.data,format:"string"};case Ae.Uri:return{formatted:t.displayData??t.data,rawValue:t.data,format:"url"};case Ae.Markdown:case Ae.RowID:return{formatted:t.data,rawValue:t.data,format:"string"};case Ae.Number:return{formatted:t.displayData,rawValue:t.data,format:"number"};case Ae.Loading:return{formatted:"#LOADING",rawValue:"",format:"string"};case Ae.Protected:return{formatted:"************",rawValue:"",format:"string"};default:Wc()}}function E6(t,e){return t.map((r,i)=>{const s=e[i];return r.map(o=>o.span!==void 0&&o.span[0]!==s?{formatted:"",rawValue:"",format:"string"}:T6(o))})}function Vx(t,e){return(e?/[\t\n",]/:/[\t\n"]/).test(t)&&(t=`"${t.replace(/"/g,'""')}"`),t}function A6(t){var n;const e=[];for(const r of t){const i=[];for(const s of r)s.format==="url"?i.push(((n=s.rawValue)==null?void 0:n.toString())??""):s.format==="string-array"?i.push(s.formatted.map(o=>Vx(o,!0)).join(",")):i.push(Vx(s.formatted,!1));e.push(i.join(" "))}return e.join(` +`)}function lm(t){return t.replace(/\t/g," ").replace(/ {2,}/g,e=>" ".repeat(e.length))}function Ux(t){return'"'+t.replace(/&/g,"&").replace(/"/g,""").replace(//g,">")+'"'}function M6(t){return t.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function R6(t){var n;const e=[];e.push('',"");for(const r of t){e.push("");for(const i of r){const s=`gdg-format="${i.format}"`;i.format==="url"?e.push(``):i.format==="string-array"?e.push(``):e.push(``)}e.push("")}return e.push("
    ${lm(i.formatted)}
      ${i.formatted.map((o,l)=>`
    1. `+lm(o)+"
    2. ").join("")}
    ${lm(i.formatted)}
    "),e.join("")}function O6(t,e){const n=E6(t,e),r=A6(n),i=R6(n);return{textPlain:r,textHtml:i}}function Kx(t){var o;const e=document.createElement("html");e.innerHTML=t.replace(/ /g," ");const n=e.querySelector("table");if(n===null)return;const r=[n],i=[];let s;for(;r.length>0;){const l=r.pop();if(l===void 0)break;if(l instanceof HTMLTableElement||l.nodeName==="TBODY")r.push(...[...l.children].reverse());else if(l instanceof HTMLTableRowElement)s!==void 0&&i.push(s),s=[],r.push(...[...l.children].reverse());else if(l instanceof HTMLTableCellElement){const a=l.cloneNode(!0),c=a.children.length===1&&a.children[0].nodeName==="P"?a.children[0]:null,f=(c==null?void 0:c.children.length)===1&&c.children[0].nodeName==="FONT",d=a.querySelectorAll("br");for(const g of d)g.replaceWith(` +`);const h=a.getAttribute("gdg-raw-value"),p=a.getAttribute("gdg-format")??"string";if(a.querySelector("a")!==null)s==null||s.push({rawValue:((o=a.querySelector("a"))==null?void 0:o.getAttribute("href"))??"",formatted:a.textContent??"",format:p});else if(a.querySelector("ol")!==null){const g=a.querySelectorAll("li");s==null||s.push({rawValue:[...g].map(b=>b.getAttribute("gdg-raw-value")??""),formatted:[...g].map(b=>b.textContent??""),format:"string-array"})}else if(h!==null)s==null||s.push({rawValue:M6(h),formatted:a.textContent??"",format:p});else{let g=a.textContent??"";f&&(g=g.replace(/\n(?!\n)/g,"")),s==null||s.push({rawValue:g??"",formatted:g??"",format:p})}}}return s!==void 0&&i.push(s),i}function P6(t,e,n,r,i){var l;const s=t;if(r==="allowPartial"||t.current===void 0||e===void 0)return t;let o=!1;do{if((t==null?void 0:t.current)===void 0)break;const a=(l=t.current)==null?void 0:l.range,u=[];if(a.width>2){const d=e({x:a.x,y:a.y,width:1,height:a.height},i.signal);if(typeof d=="function")return s;u.push(...d);const h=e({x:a.x+a.width-1,y:a.y,width:1,height:a.height},i.signal);if(typeof h=="function")return s;u.push(...h)}else{const d=e({x:a.x,y:a.y,width:a.width,height:a.height},i.signal);if(typeof d=="function")return s;u.push(...d)}let c=a.x-n,f=a.x+a.width-1-n;for(const d of u)for(const h of d)h.span!==void 0&&(c=Math.min(h.span[0],c),f=Math.max(h.span[1],f));c===a.x-n&&f===a.x+a.width-1-n?o=!0:t={current:{cell:t.current.cell??[0,0],range:{x:c+n,y:a.y,width:f-c+1,height:a.height},rangeStack:t.current.rangeStack},columns:t.columns,rows:t.rows}}while(!o);return t}function Xx(t){return t.startsWith('"')&&t.endsWith('"')&&(t=t.slice(1,-1).replace(/""/g,'"')),t}function I6(t){let e;(function(l){l[l.None=0]="None",l[l.inString=1]="inString",l[l.inStringPostQuote=2]="inStringPostQuote"})(e||(e={}));const n=[];let r=[],i=0,s=e.None;t=t.replace(/\r\n/g,` +`);let o=0;for(const l of t){switch(s){case e.None:l===" "||l===` +`?(r.push(t.slice(i,o)),i=o+1,l===` +`&&(n.push(r),r=[])):l==='"'&&(s=e.inString);break;case e.inString:l==='"'&&(s=e.inStringPostQuote);break;case e.inStringPostQuote:l==='"'?s=e.inString:((l===" "||l===` +`)&&(r.push(Xx(t.slice(i,o))),i=o+1,l===` +`&&(n.push(r),r=[])),s=e.None);break}o++}return il.map(a=>({rawValue:a,formatted:a,format:"string"})))}function Gx(t,e,n){var l;const r=O6(t,e),i=a=>{var u;(u=window.navigator.clipboard)==null||u.writeText(a)},s=(a,u)=>{var c;return((c=window.navigator.clipboard)==null?void 0:c.write)===void 0?!1:(window.navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([a],{type:"text/plain"}),"text/html":new Blob([u],{type:"text/html"})})]),!0)},o=(a,u)=>{var c,f;try{if(n===void 0||n.clipboardData===null)throw new Error("No clipboard data");(c=n==null?void 0:n.clipboardData)==null||c.setData("text/plain",a),(f=n==null?void 0:n.clipboardData)==null||f.setData("text/html",u)}catch{s(a,u)||i(a)}};((l=window.navigator.clipboard)==null?void 0:l.write)!==void 0||(n==null?void 0:n.clipboardData)!==void 0?o(r.textPlain,r.textHtml):i(r.textPlain),n==null||n.preventDefault()}function YE(t){return t!==!0}function qx(t){return typeof t=="string"?t:`${t}px`}const N6=()=>t=>t.innerWidth,_6=()=>t=>t.innerHeight,D6=ai("div")({name:"Wrapper",class:"gdg-wmyidgi",propsAsIs:!1,vars:{"wmyidgi-0":[N6()],"wmyidgi-1":[_6()]}}),L6=t=>{const{inWidth:e,inHeight:n,children:r,...i}=t;return y.createElement(D6,{innerHeight:qx(n),innerWidth:qx(e),...i},r)},$6=2,F6=1300;function z6(t,e,n){const r=Kn.useRef(0),[i,s]=t??[0,0];Kn.useEffect(()=>{if(i===0&&s===0){r.current=0;return}let o=!1,l=0;const a=u=>{var c;if(!o){if(l===0)l=u;else{const f=u-l;r.current=Math.min(1,r.current+f/F6);const d=r.current**1.618*f*$6;(c=e.current)==null||c.scrollBy(i*d,s*d),l=u,n==null||n()}window.requestAnimationFrame(a)}};return window.requestAnimationFrame(a),()=>{o=!0}},[e,i,s,n])}function B6({rowHeight:t,headerHeight:e,groupHeaderHeight:n,theme:r,overscrollX:i,overscrollY:s,scaleToRem:o,remSize:l}){const[a,u,c,f,d,h]=Kn.useMemo(()=>{if(!o||l===16)return[t,e,n,r,i,s];const p=l/16,g=t,b=xE();return[typeof g=="number"?g*p:m=>Math.ceil(g(m)*p),Math.ceil(e*p),Math.ceil(n*p),{...r,headerIconSize:((r==null?void 0:r.headerIconSize)??b.headerIconSize)*p,cellHorizontalPadding:((r==null?void 0:r.cellHorizontalPadding)??b.cellHorizontalPadding)*p,cellVerticalPadding:((r==null?void 0:r.cellVerticalPadding)??b.cellVerticalPadding)*p},Math.ceil((i??0)*p),Math.ceil((s??0)*p)]},[n,e,i,s,l,t,o,r]);return{rowHeight:a,headerHeight:u,groupHeaderHeight:c,theme:f,overscrollX:d,overscrollY:h}}const fo={downFill:!1,rightFill:!1,clear:!0,closeOverlay:!0,acceptOverlayDown:!0,acceptOverlayUp:!0,acceptOverlayLeft:!0,acceptOverlayRight:!0,copy:!0,paste:!0,cut:!0,search:!1,delete:!0,activateCell:!0,scrollToSelectedCell:!0,goToFirstCell:!0,goToFirstColumn:!0,goToFirstRow:!0,goToLastCell:!0,goToLastColumn:!0,goToLastRow:!0,goToNextPage:!0,goToPreviousPage:!0,selectToFirstCell:!0,selectToFirstColumn:!0,selectToFirstRow:!0,selectToLastCell:!0,selectToLastColumn:!0,selectToLastRow:!0,selectAll:!0,selectRow:!0,selectColumn:!0,goUpCell:!0,goRightCell:!0,goDownCell:!0,goLeftCell:!0,goUpCellRetainSelection:!0,goRightCellRetainSelection:!0,goDownCellRetainSelection:!0,goLeftCellRetainSelection:!0,selectGrowUp:!0,selectGrowRight:!0,selectGrowDown:!0,selectGrowLeft:!0};function bt(t,e){return t===!0?e:t===!1?"":t}function Yx(t){const e=Bh.value;return{activateCell:bt(t.activateCell," |Enter|shift+Enter"),clear:bt(t.clear,"any+Escape"),closeOverlay:bt(t.closeOverlay,"any+Escape"),acceptOverlayDown:bt(t.acceptOverlayDown,"Enter"),acceptOverlayUp:bt(t.acceptOverlayUp,"shift+Enter"),acceptOverlayLeft:bt(t.acceptOverlayLeft,"shift+Tab"),acceptOverlayRight:bt(t.acceptOverlayRight,"Tab"),copy:t.copy,cut:t.cut,delete:bt(t.delete,e?"Backspace|Delete":"Delete"),downFill:bt(t.downFill,"primary+_68"),scrollToSelectedCell:bt(t.scrollToSelectedCell,"primary+Enter"),goDownCell:bt(t.goDownCell,"ArrowDown"),goDownCellRetainSelection:bt(t.goDownCellRetainSelection,"alt+ArrowDown"),goLeftCell:bt(t.goLeftCell,"ArrowLeft|shift+Tab"),goLeftCellRetainSelection:bt(t.goLeftCellRetainSelection,"alt+ArrowLeft"),goRightCell:bt(t.goRightCell,"ArrowRight|Tab"),goRightCellRetainSelection:bt(t.goRightCellRetainSelection,"alt+ArrowRight"),goUpCell:bt(t.goUpCell,"ArrowUp"),goUpCellRetainSelection:bt(t.goUpCellRetainSelection,"alt+ArrowUp"),goToFirstCell:bt(t.goToFirstCell,"primary+Home"),goToFirstColumn:bt(t.goToFirstColumn,"Home|primary+ArrowLeft"),goToFirstRow:bt(t.goToFirstRow,"primary+ArrowUp"),goToLastCell:bt(t.goToLastCell,"primary+End"),goToLastColumn:bt(t.goToLastColumn,"End|primary+ArrowRight"),goToLastRow:bt(t.goToLastRow,"primary+ArrowDown"),goToNextPage:bt(t.goToNextPage,"PageDown"),goToPreviousPage:bt(t.goToPreviousPage,"PageUp"),paste:t.paste,rightFill:bt(t.rightFill,"primary+_82"),search:bt(t.search,"primary+f"),selectAll:bt(t.selectAll,"primary+a"),selectColumn:bt(t.selectColumn,"ctrl+ "),selectGrowDown:bt(t.selectGrowDown,"shift+ArrowDown"),selectGrowLeft:bt(t.selectGrowLeft,"shift+ArrowLeft"),selectGrowRight:bt(t.selectGrowRight,"shift+ArrowRight"),selectGrowUp:bt(t.selectGrowUp,"shift+ArrowUp"),selectRow:bt(t.selectRow,"shift+ "),selectToFirstCell:bt(t.selectToFirstCell,"primary+shift+Home"),selectToFirstColumn:bt(t.selectToFirstColumn,"primary+shift+ArrowLeft"),selectToFirstRow:bt(t.selectToFirstRow,"primary+shift+ArrowUp"),selectToLastCell:bt(t.selectToLastCell,"primary+shift+End"),selectToLastColumn:bt(t.selectToLastColumn,"primary+shift+ArrowRight"),selectToLastRow:bt(t.selectToLastRow,"primary+shift+ArrowDown")}}function j6(t){const e=YF(t);return Kn.useMemo(()=>{if(e===void 0)return Yx(fo);const n={...e,goToNextPage:(e==null?void 0:e.goToNextPage)??(e==null?void 0:e.pageDown)??fo.goToNextPage,goToPreviousPage:(e==null?void 0:e.goToPreviousPage)??(e==null?void 0:e.pageUp)??fo.goToPreviousPage,goToFirstCell:(e==null?void 0:e.goToFirstCell)??(e==null?void 0:e.first)??fo.goToFirstCell,goToLastCell:(e==null?void 0:e.goToLastCell)??(e==null?void 0:e.last)??fo.goToLastCell,selectToFirstCell:(e==null?void 0:e.selectToFirstCell)??(e==null?void 0:e.first)??fo.selectToFirstCell,selectToLastCell:(e==null?void 0:e.selectToLastCell)??(e==null?void 0:e.last)??fo.selectToLastCell};return Yx({...fo,...n})},[e])}const H6=y.lazy(async()=>await SE(()=>import("./data-grid-overlay-editor-pDz6NZm5.js"),[]));let W6=0;function V6(t){return X5(gx(gx(t).filter(e=>e.span!==void 0).map(e=>{var n,r;return gl((((n=e.span)==null?void 0:n[0])??0)+1,(((r=e.span)==null?void 0:r[1])??0)+1)})))}function od(t,e){return t===void 0||e===0||t.columns.length===0&&t.current===void 0?t:{current:t.current===void 0?void 0:{cell:[t.current.cell[0]+e,t.current.cell[1]],range:{...t.current.range,x:t.current.range.x+e},rangeStack:t.current.rangeStack.map(n=>({...n,x:n.x+e}))},rows:t.rows,columns:t.columns.offset(e)}}const am={kind:Ae.Loading,allowOverlay:!1},ld={columns:Pt.empty(),rows:Pt.empty(),current:void 0},U6=(t,e)=>{var l1,a1,u1;const[n,r]=y.useState(ld),[i,s]=y.useState(),o=y.useRef(null),l=y.useRef(null),[a,u]=y.useState(),c=y.useRef(null),f=y.useRef(),d=typeof window>"u"?null:window,{imageEditorOverride:h,getRowThemeOverride:p,markdownDivCreateNode:g,width:b,height:m,columns:v,rows:w,getCellContent:k,onCellClicked:x,onCellActivated:C,onFillPattern:T,onFinishedEditing:A,coercePasteValue:M,drawHeader:I,drawCell:D,editorBloom:O,onHeaderClicked:L,onColumnProposeMove:_,spanRangeBehavior:re="default",onGroupHeaderClicked:ie,onCellContextMenu:se,className:H,onHeaderContextMenu:X,getCellsForSelection:R,onGroupHeaderContextMenu:N,onGroupHeaderRenamed:P,onCellEdited:B,onCellsEdited:q,onSearchResultsChanged:W,searchResults:ye,onSearchValueChange:ee,searchValue:me,onKeyDown:Le,onKeyUp:Ue,keybindings:ze,editOnType:Mt=!0,onRowAppended:tt,onColumnMoved:Be,validateCell:ue,highlightRegions:It,rangeSelect:be="rect",columnSelect:xe="multi",rowSelect:Y="multi",rangeSelectionBlending:Se="exclusive",columnSelectionBlending:Ie="exclusive",rowSelectionBlending:Ce="exclusive",onDelete:xt,onDragStart:$e,onMouseMove:nt,onPaste:ge,copyHeaders:ot=!1,freezeColumns:rt=0,cellActivationBehavior:Ke="second-click",rowSelectionMode:an="auto",onHeaderMenuClick:mt,getGroupDetails:it,onSearchClose:dt,onItemHovered:Yt,onSelectionCleared:mn,showSearch:qn,onVisibleRegionChanged:Jt,gridSelection:jt,onGridSelectionChange:Hn,minColumnWidth:bn=50,maxColumnWidth:Yn=500,maxColumnAutoWidth:Wr,provideEditor:Ht,trailingRowOptions:Qe,freezeTrailingRows:We=0,allowedFillDirections:Lt="orthogonal",scrollOffsetX:Qt,scrollOffsetY:Zt,verticalBorder:Tn,onDragOverCell:er,onDrop:pt,onColumnResize:Wt,onColumnResizeEnd:Rt,onColumnResizeStart:Ft,customRenderers:tn,fillHandle:Vt,drawFocusRing:Ut=!0,experimental:J,fixedShadowX:st,fixedShadowY:lt,headerIcons:Jn,imageWindowLoader:Vr,initialSize:rs,isDraggable:Wl,onDragLeave:Vl,onRowMoved:ui,overscrollX:Qs,overscrollY:Zs,preventDiagonalScrolling:eo,rightElement:z,rightElementProps:oe,trapFocus:Q=!1,smoothScrollX:pe,smoothScrollY:ve,scaleToRem:gt=!1,rowHeight:Fe=34,headerHeight:ct=36,groupHeaderHeight:ft=ct,theme:Kt,isOutsideClick:nn,renderers:zn}=t,rn=typeof t.rowMarkers=="string"?void 0:t.rowMarkers,xn=(rn==null?void 0:rn.kind)??t.rowMarkers??"none",xr=(rn==null?void 0:rn.width)??t.rowMarkerWidth,to=(rn==null?void 0:rn.startIndex)??t.rowMarkerStartIndex??1,Mi=(rn==null?void 0:rn.theme)??t.rowMarkerTheme,Ri=(rn==null?void 0:rn.checkboxStyle)??"square",ar=Math.max(bn,20),Oi=Math.max(Yn,ar),yu=Math.max(Wr??Oi,ar),no=y.useMemo(()=>typeof window>"u"?{fontSize:"16px"}:window.getComputedStyle(document.documentElement),[]),vu=y.useMemo(()=>Number.parseFloat(no.fontSize),[no]),{rowHeight:kr,headerHeight:Ul,groupHeaderHeight:wu,theme:xf,overscrollX:eg,overscrollY:kf}=B6({groupHeaderHeight:ft,headerHeight:ct,overscrollX:Qs,overscrollY:Zs,remSize:vu,rowHeight:Fe,scaleToRem:gt,theme:Kt}),Pi=j6(ze),Ps=xr??(w>1e4?48:w>1e3?44:w>100?36:32),Ur=xn!=="none",K=Ur?1:0,yn=tt!==void 0,Jo=(Qe==null?void 0:Qe.sticky)===!0,[tg,Sf]=y.useState(!1),bu=qn??tg,ng=y.useCallback(()=>{dt!==void 0?dt():Sf(!1)},[dt]),Z=y.useMemo(()=>jt===void 0?void 0:od(jt,K),[jt,K])??n,ur=y.useRef();ur.current===void 0&&(ur.current=new AbortController),y.useEffect(()=>()=>ur==null?void 0:ur.current.abort(),[]);const[Bn,Kl]=C6(R,k,K,ur.current,w),xu=y.useCallback((S,F,$)=>{if(ue===void 0)return!0;const V=[S[0]-K,S[1]];return ue==null?void 0:ue(V,F,$)},[K,ue]),ro=y.useRef(jt),Ir=y.useCallback((S,F)=>{F&&(S=P6(S,Bn,K,re,ur.current)),Hn!==void 0?(ro.current=od(S,-K),Hn(ro.current)):r(S)},[Hn,Bn,K,re]),Ii=na(Wt,y.useCallback((S,F,$,V)=>{Wt==null||Wt(v[$-K],F,$-K,V)},[Wt,K,v])),rg=na(Rt,y.useCallback((S,F,$,V)=>{Rt==null||Rt(v[$-K],F,$-K,V)},[Rt,K,v])),Xl=na(Ft,y.useCallback((S,F,$,V)=>{Ft==null||Ft(v[$-K],F,$-K,V)},[Ft,K,v])),ig=na(I,y.useCallback((S,F)=>(I==null?void 0:I({...S,columnIndex:S.columnIndex-K},F))??!1,[I,K])),sg=na(D,y.useCallback((S,F)=>(D==null?void 0:D({...S,col:S.col-K},F))??!1,[D,K])),j=y.useCallback(S=>{if(xt!==void 0){const F=xt(od(S,-K));return typeof F=="boolean"?F:od(F,K)}return!0},[xt,K]),[ae,Te,we]=S6(Z,Ir,Se,Ie,Ce,be),fe=y.useMemo(()=>$o(xE(),xf),[xf]),[Pe,at]=y.useState([0,0,0]),ut=y.useMemo(()=>{if(zn===void 0)return{};const S={};for(const F of zn)S[F.kind]=F;return S},[zn]),Re=y.useCallback(S=>S.kind!==Ae.Custom?ut[S.kind]:tn==null?void 0:tn.find(F=>F.isMatch(S)),[tn,ut]);let{sizedColumns:$t,nonGrowWidth:je}=U4(v,w,Kl,Pe[0]-(K===0?0:Ps)-Pe[2],ar,yu,fe,Re,ur.current);xn!=="none"&&(je+=Ps);const Bt=y.useMemo(()=>$t.some(S=>S.group!==void 0),[$t]),ht=Bt?Ul+wu:Ul,Ct=Z.rows.length,In=xn==="none"?void 0:Ct===0?!1:Ct===w?!0:void 0,yt=y.useMemo(()=>xn==="none"?$t:[{title:"",width:Ps,icon:void 0,hasMenu:!1,style:"normal",themeOverride:Mi,rowMarker:Ri,rowMarkerChecked:In},...$t],[xn,$t,Ps,Mi,Ri,In]),[En,ci]=y.useMemo(()=>[Zt!==void 0&&typeof kr=="number"?Math.floor(Zt/kr):0,Zt!==void 0&&typeof kr=="number"?-(Zt%kr):0],[Zt,kr]),vn=y.useRef({height:1,width:1,x:0,y:0}),Kr=y.useMemo(()=>({x:vn.current.x,y:En,width:vn.current.width??1,height:vn.current.height??1,ty:ci}),[ci,En]),Nt=y.useRef(!1),[Nn,Xr,is]=qF(Kr);vn.current=Nn;const Ni=(Nn.height??1)>1;y.useLayoutEffect(()=>{if(Zt!==void 0&&c.current!==null&&Ni){if(c.current.scrollTop===Zt)return;c.current.scrollTop=Zt,c.current.scrollTop!==Zt&&is(),Nt.current=!0}},[Zt,Ni,is]);const Gl=(Nn.width??1)>1;y.useLayoutEffect(()=>{if(Qt!==void 0&&c.current!==null&&Gl){if(c.current.scrollLeft===Qt)return;c.current.scrollLeft=Qt,c.current.scrollLeft!==Qt&&is(),Nt.current=!0}},[Qt,Gl,is]);const Qo=Nn.x+K,Cf=Nn.y,Nr=y.useRef(null),Sr=y.useCallback(S=>{var F;S===!0?(F=Nr.current)==null||F.focus():window.requestAnimationFrame(()=>{var $;($=Nr.current)==null||$.focus()})},[]),cr=yn?w+1:w,fi=y.useCallback(S=>{const F=K===0?S:S.map(V=>({...V,location:[V.location[0]-K,V.location[1]]})),$=q==null?void 0:q(F);if($!==!0)for(const V of F)B==null||B(V.location,V.value);return $},[B,q,K]),[Zo,og]=y.useState(),Tf=Z.current!==void 0&&Z.current.range.width*Z.current.range.height>1?Z.current.range:void 0,ql=Ut?(l1=Z.current)==null?void 0:l1.cell:void 0,Ef=ql==null?void 0:ql[0],Af=ql==null?void 0:ql[1],DR=y.useMemo(()=>{if((It===void 0||It.length===0)&&(Tf??Ef??Af??Zo)===void 0)return;const S=[];if(It!==void 0)for(const F of It){const $=yt.length-F.range.x-K;$>0&&S.push({color:F.color,range:{...F.range,x:F.range.x+K,width:Math.min($,F.range.width)},style:F.style})}return Zo!==void 0&&S.push({color:Il(fe.accentColor,0),range:Zo,style:"dashed"}),Tf!==void 0&&S.push({color:Il(fe.accentColor,.5),range:Tf,style:"solid-outline"}),Ef!==void 0&&Af!==void 0&&S.push({color:fe.accentColor,range:{x:Ef,y:Af,width:1,height:1},style:"solid-outline"}),S.length>0?S:void 0},[Zo,Tf,Ef,Af,It,yt.length,fe.accentColor,K]),Gw=y.useRef(yt);Gw.current=yt;const Gr=y.useCallback(([S,F],$=!1)=>{var ne,G,te,ce,le,Me,Ne;const V=yn&&F===cr-1;if(S===0&&Ur)return V?am:{kind:yi.Marker,allowOverlay:!1,checkboxStyle:Ri,checked:(Z==null?void 0:Z.rows.hasIndex(F))===!0,markerKind:xn==="clickable-number"?"number":xn,row:to+F,drawHandle:ui!==void 0,cursor:xn==="clickable-number"?"pointer":void 0};if(V){const Xe=S===K?(Qe==null?void 0:Qe.hint)??"":"",Ye=Gw.current[S];if(((ne=Ye==null?void 0:Ye.trailingRowOptions)==null?void 0:ne.disabled)===!0)return am;{const Ot=((G=Ye==null?void 0:Ye.trailingRowOptions)==null?void 0:G.hint)??Xe,Ze=((te=Ye==null?void 0:Ye.trailingRowOptions)==null?void 0:te.addIcon)??(Qe==null?void 0:Qe.addIcon);return{kind:yi.NewRow,hint:Ot,allowOverlay:!1,icon:Ze}}}else{const Ee=S-K;if($||(J==null?void 0:J.strict)===!0){const Ye=vn.current,Ot=Ye.x>Ee||Ee>Ye.x+Ye.width||Ye.y>F||F>Ye.y+Ye.height||F>=ag.current,Ze=Ee===((le=(ce=Ye.extras)==null?void 0:ce.selected)==null?void 0:le[0])&&F===((Me=Ye.extras)==null?void 0:Me.selected[1]);let Ve=!1;if(((Ne=Ye.extras)==null?void 0:Ne.freezeRegions)!==void 0){for(const un of Ye.extras.freezeRegions)if(zp(un,Ee,F)){Ve=!0;break}}if(Ot&&!Ze&&!Ve)return am}let Xe=k([Ee,F]);return K!==0&&Xe.span!==void 0&&(Xe={...Xe,span:[Xe.span[0]+K,Xe.span[1]+K]}),Xe}},[yn,cr,Ur,Ri,Z==null?void 0:Z.rows,xn,to,ui,K,Qe==null?void 0:Qe.hint,Qe==null?void 0:Qe.addIcon,J==null?void 0:J.strict,k]),lg=y.useCallback(S=>{let F=(it==null?void 0:it(S))??{name:S};return P!==void 0&&S!==""&&(F={icon:F.icon,name:F.name,overrideTheme:F.overrideTheme,actions:[...F.actions??[],{title:"Rename",icon:"renameIcon",onClick:$=>cg({group:F.name,bounds:$.bounds})}]}),F},[it,P]),Mf=y.useCallback(S=>{var te;const[F,$]=S.cell,V=yt[F],U=(V==null?void 0:V.group)!==void 0?(te=lg(V.group))==null?void 0:te.overrideTheme:void 0,ne=V==null?void 0:V.themeOverride,G=p==null?void 0:p($);s({...S,theme:$o(fe,U,ne,G,S.content.themeOverride)})},[p,yt,lg,fe]),Yl=y.useCallback((S,F,$)=>{var G;if(Z.current===void 0)return;const[V,U]=Z.current.cell,ne=Gr([V,U]);if(ne.kind!==Ae.Boolean&&ne.allowOverlay){let te=ne;if($!==void 0)switch(te.kind){case Ae.Number:{const ce=O_(()=>$==="-"?-0:Number.parseFloat($),0);te={...te,data:Number.isNaN(ce)?0:ce};break}case Ae.Text:case Ae.Markdown:case Ae.Uri:te={...te,data:$};break}Mf({target:S,content:te,initialValue:$,cell:[V,U],highlight:$===void 0,forceEditMode:$!==void 0})}else ne.kind===Ae.Boolean&&F&&ne.readonly!==!0&&(fi([{location:Z.current.cell,value:{...ne,data:YE(ne.data)}}]),(G=Nr.current)==null||G.damage([{cell:Z.current.cell}]))},[Gr,Z,fi,Mf]),qw=y.useCallback((S,F)=>{var U;const $=(U=Nr.current)==null?void 0:U.getBounds(S,F);if($===void 0||c.current===null)return;const V=Gr([S,F]);V.allowOverlay&&Mf({target:$,content:V,initialValue:void 0,highlight:!0,cell:[S,F],forceEditMode:!0})},[Gr,Mf]),_n=y.useCallback((S,F,$="both",V=0,U=0,ne=void 0)=>{if(c.current!==null){const G=Nr.current,te=l.current,ce=typeof S!="number"?S.unit==="cell"?S.amount:void 0:S,le=typeof F!="number"?F.unit==="cell"?F.amount:void 0:F,Me=typeof S!="number"&&S.unit==="px"?S.amount:void 0,Ne=typeof F!="number"&&F.unit==="px"?F.amount:void 0;if(G!==null&&te!==null){let Ee={x:0,y:0,width:0,height:0},Xe=0,Ye=0;if((ce!==void 0||le!==void 0)&&(Ee=G.getBounds((ce??0)+K,le??0)??Ee,Ee.width===0||Ee.height===0))return;const Ot=te.getBoundingClientRect(),Ze=Ot.width/te.offsetWidth;if(Me!==void 0&&(Ee={...Ee,x:Me-Ot.left-c.current.scrollLeft,width:1}),Ne!==void 0&&(Ee={...Ee,y:Ne+Ot.top-c.current.scrollTop,height:1}),Ee!==void 0){const Ve={x:Ee.x-V,y:Ee.y-U,width:Ee.width+2*V,height:Ee.height+2*U};let un=0;for(let mg=0;mg0&&(fr=Hl(cr,Dn,kr));let Di=un*Ze+Ot.left+K*Ps*Ze,os=Ot.right,Li=Ot.top+ht*Ze,ls=Ot.bottom-fr*Ze;const _f=Ee.width+V*2;switch(ne==null?void 0:ne.hAlign){case"start":os=Di+_f;break;case"end":Di=os-_f;break;case"center":Di=Math.floor((Di+os)/2)-_f/2,os=Di+_f;break}const Df=Ee.height+U*2;switch(ne==null?void 0:ne.vAlign){case"start":ls=Li+Df;break;case"end":Li=ls-Df;break;case"center":Li=Math.floor((Li+ls)/2)-Df/2,ls=Li+Df;break}Di>Ve.x?Xe=Ve.x-Di:osVe.y?Ye=Ve.y-Li:ls=cr-Dn)&&(Ye=0),(Xe!==0||Ye!==0)&&(Ze!==1&&(Xe/=Ze,Ye/=Ze),c.current.scrollTo(Xe+c.current.scrollLeft,Ye+c.current.scrollTop))}}}},[K,We,Ps,ht,rt,$t,cr,Jo,kr]),Yw=y.useRef(qw),Jw=y.useRef(k),ag=y.useRef(w);Yw.current=qw,Jw.current=k,ag.current=w;const Jl=y.useCallback(async(S,F=!0)=>{var ce;const $=yt[S];if(((ce=$==null?void 0:$.trailingRowOptions)==null?void 0:ce.disabled)===!0)return;const V=tt==null?void 0:tt();let U,ne=!0;V!==void 0&&(U=await V,U==="top"&&(ne=!1),typeof U=="number"&&(ne=!1));let G=0;const te=()=>{if(ag.current<=w){G<500&&window.setTimeout(te,G),G=50+G*2;return}const le=typeof U=="number"?U:ne?w:0;Nf.current(S-K,le),ae({cell:[S,le],range:{x:S,y:le,width:1,height:1}},!1,!1,"edit");const Me=Jw.current([S-K,le]);Me.allowOverlay&&Qu(Me)&&Me.readonly!==!0&&F&&window.setTimeout(()=>{Yw.current(S,le)},0)};te()},[yt,tt,K,w,ae]),Rf=y.useCallback(S=>{var $,V;const F=((V=($=$t[S])==null?void 0:$.trailingRowOptions)==null?void 0:V.targetColumn)??(Qe==null?void 0:Qe.targetColumn);if(typeof F=="number")return F+(Ur?1:0);if(typeof F=="object"){const U=v.indexOf(F);if(U>=0)return U+(Ur?1:0)}},[$t,v,Ur,Qe==null?void 0:Qe.targetColumn]),io=y.useRef(),Ql=y.useRef(),ku=y.useCallback((S,F)=>{var U;const[$,V]=F;return $o(fe,(U=yt[$])==null?void 0:U.themeOverride,p==null?void 0:p(V),S.themeOverride)},[p,yt,fe]),Su=y.useCallback(S=>{var Me,Ne,Ee;const F=Bh.value?S.metaKey:S.ctrlKey,$=F&&Y==="multi",V=F&&xe==="multi",[U,ne]=S.location,G=Z.columns,te=Z.rows,[ce,le]=((Me=Z.current)==null?void 0:Me.cell)??[];if(S.kind==="cell"){if(Ql.current=void 0,el.current=[U,ne],U===0&&Ur){if(yn===!0&&ne===w||xn==="number"||Y==="none")return;const Xe=Gr(S.location);if(Xe.kind!==yi.Marker)return;if(ui!==void 0){const Ze=Re(Xe);ei((Ze==null?void 0:Ze.kind)===yi.Marker);const Ve=(Ne=Ze==null?void 0:Ze.onClick)==null?void 0:Ne.call(Ze,{...S,cell:Xe,posX:S.localEventX,posY:S.localEventY,bounds:S.bounds,theme:ku(Xe,S.location),preventDefault:()=>{}});if(Ve===void 0||Ve.checked===Xe.checked)return}s(void 0),Sr();const Ye=te.hasIndex(ne),Ot=io.current;if(Y==="multi"&&(S.shiftKey||S.isLongTouch===!0)&&Ot!==void 0&&te.hasIndex(Ot)){const Ze=[Math.min(Ot,ne),Math.max(Ot,ne)+1];$||an==="multi"?Te(void 0,Ze,!0):Te(Pt.fromSingleSelection(Ze),void 0,$)}else $||S.isTouch||an==="multi"?Ye?Te(te.remove(ne),void 0,!0):(Te(void 0,ne,!0),io.current=ne):Ye&&te.length===1?Te(Pt.empty(),void 0,F):(Te(Pt.fromSingleSelection(ne),void 0,F),io.current=ne)}else if(U>=K&&yn&&ne===w){const Xe=Rf(U);Jl(Xe??U)}else if(ce!==U||le!==ne){const Xe=Gr(S.location),Ye=Re(Xe);if((Ye==null?void 0:Ye.onSelect)!==void 0){let Ve=!1;if(Ye.onSelect({...S,cell:Xe,posX:S.localEventX,posY:S.localEventY,bounds:S.bounds,preventDefault:()=>Ve=!0,theme:ku(Xe,S.location)}),Ve)return}const Ot=Jo&&ne===w,Ze=Jo&&Z!==void 0&&((Ee=Z.current)==null?void 0:Ee.cell[1])===w;if((S.shiftKey||S.isLongTouch===!0)&&ce!==void 0&&le!==void 0&&Z.current!==void 0&&!Ze){if(Ot)return;const Ve=Math.min(U,ce),un=Math.max(U,ce),fr=Math.min(ne,le),Dn=Math.max(ne,le);ae({...Z.current,range:{x:Ve,y:fr,width:un-Ve+1,height:Dn-fr+1}},!0,F,"click"),io.current=void 0,Sr()}else ae({cell:[U,ne],range:{x:U,y:ne,width:1,height:1}},!0,F,"click"),io.current=void 0,s(void 0),Sr()}}else if(S.kind==="header")if(el.current=[U,ne],s(void 0),Ur&&U===0)io.current=void 0,Ql.current=void 0,Y==="multi"&&(te.length!==w?Te(Pt.fromSingleSelection([0,w]),void 0,F):Te(Pt.empty(),void 0,F),Sr());else{const Xe=Ql.current;if(xe==="multi"&&(S.shiftKey||S.isLongTouch===!0)&&Xe!==void 0&&G.hasIndex(Xe)){const Ye=[Math.min(Xe,U),Math.max(Xe,U)+1];V?we(void 0,Ye,F):we(Pt.fromSingleSelection(Ye),void 0,F)}else V?(G.hasIndex(U)?we(G.remove(U),void 0,F):we(void 0,U,F),Ql.current=U):xe!=="none"&&(we(Pt.fromSingleSelection(U),void 0,F),Ql.current=U);io.current=void 0,Sr()}else S.kind===Zr?el.current=[U,ne]:S.kind===jh&&!S.isMaybeScrollbar&&(Ir(ld,!1),s(void 0),Sr(),mn==null||mn(),io.current=void 0,Ql.current=void 0)},[Jl,xe,Sr,Re,Rf,Gr,Z,Ur,Jo,mn,ui,K,xn,Y,an,w,ae,Ir,we,Te,yn,ku]),Cu=y.useRef(!1),el=y.useRef(),Qw=y.useRef(Nn),di=y.useRef(),LR=y.useCallback(S=>{if(Zl.current=!1,Qw.current=vn.current,S.button!==0&&S.button!==1){di.current=void 0;return}const F=performance.now();di.current={button:S.button,time:F,location:S.location},(S==null?void 0:S.kind)==="header"&&(Cu.current=!0);const $=S.kind==="cell"&&S.isFillHandle;!$&&S.kind!=="cell"&&S.isEdge||(u({previousSelection:Z,fillHandle:$}),el.current=void 0,!S.isTouch&&S.button===0&&!$?Su(S):!S.isTouch&&S.button===1&&(el.current=S.location))},[Z,Su]),[ug,cg]=y.useState(),Zw=y.useCallback(S=>{if(S.kind!==Zr||xe!=="multi")return;const F=Bh.value?S.metaKey:S.ctrlKey,[$]=S.location,V=Z.columns;if($=K&&Vc(U.group,yt[te].group);te--)ne--;for(let te=$+1;te{if(Bn!==void 0&&Ii!==void 0){const F=vn.current.y,$=vn.current.height;let V=Bn({x:S,y:F,width:1,height:Math.min($,w-F)},ur.current.signal);typeof V!="object"&&(V=await V());const U=$t[S-K],G=document.createElement("canvas").getContext("2d",{alpha:!1});if(G!==null){G.font=fe.baseFontFull;const te=kE(G,fe,U,0,V,ar,Oi,!1,Re);Ii==null||Ii(U,te.width,S,te.width)}}},[$t,Bn,Oi,fe,ar,Ii,K,w,Re]),[$R,fg]=y.useState(),ea=y.useCallback(async(S,F)=>{var te,ce;const $=(te=S.current)==null?void 0:te.range;if($===void 0||Bn===void 0||F.current===void 0)return;const V=F.current.range;if(T!==void 0){let le=!1;if(T({fillDestination:{...V,x:V.x-K},patternSource:{...$,x:$.x-K},preventDefault:()=>le=!0}),le)return}let U=Bn($,ur.current.signal);typeof U!="object"&&(U=await U());const ne=U,G=[];for(let le=0;le({cell:le.location})))},[Bn,fi,T,K]),e1=y.useCallback(()=>{if(Z.current===void 0||Z.current.range.width<=1)return;const S={...Z,current:{...Z.current,range:{...Z.current.range,width:1}}};ea(S,Z)},[ea,Z]),t1=y.useCallback(()=>{if(Z.current===void 0||Z.current.range.height<=1)return;const S={...Z,current:{...Z.current,range:{...Z.current.range,height:1}}};ea(S,Z)},[ea,Z]),FR=y.useCallback((S,F)=>{var Me,Ne;const $=a;if(u(void 0),og(void 0),fg(void 0),Cu.current=!1,F)return;if(($==null?void 0:$.fillHandle)===!0&&Z.current!==void 0&&((Me=$.previousSelection)==null?void 0:Me.current)!==void 0){if(Zo===void 0)return;const Ee={...Z,current:{...Z.current,range:IE($.previousSelection.current.range,Zo)}};ea($.previousSelection,Ee),Ir(Ee,!0);return}const[V,U]=S.location,[ne,G]=el.current??[],te=()=>{Zl.current=!0},ce=Ee=>{var Ye,Ot,Ze;const Xe=Ee.isTouch||ne===V&&G===U;if(Xe&&(x==null||x([V-K,U],{...Ee,preventDefault:te})),Ee.button===1)return!Zl.current;if(!Zl.current){const Ve=Gr(S.location),un=Re(Ve);if(un!==void 0&&un.onClick!==void 0&&Xe){const Dn=un.onClick({...Ee,cell:Ve,posX:Ee.localEventX,posY:Ee.localEventY,bounds:Ee.bounds,theme:ku(Ve,S.location),preventDefault:te});Dn!==void 0&&!xa(Dn)&&oa(Dn)&&(fi([{location:Ee.location,value:Dn}]),(Ye=Nr.current)==null||Ye.damage([{cell:Ee.location}]))}if(Zl.current||Z.current===void 0)return!1;let fr=!1;switch(Ve.activationBehaviorOverride??Ke){case"double-click":case"second-click":{if(((Ze=(Ot=$==null?void 0:$.previousSelection)==null?void 0:Ot.current)==null?void 0:Ze.cell)===void 0)break;const[Dn,Di]=Z.current.cell,[os,Li]=$.previousSelection.current.cell;fr=V===Dn&&V===os&&U===Di&&U===Li&&(Ee.isDoubleClick===!0||Ke==="second-click");break}case"single-click":{fr=!0;break}}if(fr)return C==null||C([V-K,U]),Yl(Ee.bounds,!1),!0}return!1},le=S.location[0]-K;if(S.isTouch){const Ee=vn.current,Xe=Qw.current;if(Ee.x!==Xe.x||Ee.y!==Xe.y)return;if(S.isLongTouch===!0){if(S.kind==="cell"&&gc((Ne=Z.current)==null?void 0:Ne.cell,S.location)){se==null||se([le,S.location[1]],{...S,preventDefault:te});return}else if(S.kind==="header"&&Z.columns.hasIndex(V)){X==null||X(le,{...S,preventDefault:te});return}else if(S.kind===Zr){if(le<0)return;N==null||N(le,{...S,preventDefault:te});return}}S.kind==="cell"?ce(S)||Su(S):S.kind===Zr?ie==null||ie(le,{...S,preventDefault:te}):(S.kind===go&&(L==null||L(le,{...S,preventDefault:te})),Su(S));return}if(S.kind==="header"){if(le<0)return;S.isEdge?S.isDoubleClick===!0&&Of(V):S.button===0&&V===ne&&U===G&&(L==null||L(le,{...S,preventDefault:te}))}if(S.kind===Zr){if(le<0)return;S.button===0&&V===ne&&U===G&&(ie==null||ie(le,{...S,preventDefault:te}),Zl.current||Zw(S))}S.kind==="cell"&&(S.button===0||S.button===1)&&ce(S),el.current=void 0},[a,Z,K,Zo,ea,Ir,x,Gr,Re,Ke,ku,fi,C,Yl,se,X,N,Su,ie,L,Of,Zw]),zR=y.useCallback(S=>{const F={...S,location:[S.location[0]-K,S.location[1]]};nt==null||nt(F),a!==void 0&&S.buttons===0&&(u(void 0),og(void 0),fg(void 0),Cu.current=!1),fg($=>{var V;return Cu.current?[S.scrollEdge[0],0]:S.scrollEdge[0]===($==null?void 0:$[0])&&S.scrollEdge[1]===$[1]?$:a===void 0||(((V=di.current)==null?void 0:V.location[0])??0){mt==null||mt(S-K,F)},[mt,K]),ss=(a1=Z==null?void 0:Z.current)==null?void 0:a1.cell,jR=y.useCallback((S,F,$,V,U,ne)=>{Nt.current=!1;let G=ss;G!==void 0&&(G=[G[0]-K,G[1]]);const te=rt===0?void 0:{x:0,y:S.y,width:rt,height:S.height},ce=[];te!==void 0&&ce.push(te),We>0&&(ce.push({x:S.x-K,y:w-We,width:S.width,height:We}),rt>0&&ce.push({x:0,y:w-We,width:rt,height:We}));const le={x:S.x-K,y:S.y,width:S.width,height:yn&&S.y+S.height>=w?S.height-1:S.height,tx:U,ty:ne,extras:{selected:G,freezeRegion:te,freezeRegions:ce}};vn.current=le,Xr(le),at([F,$,V]),Jt==null||Jt(le,le.tx,le.ty,le.extras)},[ss,K,yn,w,rt,We,Xr,Jt]),HR=na(Be,y.useCallback((S,F)=>{Be==null||Be(S-K,F-K),xe!=="none"&&we(Pt.fromSingleSelection(F),void 0,!0)},[xe,Be,K,we])),dg=y.useRef(!1),WR=y.useCallback(S=>{if(S.location[0]===0&&K>0){S.preventDefault();return}$e==null||$e({...S,location:[S.location[0]-K,S.location[1]]}),S.defaultPrevented()||(dg.current=!0),u(void 0)},[$e,K]),VR=y.useCallback(()=>{dg.current=!1},[]),hg=y.useRef(),pg=y.useCallback(S=>{var F,$,V;if(!GE(S,hg.current)&&(hg.current=S,!(((F=di==null?void 0:di.current)==null?void 0:F.button)!==void 0&&di.current.button>=1))){if(S.buttons!==0&&a!==void 0&&(($=di.current)==null?void 0:$.location[0])===0&&S.location[0]===0&&K===1&&Y==="multi"&&a.previousSelection&&!a.previousSelection.rows.hasIndex(di.current.location[1])&&Z.rows.hasIndex(di.current.location[1])){const U=Math.min(di.current.location[1],S.location[1]),ne=Math.max(di.current.location[1],S.location[1])+1;Te(Pt.fromSingleSelection([U,ne]),void 0,!1)}if(S.buttons!==0&&a!==void 0&&Z.current!==void 0&&!dg.current&&!Cu.current&&(be==="rect"||be==="multi-rect")){const[U,ne]=Z.current.cell;let[G,te]=S.location;if(te<0&&(te=vn.current.y),a.fillHandle===!0&&((V=a.previousSelection)==null?void 0:V.current)!==void 0){const ce=a.previousSelection.current.range;te=Math.min(te,yn?w-1:w);const le=Pz(ce,G,te,Lt);og(le)}else{if(yn&&ne===w)return;if(yn&&te===w)if(S.kind===jh)te--;else return;G=Math.max(G,K);const Me=G-U,Ne=te-ne,Ee={x:Me>=0?U:G,y:Ne>=0?ne:te,width:Math.abs(Me)+1,height:Math.abs(Ne)+1};ae({...Z.current,range:Ee},!0,!1,"drag")}}Yt==null||Yt({...S,location:[S.location[0]-K,S.location[1]]})}},[Lt,a,K,Y,Z,be,Yt,Te,yn,w,ae]),UR=y.useCallback(()=>{var G,te;const S=hg.current;if(S===void 0)return;const[F,$]=S.scrollEdge;let[V,U]=S.location;const ne=vn.current;F===-1?V=((te=(G=ne.extras)==null?void 0:G.freezeRegion)==null?void 0:te.x)??ne.x:F===1&&(V=ne.x+ne.width),$===-1?U=Math.max(0,ne.y):$===1&&(U=Math.min(w-1,ne.y+ne.height)),V=Wi(V,0,yt.length-1),U=Wi(U,0,w-1),pg({...S,location:[V,U]})},[yt.length,pg,w]);z6($R,c,UR);const _i=y.useCallback(S=>{if(Z.current===void 0)return;const[F,$]=S,[V,U]=Z.current.cell,ne=Z.current.range;let G=ne.x,te=ne.x+ne.width,ce=ne.y,le=ne.y+ne.height;if($!==0)switch($){case 2:{le=w,ce=U,_n(0,le,"vertical");break}case-2:{ce=0,le=U+1,_n(0,ce,"vertical");break}case 1:{ceU+1?(le--,_n(0,le,"vertical")):(ce=Math.max(0,ce-1),_n(0,ce,"vertical"));break}default:Wc()}if(F!==0)if(F===2)te=yt.length,G=V,_n(te-1-K,0,"horizontal");else if(F===-2)G=K,te=V+1,_n(G-K,0,"horizontal");else{let Me=[];if(Bn!==void 0){const Ne=Bn({x:G,y:ce,width:te-G-K,height:le-ce},ur.current.signal);typeof Ne=="object"&&(Me=V6(Ne))}if(F===1){let Ne=!1;if(G0){const Ee=gl(G+1,V+1).find(Xe=>!Me.includes(Xe-K));Ee!==void 0&&(G=Ee,Ne=!0)}else G++,Ne=!0;Ne&&_n(G,0,"horizontal")}Ne||(te=Math.min(yt.length,te+1),_n(te-1-K,0,"horizontal"))}else if(F===-1){let Ne=!1;if(te>V+1){if(Me.length>0){const Ee=gl(te-1,V,-1).find(Xe=>!Me.includes(Xe-K));Ee!==void 0&&(te=Ee,Ne=!0)}else te--,Ne=!0;Ne&&_n(te-K,0,"horizontal")}Ne||(G=Math.max(K,G-1),_n(G-K,0,"horizontal"))}else Wc()}ae({cell:Z.current.cell,range:{x:G,y:ce,width:te-G,height:le-ce}},!0,!1,"keyboard-select")},[Bn,Z,yt.length,K,w,_n,ae]),so=y.useCallback((S,F,$,V)=>{const U=cr-($?0:1);if(S=Wi(S,K,$t.length-1+K),F=Wi(F,0,U),S===(ss==null?void 0:ss[0])&&F===(ss==null?void 0:ss[1]))return!1;if(V&&Z.current!==void 0){const ne=[...Z.current.rangeStack];(Z.current.range.width>1||Z.current.range.height>1)&&ne.push(Z.current.range),Ir({...Z,current:{cell:[S,F],range:{x:S,y:F,width:1,height:1},rangeStack:ne}},!0)}else ae({cell:[S,F],range:{x:S,y:F,width:1,height:1}},!0,!1,"keyboard-nav");return f.current!==void 0&&f.current[0]===S&&f.current[1]===F&&(f.current=void 0),_n(S-K,F),!0},[cr,K,$t.length,ss,Z,_n,Ir,ae]),KR=y.useCallback((S,F)=>{(i==null?void 0:i.cell)!==void 0&&S!==void 0&&oa(S)&&(fi([{location:i.cell,value:S}]),window.requestAnimationFrame(()=>{var U;(U=Nr.current)==null||U.damage([{cell:i.cell}])})),Sr(!0),s(void 0);const[$,V]=F;if(Z.current!==void 0&&($!==0||V!==0)){const U=Z.current.cell[1]===cr-1&&S!==void 0;so(Wi(Z.current.cell[0]+$,0,yt.length-1),Wi(Z.current.cell[1]+V,0,cr-1),U,!1)}A==null||A(S,F)},[i==null?void 0:i.cell,Sr,Z,A,fi,cr,so,yt.length]),XR=y.useMemo(()=>`gdg-overlay-${W6++}`,[]),tl=y.useCallback(S=>{var $,V,U,ne;Sr();const F=[];for(let G=S.x;G({cell:G.location})))},[Sr,k,Re,fi,K]),Tu=i!==void 0,n1=y.useCallback(S=>{var Xe,Ye;const F=()=>{S.stopPropagation(),S.preventDefault()},$={didMatch:!1},{bounds:V}=S,U=Z.columns,ne=Z.rows,G=Pi;if(!Tu&&wt(G.clear,S,$))Ir(ld,!1),mn==null||mn();else if(!Tu&&wt(G.selectAll,S,$))Ir({columns:Pt.empty(),rows:Pt.empty(),current:{cell:((Xe=Z.current)==null?void 0:Xe.cell)??[K,0],range:{x:K,y:0,width:v.length,height:w},rangeStack:[]}},!1);else if(wt(G.search,S,$))(Ye=o==null?void 0:o.current)==null||Ye.focus({preventScroll:!0}),Sf(!0);else if(wt(G.delete,S,$)){const Ot=(j==null?void 0:j(Z))??!0;if(Ot!==!1){const Ze=Ot===!0?Z:Ot;if(Ze.current!==void 0){tl(Ze.current.range);for(const Ve of Ze.current.rangeStack)tl(Ve)}for(const Ve of Ze.rows)tl({x:K,y:Ve,width:v.length,height:1});for(const Ve of Ze.columns)tl({x:Ve,y:0,width:1,height:w})}}if($.didMatch)return F(),!0;if(Z.current===void 0)return!1;let[te,ce]=Z.current.cell,le=!1,Me=!1;wt(G.scrollToSelectedCell,S,$)?Nf.current(te-K,ce):xe!=="none"&&wt(G.selectColumn,S,$)?U.hasIndex(te)?we(U.remove(te),void 0,!0):xe==="single"?we(Pt.fromSingleSelection(te),void 0,!0):we(void 0,te,!0):Y!=="none"&&wt(G.selectRow,S,$)?ne.hasIndex(ce)?Te(ne.remove(ce),void 0,!0):Y==="single"?Te(Pt.fromSingleSelection(ce),void 0,!0):Te(void 0,ce,!0):!Tu&&V!==void 0&&wt(G.activateCell,S,$)?ce===w&&yn?window.setTimeout(()=>{const Ot=Rf(te);Jl(Ot??te)},0):(C==null||C([te-K,ce]),Yl(V,!0)):Z.current.range.height>1&&wt(G.downFill,S,$)?t1():Z.current.range.width>1&&wt(G.rightFill,S,$)?e1():wt(G.goToNextPage,S,$)?ce+=Math.max(1,vn.current.height-4):wt(G.goToPreviousPage,S,$)?ce-=Math.max(1,vn.current.height-4):wt(G.goToFirstCell,S,$)?(s(void 0),ce=0,te=0):wt(G.goToLastCell,S,$)?(s(void 0),ce=Number.MAX_SAFE_INTEGER,te=Number.MAX_SAFE_INTEGER):wt(G.selectToFirstCell,S,$)?(s(void 0),_i([-2,-2])):wt(G.selectToLastCell,S,$)?(s(void 0),_i([2,2])):Tu?(wt(G.closeOverlay,S,$)&&s(void 0),wt(G.acceptOverlayDown,S,$)&&(s(void 0),ce++),wt(G.acceptOverlayUp,S,$)&&(s(void 0),ce--),wt(G.acceptOverlayLeft,S,$)&&(s(void 0),te--),wt(G.acceptOverlayRight,S,$)&&(s(void 0),te++)):(wt(G.goDownCell,S,$)?ce+=1:wt(G.goUpCell,S,$)?ce-=1:wt(G.goRightCell,S,$)?te+=1:wt(G.goLeftCell,S,$)?te-=1:wt(G.goDownCellRetainSelection,S,$)?(ce+=1,le=!0):wt(G.goUpCellRetainSelection,S,$)?(ce-=1,le=!0):wt(G.goRightCellRetainSelection,S,$)?(te+=1,le=!0):wt(G.goLeftCellRetainSelection,S,$)?(te-=1,le=!0):wt(G.goToLastRow,S,$)?ce=w-1:wt(G.goToFirstRow,S,$)?ce=Number.MIN_SAFE_INTEGER:wt(G.goToLastColumn,S,$)?te=Number.MAX_SAFE_INTEGER:wt(G.goToFirstColumn,S,$)?te=Number.MIN_SAFE_INTEGER:(be==="rect"||be==="multi-rect")&&(wt(G.selectGrowDown,S,$)?_i([0,1]):wt(G.selectGrowUp,S,$)?_i([0,-1]):wt(G.selectGrowRight,S,$)?_i([1,0]):wt(G.selectGrowLeft,S,$)?_i([-1,0]):wt(G.selectToLastRow,S,$)?_i([0,2]):wt(G.selectToFirstRow,S,$)?_i([0,-2]):wt(G.selectToLastColumn,S,$)?_i([2,0]):wt(G.selectToFirstColumn,S,$)&&_i([-2,0])),Me=$.didMatch);const Ne=so(te,ce,!1,le),Ee=$.didMatch;return Ee&&(Ne||!Me||Q)&&F(),Ee},[Tu,Z,Pi,xe,Y,be,K,w,so,Ir,mn,v.length,j,Q,tl,we,Te,yn,Rf,Jl,C,Yl,t1,e1,_i]),Eu=y.useCallback(S=>{let F=!1;if(Le!==void 0&&Le({...S,cancel:()=>{F=!0}}),F||n1(S)||Z.current===void 0)return;const[$,V]=Z.current.cell,U=vn.current;if(Mt&&!S.metaKey&&!S.ctrlKey&&Z.current!==void 0&&S.key.length===1&&/[ -~]/g.test(S.key)&&S.bounds!==void 0&&Qu(k([$-K,Math.max(0,Math.min(V,w-1))]))){if((!yn||V!==w)&&(U.y>V||V>U.y+U.height||U.x>$||$>U.x+U.width))return;Yl(S.bounds,!0,S.key),S.stopPropagation(),S.preventDefault()}},[Mt,Le,n1,Z,k,K,w,yn,Yl]),GR=y.useCallback((S,F)=>{const $=S.location[0]-K;if(S.kind==="header"&&(X==null||X($,{...S,preventDefault:F})),S.kind===Zr){if($<0)return;N==null||N($,{...S,preventDefault:F})}if(S.kind==="cell"){const[V,U]=S.location;se==null||se([$,U],{...S,preventDefault:F}),A4(Z,S.location)||so(V,U,!1,!1)}},[Z,se,N,X,K,so]),gg=y.useCallback(async S=>{var G,te,ce;if(!Pi.paste)return;function F(le,Me,Ne,Ee){var Ye,Ot;const Xe=typeof Ne=="object"?(Ne==null?void 0:Ne.join(` +`))??"":(Ne==null?void 0:Ne.toString())??"";if(!xa(le)&&Qu(le)&&le.readonly!==!0){const Ze=M==null?void 0:M(Xe,le);if(Ze!==void 0&&oa(Ze))return{location:Me,value:Ze};const Ve=Re(le);if(Ve===void 0)return;if(Ve.kind===Ae.Custom){ei(le.kind===Ae.Custom);const un=(Ye=Ve.onPaste)==null?void 0:Ye.call(Ve,Xe,le.data);return un===void 0?void 0:{location:Me,value:{...le,data:un}}}else{const un=(Ot=Ve.onPaste)==null?void 0:Ot.call(Ve,Xe,le,{formatted:Ee,formattedString:typeof Ee=="string"?Ee:Ee==null?void 0:Ee.join(` +`),rawValue:Ne});return un===void 0?void 0:(ei(un.kind===le.kind),{location:Me,value:un})}}}const $=Z.columns,V=Z.rows,U=((G=c.current)==null?void 0:G.contains(document.activeElement))===!0||((te=l.current)==null?void 0:te.contains(document.activeElement))===!0;let ne;if(Z.current!==void 0?ne=[Z.current.range.x,Z.current.range.y]:$.length===1?ne=[$.first()??0,0]:V.length===1&&(ne=[K,V.first()??0]),U&&ne!==void 0){let le,Me;const Ne="text/plain",Ee="text/html";if(navigator.clipboard.read!==void 0){const Ze=await navigator.clipboard.read();for(const Ve of Ze){if(Ve.types.includes(Ee)){const fr=await(await Ve.getType(Ee)).text(),Dn=Kx(fr);if(Dn!==void 0){le=Dn;break}}Ve.types.includes(Ne)&&(Me=await(await Ve.getType(Ne)).text())}}else if(navigator.clipboard.readText!==void 0)Me=await navigator.clipboard.readText();else if(S!==void 0&&(S==null?void 0:S.clipboardData)!==null){if(S.clipboardData.types.includes(Ee)){const Ze=S.clipboardData.getData(Ee);le=Kx(Ze)}le===void 0&&S.clipboardData.types.includes(Ne)&&(Me=S.clipboardData.getData(Ne))}else return;const[Xe,Ye]=ne,Ot=[];do{if(ge===void 0){const Ze=Gr(ne),Ve=Me??(le==null?void 0:le.map(fr=>fr.map(Dn=>Dn.rawValue).join(" ")).join(" "))??"",un=F(Ze,ne,Ve,void 0);un!==void 0&&Ot.push(un);break}if(le===void 0){if(Me===void 0)return;le=I6(Me)}if(ge===!1||typeof ge=="function"&&(ge==null?void 0:ge([ne[0]-K,ne[1]],le.map(Ze=>Ze.map(Ve=>{var un;return((un=Ve.rawValue)==null?void 0:un.toString())??""}))))!==!0)return;for(const[Ze,Ve]of le.entries()){if(Ze+Ye>=w)break;for(const[un,fr]of Ve.entries()){const Dn=[un+Xe,Ze+Ye],[Di,os]=Dn;if(Di>=yt.length||os>=cr)continue;const Li=Gr(Dn),ls=F(Li,Dn,fr.rawValue,fr.formatted);ls!==void 0&&Ot.push(ls)}}}while(!1);fi(Ot),(ce=Nr.current)==null||ce.damage(Ot.map(Ze=>({cell:Ze.location})))}},[M,Re,Gr,Z,Pi.paste,yt.length,fi,cr,ge,K,w]);rr("paste",gg,d,!1,!0);const Au=y.useCallback(async(S,F)=>{var G,te;if(!Pi.copy)return;const $=F===!0||((G=c.current)==null?void 0:G.contains(document.activeElement))===!0||((te=l.current)==null?void 0:te.contains(document.activeElement))===!0,V=Z.columns,U=Z.rows,ne=(ce,le)=>{if(!ot)Gx(ce,le,S);else{const Me=le.map(Ne=>({kind:Ae.Text,data:v[Ne].title,displayData:v[Ne].title,allowOverlay:!1}));Gx([Me,...ce],le,S)}};if($&&Bn!==void 0){if(Z.current!==void 0){let ce=Bn(Z.current.range,ur.current.signal);typeof ce!="object"&&(ce=await ce()),ne(ce,gl(Z.current.range.x-K,Z.current.range.x+Z.current.range.width-K))}else if(U!==void 0&&U.length>0){const le=[...U].map(Me=>{const Ne=Bn({x:K,y:Me,width:v.length,height:1},ur.current.signal);return typeof Ne=="object"?Ne[0]:Ne().then(Ee=>Ee[0])});if(le.some(Me=>Me instanceof Promise)){const Me=await Promise.all(le);ne(Me,gl(v.length))}else ne(le,gl(v.length))}else if(V.length>0){const ce=[],le=[];for(const Me of V){let Ne=Bn({x:Me,y:0,width:1,height:w},ur.current.signal);typeof Ne!="object"&&(Ne=await Ne()),ce.push(Ne),le.push(Me-K)}if(ce.length===1)ne(ce[0],le);else{const Me=ce.reduce((Ne,Ee)=>Ne.map((Xe,Ye)=>[...Xe,...Ee[Ye]]));ne(Me,le)}}}},[v,Bn,Z,Pi.copy,K,w,ot]);rr("copy",Au,d,!1,!1);const qR=y.useCallback(async S=>{var $,V;if(!(!Pi.cut||!((($=c.current)==null?void 0:$.contains(document.activeElement))===!0||((V=l.current)==null?void 0:V.contains(document.activeElement))===!0))&&(await Au(S),Z.current!==void 0)){let U={current:{cell:Z.current.cell,range:Z.current.range,rangeStack:[]},rows:Pt.empty(),columns:Pt.empty()};const ne=j==null?void 0:j(U);if(ne===!1||(U=ne===!0?U:ne,U.current===void 0))return;tl(U.current.range)}},[tl,Z,Pi.cut,Au,j]);rr("cut",qR,d,!1,!1);const YR=y.useCallback((S,F)=>{if(W!==void 0){K!==0&&(S=S.map(U=>[U[0]-K,U[1]])),W(S,F);return}if(S.length===0||F===-1)return;const[$,V]=S[F];f.current!==void 0&&f.current[0]===$&&f.current[1]===V||(f.current=[$,V],so($,V,!1,!1))},[W,K,so]),[Pf,If]=((u1=jt==null?void 0:jt.current)==null?void 0:u1.cell)??[],Nf=y.useRef(_n);Nf.current=_n,y.useLayoutEffect(()=>{var S,F,$,V;!Nt.current&&Pf!==void 0&&If!==void 0&&(Pf!==((F=(S=ro.current)==null?void 0:S.current)==null?void 0:F.cell[0])||If!==((V=($=ro.current)==null?void 0:$.current)==null?void 0:V.cell[1]))&&Nf.current(Pf,If),Nt.current=!1},[Pf,If]);const r1=Z.current!==void 0&&(Z.current.cell[0]>=yt.length||Z.current.cell[1]>=cr);y.useLayoutEffect(()=>{r1&&Ir(ld,!1)},[r1,Ir]);const JR=y.useMemo(()=>yn===!0&&(Qe==null?void 0:Qe.tint)===!0?Pt.fromSingleSelection(cr-1):Pt.empty(),[cr,yn,Qe==null?void 0:Qe.tint]),QR=y.useCallback(S=>typeof Tn=="boolean"?Tn:(Tn==null?void 0:Tn(S-K))??!0,[K,Tn]),ZR=y.useMemo(()=>{if(ug===void 0||l.current===null)return null;const{bounds:S,group:F}=ug,$=l.current.getBoundingClientRect();return y.createElement(x6,{bounds:S,group:F,canvasBounds:$,onClose:()=>cg(void 0),onFinish:V=>{cg(void 0),P==null||P(F,V)}})},[P,ug]),eO=Math.min(yt.length,rt+(Ur?1:0));y.useImperativeHandle(e,()=>({appendRow:(S,F)=>Jl(S+K,F),updateCells:S=>{var F;return K!==0&&(S=S.map($=>({cell:[$.cell[0]+K,$.cell[1]]}))),(F=Nr.current)==null?void 0:F.damage(S)},getBounds:(S,F)=>{var $;if(!((l==null?void 0:l.current)===null||(c==null?void 0:c.current)===null)){if(S===void 0&&F===void 0){const V=l.current.getBoundingClientRect(),U=V.width/c.current.clientWidth;return{x:V.x-c.current.scrollLeft*U,y:V.y-c.current.scrollTop*U,width:c.current.scrollWidth*U,height:c.current.scrollHeight*U}}return($=Nr.current)==null?void 0:$.getBounds((S??0)+K,F)}},focus:()=>{var S;return(S=Nr.current)==null?void 0:S.focus()},emit:async S=>{switch(S){case"delete":Eu({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!1,key:"Delete",keyCode:46,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"fill-right":Eu({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!0,key:"r",keyCode:82,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"fill-down":Eu({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!0,key:"d",keyCode:68,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"copy":await Au(void 0,!0);break;case"paste":await gg();break}},scrollTo:_n,remeasureColumns:S=>{for(const F of S)Of(F+K)}}),[Jl,Of,Au,Eu,gg,K,_n]);const[i1,s1]=ss??[],tO=y.useCallback(S=>{const[F,$]=S;if($===-1){xe!=="none"&&(we(Pt.fromSingleSelection(F),void 0,!1),Sr());return}i1===F&&s1===$||(ae({cell:S,range:{x:F,y:$,width:1,height:1}},!0,!1,"keyboard-nav"),_n(F,$))},[xe,Sr,_n,i1,s1,ae,we]),[nO,rO]=y.useState(!1),o1=y.useRef(ZT(S=>{rO(S)},5)),iO=y.useCallback(()=>{o1.current(!0),Z.current===void 0&&Z.columns.length===0&&Z.rows.length===0&&a===void 0&&ae({cell:[K,Cf],range:{x:K,y:Cf,width:1,height:1}},!0,!1,"keyboard-select")},[Cf,Z,a,K,ae]),sO=y.useCallback(()=>{o1.current(!1)},[]),[oO,lO]=y.useMemo(()=>{let S;const F=(J==null?void 0:J.scrollbarWidthOverride)??j0(),$=w+(yn?1:0);if(typeof kr=="number")S=ht+$*kr;else{let U=0;const ne=Math.min($,10);for(let G=0;Gne.width+U,0)+F;return[`${Math.min(1e5,V)}px`,`${Math.min(1e5,S)}px`]},[yt,J==null?void 0:J.scrollbarWidthOverride,kr,w,yn,ht]),aO=y.useMemo(()=>H4(fe),[fe]);return y.createElement(W4.Provider,{value:fe},y.createElement(L6,{style:aO,className:H,inWidth:b??oO,inHeight:m??lO},y.createElement(y6,{fillHandle:Vt,drawFocusRing:Ut,experimental:J,fixedShadowX:st,fixedShadowY:lt,getRowThemeOverride:p,headerIcons:Jn,imageWindowLoader:Vr,initialSize:rs,isDraggable:Wl,onDragLeave:Vl,onRowMoved:ui,overscrollX:eg,overscrollY:kf,preventDiagonalScrolling:eo,rightElement:z,rightElementProps:oe,smoothScrollX:pe,smoothScrollY:ve,className:H,enableGroups:Bt,onCanvasFocused:iO,onCanvasBlur:sO,canvasRef:l,onContextMenu:GR,theme:fe,cellXOffset:Qo,cellYOffset:Cf,accessibilityHeight:Nn.height,onDragEnd:VR,columns:yt,nonGrowWidth:je,drawHeader:ig,onColumnProposeMove:_,drawCell:sg,disabledRows:JR,freezeColumns:eO,lockColumns:K,firstColAccessible:K===0,getCellContent:Gr,minColumnWidth:ar,maxColumnWidth:Oi,searchInputRef:o,showSearch:bu,onSearchClose:ng,highlightRegions:DR,getCellsForSelection:Bn,getGroupDetails:lg,headerHeight:Ul,isFocused:nO,groupHeaderHeight:Bt?wu:0,freezeTrailingRows:We+(yn&&(Qe==null?void 0:Qe.sticky)===!0?1:0),hasAppendRow:yn,onColumnResize:Ii,onColumnResizeEnd:rg,onColumnResizeStart:Xl,onCellFocused:tO,onColumnMoved:HR,onDragStart:WR,onHeaderMenuClick:BR,onItemHovered:pg,isFilling:(a==null?void 0:a.fillHandle)===!0,onMouseMove:zR,onKeyDown:Eu,onKeyUp:Ue,onMouseDown:LR,onMouseUp:FR,onDragOverCell:er,onDrop:pt,onSearchResultsChanged:YR,onVisibleRegionChanged:jR,clientSize:Pe,rowHeight:kr,searchResults:ye,searchValue:me,onSearchValueChange:ee,rows:cr,scrollRef:c,selection:Z,translateX:Nn.tx,translateY:Nn.ty,verticalBorder:QR,gridRef:Nr,getCellRenderer:Re}),ZR,i!==void 0&&y.createElement(y.Suspense,{fallback:null},y.createElement(H6,{...i,validateCell:xu,bloom:O,id:XR,getCellRenderer:Re,className:(J==null?void 0:J.isSubGrid)===!0?"click-outside-ignore":void 0,provideEditor:Ht,imageEditorOverride:h,onFinishEditing:KR,markdownDivCreateNode:g,isOutsideClick:nn}))))},K6=y.forwardRef(U6),Jx=20,X6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??"false"},kind:Ae.Boolean,needsHover:!0,useLabel:!1,needsHoverPosition:!0,measure:()=>50,draw:t=>G6(t,t.cell.data,L0(t.cell),t.cell.maxSize??Jx),onDelete:t=>({...t,data:!1}),onClick:t=>{const{cell:e,posX:n,posY:r,bounds:i,theme:s}=t,{width:o,height:l,x:a,y:u}=i,c=e.maxSize??Jx,f=Math.floor(i.y+l/2),d=nE(c,l,s.cellVerticalPadding),h=tE(e.contentAlign??"center",a,o,s.cellHorizontalPadding,d),p=eE(h,f,d),g=rE(a+n,u+r,p);if(L0(e)&&g)return{...e,data:YE(e.data)}},onPaste:(t,e)=>{let n=Mh;return t.toLowerCase()==="true"?n=!0:t.toLowerCase()==="false"?n=!1:t.toLowerCase()==="indeterminate"&&(n=Zv),n===e.data?void 0:{...e,data:n}}};function G6(t,e,n,r){if(!n&&e===Mh)return;const{ctx:i,hoverAmount:s,theme:o,rect:l,highlighted:a,hoverX:u,hoverY:c,cell:{contentAlign:f}}=t,{x:d,y:h,width:p,height:g}=l,b=.35;let m=n?1-b+b*s:.4;e===Mh&&(m*=s),m!==0&&(i.globalAlpha=m,hw(i,o,e,d,h,p,g,a,u,c,r,f),i.globalAlpha=1)}const q6=ai("div")({name:"BubblesOverlayEditorStyle",class:"gdg-b1ygi5by",propsAsIs:!1}),Y6=t=>{const{bubbles:e}=t;return y.createElement(q6,null,e.map((n,r)=>y.createElement("div",{key:r,className:"boe-bubble"},n)),y.createElement("textarea",{className:"gdg-input",autoFocus:!0}))},J6={getAccessibilityString:t=>iE(t.data),kind:Ae.Bubble,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(t,e,n)=>e.data.reduce((r,i)=>t.measureText(i).width+r+20,0)+2*n.cellHorizontalPadding-4,draw:t=>Z6(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return y.createElement(Y6,{bubbles:e.data})},onPaste:()=>{}},Q6=4;function Z6(t,e){const{rect:n,theme:r,ctx:i,highlighted:s}=t,{x:o,y:l,width:a,height:u}=n,c=20,f=8,d=Q6;let h=o+r.cellHorizontalPadding;const p=[];for(const g of e){if(h>o+a)break;const b=pf(g,i,r.baseFontFull).width;p.push({x:h,width:b}),h+=b+f*2+d}i.beginPath();for(const g of p)Ts(i,g.x,l+(u-c)/2,g.width+f*2,c,r.roundingRadius??c/2);i.fillStyle=s?r.bgBubbleSelected:r.bgBubble,i.fill();for(const[g,b]of p.entries())i.beginPath(),i.fillStyle=r.textBubble,i.fillText(e[g],b.x+f,l+u/2+Js(i,r))}const e9=ai("div")({name:"DrilldownOverlayEditorStyle",class:"gdg-d4zsq0x",propsAsIs:!1}),t9=t=>{const{drilldowns:e}=t;return y.createElement(e9,null,e.map((n,r)=>y.createElement("div",{key:r,className:"doe-bubble"},n.img!==void 0&&y.createElement("img",{src:n.img}),y.createElement("div",null,n.text))))},n9={getAccessibilityString:t=>iE(t.data.map(e=>e.text)),kind:Ae.Drilldown,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(t,e,n)=>e.data.reduce((r,i)=>t.measureText(i.text).width+r+20+(i.img!==void 0?18:0),0)+2*n.cellHorizontalPadding-4,draw:t=>s9(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return y.createElement(t9,{drilldowns:e.data})},onPaste:()=>{}},r9=4,um={};function i9(t,e,n,r){const i=Math.ceil(window.devicePixelRatio),s=5,o=n-s*2,l=4,a=n*i,u=r+s,c=r*3,f=(c+s*2)*i,d=`${t},${e},${i},${n}`;if(um[d]!==void 0)return{el:um[d],height:a,width:f,middleWidth:l*i,sideWidth:u*i,padding:s*i,dpr:i};const h=document.createElement("canvas"),p=h.getContext("2d");return p===null?null:(h.width=f,h.height=a,p.scale(i,i),um[d]=h,p.beginPath(),Ts(p,s,s,c,o,r),p.shadowColor="rgba(24, 25, 34, 0.4)",p.shadowBlur=1,p.fillStyle=t,p.fill(),p.shadowColor="rgba(24, 25, 34, 0.3)",p.shadowOffsetY=1,p.shadowBlur=5,p.fillStyle=t,p.fill(),p.shadowOffsetY=0,p.shadowBlur=0,p.shadowBlur=0,p.beginPath(),Ts(p,s+.5,s+.5,c,o,r),p.strokeStyle=e,p.lineWidth=1,p.stroke(),{el:h,height:a,width:f,sideWidth:u*i,middleWidth:r*i,padding:s*i,dpr:i})}function s9(t,e){const{rect:n,theme:r,ctx:i,imageLoader:s,col:o,row:l}=t,{x:a,width:u}=n,c=r.baseFontFull,f=yE(i,c),d=Math.min(n.height,Math.max(16,Math.ceil(f*r.lineHeight)*2)),h=Math.floor(n.y+(n.height-d)/2),p=d-10,g=8,b=r9;let m=a+r.cellHorizontalPadding;const v=r.roundingRadius??6,w=i9(r.bgCell,r.drilldownBorder,d,v),k=[];for(const x of e){if(m>a+u)break;const T=pf(x.text,i,c).width;let A=0;x.img!==void 0&&s.loadOrGetImage(x.img,o,l)!==void 0&&(A=p-8+4);const M=T+A+g*2;k.push({x:m,width:M}),m+=M+b}if(w!==null){const{el:x,height:C,middleWidth:T,sideWidth:A,width:M,dpr:I,padding:D}=w,O=A/I,L=D/I;for(const _ of k){const re=Math.floor(_.x),ie=Math.floor(_.width),se=ie-(O-L)*2;i.imageSmoothingEnabled=!1,i.drawImage(x,0,0,A,C,re-L,h,O,d),se>0&&i.drawImage(x,A,0,T,C,re+(O-L),h,se,d),i.drawImage(x,M-A,0,A,C,re+ie-(O-L),h,O,d),i.imageSmoothingEnabled=!0}}i.beginPath();for(const[x,C]of k.entries()){const T=e[x];let A=C.x+g;if(T.img!==void 0){const M=s.loadOrGetImage(T.img,o,l);if(M!==void 0){const I=p-8;let D=0,O=0,L=M.width,_=M.height;L>_?(D+=(L-_)/2,L=_):_>L&&(O+=(_-L)/2,_=L),i.beginPath(),Ts(i,A,h+d/2-I/2,I,I,r.roundingRadius??3),i.save(),i.clip(),i.drawImage(M,D,O,L,_,A,h+d/2-I/2,I,I),i.restore(),A+=I+4}}i.beginPath(),i.fillStyle=r.textBubble,i.fillText(T.text,A,h+d/2+Js(i,r))}}const o9={getAccessibilityString:t=>t.data.join(", "),kind:Ae.Image,needsHover:!1,useLabel:!1,needsHoverPosition:!1,draw:t=>l9(t,t.cell.displayData??t.cell.data,t.cell.rounding??t.theme.roundingRadius??4,t.cell.contentAlign),measure:(t,e)=>e.data.length*50,onDelete:t=>({...t,data:[]}),provideEditor:()=>t=>{const{value:e,onFinishedEditing:n,imageEditorOverride:r}=t,i=r??JF;return y.createElement(i,{urls:e.data,canWrite:e.readonly!==!1,onCancel:n,onChange:s=>{n({...e,data:[s]})}})},onPaste:(t,e)=>{t=t.trim();const r=t.split(",").map(i=>{try{return new URL(i),i}catch{return}}).filter(i=>i!==void 0);if(!(r.length===e.data.length&&r.every((i,s)=>i===e.data[s])))return{...e,data:r}}},cm=4;function l9(t,e,n,r){const{rect:i,col:s,row:o,theme:l,ctx:a,imageLoader:u}=t,{x:c,y:f,height:d,width:h}=i,p=d-l.cellVerticalPadding*2,g=[];let b=0;for(let v=0;v0&&(a.beginPath(),Ts(a,m,f+l.cellVerticalPadding,w,p,n),a.save(),a.clip()),a.drawImage(v,m,f+l.cellVerticalPadding,w,p),n>0&&a.restore(),m+=w+cm}}function a9(t,e){let n=t*49632+e*325176;return n^=n<<13,n^=n>>17,n^=n<<5,n/4294967295*2}const u9={getAccessibilityString:()=>"",kind:Ae.Loading,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:()=>120,draw:t=>{const{cell:e,col:n,row:r,ctx:i,rect:s,theme:o}=t;if(e.skeletonWidth===void 0||e.skeletonWidth===0)return;let l=e.skeletonWidth;e.skeletonWidthVariability!==void 0&&e.skeletonWidthVariability>0&&(l+=Math.round(a9(n,r)*e.skeletonWidthVariability));const a=o.cellHorizontalPadding,u=e.skeletonHeight??Math.min(18,s.height-2*o.cellVerticalPadding);Ts(i,s.x+a,s.y+(s.height-u)/2,l,u,o.roundingRadius??3),i.fillStyle=Il(o.textDark,.1),i.fill()},onPaste:()=>{}},c9=()=>t=>t.targetWidth,Qx=ai("div")({name:"MarkdownOverlayEditorStyle",class:"gdg-m1pnx84e",propsAsIs:!1,vars:{"m1pnx84e-0":[c9(),"px"]}}),f9=t=>{const{value:e,onChange:n,forceEditMode:r,createNode:i,targetRect:s,onFinish:o,validatedSelection:l}=t,a=e.data,u=e.readonly===!0,[c,f]=y.useState(a===""||r),d=y.useCallback(()=>{f(p=>!p)},[]),h=a?"gdg-ml-6":"";return c?y.createElement(Qx,{targetWidth:s.width-20},y.createElement($p,{autoFocus:!0,highlight:!1,validatedSelection:l,value:a,onKeyDown:p=>{p.key==="Enter"&&p.stopPropagation()},onChange:n}),y.createElement("div",{className:`gdg-edit-icon gdg-checkmark-hover ${h}`,onClick:()=>o(e)},y.createElement(VF,null))):y.createElement(Qx,{targetWidth:s.width},y.createElement(m4,{contents:a,createNode:i}),!u&&y.createElement(y.Fragment,null,y.createElement("div",{className:"spacer"}),y.createElement("div",{className:`gdg-edit-icon gdg-edit-hover ${h}`,onClick:d},y.createElement(iw,null))),y.createElement("textarea",{className:"gdg-md-edit-textarea gdg-input",autoFocus:!0}))},d9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Ae.Markdown,needsHover:!1,needsHoverPosition:!1,drawPrep:gf,measure:(t,e,n)=>{const r=e.data.split(` +`)[0];return t.measureText(r).width+2*n.cellHorizontalPadding},draw:t=>Fs(t,t.cell.data,t.cell.contentAlign),onDelete:t=>({...t,data:""}),provideEditor:()=>t=>{const{onChange:e,value:n,target:r,onFinishedEditing:i,markdownDivCreateNode:s,forceEditMode:o,validatedSelection:l}=t;return y.createElement(f9,{onFinish:i,targetRect:r,value:n,validatedSelection:l,onChange:a=>e({...n,data:a.target.value}),forceEditMode:o,createNode:s})},onPaste:(t,e)=>t===e.data?void 0:{...e,data:t}},h9={getAccessibilityString:t=>t.row.toString(),kind:yi.Marker,needsHover:!0,needsHoverPosition:!1,drawPrep:p9,measure:()=>44,draw:t=>m9(t,t.cell.row,t.cell.checked,t.cell.markerKind,t.cell.drawHandle,t.cell.checkboxStyle),onClick:t=>{const{bounds:e,cell:n,posX:r,posY:i}=t,{width:s,height:o}=e,l=n.drawHandle?7+(s-7)/2:s/2,a=o/2;if(Math.abs(r-l)<=10&&Math.abs(i-a)<=10)return{...n,checked:!n.checked}},onPaste:()=>{}};function p9(t,e){const{ctx:n,theme:r}=t,i=r.markerFontFull,s=e??{};return(s==null?void 0:s.font)!==i&&(n.font=i,s.font=i),s.deprep=g9,n.textAlign="center",s}function g9(t){const{ctx:e}=t;e.textAlign="start"}function m9(t,e,n,r,i,s){const{ctx:o,rect:l,hoverAmount:a,theme:u}=t,{x:c,y:f,width:d,height:h}=l,p=n?1:r==="checkbox-visible"?.6+.4*a:a;if(r!=="number"&&p>0){o.globalAlpha=p;const g=7*(n?a:1);if(hw(o,u,n,i?c+g:c,f,i?d-g:d,h,!0,void 0,void 0,18,"center",s),i){o.globalAlpha=a,o.beginPath();for(const b of[3,6])for(const m of[-5,-1,3])o.rect(c+b,f+h/2+m,2,2);o.fillStyle=u.textLight,o.fill(),o.beginPath()}o.globalAlpha=1}if(r==="number"||r==="both"&&!n){const g=e.toString(),b=u.markerFontFull,m=c+d/2;r==="both"&&a!==0&&(o.globalAlpha=1-a),o.fillStyle=u.textLight,o.font=b,o.fillText(g,m,f+h/2+Js(o,b)),a!==0&&(o.globalAlpha=1)}}const y9={getAccessibilityString:()=>"",kind:yi.NewRow,needsHover:!0,needsHoverPosition:!1,measure:()=>200,draw:t=>v9(t,t.cell.hint,t.cell.icon),onPaste:()=>{}};function v9(t,e,n){const{ctx:r,rect:i,hoverAmount:s,theme:o,spriteManager:l}=t,{x:a,y:u,width:c,height:f}=i;r.beginPath(),r.globalAlpha=s,r.rect(a+1,u+1,c,f-2),r.fillStyle=o.bgHeaderHovered,r.fill(),r.globalAlpha=1,r.beginPath();const d=e!=="";let h=0;if(n!==void 0){const g=f-8,b=a+8/2,m=u+8/2;l.drawSprite(n,"normal",r,b,m,g,o,d?1:s),h=g}else{h=24;const p=12,g=d?p:s*p,b=d?0:(1-s)*p*.5,m=o.cellHorizontalPadding+4;g>0&&(r.moveTo(a+m+b,u+f/2),r.lineTo(a+m+b+g,u+f/2),r.moveTo(a+m+b+g*.5,u+f/2-g*.5),r.lineTo(a+m+b+g*.5,u+f/2+g*.5),r.lineWidth=2,r.strokeStyle=o.bgIconHeader,r.lineCap="round",r.stroke())}r.fillStyle=o.textMedium,r.fillText(e,h+a+o.cellHorizontalPadding+.5,u+f/2+Js(r,o)),r.beginPath()}const w9=y.lazy(async()=>await SE(()=>import("./number-overlay-editor-HYC-Cz64.js"),[])),b9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Ae.Number,needsHover:!1,needsHoverPosition:!1,useLabel:!0,drawPrep:gf,draw:t=>Fs(t,t.cell.displayData,t.cell.contentAlign),measure:(t,e,n)=>t.measureText(e.displayData).width+n.cellHorizontalPadding*2,onDelete:t=>({...t,data:void 0}),provideEditor:()=>t=>{const{isHighlighted:e,onChange:n,value:r,validatedSelection:i}=t;return y.createElement(y.Suspense,{fallback:null},y.createElement(w9,{highlight:e,disabled:r.readonly===!0,value:r.data,fixedDecimals:r.fixedDecimals,allowNegative:r.allowNegative,thousandSeparator:r.thousandSeparator,decimalSeparator:r.decimalSeparator,validatedSelection:i,onChange:s=>n({...r,data:Number.isNaN(s.floatValue??0)?0:s.floatValue})}))},onPaste:(t,e,n)=>{const r=typeof n.rawValue=="number"?n.rawValue:Number.parseFloat(typeof n.rawValue=="string"?n.rawValue:t);if(!(Number.isNaN(r)||e.data===r))return{...e,data:r,displayData:n.formattedString??e.displayData}}},x9={getAccessibilityString:()=>"",measure:()=>108,kind:Ae.Protected,needsHover:!1,needsHoverPosition:!1,draw:k9,onPaste:()=>{}};function k9(t){const{ctx:e,theme:n,rect:r}=t,{x:i,y:s,height:o}=r;e.beginPath();const l=2.5;let a=i+n.cellHorizontalPadding+l;const u=s+o/2,c=Math.cos(Zb(30))*l,f=Math.sin(Zb(30))*l;for(let d=0;d<12;d++)e.moveTo(a,u-l),e.lineTo(a,u+l),e.moveTo(a+c,u-f),e.lineTo(a-c,u+f),e.moveTo(a-c,u-f),e.lineTo(a+c,u+f),a+=8;e.lineWidth=1.1,e.lineCap="square",e.strokeStyle=n.textLight,e.stroke()}const S9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Ae.RowID,needsHover:!1,needsHoverPosition:!1,drawPrep:(t,e)=>gf(t,e,t.theme.textLight),draw:t=>Fs(t,t.cell.data,t.cell.contentAlign),measure:(t,e,n)=>t.measureText(e.data).width+n.cellHorizontalPadding*2,provideEditor:()=>t=>{const{isHighlighted:e,onChange:n,value:r,validatedSelection:i}=t;return Kn.createElement($p,{highlight:e,autoFocus:r.readonly!==!0,disabled:r.readonly!==!1,value:r.data,validatedSelection:i,onChange:s=>n({...r,data:s.target.value})})},onPaste:()=>{}},C9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Ae.Text,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!1,drawPrep:gf,useLabel:!0,draw:t=>{const{cell:e,hoverAmount:n,hyperWrapping:r,ctx:i,rect:s,theme:o,overrideCursor:l}=t,{displayData:a,contentAlign:u,hoverEffect:c,allowWrapping:f}=e;if(c===!0&&n>0){i.textBaseline="alphabetic";const d=o.cellHorizontalPadding,h=o.cellVerticalPadding,p=pf(a,i,o.baseFontFull,"alphabetic"),g=s.height-h,b=Math.min(g,p.actualBoundingBoxAscent*2.5);i.beginPath(),Ts(i,s.x+d/2,s.y+(s.height-b)/2+1,p.width+d*3,b-1,o.roundingRadius??4),i.globalAlpha=n,i.fillStyle=Il(o.textDark,.1),i.fill(),i.globalAlpha=1,i.fillStyle=o.textDark,i.textBaseline="middle",l==null||l("text")}Fs(t,a,u,f,r)},measure:(t,e,n)=>{const r=e.displayData.split(` +`,e.allowWrapping===!0?void 0:1);let i=0;for(const s of r)i=Math.max(i,t.measureText(s).width);return i+2*n.cellHorizontalPadding},onDelete:t=>({...t,data:""}),provideEditor:t=>({disablePadding:t.allowWrapping===!0,editor:e=>{const{isHighlighted:n,onChange:r,value:i,validatedSelection:s}=e;return y.createElement($p,{style:t.allowWrapping===!0?{padding:"3px 8.5px"}:void 0,highlight:n,autoFocus:i.readonly!==!0,disabled:i.readonly===!0,altNewline:!0,value:i.data,validatedSelection:s,onChange:o=>r({...i,data:o.target.value})})}}),onPaste:(t,e,n)=>t===e.data?void 0:{...e,data:t,displayData:n.formattedString??e.displayData}},T9=ai("div")({name:"UriOverlayEditorStyle",class:"gdg-u1rrojo",propsAsIs:!1}),E9=t=>{const{uri:e,onChange:n,forceEditMode:r,readonly:i,validatedSelection:s,preview:o}=t,[l,a]=y.useState(!i&&(e===""||r)),u=y.useCallback(()=>{a(!0)},[]);return l?y.createElement($p,{validatedSelection:s,highlight:!0,autoFocus:!0,value:e,onChange:n}):y.createElement(T9,null,y.createElement("a",{className:"gdg-link-area",href:e,target:"_blank",rel:"noopener noreferrer"},o),!i&&y.createElement("div",{className:"gdg-edit-icon",onClick:u},y.createElement(iw,null)),y.createElement("textarea",{className:"gdg-input",autoFocus:!0}))};function Zx(t,e,n,r){let i=n.cellHorizontalPadding;const s=e.height/2-t.actualBoundingBoxAscent/2,o=t.width,l=t.actualBoundingBoxAscent;return r==="right"?i=e.width-o-n.cellHorizontalPadding:r==="center"&&(i=e.width/2-o/2),{x:i,y:s,width:o,height:l}}const A9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Ae.Uri,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!0,useLabel:!0,drawPrep:gf,draw:t=>{const{cell:e,theme:n,overrideCursor:r,hoverX:i,hoverY:s,rect:o,ctx:l}=t,a=e.displayData??e.data,u=e.hoverEffect===!0;if(r!==void 0&&u&&i!==void 0&&s!==void 0){const c=pf(a,l,n.baseFontFull),f=Zx(c,o,n,e.contentAlign),{x:d,y:h,width:p,height:g}=f;if(i>=d-4&&i<=d-4+p+8&&s>=h-4&&s<=h-4+g+8){const b=Js(l,n.baseFontFull);r("pointer");const m=5,v=h-b;l.beginPath(),l.moveTo(o.x+d,Math.floor(o.y+v+g+m)+.5),l.lineTo(o.x+d+p,Math.floor(o.y+v+g+m)+.5),l.strokeStyle=n.linkColor,l.stroke(),l.save(),l.fillStyle=t.cellFillColor,Fs({...t,rect:{...o,x:o.x-1}},a,e.contentAlign),Fs({...t,rect:{...o,x:o.x-2}},a,e.contentAlign),Fs({...t,rect:{...o,x:o.x+1}},a,e.contentAlign),Fs({...t,rect:{...o,x:o.x+2}},a,e.contentAlign),l.restore()}}l.fillStyle=u?n.linkColor:n.textDark,Fs(t,a,e.contentAlign)},onClick:t=>{const{cell:e,bounds:n,posX:r,posY:i,theme:s}=t,o=e.displayData??e.data;if(e.hoverEffect!==!0||e.onClickUri===void 0)return;const l=_4(o,s.baseFontFull);if(l===void 0)return;const a=Zx(l,n,s,e.contentAlign);zp({x:a.x-4,y:a.y-4,width:a.width+8,height:a.height+8},r,i)&&e.onClickUri(t)},measure:(t,e,n)=>t.measureText(e.displayData??e.data).width+n.cellHorizontalPadding*2,onDelete:t=>({...t,data:""}),provideEditor:t=>e=>{const{onChange:n,value:r,forceEditMode:i,validatedSelection:s}=e;return y.createElement(E9,{forceEditMode:r.readonly!==!0&&(i||t.hoverEffect===!0&&t.onClickUri!==void 0),uri:r.data,preview:r.displayData??r.data,validatedSelection:s,readonly:r.readonly===!0,onChange:o=>n({...r,data:o.target.value})})},onPaste:(t,e,n)=>t===e.data?void 0:{...e,data:t,displayData:n.formattedString??e.displayData}},M9=[h9,y9,X6,J6,n9,o9,u9,d9,b9,x9,S9,C9,A9];var R9=QT,O9=zl,P9="Expected a function";function I9(t,e,n){var r=!0,i=!0;if(typeof t!="function")throw new TypeError(P9);return O9(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),R9(t,e,{leading:r,maxWait:e,trailing:i})}var N9=I9;const _9=es(N9),fm=[];class D9 extends wE{constructor(){super(...arguments);kt(this,"imageLoaded",()=>{});kt(this,"loadedLocations",[]);kt(this,"cache",{});kt(this,"sendLoaded",_9(()=>{this.imageLoaded(new yc(this.loadedLocations)),this.loadedLocations=[]},20));kt(this,"clearOutOfWindow",()=>{const n=Object.keys(this.cache);for(const r of n){const i=this.cache[r];let s=!1;for(let o=0;o{a||(a=!0,fm.length<12?fm.unshift(l):o||(l.src=""))}},c=new Promise(f=>l.addEventListener("load",()=>f(null)));requestAnimationFrame(async()=>{try{l.src=n,await c,await l.decode();const f=this.cache[s];if(f!==void 0&&!a){f.img=l;for(const d of f.cells)this.loadedLocations.push(cw(d));o=!0,this.sendLoaded()}}catch{u.cancel()}}),this.cache[s]=u}loadOrGetImage(n,r,i){const s=n,o=this.cache[s];if(o!==void 0){const l=Vi(r,i);return o.cells.includes(l)||o.cells.push(l),o.img}else this.loadImage(n,r,i,s)}}const ek="\uFEFF",L9=/^\s*(?:\|?\s*:?-{2,}:?\s*(?:\|\s*:?-{2,}:?\s*)+\|?|\|\s*:?-{2,}:?\s*\||\+[-=]+(?:\+[-=]+)*\+|[-=]+(?:\+[-=]+)+)\s*$/m,ia=/^\s*(?:\|?\s*:?-{2,}:?\s*(?:\|\s*:?-{2,}:?\s*)+\|?|\|\s*:?-{2,}:?\s*\|)\s*$/,JE=/^\s*\+[-=]+(?:\+[-=]+)*\+\s*$/,$9=/^\s*[-=]+(?:\+[-=]+)+\s*$/,tk=/^\s*(?:\(\d+\s+rows?\)|\d+\s+rows?\s+in\s+set(?:\s*\([^)]*\))?)\s*$/i,ec=/^\s*(?:`{3,}|~{3,})/,Kd=/^\s*#{1,6}\s+(.+?)\s*#*\s*$/,F9=/^\s*(?:\*\*([^*]+)\*\*|__([^_]+)__)\s*:?\s*$/,z9=/^\s*(?:={3,}|-{3,})\s*$/;function Xd(t){for(let e=0;e=0&&t[n]==="\\";n--)e++;return e%2===0}function nk(t){let e=t.trim();e.startsWith("|")&&(e=e.slice(1)),B9(e)&&(e=e.slice(0,-1));const n=[];let r="";for(let i=0;ir.trim())}function dl(t){return JE.test(t)||$9.test(t)}const rk=32;function dm(t){const e=t.replace(/(\*\*|__|`)*/g,"").replace(/\s+/g," ").replace(/\s*:\s*$/,"").trim();return e?e.length>rk?`${e.slice(0,rk-1).trimEnd()}…`:e:null}function hm(t,e,n){if(e)return e;const r=n.slice(0,3).map(i=>i.trim()).filter(Boolean).join(", ");return r?`Table ${t+1} (${r})`:`Table ${t+1}`}function j9(t,e){const n=Kd.exec(t);if(n){const i=dm(n[1]);if(i)return{title:i,consumedNextLine:!1}}const r=F9.exec(t);if(r){const i=dm(r[1]??r[2]??"");if(i)return{title:i,consumedNextLine:!1}}if(e!==void 0&&z9.test(e)&&t.trim().length>0&&!Xd(t)&&!dl(t)&&!ec.test(t)){const i=dm(t);if(i)return{title:i,consumedNextLine:!0}}return null}function QE(t){if(!t)return[];const e=t.startsWith(ek)?t.slice(ek.length):t,n=e.slice(0,64*1024);if(!n.includes("|")||!L9.test(n))return[];const r=e.split(/\r?\n/),i=[];let s=null,o=0;for(;o=2&&d.length>=1){const h=ad(d[0],!0);if(h.length>0&&!h.every(p=>p==="")){const p=d.slice(1).map(v=>ad(v,!0)),g=_a(h,p,","),b=i.length,m=s;i.push({index:b,title:m,label:hm(b,m,h),headers:h,cleanedCsv:g,rows:p.length,cols:h.length,kind:"box"}),s=null,o=c;continue}}o++;continue}if(Xd(l)&&!dl(l)&&!ia.test(l)&&!Kd.test(l)&&o+10&&!c.every(f=>f==="")){const f=[];let d=o+2;for(;d0&&!p.every(g=>g==="")){const g=c.slice(1).map(w=>ad(w,h)),b=_a(p,g,","),m=i.length,v=s;i.push({index:m,title:v,label:hm(m,v,p),headers:p,cleanedCsv:b,rows:g.length,cols:p.length,kind:"box"}),s=null,o=f;continue}}const u=j9(l,r[o+1]);if(u){s=u.title,o+=u.consumedNextLine?2:1;continue}o++}return i}function Bp(t,e=0){const n=QE(t);if(n.length===0)return null;const r=Math.min(Math.max(0,Math.trunc(e)||0),n.length-1),i=n[r];return{cleanedCsv:i.cleanedCsv,rows:i.rows,cols:i.cols,kind:i.kind}}const pm="\uFEFF";function H9(t){const e={",":0,";":0," ":0};let n=",",r=-1,i=0,s=!1;for(let o=0;or&&(n=o,r=e[o]);return n}function W9(t,e,n){if(t[e]==='"'){let i="",s=e+1;for(;;){if(s>=t.length)return[i,s];const o=t[s];if(o==='"')if(t[s+1]==='"')i+='"',s+=2;else{for(s++;s=o.length)break;if(o[x]===a){h=x+1,p=!0;continue}h=o[x]==="\r"&&o[x+1]===` +`?x+2:x+1,u.push(f),c.push({start:d+l,end:x+l}),f=[]}f.length>0?(u.push(f),c.push({start:d+l,end:o.length+l})):u.length===0&&f.length===0&&o.length>0&&(u.push([""]),c.push({start:0+l,end:o.length+l}));const g=u.length>0?u[0]:[],b=g.length,m=u.slice(1),v=m.map(k=>k.length),w=m.map(k=>k.length===b?k:k.length>b?k.slice(0,b):[...k,...Array(b-k.length).fill("")]);return{headers:g,rows:w,delimiter:a,rowWidths:v,rowSpans:c.slice(1)}}function qa(t,e=","){const n=r=>r.includes('"')?`"${r.replaceAll('"','""')}"`:r.includes(e)||r.includes(` +`)||r.includes("\r")?`"${r}"`:r;return t.map(n).join(e)}function _a(t,e,n=","){return[t,...e].map(r=>qa(r,n)).join(` +`)}function mw(t,e){return mf(t,e).headers}function V9(t){const e=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/,n=Array.from({length:t.headers.length},()=>!0),r=Array.from({length:t.headers.length},()=>!1);for(const i of t.rows)for(let s=0;si&&r[s])}function ZE(t,e){let n="",r=0;for(const{start:i,end:s,replacement:o}of e)n+=t.slice(r,i)+o,r=s;return n+t.slice(r)}function U9(t,e){return t[e]==="\r"?t[e+1]===` +`?2:1:t[e]===` +`?1:0}function ik(t,e){return t[e-2]==="\r"&&t[e-1]===` +`?2:t[e-1]==="\r"||t[e-1]===` +`?1:0}const sk="\uFEFF";function eA(t,e){const n=t.startsWith(sk)?sk.length:0,r=e.rowSpans[0];if(r!==void 0)return{start:n,end:r.start-ik(t,r.start)};const i=t.slice(n);return{start:n,end:n+i.length-ik(t,t.length)}}function gm(t,e,n){const r=[...new Set(n)].flatMap(i=>{const s=e.rowSpans[i];return s===void 0?[]:[s]}).sort((i,s)=>i.start-s.start).map(i=>({start:i.start,end:i.end+U9(t,i.end),replacement:""}));return r.length===0?t:ZE(t,r)}function ok(t,e,n){const r=new Set([...n].filter(o=>o>=0&&ou!r.has(c));s.push({start:o.start,end:o.end,replacement:qa(a,e.delimiter)})}return ZE(t,s)}function K9(t,e,n,r){if(!t||n<0||n>=e.headers.length)return t;const i=eA(t,e),s=mw(t.slice(i.start,i.end),e.delimiter);if(n>=s.length||s[n]===r)return t;const o=s.map((a,u)=>u===n?r:a),l=qa(o,e.delimiter);return t.slice(0,i.start)+l+t.slice(i.end)}const ey=50;function sl(t=""){return{past:[],present:t,future:[]}}function lk(t,e,n=ey){if(e===t.present)return t;if(t.present===""&&t.past.length===0&&t.future.length===0)return{past:[],present:e,future:[]};const r=[...t.past,t.present];return{past:r.length>n?r.slice(r.length-n):r,present:e,future:[]}}function X9(t){if(t.past.length===0)return t;const e=t.past[t.past.length-1];return{past:t.past.slice(0,t.past.length-1),present:e,future:[t.present,...t.future]}}function G9(t){if(t.future.length===0)return t;const[e,...n]=t.future,r=[...t.past,t.present];return{past:r.length>ey?r.slice(r.length-ey):r,present:e,future:n}}function q9(t){if(t.altKey||!t.metaKey&&!t.ctrlKey)return null;const e=t.key.toLowerCase();return e==="z"?t.shiftKey?"redo":"undo":e==="y"&&!t.shiftKey?"redo":null}const ak=/^[+-]?\d{16,}$/;function Y9(t,e){const n=Array.from({length:t.length},(i,s)=>s);if(e==="")return n;const r=e.toLowerCase();return n.filter(i=>{const s=t[i];for(let o=0;o{var c,f;const a=((c=e[o])==null?void 0:c[n])??"",u=((f=e[l])==null?void 0:f[n])??"";if(i){const d=a===""?NaN:Number(a),h=u===""?NaN:Number(u),p=Number.isNaN(d),g=Number.isNaN(h);if(p||g)return p&&g?0:p?1:-1;if(ak.test(a)&&ak.test(u)){const b=BigInt(a),m=BigInt(u);return s*(bm?1:0)}return s*(d-h)}return s*a.localeCompare(u)})}function Q9(t,e,n){if(n.length===0||t.headers.length===0)return"";const r=t.delimiter||",",i=qa(n.map(o=>t.headers[o]??""),r),s=e.filter(o=>o>=0&&oqa(n.map(l=>{var a;return((a=t.rows[o])==null?void 0:a[l])??""}),r));return[i,...s].join(` +`)}const Z9=` + +`;function ud(t,e){return Math.max(0,Math.min(t,e))}function uk(t,e,n,r){const i=t.headers.length,s=[];for(const a of n.ranges){const u=ud(a.x,r+i),c=ud(a.x+a.width,r+i);if(c<=r)continue;const f=Math.max(0,u-r),d=c-r;if(d<=f)continue;const h=ud(a.y,e.length),p=ud(a.y+a.height,e.length);if(p<=h)continue;const g=t.headers.slice(f,d),b=[];for(let m=h;mw[f+x]??""))}b.length!==0&&s.push(_a(g,b,t.delimiter))}if(s.length>0)return s.join(Z9);const o=[...n.rows].filter(a=>a>=0&&ae[a]).filter(a=>a!==void 0);if(o.length>0)return _a(t.headers,o.map(a=>t.rows[a]??[]),t.delimiter);const l=[...n.columns].filter(a=>a>=r&&a0){const a=l.map(c=>t.headers[c-r]),u=e.map(c=>{const f=t.rows[c]??[];return l.map(d=>f[d-r]??"")});return _a(a,u,t.delimiter)}return null}const ol=1e5,eV=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?$/;function tV(t,e,n,r){var p;const i=t.headers.length,s=e.length;if(i===0||s===0)return null;const o=new Set;for(const g of n.ranges){if(o.size>=ol)break;const b=Math.max(0,g.x-r),m=Math.min(i,g.x+g.width-r);if(m<=b)continue;const v=Math.max(0,g.y),w=Math.min(s,g.y+g.height);if(!(w<=v))for(let k=v;k=ol);k++){const x=k*i;for(let C=b;C=ol));C++);}}for(const g of n.rows){if(o.size>=ol)break;if(g<0||g>=s)continue;const b=g*i;for(let m=0;m=ol));m++);}for(const g of n.columns){if(o.size>=ol)break;const b=g-r;if(!(b<0||b>=i))for(let m=0;m=ol));m++);}const l=o.size;if(l===0||l<2&&n.rows.length===0&&n.columns.length===0)return null;let a=0,u=0,c=0,f=null,d=null;const h=new Set;for(const g of o){const b=Math.floor(g/i),m=g%i,v=e[b],k=((v!==void 0?(p=t.rows[v])==null?void 0:p[m]:void 0)??"").trim();if(k===""){a+=1;continue}if(h.add(k),eV.test(k)){const x=Number(k);Number.isFinite(x)&&(u+=1,c+=x,(f===null||xd)&&(d=x))}}return{cellCount:l,distinctCount:h.size,emptyCount:a,numericCount:u,sum:u>0?c:null,avg:u>0?c/u:null,min:u>0?f:null,max:u>0?d:null}}const ck=24,mm=26,fk=110,ym=40,nV=12,tr=1,dk='ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',hk='ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',rV=[{mode:"auto",label:"Auto"},{mode:"string",label:"String"},{mode:"number",label:"Number"},{mode:"boolean",label:"Boolean"}];function pk(t){return t==="string"?"STR":t==="number"?"NUM":t==="boolean"?"BOOL":null}function gk(t){if(!(t instanceof HTMLElement))return!1;const e=t.tagName;return e==="INPUT"||e==="TEXTAREA"||t.isContentEditable}const ll="inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background px-1.5 py-0.5 text-[11px] font-medium text-foreground hover:bg-muted outline-none focus-visible:ring-3 focus-visible:ring-ring/50",Gd=new Intl.NumberFormat("en-US",{maximumFractionDigits:4});function cd(t){return Gd.format(Object.is(t,-0)?0:t)}function iV(t){const e=[`Cells: ${Gd.format(t.cellCount)}`,`Distinct: ${Gd.format(t.distinctCount)}`];return t.emptyCount>0&&e.push(`Empty: ${Gd.format(t.emptyCount)}`),t.numericCount>0&&t.sum!==null&&t.avg!==null&&t.min!==null&&t.max!==null&&e.push(`Sum: ${cd(t.sum)}`,`Avg: ${cd(t.avg)}`,`Min: ${cd(t.min)}`,`Max: ${cd(t.max)}`),e.join(" · ")}function sV(t){return t?{accentColor:"hsl(0 0% 98%)",accentFg:"hsl(240 10% 3.9%)",accentLight:"hsla(240, 4.9%, 70%, 0.18)",textDark:"hsl(0 0% 98%)",textMedium:"hsl(240 5% 64.9%)",textLight:"hsla(240, 5%, 64.9%, 0.4)",textBubble:"hsl(0 0% 98%)",textHeader:"hsl(240 5% 64.9%)",textHeaderSelected:"hsl(0 0% 98%)",bgCell:"hsl(240 6% 7%)",bgCellMedium:"hsl(240 6% 7%)",bgHeader:"hsl(240 6% 7%)",bgHeaderHasFocus:"hsl(240 3.7% 15.9%)",bgHeaderHovered:"hsl(240 3.7% 15.9%)",bgBubble:"hsl(240 3.7% 15.9%)",bgBubbleSelected:"hsl(240 6% 7%)",bgSearchResult:"hsl(240 3.7% 15.9%)",borderColor:"hsl(240 3.7% 15.9%)",horizontalBorderColor:"hsla(240, 3.7%, 15.9%, 0.6)",headerBottomBorderColor:"hsl(240 3.7% 15.9%)",linkColor:"hsl(0 0% 98%)",cellHorizontalPadding:8,cellVerticalPadding:3,headerFontStyle:"600 11px",baseFontStyle:"12px",editorFontSize:"12px",fontFamily:hk,lineHeight:1}:{accentColor:"hsl(240 10% 3.9%)",accentFg:"hsl(0 0% 100%)",accentLight:"hsla(240, 4.8%, 45%, 0.14)",textDark:"hsl(240 10% 3.9%)",textMedium:"hsl(240 3.8% 46.1%)",textLight:"hsla(240, 3.8%, 46.1%, 0.4)",textBubble:"hsl(240 10% 3.9%)",textHeader:"hsl(240 3.8% 46.1%)",textHeaderSelected:"hsl(240 10% 3.9%)",bgCell:"hsl(0 0% 100%)",bgCellMedium:"hsl(0 0% 100%)",bgHeader:"hsl(0 0% 100%)",bgHeaderHasFocus:"hsl(240 4.8% 95.9%)",bgHeaderHovered:"hsl(240 4.8% 95.9%)",bgBubble:"hsl(240 4.8% 95.9%)",bgBubbleSelected:"hsl(0 0% 100%)",bgSearchResult:"hsl(48 96% 89%)",borderColor:"hsl(240 5.9% 90%)",horizontalBorderColor:"hsla(240, 5.9%, 90%, 0.6)",headerBottomBorderColor:"hsl(240 5.9% 90%)",linkColor:"hsl(240 10% 3.9%)",cellHorizontalPadding:8,cellVerticalPadding:3,headerFontStyle:"600 11px",baseFontStyle:"12px",editorFontSize:"12px",fontFamily:hk,lineHeight:1}}function oV(t){return t?"hsla(45, 96%, 65%, 0.3)":"hsl(48 96% 89%)"}function tA({text:t,delimiter:e,testId:n="csv-table",dark:r=!1,onCellCommit:i,onUndo:s,onRedo:o,onCopySelection:l,columnTypes:a,onChangeColumnTypes:u,onProjectedCsvChange:c}){const f=y.useRef(null),d=y.useRef(null),h=y.useRef(null),p=y.useRef(null),[g,b]=y.useState(""),[m,v]=y.useState(""),[w,k]=y.useState(null),x=y.useRef(w);x.current=w;const C=y.useRef(null),[T,A]=y.useState(null),[M,I]=y.useState(""),D=y.useRef(null),[O,L]=y.useState(()=>new Set),[_,re]=y.useState(!1),[ie,se]=y.useState(!1),[H,X]=y.useState(void 0),[R,N]=y.useState(()=>new Set),P=y.useRef(R),[B,q]=y.useState(0),[W,ye]=y.useState({}),ee=i!==void 0,me=a??W,Le=y.useCallback(z=>{ye(z),u==null||u(z)},[u]),Ue=y.useMemo(()=>sV(r),[r]),ze=oV(r),Mt=r?"hsl(240 3.7% 15.9%)":"hsl(240 4.8% 95.9%)",tt=y.useRef();tt.current===void 0&&(tt.current=new D9);const Be=y.useMemo(()=>{var z;return e===void 0?((z=Bp(t))==null?void 0:z.cleanedCsv)??t:t},[t,e]),ue=y.useMemo(()=>mf(Be,e),[Be,e]),It=y.useMemo(()=>V9(ue),[ue]),be=ue.headers.length,xe=y.useRef(ue.headers);if(xe.current!==ue.headers){const z=xe.current,oe=ue.headers;xe.current=oe;const Q=z.length===oe.length,pe=Q?oe.reduce((ve,gt,Fe)=>gt===z[Fe]?ve:ve+1,0):1/0;(!Q||pe>1||pe===1&&oe.length<=1)&&O.size>0&&L(new Set)}const Y=y.useMemo(()=>{const z=Array.from({length:be},(Q,pe)=>pe);if(O.size===0)return z;const oe=z.filter(Q=>!O.has(Q));return oe.length>0?oe:z},[be,O]),Se=y.useRef(Y);Se.current=Y;const Ie=y.useMemo(()=>Y.length===ue.headers.length?ue:{...ue,headers:Y.map(z=>ue.headers[z]??""),rows:ue.rows.map(z=>Y.map(oe=>z[oe]??""))},[ue,Y]),Ce=y.useRef({text:Be,table:ue,visibleTable:Ie});Ce.current={text:Be,table:ue,visibleTable:Ie};const xt=y.useRef(H);xt.current=H,y.useEffect(()=>{const z=window.setTimeout(()=>v(g),150);return()=>window.clearTimeout(z)},[g]);const $e=y.useMemo(()=>{const z=Y9(ue.rows,m);return w?J9(z,ue.rows,w.col,w.dir,It[w.col]??!1):z},[ue,m,w,It]),nt=y.useRef($e);nt.current=$e,y.useEffect(()=>{const z=d.current;if(!z||typeof ResizeObserver>"u")return;const oe=new ResizeObserver(()=>q(z.clientWidth));return oe.observe(z),q(z.clientWidth),()=>oe.disconnect()},[]);const ge=Math.max(fk,Math.floor((B-ym)/Math.max(1,Y.length)));y.useEffect(()=>{if(!_)return;const z=Q=>{Q.key==="Escape"&&(Q.stopPropagation(),re(!1))},oe=Q=>{const pe=h.current;pe===null||!(Q.target instanceof Node)||pe.contains(Q.target)||re(!1)};return document.addEventListener("keydown",z),document.addEventListener("click",oe),()=>{document.removeEventListener("keydown",z),document.removeEventListener("click",oe)}},[_]);const ot=y.useCallback(z=>{L(oe=>{const Q=new Set(oe);if(Q.has(z))Q.delete(z);else{if(be-(Q.size+1)<1)return oe;Q.add(z)}return Q}),X(oe=>oe&&oe.columns.length>0?{...oe,columns:Pt.empty()}:oe)},[be]),rt=y.useCallback(()=>{L(new Set),X(z=>z&&z.columns.length>0?{...z,columns:Pt.empty()}:z)},[]),Ke=Y.length!ie||!an?null:Q9(ue,$e,Y),[ie,an,ue,$e,Y]),it=y.useRef(c);it.current=c,y.useEffect(()=>{var z;(z=it.current)==null||z.call(it,mt)},[mt]),y.useEffect(()=>()=>{var z;(z=it.current)==null||z.call(it,null)},[]),y.useEffect(()=>{N(z=>{let oe=!1;const Q=new Set;for(const pe of z)pe{X(z=>{if(!z||z.rows.length===0)return z;const oe=[];for(const pe of P.current){const ve=$e.indexOf(pe);ve!==-1&&oe.push(ve)}oe.sort((pe,ve)=>pe-ve);const Q=oe.reduce((pe,ve)=>pe.add(ve),Pt.empty());return Q.equals(z.rows)?z:{...z,rows:Q}})},[$e]),y.useEffect(()=>{k(z=>z!==null&&z.col>=be?null:z),A(z=>z!==null&&z.col>=be?null:z)},[be]);const dt=m!=="",Yt=ue.rows.length,mn=mm+Math.min($e.length,nV)*ck,qn=()=>{b(""),v("")},Jt=y.useCallback((z,oe)=>{var ve;if(z0||Fe.height>0)?{x:Math.max(0,ct.x-Fe.left),y:Math.max(0,ct.y-Fe.top),width:ct.width,height:ct.height}:ct??{x:ym+Q*ge,y:0,width:ge,height:mm};I(gt),A({col:pe,bounds:ft});return}C.current=x.current,A(null),k(gt=>!gt||gt.col!==pe?{col:pe,dir:"asc"}:gt.dir==="asc"?{col:pe,dir:"desc"}:null)}},[ee,ge]),jt=y.useCallback(()=>{if(!T)return;const{col:z}=T;if(A(null),!i)return;const{text:oe,table:Q}=Ce.current,pe=Q.headers[z]??"",ve=K9(oe,Q,z,M);if(ve!==oe){if(pe!==""&&pe!==M&&me[pe]!==void 0){const gt={...me},Fe=gt[pe];delete gt[pe],M!==""&&Fe!==void 0&&(gt[M]=Fe),Le(gt)}i(ve)}},[T,M,i,me,Le]),Hn=y.useCallback(()=>{A(null)},[]);y.useEffect(()=>{if(!T)return;const z=D.current;z&&(z.focus(),z.select())},[T]);const bn=y.useCallback((z,oe)=>{const Q=nt.current,pe=Q[oe];if(pe===void 0)return;const ve=P.current,gt=p.current;let Fe;if(z.shiftKey&>!==null&>!==pe){const ft=Q.indexOf(gt),Kt=Q.indexOf(pe),nn=ft===-1?Kt:ft,[zn,rn]=nn<=Kt?[nn,Kt]:[Kt,nn];Fe=z.metaKey||z.ctrlKey?new Set(ve):new Set;for(let xn=zn;xn<=rn;xn++){const xr=Q[xn];xr!==void 0&&Fe.add(xr)}}else z.metaKey||z.ctrlKey?(Fe=new Set(ve),Fe.has(pe)?Fe.delete(pe):Fe.add(pe)):Fe=new Set([pe]);p.current=pe,P.current=Fe,N(Fe);const ct=[...Fe].map(ft=>Q.indexOf(ft)).filter(ft=>ft!==-1).sort((ft,Kt)=>ft-Kt);X(ft=>({current:ft==null?void 0:ft.current,columns:(ft==null?void 0:ft.columns)??Pt.empty(),rows:ct.reduce((Kt,nn)=>Kt.add(nn),Pt.empty())}))},[]),Yn=y.useCallback(()=>{p.current=null,P.current=new Set,N(new Set),X(void 0)},[]),Wr=y.useCallback(z=>{const oe=new Set;for(const Q of z.rows){const pe=nt.current[Q];pe!==void 0&&oe.add(pe)}P.current=oe,N(oe),X(z)},[]),Ht=y.useCallback(()=>{Yn()},[Yn]),Qe=y.useMemo(()=>$e.filter(z=>R.has(z)),[$e,R]),We=y.useMemo(()=>[...(H==null?void 0:H.columns)??[]].filter(z=>z>=tr).map(z=>Y[z-tr]).filter(z=>z!==void 0),[H,Y]),Lt=We.length,Qt=y.useMemo(()=>We.map(z=>ue.headers[z]).filter(z=>z!==void 0),[We,ue.headers]),Zt=y.useMemo(()=>{if(Qt.length===0)return null;const z=me[Qt[0]]??"auto";for(let oe=1;oe{if(!ee||Qt.length===0)return;const oe={...me};for(const Q of Qt)z==="auto"?delete oe[Q]:oe[Q]=z;Le(oe)},[ee,Qt,me,Le]),er=y.useMemo(()=>ee?ue.headers.filter(z=>pk(me[z])!==null).length:0,[ee,ue.headers,me]),pt=y.useMemo(()=>({ranges:H!=null&&H.current?[H.current.range,...H.current.rangeStack]:[],columns:H?[...H.columns]:[],rows:R.size>0?$e.reduce((z,oe,Q)=>(R.has(oe)&&z.push(Q),z),[]):H?[...H.rows]:[]}),[H,R,$e]),Wt=tr,Rt=y.useMemo(()=>tV(Ie,$e,pt,Wt),[Ie,$e,pt,Wt]),Ft=Qe.length>0||Lt>0||Rt!==null,tn=y.useRef(l);tn.current=l;const Vt=()=>{var Q,pe;const z=xt.current,oe=uk(Ce.current.visibleTable,nt.current,{ranges:z!=null&&z.current?[z.current.range,...z.current.rangeStack]:[],columns:z?[...z.columns]:[],rows:z?[...z.rows]:[]},tr);oe!==null&&((Q=tn.current)==null||Q.call(tn),(pe=navigator.clipboard)==null||pe.writeText(oe).catch(()=>{}))};y.useEffect(()=>{const z=oe=>{var Fe,ct;const Q=f.current;if(!Q||!Q.contains(document.activeElement))return;const pe=document.activeElement;if(pe&&(pe.tagName==="INPUT"||pe.tagName==="TEXTAREA"||pe.isContentEditable))return;const ve=xt.current,gt=uk(Ce.current.visibleTable,nt.current,{ranges:ve!=null&&ve.current?[ve.current.range,...ve.current.rangeStack]:[],columns:ve?[...ve.columns]:[],rows:ve?[...ve.rows]:[]},tr);gt!==null&&(oe.preventDefault(),oe.stopImmediatePropagation(),(Fe=oe.clipboardData)==null||Fe.setData("text/plain",gt),(ct=tn.current)==null||ct.call(tn))};return window.addEventListener("copy",z,{capture:!0}),()=>window.removeEventListener("copy",z,{capture:!0})},[]),y.useEffect(()=>{if(!s&&!o)return;const z=oe=>{const Q=f.current;if(!Q)return;const pe=oe.target instanceof Node&&Q.contains(oe.target),ve=document.activeElement instanceof Node&&Q.contains(document.activeElement);if(!pe&&!ve||gk(oe.target)||gk(document.activeElement))return;const gt=q9(oe);gt==="undo"&&s?(oe.preventDefault(),s()):gt==="redo"&&o&&(oe.preventDefault(),o())};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[s,o]);const Ut=y.useCallback(z=>{var Q;const oe=f.current!==null&&document.activeElement instanceof Node&&f.current.contains(document.activeElement);Yn(),i==null||i(z),oe&&((Q=d.current)==null||Q.focus({preventScroll:!0}))},[Yn,i]),J=be>0&&We.length>=be,st=()=>{!ee||Qe.length===0||Ut(gm(Ce.current.text,Ce.current.table,Qe))},lt=()=>{!ee||J||We.length===0||Ut(ok(Ce.current.text,Ce.current.table,We))},Jn=y.useCallback(z=>{if(!i)return!1;const{text:Q,table:pe}=Ce.current,ve=nt.current;if(z.rows.length>0){const ct=[...z.rows].map(ft=>ve[ft]).filter(ft=>ft!==void 0);if(ct.length>0)return Ut(gm(Q,pe,ct)),!1}if(z.columns.length>0){const ct=[...z.columns].filter(ft=>ft>=tr).map(ft=>Se.current[ft-tr]).filter(ft=>ft!==void 0&&ft>=0&&ft0&&ct.length0&&Ut(gm(Q,pe,Fe)),!1},[Ut,i]),Vr=y.useCallback(z=>{const oe=i;if(!oe)return!1;const{text:Q,table:pe}=Ce.current,ve=nt.current,gt=[...z].sort((ft,Kt)=>ft.location[1]-Kt.location[1]);let Fe=Q,ct=0;for(const{location:ft,value:Kt}of gt){const nn=ft[0]-tr,zn=nn>=0?Se.current[nn]:void 0,rn=ft[1];if(zn===void 0||zn<0||Kt.kind!==Ae.Text)continue;const xn=ve[rn],xr=xn===void 0?void 0:pe.rowSpans[xn];if(!xr)continue;const to=Fe.slice(xr.start+ct,xr.end+ct),Mi=mw(to,pe.delimiter);for(;Mi.length<=zn;)Mi.push("");const Ri=Kt.data??"";if(Mi[zn]===Ri)continue;Mi[zn]=Ri;const ar=qa(Mi,pe.delimiter);Fe=Fe.slice(0,xr.start+ct)+ar+Fe.slice(xr.end+ct),ct+=ar.length-(xr.end-xr.start)}return Fe!==Q&&oe(Fe),!0},[i]),rs=y.useCallback(z=>{var Fe;const[oe,Q]=z,pe=nt.current[Q];if(oe{const oe=[];for(let Q=z.y;Q{z[0]>=tr||bn(oe,z[1])},[bn]),ui=y.useMemo(()=>{const z={title:"#",id:"__gutter",width:ym,themeOverride:{baseFontStyle:`11px ${dk}`,textDark:"hsla(240, 3.8%, 46.1%, 0.4)"}},oe=Y.map(Q=>{const pe=ue.headers[Q]??"",ve=ee?pk(me[pe]):null;return{title:ve?`${pe.toUpperCase()} [${ve}]`:pe.toUpperCase(),id:`c${Q}`,width:ge,themeOverride:It[Q]?{baseFontStyle:`12px ${dk}`}:void 0}});return[z,...oe]},[ue.headers,Y,It,ge,ee,me]),Qs=y.useCallback((z,oe)=>{const{ctx:Q,columnIndex:pe,rect:ve,theme:gt,isSelected:Fe}=z;Q.save();try{if(Q.letterSpacing="0.5px",Fe&&(Q.fillStyle=gt.bgHeaderHovered,Q.fillRect(ve.x,ve.y,ve.width,ve.height),Q.fillStyle=gt.accentColor,Q.fillRect(ve.x,ve.y+ve.height-2,ve.width,2)),pe{const{ctx:Q,cell:pe,rect:ve,col:gt,theme:Fe}=z,ct=gt-tr;if(ct>=0&&dt&&pe.kind===Ae.Text){const ft=lV(pe.data,m);if(ft!==null){Q.save();try{const Kt=`${Fe.baseFontStyle} ${Fe.fontFamily}`;Q.font=Kt;let nn=ve.x+Fe.cellHorizontalPadding;const zn=ve.y+ve.height/2+Js(Q,Kt);for(const rn of ft){const xn=Q.measureText(rn.text).width;rn.hit&&xn>0&&(Q.fillStyle=ze,Q.fillRect(nn-1,zn-7,xn+2,14)),nn+=xn}}finally{Q.restore()}}}if(oe(),ct>=0&&pe.kind===Ae.Text&&pe.data===""){Q.save();try{Q.font=`${Fe.baseFontStyle} ${Fe.fontFamily}`,Q.fillStyle=Fe.textLight,Q.fillText("—",ve.x+Fe.cellHorizontalPadding,ve.y+ve.height/2+.5)}finally{Q.restore()}}},[dt,m,ze]),eo=y.useCallback(z=>{const oe=nt.current[z];return oe!==void 0&&P.current.has(oe)?{bgCell:Mt,bgCellMedium:Mt}:void 0},[Mt]);return be===0?E.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"No columns detected."}):E.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",ref:f,children:[E.jsxs("div",{"data-testid":`${n}-toolbar`,className:"flex flex-none flex-wrap items-center gap-1.5 border-b border-border bg-panel px-2 py-1",children:[E.jsxs("div",{className:"relative min-w-32 flex-1 sm:max-w-64",children:[E.jsx(TN,{"aria-hidden":"true",className:"pointer-events-none absolute left-1.5 top-1/2 size-3 -translate-y-1/2 text-muted-foreground/60"}),E.jsx("input",{type:"text","data-testid":`${n}-search`,"aria-label":"Search rows",value:g,onChange:z=>b(z.target.value),onKeyDown:z=>{z.key==="Escape"&&qn()},placeholder:"Search…",className:"h-6 w-full rounded-md border border-border bg-background pl-6 pr-6 text-xs text-foreground outline-none placeholder:text-muted-foreground/50 focus-visible:ring-3 focus-visible:ring-ring/50"}),g!==""&&E.jsx("button",{type:"button","data-testid":`${n}-clear-search`,"aria-label":"Clear search",onClick:qn,className:"absolute right-1 top-1/2 -translate-y-1/2 cursor-pointer rounded p-0.5 text-muted-foreground/60 outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:E.jsx(Ah,{"aria-hidden":"true",className:"size-3"})})]}),E.jsx("span",{"data-testid":`${n}-count`,role:"status",className:"rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium tabular-nums text-muted-foreground",children:dt?`${$e.length.toLocaleString()} of ${Yt.toLocaleString()}`:`${Yt.toLocaleString()} rows`}),ee&&er>0&&E.jsxs("button",{type:"button","data-testid":"input-table-column-types-reset",onClick:()=>Le({}),title:"Reset all pinned column types to Auto",className:ll,children:[`${er} ${er===1?"column type":"column types"} pinned`,E.jsx(Ah,{"aria-hidden":"true",className:"size-3 text-muted-foreground"})]}),E.jsxs("div",{ref:h,className:"relative",children:[E.jsxs("button",{type:"button","data-testid":`${n}-columns-button`,"aria-expanded":_,"aria-haspopup":"dialog","aria-label":"Columns",onClick:()=>re(z=>!z),className:Un(ll,Ke&&"border-foreground/30 bg-muted font-semibold"),children:[E.jsx(hN,{"aria-hidden":"true",className:"size-3"}),E.jsx("span",{children:Ke?`Columns (${Y.length}/${be})`:"Columns"})]}),_&&E.jsxs("div",{"data-testid":`${n}-columns-popout`,role:"dialog","aria-label":"Visible columns",className:"absolute left-0 top-7 z-30 min-w-44 max-w-64 rounded-md border border-border bg-panel p-1.5 shadow-md",children:[E.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 border-b border-border px-1.5 pb-1",children:[E.jsxs("span",{className:"text-[11px] font-semibold text-foreground",children:["Columns (",Y.length,"/",be,")"]}),Ke&&E.jsx("button",{type:"button","data-testid":`${n}-columns-reset`,onClick:rt,className:"cursor-pointer rounded px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground",children:"Show all"})]}),E.jsx("div",{className:"max-h-56 overflow-y-auto",children:ue.headers.map((z,oe)=>{const Q=!O.has(oe),pe=Q&&Y.length<=1,ve=z!==""?z:`Column ${oe+1}`;return E.jsxs("label",{className:Un("flex items-center gap-2 rounded px-1.5 py-1 text-xs",pe?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-muted"),children:[E.jsx("input",{type:"checkbox","data-testid":`${n}-column-toggle-${oe}`,checked:Q,disabled:pe,onChange:()=>ot(oe),className:"size-3.5 accent-foreground"}),E.jsx("span",{className:"truncate font-mono text-[11px] text-foreground",children:ve})]},oe)})})]})]}),an&&E.jsx("button",{type:"button","data-testid":`${n}-apply-view`,"aria-pressed":ie,onClick:()=>se(z=>!z),className:Un("inline-flex cursor-pointer items-center gap-1 rounded-md border px-2 py-0.5 text-[11px] font-medium transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50",ie?"border-foreground bg-foreground text-background hover:bg-foreground/90":"border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground"),children:"Apply view to output"}),Ft&&E.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[E.jsx("span",{"data-testid":`${n}-selected-count`,className:"text-[11px] font-medium tabular-nums text-muted-foreground",children:Qe.length>0?`${Qe.length.toLocaleString()} selected`:Lt>0?`${Lt.toLocaleString()} ${Lt===1?"column":"columns"} selected`:`${((Rt==null?void 0:Rt.cellCount)??0).toLocaleString()} cells selected`}),Rt!==null&&E.jsx("span",{"data-testid":`${n}-selection-stats`,className:"rounded-md bg-muted px-2 py-0.5 font-mono text-[11px] font-medium tabular-nums text-muted-foreground",children:iV(Rt)}),E.jsxs("button",{type:"button","data-testid":`${n}-copy`,onClick:Vt,className:ll,children:[E.jsx(Wv,{"aria-hidden":"true",className:"size-3"}),"Copy as CSV"]}),ee&&Qe.length>0&&E.jsxs("button",{type:"button","data-testid":`${n}-delete-rows`,onClick:st,title:`Deletes the ${Qe.length} selected ${Qe.length===1?"row":"rows"} from the source CSV`,className:ll,children:[E.jsx(Eh,{"aria-hidden":"true",className:"size-3"}),"Delete ",Qe.length.toLocaleString()," ",Qe.length===1?"row":"rows"]}),ee&&Lt>0&&E.jsxs(E.Fragment,{children:[E.jsx("span",{role:"group","aria-label":"Column type override","data-testid":"input-table-column-type-group",className:"inline-flex items-center gap-0.5 rounded-md border border-border bg-muted/60 p-0.5",children:rV.map(({mode:z,label:oe})=>{const Q=Zt===z;return E.jsx("button",{type:"button","data-testid":`input-table-column-type-${z}`,"aria-pressed":Q,onClick:()=>Tn(z),className:Q?"cursor-pointer rounded bg-background px-1.5 py-0.5 text-[11px] font-medium text-foreground shadow-2xs outline-none focus-visible:ring-3 focus-visible:ring-ring/50":"cursor-pointer rounded px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:oe},z)})}),E.jsxs("button",{type:"button","data-testid":`${n}-delete-columns`,onClick:lt,disabled:J,title:J?"At least one column must remain — the converter needs a column to detect":`Deletes the ${Lt} selected ${Lt===1?"column":"columns"} from the source CSV`,className:`${ll} disabled:cursor-not-allowed disabled:opacity-50`,children:[E.jsx(Eh,{"aria-hidden":"true",className:"size-3"}),"Delete ",Lt.toLocaleString()," ",Lt===1?"column":"columns"]})]}),E.jsx("button",{type:"button","data-testid":`${n}-clear-selection`,onClick:Yn,className:ll,children:"Clear"})]})]}),E.jsxs("div",{ref:d,"data-testid":n,role:"grid",tabIndex:-1,"aria-rowcount":$e.length+1,className:"relative min-h-0 flex-1 outline-none",style:{minHeight:mn},children:[E.jsx("div",{className:"absolute inset-0",children:E.jsx(K6,{imageWindowLoader:tt.current,renderers:M9,columns:ui,rows:$e.length,getCellContent:rs,getCellsForSelection:Wl,onCellsEdited:ee?Vr:void 0,onDelete:ee?Jn:void 0,onCellClicked:Vl,onHeaderClicked:Jt,onGridSelectionChange:Wr,onSelectionCleared:Ht,gridSelection:H,rangeSelect:"multi-rect",columnSelect:"multi",rowSelect:"multi",rowHeight:ck,headerHeight:mm,freezeColumns:tr,fillHandle:ee,onPaste:ee?()=>!0:!1,keybindings:{search:!1},theme:Ue,drawHeader:Qs,drawCell:Zs,getRowThemeOverride:eo,minColumnWidth:fk,smoothScrollX:!0,smoothScrollY:!0,verticalBorder:!1})}),T!==null&&E.jsx("input",{ref:D,type:"text","data-testid":"csv-header-rename-input","aria-label":`Rename column ${ue.headers[T.col]??""}`,value:M,onChange:z=>I(z.target.value),onBlur:jt,onKeyDown:z=>{z.key==="Enter"?(z.preventDefault(),z.stopPropagation(),jt()):z.key==="Escape"&&(z.preventDefault(),z.stopPropagation(),Hn())},style:{left:T.bounds.x,top:T.bounds.y,width:Math.max(60,T.bounds.width),height:T.bounds.height},className:"absolute z-20 border border-ring bg-background px-2 font-mono text-[11px] font-semibold tracking-wider text-foreground outline-none ring-2 ring-ring/50"}),dt&&$e.length===0&&E.jsxs("div",{"data-testid":`${n}-empty-filter`,className:"absolute inset-x-0 top-0 z-10 flex flex-col items-center gap-2 p-6 text-sm text-muted-foreground",children:[E.jsxs("span",{children:["No rows matching “",m,"”."]}),E.jsx("button",{type:"button",onClick:qn,className:ll,children:"Show all rows"})]}),ee&&!dt&&$e.length===0&&E.jsx("div",{"data-testid":`${n}-empty-rows`,className:"absolute inset-x-0 top-0 z-10 flex flex-col items-center gap-2 p-6 text-sm text-muted-foreground",children:E.jsx("span",{children:"No rows. Paste or upload data to start over."})})]})]})}function lV(t,e){if(e===""||t==="")return null;const n=e.toLowerCase();if(!t.toLowerCase().includes(n))return null;const r=[],i=t.toLowerCase();let s=0;for(;;){const o=i.indexOf(n,s);if(o===-1)break;o>s&&r.push({text:t.slice(s,o),hit:!1}),r.push({text:t.slice(o,o+n.length),hit:!0}),s=o+n.length}return s"u"?void 0:navigator),s=y.useRef(null);y.useEffect(()=>{var l;(l=s.current)==null||l.focus()},[]);const o=t==="CSV";return E.jsx("div",{"data-testid":"dropzone",className:"flex flex-1 flex-col items-center justify-center p-3 md:p-6 md:px-16",children:E.jsxs("div",{className:"flex w-full max-w-sm flex-col items-center gap-2.5 md:gap-3",children:[E.jsx("div",{"aria-hidden":"true",className:"flex size-9 items-center justify-center rounded-xl border border-border bg-muted/50 text-muted-foreground md:size-11",children:E.jsx(uN,{className:"size-4 md:size-5"})}),E.jsxs("p",{className:"text-sm font-medium text-foreground",children:["Paste ",o?"CSV or TSV":"JSON"," here"]}),E.jsx("textarea",{ref:s,"data-testid":"paste-field",rows:1,"aria-label":`Paste ${o?"CSV or TSV":"JSON"} data — or press ${i} to paste anywhere on this page`,placeholder:o?"Paste CSV or TSV text here":"Paste JSON here",spellCheck:!1,onChange:l=>{const a=l.currentTarget;a.rows=fV(a.value),e(a.value)},className:"min-h-11 w-full resize-none rounded-md border border-border bg-background px-3 py-2.5 font-mono text-[12.5px] leading-relaxed text-foreground transition-colors placeholder:text-muted-foreground focus:outline-none focus-visible:border-sky-600 dark:focus-visible:border-sky-400"}),E.jsxs("p",{className:"text-center text-[13px] leading-relaxed text-muted-foreground",children:["or drag & drop a file anywhere in this pane — you can also paste anywhere on the page (",E.jsx("kbd",{"data-testid":"paste-shortcut",className:"rounded border border-border bg-muted px-1.5 py-0.5 font-mono text-[11px] font-medium text-foreground",children:i}),")"]}),E.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[E.jsxs("button",{type:"button","data-testid":"choose-file",onClick:n,className:"inline-flex h-8 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-lg border border-border bg-background px-3 text-[13px] font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 [&_svg]:size-3.5",children:[E.jsx(AT,{"aria-hidden":"true"}),"Choose file"]}),E.jsxs("button",{type:"button","data-testid":"try-example",onClick:r,className:"inline-flex h-8 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-lg px-3 text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 [&_svg]:size-3.5",children:[E.jsx(AN,{"aria-hidden":"true"}),"Try an example"]})]})]})})}let ty=[],nA=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=nA[r])e=r+1;else return!0;if(e==n)return!1}}function mk(t){return t>=127462&&t<=127487}const yk=8205;function pV(t,e,n=!0,r=!0){return(n?rA:gV)(t,e,r)}function rA(t,e,n){if(e==t.length)return e;e&&iA(t.charCodeAt(e))&&sA(t.charCodeAt(e-1))&&e--;let r=vm(t,e);for(e+=vk(r);e=0&&mk(vm(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function gV(t,e,n){for(;e>1;){let r=rA(t,e-2,n);if(r=56320&&t<57344}function sA(t){return t>=55296&&t<56320}function vk(t){return t<65536?1:2}class _t{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=Ya(this,e,n);let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),gs.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=Ya(this,e,n);let r=[];return this.decompose(e,n,r,0),gs.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new vc(this),s=new vc(e);for(let o=n,l=n;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(l+=i.value.length,i.done||l>=r)return!0}}iter(e=1){return new vc(this,e)}iterRange(e,n=this.length){return new oA(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new lA(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?_t.empty:e.length<=32?new Ln(e):gs.from(Ln.split(e,[]))}}class Ln extends _t{constructor(e,n=mV(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.text[s],l=i+o.length;if((n?r:l)>=e)return new yV(i,l,r,o);i=l+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new Ln(wk(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),l=qd(s.text,o.text.slice(),0,s.length);if(l.length<=32)r.push(new Ln(l,o.length+s.length));else{let a=l.length>>1;r.push(new Ln(l.slice(0,a)),new Ln(l.slice(a)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof Ln))return super.replace(e,n,r);[e,n]=Ya(this,e,n);let i=qd(this.text,qd(r.text,wk(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new Ln(i,s):gs.from(Ln.split(i,[]),s)}sliceString(e,n=this.length,r=` +`){[e,n]=Ya(this,e,n);let i="";for(let s=0,o=0;s<=n&&oe&&o&&(i+=r),es&&(i+=l.slice(Math.max(0,e-s),n-s)),s=a+1}return i}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],i=-1;for(let s of e)r.push(s),i+=s.length+1,r.length==32&&(n.push(new Ln(r,i)),r=[],i=-1);return i>-1&&n.push(new Ln(r,i)),n}}class gs extends _t{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.children[s],l=i+o.length,a=r+o.lines-1;if((n?a:l)>=e)return o.lineInner(e,n,r,i);i=l+1,r=a+1}}decompose(e,n,r,i){for(let s=0,o=0;o<=n&&s=o){let u=i&((o<=e?1:0)|(a>=n?2:0));o>=e&&a<=n&&!u?r.push(l):l.decompose(e-o,n-o,r,u)}o=a+1}}replace(e,n,r){if([e,n]=Ya(this,e,n),r.lines=s&&n<=l){let a=o.replace(e-s,n-s,r),u=this.lines-o.lines+a.lines;if(a.lines>4&&a.lines>u>>6){let c=this.children.slice();return c[i]=a,new gs(c,this.length-(n-e)+r.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` +`){[e,n]=Ya(this,e,n);let i="";for(let s=0,o=0;se&&s&&(i+=r),eo&&(i+=l.sliceString(e-o,n-o,r)),o=a+1}return i}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof gs))return 0;let r=0,[i,s,o,l]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=n,s+=n){if(i==o||s==l)return r;let a=this.children[i],u=e.children[s];if(a!=u)return r+a.scanIdentical(u,n);r+=a.length+1}}static from(e,n=e.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let h of e)r+=h.lines;if(r<32){let h=[];for(let p of e)p.flatten(h);return new Ln(h,n)}let i=Math.max(32,r>>5),s=i<<1,o=i>>1,l=[],a=0,u=-1,c=[];function f(h){let p;if(h.lines>s&&h instanceof gs)for(let g of h.children)f(g);else h.lines>o&&(a>o||!a)?(d(),l.push(h)):h instanceof Ln&&a&&(p=c[c.length-1])instanceof Ln&&h.lines+p.lines<=32?(a+=h.lines,u+=h.length+1,c[c.length-1]=new Ln(p.text.concat(h.text),p.length+1+h.length)):(a+h.lines>i&&d(),a+=h.lines,u+=h.length+1,c.push(h))}function d(){a!=0&&(l.push(c.length==1?c[0]:gs.from(c,u)),u=-1,a=c.length=0)}for(let h of e)f(h);return d(),l.length==1?l[0]:new gs(l,n)}}_t.empty=new Ln([""],0);function mV(t){let e=-1;for(let n of t)e+=n.length+1;return e}function qd(t,e,n=0,r=1e9){for(let i=0,s=0,o=!0;s=n&&(a>r&&(l=l.slice(0,r-i)),i0?1:(e instanceof Ln?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,i=this.nodes[r],s=this.offsets[r],o=s>>1,l=i instanceof Ln?i.text.length:i.children.length;if(o==(n>0?l:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(i instanceof Ln){let a=i.text[o+(n<0?-1:0)];if(this.offsets[r]+=n,a.length>Math.max(0,e))return this.value=e==0?a:n>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=i.children[o+(n<0?-1:0)];e>a.length?(e-=a.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(a),this.offsets.push(n>0?1:(a instanceof Ln?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class oA{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new vc(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*n,this.value=i.length<=r?i:n<0?i.slice(i.length-r):i.slice(0,r),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class lA{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:i}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(_t.prototype[Symbol.iterator]=function(){return this.iter()},vc.prototype[Symbol.iterator]=oA.prototype[Symbol.iterator]=lA.prototype[Symbol.iterator]=function(){return this});class yV{constructor(e,n,r,i){this.from=e,this.to=n,this.number=r,this.text=i}get length(){return this.to-this.from}}function Ya(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function vr(t,e,n=!0,r=!0){return pV(t,e,n,r)}function vV(t){return t>=56320&&t<57344}function wV(t){return t>=55296&&t<56320}function bV(t,e){let n=t.charCodeAt(e);if(!wV(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return vV(r)?(n-55296<<10)+(r-56320)+65536:n}function xV(t){return t<65536?1:2}const ny=/\r\n?|\n/;var Dr=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(Dr||(Dr={}));class Es{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return s+(e-i);s+=l}else{if(r!=Dr.Simple&&u>=e&&(r==Dr.TrackDel&&ie||r==Dr.TrackBefore&&ie))return null;if(u>e||u==e&&n<0&&!l)return e==i||n<0?s:s+a;s+=a}i=u}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return s}touchesRange(e,n=e){for(let r=0,i=0;r=0&&i<=n&&l>=e)return in?"cover":!0;i=l}return!1}toString(){let e="";for(let n=0;n=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Es(e)}static create(e){return new Es(e)}}class Vn extends Es{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return ry(this,(n,r,i,s,o)=>e=e.replace(i,i+(r-n),o),!1),e}mapDesc(e,n=!1){return iy(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let i=0,s=0;i=0){n[i]=l,n[i+1]=o;let a=i>>1;for(;r.length0&&Ao(r,n,s.text),s.forward(c),l+=c}let u=e[o++];for(;l>1].toJSON()))}return e}static of(e,n,r){let i=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!i.length)return;od||f<0||d>n)throw new RangeError(`Invalid change range ${f} to ${d} (in doc of length ${n})`);let p=h?typeof h=="string"?_t.of(h.split(r||ny)):h:_t.empty,g=p.length;if(f==d&&g==0)return;fo&&mr(i,f-o,-1),mr(i,d-f,g),Ao(s,i,p),o=d}}return u(e),a(!l),l}static empty(e){return new Vn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let i=0;il&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;r.length=0&&n<=0&&n==t[i+1]?t[i]+=e:i>=0&&e==0&&t[i]==0?t[i+1]+=n:r?(t[i]+=e,t[i+1]+=n):t.push(e,n)}function Ao(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||o==t.sections.length||t.sections[o+1]<0);)l=t.sections[o++],a=t.sections[o++];e(i,u,s,c,f),i=u,s=c}}}function iy(t,e,n,r=!1){let i=[],s=r?[]:null,o=new Uc(t),l=new Uc(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let u=Math.min(o.len,l.len);mr(i,u,-1),o.forward(u),l.forward(u)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len=0&&a=0){let u=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);u+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.lena||o.ins>=0&&o.len>a)&&(l||r.length>u),s.forward2(a),o.forward(a)}}}}class Uc{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?_t.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?_t.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class ko{constructor(e,n,r,i){this.from=e,this.to=n,this.flags=r,this.goalColumn=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,i;return this.empty?r=i=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new ko(r,i,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return de.range(e,n,void 0,void 0,r);let i=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return de.range(this.anchor,i,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return de.range(e.anchor,e.head)}static create(e,n,r,i){return new ko(e,n,r,i)}}class de{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:de.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new de(e.ranges.map(n=>ko.fromJSON(n)),e.main)}static single(e,n=e){return new de([de.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;ii.from-s.from),n=e.indexOf(r);for(let i=1;is.head?de.range(a,l):de.range(l,a))}}return new de(e,n)}}function uA(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let yw=0;class He{constructor(e,n,r,i,s){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=yw++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new He(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:vw),!!e.static,e.enables)}of(e){return new Yd([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Yd(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Yd(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function vw(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Yd{constructor(e,n,r,i){this.dependencies=e,this.facet=n,this.type=r,this.value=i,this.id=yw++}dynamicSlot(e){var n;let r=this.value,i=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,u=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?u=!0:((n=e[f.id])!==null&&n!==void 0?n:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=r(f),1},update(f,d){if(a&&d.docChanged||u&&(d.docChanged||d.selection)||sy(f,c)){let h=r(f);if(l?!bk(h,f.values[o],i):!i(h,f.values[o]))return f.values[o]=h,1}return 0},reconfigure:(f,d)=>{let h,p=d.config.address[s];if(p!=null){let g=Wh(d,p);if(this.dependencies.every(b=>b instanceof He?d.facet(b)===f.facet(b):b instanceof Os?d.field(b,!1)==f.field(b,!1):!0)||(l?bk(h=r(f),g,i):i(h=r(f),g)))return f.values[o]=g,0}else h=r(f);return f.values[o]=h,1}}}get extension(){return this}}function bk(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[a.id]),i=n.map(a=>a.type),s=r.filter(a=>!(a&1)),o=t[e.id]>>1;function l(a){let u=[];for(let c=0;cr===i),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(fd).find(r=>r.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,i)=>{let s=r.values[n],o=this.updateF(s,i);return this.compareF(s,o)?0:(r.values[n]=o,1)},reconfigure:(r,i)=>{let s=r.facet(fd),o=i.facet(fd),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(r.values[n]=l.create(r),1):i.config.address[this.id]!=null?(r.values[n]=i.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,fd.of({field:this,create:e})]}get extension(){return this}}const ml={lowest:4,low:3,default:2,high:1,highest:0};function Hu(t){return e=>new cA(e,t)}const ww={highest:Hu(ml.highest),high:Hu(ml.high),default:Hu(ml.default),low:Hu(ml.low),lowest:Hu(ml.lowest)};class cA{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class Tl{of(e){return new oy(this,e)}reconfigure(e){return Tl.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class oy{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Hh{constructor(e,n,r,i,s,o){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=i,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let i=[],s=Object.create(null),o=new Map;for(let d of SV(e,n,o))d instanceof Os?i.push(d):(s[d.facet.id]||(s[d.facet.id]=[])).push(d);let l=Object.create(null),a=[],u=[];for(let d of i)l[d.id]=u.length<<1,u.push(h=>d.slot(h));let c=r==null?void 0:r.config.facets;for(let d in s){let h=s[d],p=h[0].facet,g=c&&c[d]||[];if(h.every(b=>b.type==0))if(l[p.id]=a.length<<1|1,vw(g,h))a.push(r.facet(p));else{let b=p.combine(h.map(m=>m.value));a.push(r&&p.compare(b,r.facet(p))?r.facet(p):b)}else{for(let b of h)b.type==0?(l[b.id]=a.length<<1|1,a.push(b.value)):(l[b.id]=u.length<<1,u.push(m=>b.dynamicSlot(m)));l[p.id]=u.length<<1,u.push(b=>kV(b,p,h))}}let f=u.map(d=>d(l));return new Hh(e,o,f,l,a,s)}}function SV(t,e,n){let r=[[],[],[],[],[]],i=new Map;function s(o,l){let a=i.get(o);if(a!=null){if(a<=l)return;let u=r[a].indexOf(o);u>-1&&r[a].splice(u,1),o instanceof oy&&n.delete(o.compartment)}if(i.set(o,l),Array.isArray(o))for(let u of o)s(u,l);else if(o instanceof oy){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;n.set(o.compartment,u),s(u,l)}else if(o instanceof cA)s(o.inner,o.prec);else if(o instanceof Os)r[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Yd)r[l].push(o),o.facet.extensions&&s(o.facet.extensions,ml.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(u==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(u,l)}}return s(t,ml.default),r.reduce((o,l)=>o.concat(l))}function wc(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let i=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|i}function Wh(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const fA=He.define(),ly=He.define({combine:t=>t.some(e=>e),static:!0}),dA=He.define({combine:t=>t.length?t[0]:void 0,static:!0}),hA=He.define(),pA=He.define(),gA=He.define(),mA=He.define({combine:t=>t.length?t[0]:!1});class qo{constructor(e,n){this.type=e,this.value=n}static define(){return new CV}}class CV{of(e){return new qo(this,e)}}class TV{constructor(e){this.map=e}of(e){return new on(this,e)}}class on{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new on(this.type,n)}is(e){return this.type==e}static define(e={}){return new TV(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let i of e){let s=i.map(n);s&&r.push(s)}return r}}on.reconfigure=on.define();on.appendConfig=on.define();class Gn{constructor(e,n,r,i,s,o){this.startState=e,this.changes=n,this.selection=r,this.effects=i,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,r&&uA(r,n.newLength),s.some(l=>l.type==Gn.time)||(this.annotations=s.concat(Gn.time.of(Date.now())))}static create(e,n,r,i,s,o){return new Gn(e,n,r,i,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(Gn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}Gn.time=qo.define();Gn.userEvent=qo.define();Gn.addToHistory=qo.define();Gn.remote=qo.define();function EV(t,e){let n=[];for(let r=0,i=0;;){let s,o;if(r=t[r]))s=t[r++],o=t[r++];else if(i=0;i--){let s=r[i](t);s instanceof Gn?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Gn?t=s[0]:t=vA(e,Da(s),!1)}return t}function MV(t){let e=t.startState,n=e.facet(gA),r=t;for(let i=n.length-1;i>=0;i--){let s=n[i](t);s&&Object.keys(s).length&&(r=yA(r,ay(e,s,t.changes.newLength),!0))}return r==t?t:Gn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const RV=[];function Da(t){return t==null?RV:Array.isArray(t)?t:[t]}var Hs=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Hs||(Hs={}));const OV=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let uy;try{uy=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function PV(t){if(uy)return uy.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||OV.test(n)))return!0}return!1}function IV(t){return e=>{if(!/\S/.test(e))return Hs.Space;if(PV(e))return Hs.Word;for(let n=0;n-1)return Hs.Word;return Hs.Other}}class zt{constructor(e,n,r,i,s,o){this.config=e,this.doc=n,this.selection=r,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;li.set(u,a)),n=null),i.set(l.value.compartment,l.value.extension)):l.is(on.reconfigure)?(n=null,r=l.value):l.is(on.appendConfig)&&(n=null,r=Da(r).concat(l.value));let s;n?s=e.startState.values.slice():(n=Hh.resolve(r,i,this),s=new zt(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(a,u)=>u.reconfigure(a,this),null).values);let o=e.startState.facet(ly)?e.newSelection:e.newSelection.asSingle();new zt(n,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:de.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),i=this.changes(r.changes),s=[r.range],o=Da(r.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return zt.create({doc:e.doc,selection:de.fromJSON(e.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(e={}){let n=Hh.resolve(e.extensions||[],new Map),r=e.doc instanceof _t?e.doc:_t.of((e.doc||"").split(n.staticFacet(zt.lineSeparator)||ny)),i=e.selection?e.selection instanceof de?e.selection:de.single(e.selection.anchor,e.selection.head):de.single(0);return uA(i,r.length),n.staticFacet(ly)||(i=i.asSingle()),new zt(n,r,i,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(zt.tabSize)}get lineBreak(){return this.facet(zt.lineSeparator)||` +`}get readOnly(){return this.facet(mA)}phrase(e,...n){for(let r of this.facet(zt.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,i)=>{if(i=="$")return"$";let s=+(i||1);return!s||s>n.length?r:n[s-1]})),e}languageDataAt(e,n,r=-1){let i=[];for(let s of this.facet(fA))for(let o of s(this,n,r))Object.prototype.hasOwnProperty.call(o,e)&&i.push(o[e]);return i}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return IV(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:i}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-r,l=e-r;for(;o>0;){let a=vr(n,o,!1);if(s(n.slice(a,o))!=Hs.Word)break;o=a}for(;lt.length?t[0]:4});zt.lineSeparator=dA;zt.readOnly=mA;zt.phrases=He.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(i=>t[i]==e[i])}});zt.languageData=fA;zt.changeFilter=hA;zt.transactionFilter=pA;zt.transactionExtender=gA;Tl.reconfigure=on.define();function wA(t,e,n={}){let r={};for(let i of t)for(let s of Object.keys(i)){let o=i[s],l=r[s];if(l===void 0)r[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(n,s))r[s]=n[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let i in e)r[i]===void 0&&(r[i]=e[i]);return r}class Nl{eq(e){return this==e}range(e,n=e){return cy.create(e,n,this)}}Nl.prototype.startSide=Nl.prototype.endSide=0;Nl.prototype.point=!1;Nl.prototype.mapMode=Dr.TrackDel;function bw(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let cy=class bA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new bA(e,n,r)}};function fy(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class xw{constructor(e,n,r,i){this.from=e,this.to=n,this.value=r,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,n,r,i=0){let s=r?this.to:this.from;for(let o=i,l=s.length;;){if(o==l)return o;let a=o+l>>1,u=s[a]-e||(r?this.value[a].endSide:this.value[a].startSide)-n;if(a==o)return u>=0?o:l;u>=0?l=a:o=a+1}}between(e,n,r,i){for(let s=this.findIndex(n,-1e9,!0),o=this.findIndex(r,1e9,!1,s);sh||d==h&&u.startSide>0&&u.endSide<=0)continue;(h-d||u.endSide-u.startSide)<0||(o<0&&(o=d),u.point&&(l=Math.max(l,h-d)),r.push(u),i.push(d-o),s.push(h-o))}return{mapped:r.length?new xw(i,s,r,l):null,pos:o}}}class Gt{constructor(e,n,r,i){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=i}static create(e,n,r,i){return new Gt(e,n,r,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:s=this.length}=e,o=e.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(fy)),this.isEmpty)return n.length?Gt.of(n):this;let l=new xA(this,null,-1).goto(0),a=0,u=[],c=new Ja;for(;l.value||a=0){let f=n[a++];c.addInner(f.from,f.to,f.value)||u.push(f)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||sl.to||s=s&&e<=s+o.length&&o.between(s,e-s,n-s,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return Kc.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return Kc.from(e).goto(n)}static compare(e,n,r,i,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=n.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=xk(o,l,r),u=new Wu(o,a,s),c=new Wu(l,a,s);r.iterGaps((f,d,h)=>kk(u,f,c,d,h,i)),r.empty&&r.length==0&&kk(u,0,c,0,0,i)}static eq(e,n,r=0,i){i==null&&(i=999999999);let s=e.filter(c=>!c.isEmpty&&n.indexOf(c)<0),o=n.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=xk(s,o),a=new Wu(s,l,0).goto(r),u=new Wu(o,l,0).goto(r);for(;;){if(a.to!=u.to||!dy(a.active,u.active)||a.point&&(!u.point||!bw(a.point,u.point)))return!1;if(a.to>i)return!0;a.next(),u.next()}}static spans(e,n,r,i,s=-1){let o=new Wu(e,null,s).goto(n),l=n,a=o.openStart;for(;;){let u=Math.min(o.to,r);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFroml&&(i.span(l,u,o.active,a),a=o.openEnd(u));if(o.to>r)return a+(o.point&&o.to>r?1:0);l=o.to,o.next()}}static of(e,n=!1){let r=new Ja;for(let i of e instanceof cy?[e]:n?NV(e):e)r.add(i.from,i.to,i.value);return r.finish()}static join(e){if(!e.length)return Gt.empty;let n=e[e.length-1];for(let r=e.length-2;r>=0;r--)for(let i=e[r];i!=Gt.empty;i=i.nextLayer)n=new Gt(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}}Gt.empty=new Gt([],[],null,-1);function NV(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(fy);e=r}return t}Gt.empty.nextLayer=Gt.empty;class Ja{finishChunk(e){this.chunks.push(new xw(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,n,r){this.addInner(e,n,r)||(this.nextLayer||(this.nextLayer=new Ja)).add(e,n,r)}addInner(e,n,r){let i=e-this.lastTo||r.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return i<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(Gt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=Gt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function xk(t,e,n){let r=new Map;for(let s of t)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&i.push(new xA(o,n,r,s));return i.length==1?i[0]:new Kc(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)wm(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)wm(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),wm(this.heap,0)}}}function wm(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let i=t[r];if(r+1=0&&(i=t[r+1],r++),n.compare(i)<0)break;t[r]=n,t[e]=i,e=r}}class Wu{constructor(e,n,r){this.minPoint=r,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Kc.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){dd(this.active,e),dd(this.activeTo,e),dd(this.activeRank,e),this.minActive=Sk(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:i,rank:s}=this.cursor;for(;n0;)n++;hd(this.active,n,r),hd(this.activeTo,n,i),hd(this.activeRank,n,s),e&&hd(e,n,this.cursor.from),this.minActive=Sk(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)<0){if(this.activeTo[i]>e){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),r&&dd(r,i)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[i]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function kk(t,e,n,r,i,s){t.goto(e),n.goto(r);let o=r+i,l=r,a=r-e,u=!!s.boundChange;for(let c=!1;;){let f=t.to+a-n.to,d=f||t.endSide-n.endSide,h=d<0?t.to+a:n.to,p=Math.min(h,o);if(t.point||n.point?(t.point&&n.point&&bw(t.point,n.point)&&dy(t.activeForPoint(t.to),n.activeForPoint(n.to))||s.comparePoint(l,p,t.point,n.point),c=!1):(c&&s.boundChange(l),p>l&&!dy(t.active,n.active)&&s.compareRange(l,p,t.active,n.active),u&&po)break;l=h,d<=0&&t.next(),d>=0&&n.next()}}function dy(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Sk(t,e){let n=-1,r=1e9;for(let i=0;i=e)return i;if(i==t.length)break;s+=t.charCodeAt(i)==9?n-s%n:1,i=vr(t,i)}return t.length}const hy="ͼ",Ck=typeof Symbol>"u"?"__"+hy:Symbol.for(hy),py=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Tk=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class jo{constructor(e,n){this.rules=[];let{finish:r}=n||{};function i(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,u){let c=[],f=/^@(\w+)\b/.exec(o[0]),d=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let h in l){let p=l[h];if(/&/.test(h))s(h.split(/,\s*/).map(g=>o.map(b=>g.replace(/&/,b))).reduce((g,b)=>g.concat(b)),p,a);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+h+") should be a primitive value.");s(i(h),p,c,d)}else p!=null&&c.push(h.replace(/_.*/,"").replace(/[A-Z]/g,g=>"-"+g.toLowerCase())+": "+p+";")}(c.length||d)&&a.push((r&&!f&&!u?o.map(r):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(i(o),e[o],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=Tk[Ck]||1;return Tk[Ck]=e+1,hy+e.toString(36)}static mount(e,n,r){let i=e[py],s=r&&r.nonce;i?s&&i.setNonce(s):i=new DV(e,s),i.mount(Array.isArray(n)?n:[n],e)}}let Ek=new Map;class DV{constructor(e,n){let r=e.ownerDocument||e,i=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let s=Ek.get(r);if(s)return e[py]=s;this.sheet=new i.CSSStyleSheet,Ek.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[py]=this}mount(e,n){let r=this.sheet,i=0,s=0;for(let o=0;o-1&&(this.modules.splice(a,1),s--,a=-1),a==-1){if(this.modules.splice(s++,0,l),r)for(let u=0;u",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},LV=typeof navigator<"u"&&/Mac/.test(navigator.platform),$V=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var sr=0;sr<10;sr++)Ho[48+sr]=Ho[96+sr]=String(sr);for(var sr=1;sr<=24;sr++)Ho[sr+111]="F"+sr;for(var sr=65;sr<=90;sr++)Ho[sr]=String.fromCharCode(sr+32),Xc[sr]=String.fromCharCode(sr);for(var bm in Ho)Xc.hasOwnProperty(bm)||(Xc[bm]=Ho[bm]);function FV(t){var e=LV&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||$V&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Xc:Ho)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}function ms(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,n=arguments[1];if(n&&typeof n=="object"&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i=="string"?t.setAttribute(r,i):i!=null&&(t[r]=i)}e++}for(;e2);var Oe={mac:Rk||/Mac/.test(Er.platform),windows:/Win/.test(Er.platform),linux:/Linux|X11/.test(Er.platform),ie:Hp,ie_version:SA?gy.documentMode||6:yy?+yy[1]:my?+my[1]:0,gecko:Ak,gecko_version:Ak?+(/Firefox\/(\d+)/.exec(Er.userAgent)||[0,0])[1]:0,chrome:!!xm,chrome_version:xm?+xm[1]:0,ios:Rk,android:/Android\b/.test(Er.userAgent),webkit:Mk,webkit_version:Mk?+(/\bAppleWebKit\/(\d+)/.exec(Er.userAgent)||[0,0])[1]:0,safari:vy,safari_version:vy?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Er.userAgent)||[0,0])[1]:0,tabSize:gy.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function kw(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const Vh=Object.create(null);function Sw(t,e,n){if(t==e)return!0;t||(t=Vh),e||(e=Vh);let r=Object.keys(t),i=Object.keys(e);if(r.length-0!=i.length-0)return!1;for(let s of r)if(s!=n&&(i.indexOf(s)==-1||t[s]!==e[s]))return!1;return!0}function zV(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function Ok(t,e,n){let r=!1;if(e)for(let i in e)n&&i in n||(r=!0,i=="style"?t.style.cssText="":t.removeAttribute(i));if(n)for(let i in n)e&&e[i]==n[i]||(r=!0,i=="style"?t.style.cssText=n[i]:t.setAttribute(i,n[i]));return r}function BV(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new _l(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,i;if(e.isBlockGap)r=-5e8,i=4e8;else{let{start:s,end:o}=CA(e,n);r=(s?n?-3e8:-1:5e8)-1,i=(o?n?2e8:1:-6e8)+1}return new _l(e,r,i,n,e.widget||null,!0)}static line(e){return new vf(e)}static set(e,n=!1){return Gt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}en.none=Gt.empty;class yf extends en{constructor(e){let{start:n,end:r}=CA(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?kw(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Vh}eq(e){return this==e||e instanceof yf&&this.tagName==e.tagName&&Sw(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}yf.prototype.point=!1;class vf extends en{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof vf&&this.spec.class==e.spec.class&&Sw(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}vf.prototype.mapMode=Dr.TrackBefore;vf.prototype.point=!0;class _l extends en{constructor(e,n,r,i,s,o){super(n,r,s,e),this.block=i,this.isReplace=o,this.mapMode=i?n<=0?Dr.TrackBefore:Dr.TrackAfter:Dr.TrackDel}get type(){return this.startSide!=this.endSide?ki.WidgetRange:this.startSide<=0?ki.WidgetBefore:ki.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof _l&&jV(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}_l.prototype.point=!0;function CA(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function jV(t,e){return t==e||!!(t&&e&&t.compare(e))}function La(t,e,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=t?n[i]=Math.max(n[i],e):n.push(t,e)}class Gc extends Nl{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Gc&&this.tagName==e.tagName&&Sw(this.attributes,e.attributes)}static create(e){return new Gc(e.tagName,e.attributes||Vh,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return Gt.of(e,n)}}Gc.prototype.startSide=Gc.prototype.endSide=-1;function qc(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function wy(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function bc(t,e){if(!e.anchorNode)return!1;try{return wy(t,e.anchorNode)}catch{return!1}}function xc(t){return t.nodeType==3?Jc(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function kc(t,e,n,r){return n?Pk(t,e,n,r,-1)||Pk(t,e,n,r,1):!1}function Wo(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function Uh(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function Pk(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:qs(t))){if(t.nodeName=="DIV")return!1;let s=t.parentNode;if(!s||s.nodeType!=1)return!1;e=Wo(t)+(i<0?0:1),t=s}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=i<0?qs(t):0}else return!1}}function qs(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Yc(t,e){let{left:n,right:r}=t;if(n==r)return t;let i=e?n:r;return{left:i,right:i,top:t.top,bottom:t.bottom}}function HV(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function TA(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function WV(t,e,n,r,i,s,o,l){let a=t.ownerDocument,u=a.defaultView||window;for(let c=t,f=!1;c&&!f;)if(c.nodeType==1){let d,h=c==a.body,p=1,g=1;if(h)d=HV(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let v=c.getBoundingClientRect();({scaleX:p,scaleY:g}=TA(c,v)),d={left:v.left,right:v.left+c.clientWidth*p,top:v.top,bottom:v.top+c.clientHeight*g}}let b=0,m=0;if(i=="nearest")e.top0&&e.bottom>d.bottom+m&&(m=e.bottom-d.bottom+o)):e.bottom>d.bottom-o&&(m=e.bottom-d.bottom+o,n<0&&e.top-m0&&e.right>d.right+b&&(b=e.right-d.right+s)):e.right>d.right-s&&(b=e.right-d.right+s,n<0&&e.leftd.bottom||e.leftd.right)&&(e={left:Math.max(e.left,d.left),right:Math.min(e.right,d.right),top:Math.max(e.top,d.top),bottom:Math.min(e.bottom,d.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function EA(t,e=!0){let n=t.ownerDocument,r=null,i=null;for(let s=t.parentNode;s&&!(s==n.body||(!e||r)&&i);)if(s.nodeType==1)!i&&s.scrollHeight>s.clientHeight&&(i=s),e&&!r&&s.scrollWidth>s.clientWidth&&(r=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:r,y:i}}class VV{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?qs(n):0),r,Math.min(e.focusOffset,r?qs(r):0))}set(e,n,r,i){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=i}}function AA(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function MA(t,e=!0){for(let{node:n,left:r,top:i}of t)e&&n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}let hl=null;Oe.safari&&Oe.safari_version>=26&&(hl=!1);function RA(t){if(t.setActive)return t.setActive();if(hl)return t.focus(hl);let e=AA(t);t.focus(hl==null?{get preventScroll(){return hl={preventScroll:!0},!0}}:void 0),hl||(hl=!1,MA(e))}let Ik;function Jc(t,e,n=e){let r=Ik||(Ik=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function $a(t,e,n,r){let i={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let s=new KeyboardEvent("keydown",i);s.synthetic=!0,t.dispatchEvent(s);let o=new KeyboardEvent("keyup",i);return o.synthetic=!0,t.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function UV(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function KV(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,qs(n));;)if(r){if(n.nodeType!=1)return!1;let i=n.childNodes[r-1];i.contentEditable=="false"?r--:(n=i,r=qs(n))}else{if(n==t)return!0;r=Wo(n),n=n.parentNode}}function OA(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function PA(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=qs(n)}else if(n.parentNode&&!Uh(n))r=Wo(n),n=n.parentNode;else return null}}function IA(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(l.level==r)return o;(s<0||(i!=0?i<0?l.fromn:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function DA(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;g-=3)if(us[g+1]==-h){let b=us[g+2],m=b&2?i:b&4?b&1?s:i:0;m&&(sn[f]=sn[us[g]]=m),l=g;break}}else{if(us.length==189)break;us[l++]=f,us[l++]=d,us[l++]=a}else if((p=sn[f])==2||p==1){let g=p==i;a=g?0:1;for(let b=l-3;b>=0;b-=3){let m=us[b+2];if(m&2)break;if(g)us[b+2]|=2;else{if(m&4)break;us[b+2]|=4}}}}}function QV(t,e,n,r){for(let i=0,s=r;i<=n.length;i++){let o=i?n[i-1].to:t,l=ia;)p==b&&(p=n[--g].from,b=g?n[g-1].to:t),sn[--p]=h;a=c}else s=u,a++}}}function xy(t,e,n,r,i,s,o){let l=r%2?2:1;if(r%2==i%2)for(let a=e,u=0;aa&&o.push(new bs(a,g.from,h));let b=g.direction==Dl!=!(h%2);ky(t,b?r+1:r,i,g.inner,g.from,g.to,o),a=g.to}p=g.to}else{if(p==n||(c?sn[p]!=l:sn[p]==l))break;p++}d?xy(t,a,p,r+1,i,d,o):ae;){let c=!0,f=!1;if(!u||a>s[u-1].to){let g=sn[a-1];g!=l&&(c=!1,f=g==16)}let d=!c&&l==1?[]:null,h=c?r:r+1,p=a;e:for(;;)if(u&&p==s[u-1].to){if(f)break e;let g=s[--u];if(!c)for(let b=g.from,m=u;;){if(b==e)break e;if(m&&s[m-1].to==b)b=s[--m].from;else{if(sn[b-1]==l)break e;break}}if(d)d.push(g);else{g.tosn.length;)sn[sn.length]=256;let r=[],i=e==Dl?0:1;return ky(t,i,i,n,0,t.length,r),r}function LA(t){return[new bs(0,t,0)]}let $A="";function eU(t,e,n,r,i){var s;let o=r.head-t.from,l=bs.find(e,o,(s=r.bidiLevel)!==null&&s!==void 0?s:-1,r.assoc),a=e[l],u=a.side(i,n);if(o==u){let d=l+=i?1:-1;if(d<0||d>=e.length)return null;a=e[l=d],o=a.side(!i,n),u=a.side(i,n)}let c=vr(t.text,o,a.forward(i,n));(ca.to)&&(c=u),$A=t.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(i?e.length-1:0)?null:e[l+(i?1:-1)];return f&&c==u&&f.level+(i?0:1)t.some(e=>e)}),nU=He.define({combine:t=>t.some(e=>e)}),UA=He.define();class Fa{constructor(e,n,r,i,s,o=!1){this.range=e,this.y=n,this.x=r,this.yMargin=i,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new Fa(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Fa(de.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const pd=on.define({map:(t,e)=>t.map(e)}),KA=on.define();function vi(t,e,n){let r=t.facet(jA);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const zs=He.define({combine:t=>t.length?t[0]:!0});let rU=0;const Ca=He.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let a=[];return o&&a.push(Wp.of(u=>{let c=u.plugin(l);return c?o(c):en.none})),s&&a.push(s(l)),a})}static fromClass(e,n){return Ei.define((r,i)=>new e(r,i),n)}}class km{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(vi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){vi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){vi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const XA=He.define(),Aw=He.define(),Wp=He.define(),GA=He.define(),Mw=He.define(),wf=He.define(),qA=He.define();function Nk(t,e){let n=t.state.facet(qA);if(!n.length)return n;let r=n.map(s=>s instanceof Function?s(t):s),i=[];return Gt.spans(r,e.from,e.to,{point(){},span(s,o,l,a){let u=s-e.from,c=o-e.from,f=i;for(let d=l.length-1;d>=0;d--,a--){let h=l[d].spec.bidiIsolate,p;if(h==null&&(h=tU(e.text,u,c)),a>0&&f.length&&(p=f[f.length-1]).to==u&&p.direction==h)p.to=c,f=p.inner;else{let g={from:u,to:c,direction:h,inner:[]};f.push(g),f=g.inner}}}}),i}const YA=He.define();function Rw(t){let e=0,n=0,r=0,i=0;for(let s of t.state.facet(YA)){let o=s(t);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:e,right:n,top:r,bottom:i}}const tc=He.define();class wi{constructor(e,n,r,i){this.fromA=e,this.toA=n,this.fromB=r,this.toB=i}join(e){return new wi(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let i=e[n-1];if(!(i.fromA>r.toA)){if(i.toAi.push(new wi(s,o,l,a))),this.changedRanges=i}static create(e,n,r){return new Kh(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const iU=[];class On{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return iU}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&zV(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;for(let i of this.children){if(i==e)return r;r+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Wo(this.dom),i=this.length?e>0:n>0;return new Ki(this.parent.dom,r+(i?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Up)return e;return null}static get(e){return e.cmTile}}class Vp extends On{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,i,s=(e==null?void 0:e.node)==n?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,i=r?r.nextSibling:n.firstChild,s&&i!=l.dom&&(s.written=!0),l.dom.parentNode==n)for(;i&&i!=l.dom;)i=_k(i);else n.insertBefore(l.dom,i);r=l.dom}for(i=r?r.nextSibling:n.firstChild,s&&i&&(s.written=!0);i;)i=_k(i);this.length=o}}function _k(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Up extends Vp{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=On.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,i=0,s=0;;)if(i==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&s++,i=n.pop()}else{let o=r.children[i++];if(o instanceof Vs)n.push(i),r=o,i=0;else{let l=s+o.length,a=e(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(e,n){let r,i=-1,s,o=-1;if(this.blockTiles((l,a)=>{let u=a+l.length;if(e>=a&&e<=u){if(l.isWidget()&&n>=-1&&n<=1){if(l.flags&32)return!0;l.flags&16&&(r=void 0)}(ae||e==a&&(n>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-a)}}),!r&&!s)throw new Error("No tile at position "+e);return r&&n<0||!s?{tile:r,offset:i}:{tile:s,offset:o}}}class Vs extends Vp{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new Vs(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class Qa extends Vp{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let i=new Qa(n||document.createElement("div"),e);return(!n||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,n,r){let i=null,s=-1,o=null,l=-1;function a(c,f){for(let d=0,h=0;d=f&&(p.isComposite()?a(p,f-h):(!o||o.isHidden&&(n>0&&!(o.flags&32)||r&&oU(o,p)))&&(g>f||p.flags&32&&n<=1)?(o=p,l=f-h):(h=-1)&&(i=p,s=f-h)),h=g}}a(this,e);let u=(n<0?i:o)||i||o;return u?{tile:u,offset:u==i?s:l}:null}coordsIn(e,n,r){let i=this.resolveInline(e,n,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),n,r):sU(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:i,offset:s}=r;if(this.dom.contains(i.dom))return i.isText()?new Ki(i.dom,Math.min(i.dom.nodeValue.length,s)):i.domPosFor(s,i.flags&16?1:i.flags&32?-1:n);let o=r.tile.parent,l=!1;for(let a of o.children){if(l)return new Ki(a.dom,0);a==r.tile&&(l=!0)}}return new Ki(this.dom,0)}}function sU(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=xc(e);return n[n.length-1]||null}function oU(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.topi&&(e=i);let s=e,o=e,l=0;e==0&&n<0||e==i&&n>=0?Oe.chrome||Oe.gecko||(e?(s--,l=1):o=0)?0:a.length-1];return Oe.safari&&!l&&u.width==0&&(u=Array.prototype.find.call(a,c=>c.width)||u),r==null?u:Yc(u,(l?l>0:n<0)==r)}static of(e,n){let r=new xl(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Ll extends On{constructor(e,n,r,i){super(e,n,i),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let i=this.widget.coordsAt(this.dom,e,n);if(i)return i;if(r)return Yc(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?s.length-1:0;o=s[a],!(e>0?a==0:a==s.length-1||o.top0==r)}}class lU{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:i,index:s,beforeBreak:o,parents:l}=this;for(;e||n>0;)if(i.isComposite())if(o){if(!e)break;r&&r.break(),e--,o=!1}else if(s==i.children.length){if(!e&&!l.length)break;r&&r.leave(i),o=!!i.breakAfter,{tile:i,index:s}=l.pop(),s++}else{let a=i.children[s],u=a.breakAfter;(n>0?a.length<=e:a.length=0;l--){let a=n.marks[l],u=i.lastChild;if(u instanceof Lr&&u.mark.eq(a.mark))u.dom!=a.dom&&u.setDOM(Sm(a.dom)),i=u;else{if(this.cache.reused.get(a)){let f=On.get(a.dom);f&&f.setDOM(Sm(a.dom))}let c=Lr.of(a.mark,a.dom);i.append(c),i=c}this.cache.reused.set(a,2)}let s=On.get(e.text);s&&this.cache.reused.set(s,2);let o=new xl(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,i.append(o)}addInlineWidget(e,n,r){let i=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);i||this.flushBuffer();let s=this.ensureMarks(n,r);!i&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=JA);let i=Qa.start(e,n||((r=this.cache.find(Qa))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=i)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let i=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(n>0&&(l=i.lastChild)&&l instanceof Lr&&l.mark.eq(o))i=l,n--;else{let a=Lr.of(o,(r=this.cache.find(Lr,u=>u.mark.eq(o)))===null||r===void 0?void 0:r.dom);i.append(a),i=a,n=0}}return i}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Dk(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Dk(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Cm,0,32)||new Ll(Cm.toDOM(),0,Cm,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,r=new aU(e.from,e.to,e.value,n),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-r.rank||this.wrappers[i-1].to-r.to)<0;)i--;this.wrappers.splice(i,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let i=n.lastChild;if(r.fromo.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(s),n=s}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(Xh,void 0,1);return r&&(r.flags=n),r||new Xh(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class cU{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:i,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=i;let l=this.textOff=Math.min(e,i.length);return s?null:i.slice(0,l)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const Gh=[Ll,Qa,xl,Lr,Xh,Vs,Up];for(let t=0;t[]),this.index=Gh.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let i=e.bucket,s=this.buckets[i],o=this.index[i];for(let l=0;l{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let i=0,s=0,o=0;;){let l=oi){let u=a-i;this.preserve(u,!o,!l),i=a,s+=u}if(!l)break;n&&l.fromA<=n.range.fromA&&l.toA>=n.range.toA?(this.forward(l.fromA,n.range.fromA,n.range.fromA{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let u=a>0||l{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof Lr&&i.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?i.length&&(i.length=s=0):o instanceof Lr&&(i.shift(),s=Math.min(s,i.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,i=this.builder,s=-1,o=Gt.spans(this.decorations,e,n,{point:(l,a,u,c,f,d)=>{if(u instanceof _l){if(this.disallowBlockEffectsFor[d]){if(u.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=c.length,f>c.length)i.continueWidget(a-l);else{let h=u.widget||(u.block?Za.block:Za.inline),p=hU(u),g=this.cache.findWidget(h,a-l,p)||Ll.of(h,this.view,a-l,p);u.block?(u.startSide>0&&i.addLineStartIfNotCovered(r),i.addBlockWidget(g)):(i.ensureLine(r),i.addInlineWidget(g,c,f))}r=null}else r=pU(r,u);a>l&&this.text.skip(a-l)},span:(l,a,u,c)=>{for(let f=l;f-1&&(this.openWidget=o>s),this.openWidget||i.addLineStartIfNotCovered(r),this.openMarks=o}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let i=e.parentNode;;i=i.parentNode){let s=On.get(i);if(i==this.view.contentDOM)break;s instanceof Lr?n.push(s):s!=null&&s.isLine()?r=s:s instanceof Vs||(i.nodeName=="DIV"&&!r&&i!=this.view.contentDOM?r=new Qa(i,JA):r||n.push(Lr.of(new yf({tagName:i.nodeName.toLowerCase(),attributes:BV(i)}),i)))}return{line:r,marks:n}}}function Dk(t,e){let n=r=>{for(let i of r.children)if((e?i.isText():i.length)||n(i))return!0;return!1};return n(t)}function hU(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const JA={class:"cm-line"};function pU(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&kw(n,t),r&&(t.class+=" "+r)),t}function gU(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Lr&&e.push(r.mark)}return e}function Sm(t){let e=On.get(t);return e&&e.setDOM(t.cloneNode()),t}class Za extends gu{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Za.inline=new Za("span");Za.block=new Za("div");const Cm=new class extends gu{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Lk{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=en.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Up(e,e.contentDOM),this.updateInner([new wi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:c,toA:f})=>fthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let i=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?i=this.domChanged.newSel.head:!CU(e.changes,this.hasComposition)&&!e.selectionSet&&(i=e.state.selection.main.head));let s=i>-1?yU(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:f}=this.hasComposition;r=new wi(c,f,e.changes.mapPos(c,-1),e.changes.mapPos(f,1)).addToSet(r.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Oe.ie||Oe.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=bU(o,this.decorations,e.changes);a.length&&(r=wi.extendWithRanges(r,a));let u=kU(l,this.blockWrappers,e.changes);return u.length&&(r=wi.extendWithRanges(r,u)),s&&!r.some(c=>c.fromA<=s.range.fromA&&c.toA>=s.range.toA)&&(r=s.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let o=this.tile,l=new dU(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&On.get(n.text)&&l.cache.reused.set(On.get(n.text),2),this.tile=l.run(e,n),Cy(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||r.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let i=[];if(this.view.viewport.from||this.view.viewport.to-1)&&bc(r,this.view.observer.selectionRange)&&!(i&&r.contains(i));if(!(s||n||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,u,c;if(a.empty?c=u=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),u=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),Oe.gecko&&a.empty&&!this.hasComposition&&mU(u)){let d=document.createTextNode("");this.view.observer.ignore(()=>u.node.insertBefore(d,u.node.childNodes[u.offset]||null)),u=c=new Ki(d,0),l=!0}let f=this.view.observer.selectionRange;(l||!f.focusNode||(!kc(u.node,u.offset,f.anchorNode,f.anchorOffset)||!kc(c.node,c.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(f.focusNode)&&SU(f.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let d=qc(this.view.root);if(d)if(a.empty){if(Oe.gecko){let h=vU(u.node,u.offset);if(h&&h!=3){let p=(h==1?PA:IA)(u.node,u.offset);p&&(u=new Ki(p.node,p.offset))}}d.collapse(u.node,u.offset),a.bidiLevel!=null&&d.caretBidiLevel!==void 0&&(d.caretBidiLevel=a.bidiLevel)}else if(d.extend){d.collapse(u.node,u.offset);try{d.extend(c.node,c.offset)}catch{}}else{let h=document.createRange();a.anchor>a.head&&([u,c]=[c,u]),h.setEnd(c.node,c.offset),h.setStart(u.node,u.offset),d.removeAllRanges(),d.addRange(h)}o&&this.view.root.activeElement==r&&(r.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(u,c)),this.impreciseAnchor=u.precise?null:new Ki(f.anchorNode,f.anchorOffset),this.impreciseHead=c.precise?null:new Ki(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&kc(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=qc(e.root),{anchorNode:i,anchorOffset:s}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let o=this.lineAt(n.head,n.assoc);if(!o)return;let l=o.posAtStart;if(n.head==l||n.head==l+o.length)return;let a=this.coordsAt(n.head,-1),u=this.coordsAt(n.head,1);if(!a||!u||a.bottom>u.top)return;let c=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(c.node,c.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=n.from&&r.collapse(i,s)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let i=r.posAtStart;if(r.isComposite()){let s;if(e==r.dom)s=r.dom.childNodes[n];else{let o=qs(e)==0?0:n==0?-1:1;for(;;){let l=e.parentNode;if(l==r.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==r.dom.firstChild)return i;for(;s&&!On.get(s);)s=s.nextSibling;if(!s)return i+r.length;for(let o=0,l=i;;o++){let a=r.children[o];if(a.dom==s)return l;l+=a.length+a.breakAfter}}else return r.isText()?e==r.dom?i+n:i+(n?r.length:0):i}domAtPos(e,n){let{tile:r,offset:i}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(i,n):r.domIn(i,n)}inlineDOMNearPos(e,n){let r,i=-1,s=!1,o,l=-1,a=!1;return this.tile.blockTiles((u,c)=>{if(u.isWidget()){if(u.flags&32&&c>=e)return!0;u.flags&16&&(s=!0)}else{let f=c+u.length;if(c<=e&&(r=u,i=e-c,s=f=e&&!o&&(o=u,l=e-c,a=c>e),c>e&&o)return!0}}),!r&&!o?this.domAtPos(e,n):(s&&o?r=null:a&&r&&(o=null),r&&n<0||!o?r.domIn(i,n):o.domIn(l,n))}coordsAt(e,n,r){let{tile:i,offset:s}=this.tile.resolveBlock(e,n);return i.isWidget()?i.widget instanceof Tm?null:i.coordsInWidget(s,n,!0):i.coordsIn(s,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function i(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let a=i(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(s.isText()&&oMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==Rn.LTR,u=0,c=(f,d,h)=>{for(let p=0;pi);p++){let g=f.children[p],b=d+g.length,m=g.dom.getBoundingClientRect(),{height:v}=m;if(h&&!p&&(u+=m.top-h.top),g instanceof Vs)b>r&&c(g,d,m);else if(d>=r&&(u>0&&n.push(-u),n.push(v+u),u=0,o)){let w=g.dom.lastChild,k=w?xc(w):[];if(k.length){let x=k[k.length-1],C=a?x.right-m.left:m.right-x.left;C>l&&(l=C,this.minWidth=s,this.minWidthFrom=d,this.minWidthTo=b)}}h&&p==f.children.length-1&&(u+=h.bottom-m.bottom),d=b+g.breakAfter}};return c(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Rn.RTL:Rn.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let u of o.children){if(!u.isText()||/[^ -~]/.test(u.text))return;let c=xc(u.dom);if(c.length!=1)return;l+=c[0].width,a=c[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let n=document.createElement("div"),r,i,s;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let o=xc(n.firstChild)[0];r=n.getBoundingClientRect().height,i=o&&o.width?o.width/27:7,s=o&&o.height?o.height:r,n.remove()}),{lineHeight:r,charWidth:i,textHeight:s}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,i=0;;i++){let s=i==n.viewports.length?null:n.viewports[i],o=s?s.from-1:this.view.state.doc.length;if(o>r){let l=(n.lineBlockAt(o).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(en.replace({widget:new Tm(l),block:!0,inclusive:!0,isBlockGap:!0}).range(r,o))}if(!s)break;r=s.to+1}return en.set(e)}updateDeco(){let e=1,n=this.view.state.facet(Wp).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),r=!1,i=this.view.state.facet(Mw).map((s,o)=>{let l=typeof s=="function";return l&&(r=!0),l?s(this.view):s});for(i.length&&(this.dynamicDecorationMap[e++]=r,n.push(Gt.join(i))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let u=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=u.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let u of this.view.state.facet(UA))try{if(u(this.view,e.range,e))return!0}catch(c){vi(this.view.state,c,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),i;if(!r)return;!n.empty&&(i=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,i.left),top:Math.min(r.top,i.top),right:Math.max(r.right,i.right),bottom:Math.max(r.bottom,i.bottom)});let s=Rw(this.view),o={left:r.left-s.left,top:r.top-s.top,right:r.right+s.right,bottom:r.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(WV(this.view.scrollDOM,o,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){Cy(this.tile)}}function Cy(t,e){let n=e==null?void 0:e.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)Cy(r,e)}}function mU(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function QA(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=PA(n.focusNode,n.focusOffset),i=IA(n.focusNode,n.focusOffset),s=r||i;if(i&&r&&i.node!=r.node){let l=On.get(i.node);if(!l||l.isText()&&l.text!=i.node.nodeValue)s=i;else if(t.docView.lastCompositionAfterCursor){let a=On.get(r.node);!a||a.isText()&&a.text!=r.node.nodeValue||(s=i)}}if(t.docView.lastCompositionAfterCursor=s!=r,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function yU(t,e,n){let r=QA(t,n);if(!r)return null;let{node:i,from:s,to:o}=r,l=i.nodeValue;if(/[\n\r]/.test(l)||t.state.doc.sliceString(r.from,r.to)!=l)return null;let a=e.invertedDesc;return{range:new wi(a.mapPos(s),a.mapPos(o),s,o),text:i}}function vU(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class Tm extends gu{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function TU(t,e,n=1){let r=t.charCategorizer(e),i=t.doc.lineAt(e),s=e-i.from;if(i.length==0)return de.cursor(e);s==0?n=1:s==i.length&&(n=-1);let o=s,l=s;n<0?o=vr(i.text,s,!1):l=vr(i.text,s);let a=r(i.text.slice(o,l));for(;o>0;){let u=vr(i.text,o,!1);if(r(i.text.slice(u,o))!=a)break;o=u}for(;lt.defaultLineHeight*1.5){let l=t.viewState.heightOracle.textHeight,a=Math.floor((i-n.top-(t.defaultLineHeight-l)*.5)/l);s+=a*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(n.from,n.to);return n.from+_V(o,s,t.state.tabSize)}function AU(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let i;for(let s of r.type){if(s.from>e)break;if(!(s.toe)return s;(!i||s.type==ki.Text&&(i.type!=s.type||(n<0?s.frome)))&&(i=s)}}return i||r}return r}function MU(t,e,n,r){let i=AU(t,e.head,e.assoc||-1),s=!r||i.type!=ki.Text||!(t.lineWrapping||i.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>i.from?e.head-1:e.head);if(s){let o=t.dom.getBoundingClientRect(),l=t.textDirectionAt(i.from),a=t.posAtCoords({x:n==(l==Rn.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return de.cursor(a,n?-1:1)}return de.cursor(n?i.to:i.from,n?-1:1)}function $k(t,e,n,r){let i=t.state.doc.lineAt(e.head),s=t.bidiSpans(i),o=t.textDirectionAt(i.from);for(let l=e,a=null;;){let u=eU(i,s,o,l,n),c=$A;if(!u){if(i.number==(n?t.state.doc.lines:1))return l;c=` +`,i=t.state.doc.line(i.number+(n?1:-1)),s=t.bidiSpans(i),u=t.visualLineSide(i,!n)}if(a){if(!a(c))return l}else{if(!r)return u;a=r(c)}l=u}}function RU(t,e,n){let r=t.state.charCategorizer(e),i=r(n);return s=>{let o=r(s);return i==Hs.Space&&(i=o),i==o}}function OU(t,e,n,r){let i=e.head,s=n?1:-1;if(i==(n?t.state.doc.length:0))return de.cursor(i,e.assoc);let o=e.goalColumn,l,a=t.contentDOM.getBoundingClientRect(),u=t.coordsAtPos(i,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),c=t.documentTop;if(u)o==null&&(o=u.left-a.left),l=s<0?u.top:u.bottom;else{let p=t.viewState.lineBlockAt(i);o==null&&(o=Math.min(a.right-a.left,t.defaultCharacterWidth*(i-p.from))),l=(s<0?p.top:p.bottom)+c}let f=a.left+o,d=t.viewState.heightOracle.textHeight>>1,h=r??d;for(let p=0;;p+=d){let g=l+(h+p)*s,b=Ty(t,{x:f,y:g},!1,s);if(n?g>a.bottom:gl:v{if(e>s&&ei(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:de.cursor(r,rt.viewState.docHeight)return new ys(t.state.doc.length,-1);if(u=t.elementAtHeight(a),r==null)break;if(u.type==ki.Text){if(r<0?u.tot.viewport.to)break;let d=t.docView.coordsAt(r<0?u.from:u.to,r>0?-1:1);if(d&&(r<0?d.top<=a+s:d.bottom>=a+s))break}let f=t.viewState.heightOracle.textHeight/2;a=r>0?u.bottom+f:u.top-f}if(t.viewport.from>=u.to||t.viewport.to<=u.from){if(n)return null;if(u.type==ki.Text){let f=EU(t,i,u,o,l);return new ys(f,f==u.from?1:-1)}}if(u.type!=ki.Text)return a<(u.top+u.bottom)/2?new ys(u.from,1):new ys(u.to,-1);let c=t.docView.lineAt(u.from,2);return(!c||c.length!=u.length)&&(c=t.docView.lineAt(u.from,-2)),new PU(t,o,l,t.textDirectionAt(u.from)).scanTile(c,u.from)}class PU{constructor(e,n,r,i){this.view=e,this.x=n,this.y=r,this.baseDir=i,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+i.from>1;t:if(o.has(g)){for(let v=1;v=s&&(w-=p),!o.has(w)){g=w;break t}}break e}o.add(g);let b=n(g),m=0;if(b)for(let v=0;v1))if(w.bottomthis.y)(!u||u.top>w.top)&&(u=w),m=-1;else{let k=w.left>this.x?this.x-w.left:w.right(p+p+g)/3)return this.y=a.bottom-1,this.scan(e,n,!0);if(u&&u.top<(p+g+g)/3)return this.y=u.top+1,this.scan(e,n,!0)}let h=(l?this.dirAt(e[c],1):this.baseDir)==Rn.LTR;return{i:c,after:this.x>(d.left+d.right)/2==h}}scanText(e,n){let r=[];for(let s=0;s{let o=r[s]-n,l=r[s+1]-n;return Jc(e.dom,o,l).getClientRects()});return i.after?new ys(r[i.i+1],-1):new ys(r[i.i],1)}scanTile(e,n){if(!e.length)return new ys(n,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,n);if(l.isComposite())return this.scanTile(l,n)}let r=[n];for(let l=0,a=n;l{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:Jc(a.dom,0,a.length)).getClientRects()}),s=e.children[i.i],o=r[i.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):i.after?new ys(r[i.i+1],-1):new ys(o,1)}}const aa="￿";class IU{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(zt.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=aa}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let i=e;;){this.findPointBefore(r,i);let s=this.text.length;this.readNode(i);let o=On.get(i),l=i.nextSibling;if(l==n){o!=null&&o.breakAfter&&!l&&r!=this.view.contentDOM&&this.lineBreak();break}let a=On.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Uh(i))||Uh(l)&&(i.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>s)&&!_U(l,n)&&this.lineBreak(),i=l}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=n.indexOf(this.lineSeparator,r),o=this.lineSeparator.length):(l=i.exec(n))&&(s=l.index,o=l[0].length),this.append(n.slice(r,s<0?n.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);r=s+o}}readNode(e){let n=On.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let i=r.iter();!i.next().done;)i.lineBreak?this.lineBreak():this.append(i.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(NU(e,r.node,r.offset)?n:0))}}function NU(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=eM(e.docView.tile,n,r,0))){let a=s||o?[]:$U(e),u=new IU(a,e);u.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=u.text,this.newSel=FU(a,this.bounds.from)}else{let a=e.observer.selectionRange,u=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!wy(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!wy(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),f=e.viewport;if((Oe.ios||Oe.chrome)&&u!=c&&Math.min(u,c)<=l.main.from&&Math.max(u,c)>=l.main.to&&(f.from>0||f.to-1&&l.ranges.length>1)this.newSel=l.replaceRange(de.range(c,u));else if(e.lineWrapping&&c==u&&!(l.main.empty&&l.main.head==u)&&e.inputState.lastTouchTime>Date.now()-100){let d=e.coordsAtPos(u,-1),h=0;d&&(h=e.inputState.lastTouchY<=d.bottom?-1:1),this.newSel=de.create([de.cursor(u,h)])}else this.newSel=de.single(c,u)}}}function eM(t,e,n,r){if(t.isComposite()){let i=-1,s=-1,o=-1,l=-1;for(let a=0,u=r,c=r;an)return eM(f,e,n,u);if(d>=e&&i==-1&&(i=a,s=u),u>n&&f.dom.parentNode==t.dom){o=a,l=c;break}c=d,u=d+f.breakAfter}return{from:s,to:l<0?r+t.length:l,startDOM:(i?t.children[i-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:o=0?t.children[o].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function tM(t,e){let n,{newSel:r}=e,{state:i}=t,s=i.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,u=s.from,c=null;(o===8||Oe.android&&e.text.length=l&&s.to<=a&&(e.typeOver||f!=e.text)&&f.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&f.slice(s.to-l)==e.text.slice(d=e.text.length-(f.length-(s.to-l)))?n={from:s.from,to:s.to,insert:_t.of(e.text.slice(s.from-l,d).split(aa))}:(h=nM(f,e.text,u-l,c))&&(Oe.chrome&&o==13&&h.toB==h.from+2&&e.text.slice(h.from,h.toB)==aa+aa&&h.toB--,n={from:l+h.from,to:l+h.toA,insert:_t.of(e.text.slice(h.from,h.toB).split(aa))})}else r&&(!t.hasFocus&&i.facet(zs)||qh(r,s))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==s.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=de.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:_t.of([n.insert.toString().replace("."," ")])}):i.doc.lineAt(s.from).toDate.now()-50?n={from:s.from,to:s.to,insert:i.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==s.head&&n.insert.toString()==` + `&&t.lineWrapping&&(r&&(r=de.single(r.main.anchor-1,r.main.head-1)),n={from:s.from,to:s.to,insert:_t.of([" "])}),n)return Ow(t,n,r,o);if(r&&!qh(r,s)){let l=!1,a="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(l=!0),a=t.inputState.lastSelectionOrigin,a=="select.pointer"&&(r=ZA(i.facet(wf).map(u=>u(t)),r))),t.dispatch({selection:r,scrollIntoView:l,userEvent:a}),!0}else return!1}function Ow(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let i=t.state.selection.main;if(Oe.android&&(e.to==i.to&&(e.from==i.from||e.from==i.from-1&&t.state.sliceDoc(e.from,i.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&$a(t.contentDOM,"Enter",13)||(e.from==i.from-1&&e.to==i.to&&e.insert.length==0||r==8&&e.insert.lengthi.head)&&$a(t.contentDOM,"Backspace",8)||e.from==i.from&&e.to==i.to+1&&e.insert.length==0&&$a(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,l=()=>o||(o=LU(t,e,n));return t.state.facet(HA).some(a=>a(t,e.from,e.to,s,l))||t.dispatch(l()),!0}function LU(t,e,n){let r,i=t.state,s=i.selection.main,o=-1;if(e.from==e.to&&e.froms.to){let a=e.fromf(t)),u,a);e.from==c&&(o=c)}if(o>-1)r={changes:e,selection:de.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let a=s.frome.to?i.sliceDoc(e.to,s.to):"";r=i.replaceSelection(t.state.toText(a+e.insert.sliceString(0,void 0,t.state.lineBreak)+u))}else{let a=i.changes(e),u=n&&n.main.to<=a.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let c=t.state.sliceDoc(e.from,e.to),f,d=n&&QA(t,n.main.head);if(d){let p=e.insert.length-(e.to-e.from);f={from:d.from,to:d.to-p}}else f=t.state.doc.lineAt(s.head);let h=s.to-e.to;r=i.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:u||p.map(a)};let g=p.to-h,b=g-c.length;if(t.state.sliceDoc(b,g)!=c||g>=f.from&&b<=f.to)return{range:p};let m=i.changes({from:b,to:g,insert:e.insert}),v=p.to-s.to;return{changes:m,range:u?de.range(Math.max(0,u.anchor+v),Math.max(0,u.head+v)):p.map(m)}})}else r={changes:a,selection:u&&i.selection.replaceRange(u)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:l,scrollIntoView:!0})}function nM(t,e,n,r){let i=Math.min(t.length,e.length),s=0;for(;s0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(r=="end"){let a=Math.max(0,s-Math.min(o,l));n-=o+a-s}if(o=o?s-n:0;s-=a,l=s+(l-o),o=s}else if(l=l?s-n:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function $U(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}=t.observer.selectionRange;return n&&(e.push(new Fk(n,r)),(i!=n||s!=r)&&e.push(new Fk(i,s))),e}function FU(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?de.single(n+e,r+e):null}function qh(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zU{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&t7(e.contentDOM.ownerDocument)}handleEvent(e){!GU(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let i of r.observers)i(this.view,n);for(let i of r.handlers){if(n.defaultPrevented)break;if(i(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=jU(e),r=this.handlers,i=this.view.contentDOM;for(let s in n)if(s!="scroll"){let o=!n[s].handlers.length,l=r[s];l&&o!=!l.handlers.length&&(i.removeEventListener(s,this.handleEvent),l=null),l||i.addEventListener(s,this.handleEvent,{passive:o})}for(let s in r)s!="scroll"&&!n[s]&&i.removeEventListener(s,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&iM.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(rM.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||HU.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&BU(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function BU(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function zk(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(i){vi(n.state,i)}}}function jU(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let i=r.spec,s=i&&i.plugin.domEventHandlers,o=i&&i.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&n(l).handlers.push(zk(r.value,a))}if(o)for(let l in o){let a=o[l];a&&n(l).observers.push(zk(r.value,a))}}for(let r in Zi)n(r).handlers.push(Zi[r]);for(let r in Rr)n(r).observers.push(Rr[r]);return e}const rM=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],HU="dthko",iM=[16,17,18,20,91,92,224,225],gd=6;function md(t){return Math.max(0,t)*.7+8}function WU(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class VU{constructor(e,n,r,i){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=EA(e.contentDOM),this.atoms=e.state.facet(wf).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(zt.allowMultipleSelections)&&UU(e,n),this.dragging=XU(e,n)&&lM(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&WU(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,i=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:i,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=Rw(this.view);e.clientX-a.left<=i+gd?n=-md(i-e.clientX):e.clientX+a.right>=o-gd&&(n=md(e.clientX-o)),e.clientY-a.top<=s+gd?r=-md(s-e.clientY):e.clientY+a.bottom>=l-gd&&(r=md(e.clientY-l)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=ZA(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function UU(t,e){let n=t.state.facet(FA);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function KU(t,e){let n=t.state.facet(zA);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XU(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=qc(t.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let s=0;s=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function GU(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=On.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Zi=Object.create(null),Rr=Object.create(null),sM=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function qU(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),oM(t,n.value)},50)}function Kp(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function oM(t,e){e=Kp(t.state,Tw,e);let{state:n}=t,r,i=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(Ey!=null&&n.selection.ranges.every(a=>a.empty)&&Ey==s.toString()){let a=-1;r=n.changeByRange(u=>{let c=n.doc.lineAt(u.from);if(c.from==a)return{range:u};a=c.from;let f=n.toText((o?s.line(i++).text:e)+n.lineBreak);return{changes:{from:c.from,insert:f},range:de.cursor(u.from+f.length)}})}else o?r=n.changeByRange(a=>{let u=s.line(i++);return{changes:{from:a.from,to:a.to,insert:u.text},range:de.cursor(a.from+u.length)}}):r=n.replaceSelection(s);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}Rr.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};Rr.wheel=Rr.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};Zi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);Rr.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")};Rr.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};Rr.touchend=(t,e)=>{t.inputState.touchActive=!1};Zi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(BA))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=JU(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new VU(t,e,n,r)),r&&t.observer.ignore(()=>{RA(t.contentDOM);let s=t.root.activeElement;s&&!s.contains(t.contentDOM)&&s.blur()});let i=t.inputState.mouseSelection;if(i)return i.start(e),i.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Bk(t,e,n,r){if(r==1)return de.cursor(e,n);if(r==2)return TU(t.state,e,n);{let i=t.docView.lineAt(e,n),s=t.state.doc.lineAt(i?i.posAtEnd:e),o=i?i.posAtStart:s.from,l=i?i.posAtEnd:s.to;return lDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Hk+1)%3:1}function JU(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=lM(e),i=t.state.selection;return{update(s){s.docChanged&&(n.pos=s.changes.mapPos(n.pos),i=i.map(s.changes))},get(s,o,l){let a=t.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),u,c=Bk(t,a.pos,a.assoc,r);if(n.pos!=a.pos&&!o){let f=Bk(t,n.pos,n.assoc,r),d=Math.min(f.from,c.from),h=Math.max(f.to,c.to);c=d1&&(u=QU(i,a.pos))?u:l?i.addRange(c):de.create([c])}}}function QU(t,e){for(let n=0;n=e)return de.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Zi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let i=t.docView.tile.nearest(e.target);if(i&&i.isWidget()){let s=i.posAtStart,o=s+i.length;(s>=n.to||o<=n.from)&&(n=de.undirectionalRange(s,o))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",Kp(t.state,Ew,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Zi.dragend=t=>(t.inputState.draggedContent=null,!1);function Vk(t,e,n,r){if(n=Kp(t.state,Tw,n),!n)return;let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=r&&s&&KU(t,e)?{from:s.from,to:s.to}:null,l={from:i,insert:n},a=t.state.changes(o?[o,l]:l);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(i,-1),head:a.mapPos(i,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Zi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,s=()=>{++i==n.length&&Vk(t,e,r.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(r[o]=l.result),s()},l.readAsText(n[o])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return Vk(t,e,r,!0),!0}return!1};Zi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=sM?null:e.clipboardData;return n?(oM(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(qU(t),!1)};function ZU(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function e7(t){let e=[],n=[],r=!1;for(let i of t.selection.ranges)i.empty||(e.push(t.sliceDoc(i.from,i.to)),n.push(i));if(!e.length){let i=-1;for(let{from:s}of t.selection.ranges){let o=t.doc.lineAt(s);o.number>i&&(e.push(o.text),n.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),i=o.number}r=!0}return{text:Kp(t,Ew,e.join(t.lineBreak)),ranges:n,linewise:r}}let Ey=null;Zi.copy=Zi.cut=(t,e)=>{if(!bc(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=e7(t.state);if(!n&&!i)return!1;Ey=i?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=sM?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(ZU(t,n),!1)};const aM=qo.define();function uM(t,e){let n=[];for(let r of t.facet(WA)){let i=r(t,e);i&&n.push(i)}return n.length?t.update({effects:n,annotations:aM.of(!0)}):null}function cM(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=uM(t.state,e);n?t.dispatch(n):t.update([])}},10)}Rr.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),cM(t)};Rr.blur=t=>{t.observer.clearSelectionRange(),cM(t)};Rr.compositionstart=Rr.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};Rr.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};Rr.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};Zi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let s=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],a=t.posAtDOM(l.startContainer,l.startOffset),u=t.posAtDOM(l.endContainer,l.endOffset);return Ow(t,{from:a,to:u,insert:t.state.toText(s)},null),!0}}let i;if(Oe.chrome&&Oe.android&&(i=rM.find(s=>s.inputType==e.inputType))&&(t.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let s=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>Rr.compositionend(t,e),20),!1};const Uk=new Set;function t7(t){Uk.has(t)||(Uk.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const Kk=["pre-wrap","normal","pre-line","break-spaces"];let eu=!1;function Xk(){eu=!1}class n7{constructor(e){this.lineWrapping=e,this.doc=_t.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Kk.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,a=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=n,this.charWidth=r,this.textHeight=i,this.lineLength=s,a){this.heightSamples={};for(let u=0;u0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Jd&&(eu=!0),this.height=e)}replace(e,n,r){return Mr.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,i){let s=this,o=r.doc;for(let l=i.length-1;l>=0;l--){let{fromA:a,toA:u,fromB:c,toB:f}=i[l],d=s.lineAt(a,cn.ByPosNoHeight,r.setDoc(n),0,0),h=d.to>=u?d:s.lineAt(u,cn.ByPosNoHeight,r,0,0);for(f+=h.to-u,u=h.to;l>0&&d.from<=i[l-1].toA;)a=i[l-1].fromA,c=i[l-1].fromB,l--,as*2){let l=e[n-1];l.break?e.splice(--n,1,l.left,null,l.right):e.splice(--n,1,l.left,l.right),r+=1+l.break,i-=l.size}else if(s>i*2){let l=e[r];l.break?e.splice(r,1,l.left,null,l.right):e.splice(r,1,l.left,l.right),r+=2+l.break,s-=l.size}else break;else if(i=s&&o(this.lineAt(0,cn.ByPos,r,i,s))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,i){return i&&i.from<=n&&i.more&&this.setMeasuredHeight(i),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Qr extends fM{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ui(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let i=r[0];return r.length==1&&(i instanceof Qr||i instanceof ir&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof ir?i=new Qr(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):Mr.of(r)}updateHeight(e,n=0,r=!1,i){return i&&i.from<=n&&i.more?this.setMeasuredHeight(i):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class ir extends Mr{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,i=e.doc.lineAt(n+this.length).number,s=i-r+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:r,lastLine:i,perLine:o,perChar:l}}blockAt(e,n,r,i){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(n,i);if(n.lineWrapping){let u=i+(e0){let s=r[r.length-1];s instanceof ir?r[r.length-1]=new ir(s.length+i):r.push(null,new ir(i-1))}if(e>0){let s=r[0];s instanceof ir?r[0]=new ir(e+s.length):r.unshift(new ir(e-1),null)}return Mr.of(r)}decomposeLeft(e,n){n.push(new ir(e-1),null)}decomposeRight(e,n){n.push(null,new ir(this.length-e-1))}updateHeight(e,n=0,r=!1,i){let s=n+this.length;if(i&&i.from<=n+this.length&&i.more){let o=[],l=Math.max(n,i.from),a=-1;for(i.from>n&&o.push(new ir(i.from-n-1).updateHeight(e,n));l<=s&&i.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=i.heights[i.index++],d=0;f<0&&(d=-f,f=i.heights[i.index++]),a==-1?a=f:Math.abs(f-a)>=Jd&&(a=-2);let h=new Qr(c,f,d);h.outdated=!1,o.push(h),l+=c+1}l<=s&&o.push(null,new ir(s-l).updateHeight(e,l));let u=Mr.of(o);return(a<0||Math.abs(u.height-this.height)>=Jd||Math.abs(a-this.heightMetrics(e,n).perLine)>=Jd)&&(eu=!0),Yh(this,u)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class s7 extends Mr{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,i){let s=r+this.left.height;return el))return u;let c=n==cn.ByPosNoHeight?cn.ByPosNoHeight:cn.ByPos;return a?u.join(this.right.lineAt(l,c,r,o,l)):this.left.lineAt(l,c,r,i,s).join(u)}forEachLine(e,n,r,i,s,o){let l=i+this.left.height,a=s+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,n,r,l,a,o);else{let u=this.lineAt(a,cn.ByPos,r,i,s);e=e&&u.from<=n&&o(u),n>u.to&&this.right.forEachLine(u.to+1,n,r,l,a,o)}}replace(e,n,r){let i=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-i,n-i,r));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of r)s.push(l);if(e>0&&Gk(s,o-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,i=r+this.break;if(e>=i)return this.right.decomposeRight(e-i,n);e2*n.size||n.size>2*e.size?Mr.of(this.break?[e,null,n]:[e,n]):(this.left=Yh(this.left,e),this.right=Yh(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,i){let{left:s,right:o}=this,l=n+s.length+this.break,a=null;return i&&i.from<=n+s.length&&i.more?a=s=s.updateHeight(e,n,r,i):s.updateHeight(e,n,r),i&&i.from<=l+o.length&&i.more?a=o=o.updateHeight(e,l,r,i):o.updateHeight(e,l,r),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Gk(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof ir&&(r=t[e+1])instanceof ir&&t.splice(e-1,3,new ir(n.length+1+r.length))}const o7=5;class Pw{constructor(e,n){this.pos=e,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof Qr?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Qr(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=o7)&&this.addLineDeco(i,s,o)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Qr(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new ir(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Qr)return e;let n=new Qr(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let i=this.ensureLine();i.length+=r,i.collapsed+=r,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Qr)&&!this.isCovered?this.nodes.push(new Qr(0,-1,0)):(this.writtenToc.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let d=c.getBoundingClientRect();s=Math.max(s,d.left),o=Math.min(o,d.right),l=Math.max(l,d.top),a=Math.min(u==t.parentNode?i.innerHeight:a,d.bottom)}u=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:l-(n.top+e),bottom:Math.max(l,a)-(n.top+e)}}function c7(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function f7(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class Am{constructor(e,n,r,i){this.from=e,this.to=n,this.size=r,this.displaySize=i}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new n7(r),this.stateDeco=Jk(n),this.heightMap=Mr.empty().applyChanges(this.stateDeco,_t.empty,this.heightOracle.setDoc(n.doc),[new wi(0,0,0,n.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=en.set(this.lineGaps.map(i=>i.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let i=r?n.head:n.anchor;if(!e.some(({from:s,to:o})=>i>=s&&i<=o)){let{from:s,to:o}=this.lineBlockAt(i);e.push(new yd(s,o))}}return this.viewports=e.sort((r,i)=>r.from-i.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Yk:new Iw(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(nc(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=Jk(this.state);let i=e.changedRanges,s=wi.extendWithRanges(i,l7(r,this.stateDeco,e?e.changes:Vn.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Xk(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||eu)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,n));let u=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(u||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(nU)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),i=this.heightOracle,s=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Rn.RTL:Rn.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=n.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let u=0,c=0;if(l.width&&l.height){let{scaleX:x,scaleY:C}=TA(n,l);(x>.005&&Math.abs(this.scaleX-x)>.005||C>.005&&Math.abs(this.scaleY-C)>.005)&&(this.scaleX=x,this.scaleY=C,u|=16,o=a=!0)}let f=(parseInt(r.paddingTop)||0)*this.scaleY,d=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=d)&&(this.paddingTop=f,this.paddingBottom=d,u|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,u|=16);let h=EA(this.view.contentDOM,!1).y;h!=this.scrollParent&&(this.scrollParent=h,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=OA(this.scrollParent||e.win);let g=(this.printing?f7:u7)(n,this.paddingTop),b=g.top-this.pixelViewport.top,m=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(a=!0)),!this.inView&&!this.scrollTarget&&!c7(e.dom))return 0;let w=l.width;if((this.contentDOMWidth!=w||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,u|=16),a){let x=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(x)&&(o=!0),o||i.lineWrapping&&Math.abs(w-this.contentDOMWidth)>i.charWidth){let{lineHeight:C,charWidth:T,textHeight:A}=e.docView.measureTextSize();o=C>0&&i.refresh(s,C,T,A,Math.max(5,w/T),x),o&&(e.docView.minWidth=0,u|=16)}b>0&&m>0?c=Math.max(b,m):b<0&&m<0&&(c=Math.min(b,m)),Xk();for(let C of this.viewports){let T=C.from==this.viewport.from?x:e.docView.measureVisibleLineHeights(C);this.heightMap=(o?Mr.empty().applyChanges(this.stateDeco,_t.empty,this.heightOracle,[new wi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new r7(C.from,T))}eu&&(u|=2)}let k=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return k&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),u|=this.updateForViewport()),(u&2||k)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new yd(i.lineAt(o-r*1e3,cn.ByHeight,s,0,0).from,i.lineAt(l+(1-r)*1e3,cn.ByHeight,s,0,0).to);if(n){let{head:u}=n.range;if(ua.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=i.lineAt(u,cn.ByPos,s,0,0),d;n.y=="center"?d=(f.top+f.bottom)/2-c/2:n.y=="start"||n.y=="nearest"&&u=l+Math.max(10,Math.min(r,250)))&&i>o-2*1e3&&s>1,o=i<<1;if(this.defaultTextDirection!=Rn.LTR&&!r)return[];let l=[],a=(c,f,d,h)=>{if(f-cc&&mm.from>=d.from&&m.to<=d.to&&Math.abs(m.from-c)m.fromv));if(!b){if(fw.from<=f&&w.to>=f)){let w=n.moveToLineBoundary(de.cursor(f),!1,!0).head;w>c&&(f=w)}let m=this.gapSize(d,c,f,h),v=r||m<2e6?m:2e6;b=new Am(c,f,m,v)}l.push(b)},u=c=>{if(c.length2e6)for(let C of e)C.from>=c.from&&C.fromc.from&&a(c.from,h,c,f),pn.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];Gt.spans(n,this.viewport.from,this.viewport.to,{span(s,o){r.push({from:s,to:o})},point(){}},20);let i=0;if(r.length!=this.visibleRanges.length)i=12;else for(let s=0;s=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||nc(this.heightMap.lineAt(e,cn.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||nc(this.heightMap.lineAt(this.scaler.fromDOM(e),cn.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return nc(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class yd{constructor(e,n){this.from=e,this.to=n}}function h7(t,e,n){let r=[],i=t,s=0;return Gt.spans(n,t,e,{span(){},point(o,l){o>i&&(r.push({from:i,to:o}),s+=o-i),i=l}},20),i=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let i=0;;i++){let{from:s,to:o}=e[i],l=o-s;if(r<=l)return s+r;r-=l}}function wd(t,e){let n=0;for(let{from:r,to:i}of t.ranges){if(e<=i){n+=e-r;break}n+=i-r}return n/t.total}function p7(t,e){for(let n of t)if(e(n))return n}const Yk={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function Jk(t){let e=t.facet(Wp).filter(r=>typeof r!="function"),n=t.facet(Mw).filter(r=>typeof r!="function");return n.length&&e.push(Gt.join(n)),e}class Iw{constructor(e,n,r){let i=0,s=0,o=0;this.viewports=r.map(({from:l,to:a})=>{let u=n.lineAt(l,cn.ByPos,e,0,0).top,c=n.lineAt(a,cn.ByPos,e,0,0).bottom;return i+=c-u,{from:l,to:a,top:u,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(n.height-i);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let n=0,r=0,i=0;;n++){let s=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function nc(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ui(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(i=>nc(i,e)):t._content)}const bd=He.define({combine:t=>t.join(" ")}),Ay=He.define({combine:t=>t.indexOf(!0)>-1}),My=jo.newName(),dM=jo.newName(),hM=jo.newName(),pM={"&light":"."+dM,"&dark":"."+hM};function Ry(t,e,n){return new jo(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,i=>{if(i=="&")return t;if(!n||!n[i])throw new RangeError(`Unsupported selector: ${i}`);return n[i]}):t+" "+r}})}const g7=Ry("."+My,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},pM),m7={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Mm=Oe.ie&&Oe.ie_version<=11;class y7{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new VV,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new w7(e),e.state.facet(zs)&&(e.contentDOM.editContext=this.editContext.editContext)),Mm&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,i=this.selectionRange;if(r.state.facet(zs)?r.root.activeElement!=this.dom:!bc(this.dom,i))return;let s=i.anchorNode&&r.docView.tile.nearest(i.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&i.focusNode&&kc(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=qc(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&v7(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let i=bc(this.dom,r);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&$a(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(i)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,i=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(i=!0),n==-1?{from:n,to:r}=o:(n=Math.min(o.from,n),r=Math.max(o.to,r)))}return{from:n,to:r,typeOver:i}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),i=this.selectionChanged&&bc(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new DU(this.view,e,n,r);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,i=tM(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!qh(this.view.state.selection,n.newSel.main))&&this.view.update([]),i}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=Qk(n,e.previousSibling||e.target.previousSibling,-1),i=Qk(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:i?n.posBefore(i):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(zs)!=e.state.facet(zs)&&(e.view.contentDOM.editContext=e.state.facet(zs)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Qk(t,e,n){for(;e;){let r=On.get(e);if(r&&r.parent==t)return r;let i=e.parentNode;e=i!=t.dom?i:n>0?e.nextSibling:e.previousSibling}return null}function Zk(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor,1);return kc(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function v7(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Zk(t,i)}let n=null;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?Zk(t,n):null}class w7{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let i=e.state.selection.main,{anchor:s,head:o}=i,l=this.toEditorPos(r.updateRangeStart),a=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:l,drifted:!1});let u=a-l>r.text.length;l==this.from&&sthis.to&&(a=s);let c=nM(e.state.sliceDoc(l,a),r.text,(u?i.from:i.to)-l,u?"end":null);if(!c){let d=de.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));qh(d,i)||e.dispatch({selection:d,userEvent:"select"});return}let f={from:c.from+l,to:c.toA+l,insert:_t.of(r.text.slice(c.from,c.toB).split(` +`))};if((Oe.mac||Oe.android)&&f.from==o-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:_t.of([r.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let d=this.to-this.from+(f.to-f.from+f.insert.length);Ow(e,f,de.single(this.toEditorPos(r.selectionStart,d),this.toEditorPos(r.selectionEnd,d)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let i=[],s=null;for(let o=this.toEditorPos(r.rangeStart),l=this.toEditorPos(r.rangeEnd);o{let i=[];for(let s of r.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),u=this.toEditorPos(s.rangeEnd);if(a{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let i=qc(r.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,i=this.pendingContextChange;return e.changes.iterChanges((s,o,l,a,u)=>{if(r)return;let c=u.length-(o-s);if(i&&o>=i.to)if(i.from==s&&i.to==o&&i.insert.eq(u)){i=this.pendingContextChange=null,n+=c,this.to+=c;return}else i=null,this.revertPending(e.state);if(s+=n,o+=n,o<=this.from)this.from+=c,this.to+=c;else if(sthis.to||this.to-this.from+u.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),u.toString()),this.to+=c}n+=c}),i&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(i=>!i.isUserEvent("input.type")&&i.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),i=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(r,i)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to1e4*3)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class qe{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(i=>i.forEach(s=>r(s,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||UV(e.parent)||document,this.viewState=new qk(this,e.state||zt.create(e)),e.scrollTo&&e.scrollTo.is(pd)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ca).map(i=>new km(i));for(let i of this.plugins)i.update(this);this.observer=new y7(this),this.inputState=new zU(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Lk(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof Gn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,i,s=this.state;for(let d of e){if(d.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=d.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(d=>d.annotation(aM))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=uM(s,o),a||(l=1));let u=this.observer.delayedAndroidKey,c=null;if(u?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(zt.phrases)!=this.state.facet(zt.phrases))return this.setState(s);i=Kh.create(this,s,e),i.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let d of e){if(f&&(f=f.map(d.changes)),d.scrollIntoView){let{main:h}=d.state.selection,{x:p,y:g}=this.state.facet(qe.cursorScrollMargin);f=new Fa(h.empty?h:de.cursor(h.head,h.head>h.anchor?-1:1),"nearest","nearest",g,p)}for(let h of d.effects)h.is(pd)&&(f=h.value.clip(this.state))}this.viewState.update(i,f),this.bidiCache=Jh.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(tc)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(d=>d.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(bd)!=i.state.facet(bd)&&(this.viewState.mustMeasureContent=!0),(n||r||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let d of this.state.facet(Sy))try{d(i)}catch(h){vi(this.state,h,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!tM(this,c)&&u.force&&$a(this.contentDOM,u.key,u.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new qk(this,e),this.plugins=e.facet(Ca).map(r=>new km(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Lk(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(Ca),r=e.state.facet(Ca);if(n!=r){let i=[];for(let s of r){let o=n.indexOf(s);if(o<0)i.push(new km(s));else{let l=this.plugins[o];l.mustUpdate=e,i.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=e;for(let i=0;i-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,i=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(OA(r||this.win))s=-1,o=this.viewState.heightMap.height;else{let h=this.viewState.scrollAnchorAt(i);s=h.from,o=h.top}this.updateState=1;let a=this.viewState.measure();if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];a&4||([this.measureRequests,u]=[u,this.measureRequests]);let c=u.map(h=>{try{return h.read(this)}catch(p){return vi(this.state,p),eS}}),f=Kh.create(this,this.state,[]),d=!1;f.flags|=a,n?n.flags|=a:n=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),d=this.docView.update(f),d&&this.docViewUpdate());for(let h=0;h1||p<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){i=i+p,r?s<0?r.scrollTop=r.scrollHeight:r.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let l of this.state.facet(Sy))l(n)}get themeClasses(){return My+" "+(this.state.facet(Ay)?hM:dM)+" "+this.state.facet(bd)}updateAttrs(){let e=tS(this,XA,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(zs)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),tS(this,Aw,n);let r=this.observer.ignore(()=>{let i=Ok(this.contentDOM,this.contentAttrs,n),s=Ok(this.dom,this.editorAttrs,e);return i||s});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let i of r.effects)if(i.is(qe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(tc);let e=this.state.facet(qe.cspNonce);jo.mount(this.root,this.styleModules.concat(g7).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,r){return Em(this,e,$k(this,e,n,r))}moveByGroup(e,n){return Em(this,e,$k(this,e,n,r=>RU(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),i=this.textDirectionAt(e.from),s=r[n?r.length-1:0];return de.cursor(s.side(n,i)+e.from,s.forward(!n,i)?1:-1)}moveToLineBoundary(e,n,r=!0){return MU(this,e,n,r)}moveVertically(e,n,r){return Em(this,e,OU(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=Ty(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),Ty(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),s=i[bs.find(i,e-r.from,-1,n)];return this.docView.coordsAt(e,n,s.dir==Rn.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(VA)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>b7)return LA(e.length);let n=this.textDirectionAt(e.from),r;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==n&&(s.fresh||DA(s.isolates,r=Nk(this,e))))return s.order;r||(r=Nk(this,e));let i=ZV(e.text,n,r);return this.bidiCache.push(new Jh(e.from,e.to,n,r,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{RA(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,i,s,o;return pd.of(new Fa(typeof e=="number"?de.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(i=n.x)!==null&&i!==void 0?i:"nearest",(s=n.yMargin)!==null&&s!==void 0?s:5,(o=n.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return pd.of(new Fa(de.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Ei.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Ei.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=jo.newName(),i=[bd.of(r),tc.of(Ry(`.${r}`,e))];return n&&n.dark&&i.push(Ay.of(!0)),i}static baseTheme(e){return ww.lowest(tc.of(Ry("."+My,e,pM)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),i=r&&On.get(r)||On.get(e);return((n=i==null?void 0:i.root)===null||n===void 0?void 0:n.view)||null}}qe.styleModule=tc;qe.inputHandler=HA;qe.clipboardInputFilter=Tw;qe.clipboardOutputFilter=Ew;qe.scrollHandler=UA;qe.focusChangeEffect=WA;qe.perLineTextDirection=VA;qe.exceptionSink=jA;qe.updateListener=Sy;qe.editable=zs;qe.mouseSelectionStyle=BA;qe.dragMovesSelection=zA;qe.clickAddsSelectionRange=FA;qe.decorations=Wp;qe.blockWrappers=GA;qe.outerDecorations=Mw;qe.atomicRanges=wf;qe.bidiIsolatedRanges=qA;qe.cursorScrollMargin=He.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}});qe.scrollMargins=YA;qe.darkTheme=Ay;qe.cspNonce=He.define({combine:t=>t.length?t[0]:""});qe.contentAttributes=Aw;qe.editorAttributes=XA;qe.lineWrapping=qe.contentAttributes.of({class:"cm-lineWrapping"});qe.announce=on.define();const b7=4096,eS={};class Jh{constructor(e,n,r,i,s,o){this.from=e,this.to=n,this.dir=r,this.isolates=i,this.fresh=s,this.order=o}static update(e,n){if(n.empty&&!e.some(s=>s.fresh))return e;let r=[],i=e.length?e[e.length-1].dir:Rn.LTR;for(let s=Math.max(0,e.length-10);s=0;i--){let s=r[i],o=typeof s=="function"?s(t):s;o&&kw(o,n)}return n}const x7=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function k7(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let i,s,o,l;for(let a=0;ar.concat(i),[]))),n}let So=null;const T7=4e3;function E7(t,e=x7){let n=Object.create(null),r=Object.create(null),i=(o,l)=>{let a=r[o];if(a==null)r[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,u,c)=>{var f,d;let h=n[o]||(n[o]=Object.create(null)),p=l.split(/ (?!$)/).map(m=>k7(m,e));for(let m=1;m{let k=So={view:w,prefix:v,scope:o};return setTimeout(()=>{So==k&&(So=null)},T7),!0}]})}let g=p.join(" ");i(g,!1);let b=h[g]||(h[g]={preventDefault:!1,stopPropagation:!1,run:((d=(f=h._any)===null||f===void 0?void 0:f.run)===null||d===void 0?void 0:d.slice())||[]});a&&b.run.push(a),u&&(b.preventDefault=!0),c&&(b.stopPropagation=!0)};for(let o of t){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let u of l){let c=n[u]||(n[u]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let d in c)c[d].run.push(h=>f(h,Oy))}let a=o[e]||o.key;if(a)for(let u of l)s(u,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(u,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return n}let Oy=null;function A7(t,e,n,r){Oy=e;let i=FV(e),s=bV(i,0),o=xV(s)==i.length&&i!=" ",l="",a=!1,u=!1,c=!1;So&&So.view==n&&So.scope==r&&(l=So.prefix+" ",iM.indexOf(e.keyCode)<0&&(u=!0,So=null));let f=new Set,d=b=>{if(b){for(let m of b.run)if(!f.has(m)&&(f.add(m),m(n)))return b.stopPropagation&&(c=!0),!0;b.preventDefault&&(b.stopPropagation&&(c=!0),u=!0)}return!1},h=t[r],p,g;return h&&(d(h[l+xd(i,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=Ho[e.keyCode])&&p!=i?(d(h[l+xd(p,e,!0)])||e.shiftKey&&(g=Xc[e.keyCode])!=i&&g!=p&&d(h[l+xd(g,e,!1)]))&&(a=!0):o&&e.shiftKey&&d(h[l+xd(i,e,!0)])&&(a=!0),!a&&d(h._any)&&(a=!0)),u&&(a=!0),a&&c&&e.stopPropagation(),Oy=null,a}class M7 extends gu{constructor(e){super(),this.content=e}toDOM(e){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(e){let n=e.firstChild?xc(e.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(e.parentNode),i=Yc(n[0],r.direction!="rtl"),s=parseInt(r.lineHeight);return i.bottom-i.top>s*1.5?{left:i.left,right:i.right,top:i.top,bottom:i.top+s}:i}ignoreEvent(){return!1}}function R7(t){let e=Ei.fromClass(class{constructor(n){this.view=n,this.placeholder=t?en.set([en.widget({widget:new M7(t),side:1}).range(0)]):en.none}get decorations(){return this.view.state.doc.length?en.none:this.placeholder}},{decorations:n=>n.decorations});return typeof t=="string"?[e,qe.contentAttributes.of({"aria-placeholder":t})]:e}const kd="-10000px";class mM{constructor(e,n,r,i){this.facet=n,this.createTooltipView=r,this.removeTooltipView=i,this.input=e.state.facet(n),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=r(o,s))}update(e,n){var r;let i=e.state.facet(this.facet),s=i.filter(a=>a);if(i===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=n?[]:null;for(let a=0;an[u]=a),n.length=l.length),this.input=i,this.tooltips=s,this.tooltipViews=o,!0}}function O7(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const Rm=He.define({combine:t=>{var e,n,r;return{position:Oe.ios?"absolute":((e=t.find(i=>i.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((n=t.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=t.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||O7}}}),rS=new WeakMap,yM=Ei.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(Rm);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new mM(t,vM,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let n=e||t.geometryChanged,r=t.state.facet(Rm);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(t,e){let n=t.create(this.view),r=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),t.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=kd,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var t,e,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(t=r.destroy)===null||t===void 0||t.call(r);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(Oe.safari){let o=s.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else n=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(t=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=Rw(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(Rm).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:s}=t,o=[];for(let l=0;l=Math.min(n.bottom,r.bottom)||f.rightMath.min(n.right,r.right)+.1)){c.style.top=kd;continue}let h=a.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,p=h?7:0,g=d.right-d.left,b=(e=rS.get(u))!==null&&e!==void 0?e:d.bottom-d.top,m=u.offset||I7,v=this.view.textDirection==Rn.LTR,w=d.width>r.right-r.left?v?r.left:r.right-d.width:v?Math.max(r.left,Math.min(f.left-(h?14:0)+m.x,r.right-g)):Math.min(Math.max(r.left,f.left-g+(h?14:0)-m.x),r.right-g),k=this.above[l];!a.strictSide&&(k?f.top-b-p-m.yr.bottom)&&k==r.bottom-f.bottom>f.top-r.top&&(k=this.above[l]=!k);let x=(k?f.top-r.top:r.bottom-f.bottom)-p;if(xw&&A.topC&&(C=k?A.top-b-2-p:A.bottom+p+2);if(this.position=="absolute"?(c.style.top=(C-t.parent.top)/s+"px",iS(c,(w-t.parent.left)/i)):(c.style.top=C/s+"px",iS(c,w/i)),h){let A=f.left+(v?m.x:-m.x)-(w+14-7);h.style.left=A/i+"px"}u.overlap!==!0&&o.push({left:w,top:C,right:T,bottom:C+b}),c.classList.toggle("cm-tooltip-above",k),c.classList.toggle("cm-tooltip-below",!k),u.positioned&&u.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=kd}},{eventObservers:{scroll(){this.maybeMeasure()}}});function iS(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}const P7=qe.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),I7={x:0,y:0},vM=He.define({enables:[yM,P7]}),Qh=He.define({combine:t=>t.reduce((e,n)=>e.concat(n),[])});class Xp{static create(e){return new Xp(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new mM(e,Qh,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(e,n){let r=e.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(e){for(let n of this.manager.tooltipViews)n.mount&&n.mount(e);this.mounted=!0}positioned(e){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let n of this.manager.tooltipViews)(e=n.destroy)===null||e===void 0||e.call(n)}passProp(e){let n;for(let r of this.manager.tooltipViews){let i=r[e];if(i!==void 0){if(n===void 0)n=i;else if(n!==i)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const N7=vM.compute([Qh],t=>{let e=t.facet(Qh);return e.length===0?null:{pos:Math.min(...e.map(n=>n.pos)),end:Math.max(...e.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:Xp.create,above:e[0].above,arrow:e.some(n=>n.arrow)}}),_7=He.define();class D7{constructor(e,n,r,i,s,o){this.view=e,this.source=n,this.field=r,this.locked=i,this.setHover=s,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;eo.bottom||n.xo.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),a=l&&l.dir==Rn.RTL?-1:1;s=n.x{if(l&&!(Array.isArray(l)&&!l.length)){let a=Array.isArray(l)?l:[l];i&&this.locked.set(a,i),e.dispatch({effects:this.setHover.of(a)})}};if(s&&"then"in s){let l=this.pending={pos:n};s.then(a=>{this.pending==l&&(this.pending=null,o(a))},a=>vi(e.state,a,"hover tooltip"))}else o(s)}get tooltip(){let e=this.view.plugin(yM),n=e?e.manager.tooltips.findIndex(r=>r.create==Xp.create):-1;return n>-1?e.manager.tooltipViews[n]:null}mousemove(e){var n,r;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:s}=this;if(i.length&&!this.locked.has(i)&&s&&!L7(s.dom,e)||this.pending){let{pos:o}=i[0]||this.pending,l=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!$7(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length&&!this.locked.has(n)){let{tooltip:r}=this;r&&r.dom.contains(e.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let n=r=>{e.removeEventListener("mouseleave",n);let{active:i}=this;i.length&&!this.locked.has(i)&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Sd=4;function L7(t,e){let{left:n,right:r,top:i,bottom:s}=t.getBoundingClientRect(),o;if(o=t.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();i=Math.min(l.top,i),s=Math.max(l.bottom,s)}return e.clientX>=n-Sd&&e.clientX<=r+Sd&&e.clientY>=i-Sd&&e.clientY<=s+Sd}function $7(t,e,n,r,i,s){let o=t.scrollDOM.getBoundingClientRect(),l=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>r||o.righti||Math.min(o.bottom,l)=e&&a<=n}function F7(t,e={}){let n=on.define(),r=new WeakMap,i=Os.define({create(){return[]},update(o,l){let a=r.get(o);if(o.length&&(e.hideOnChange&&(l.docChanged||l.selection)?o=[]:a&&a(l)?o=[]:e.hideOn&&(o=o.filter(u=>!e.hideOn(l,u)))),l.docChanged&&o.length){let u=[];for(let c of o){let f=l.changes.mapPos(c.pos,-1,Dr.TrackDel);if(f!=null){let d=Object.assign(Object.create(null),c);d.pos=f,d.end!=null&&(d.end=l.changes.mapPos(d.end)),u.push(d)}}o=u}for(let u of l.effects)u.is(n)&&(o=u.value,a=void 0),(u.is(z7)&&!u.value||u.value==i)&&(o=[]);return o.length&&a&&r.set(o,a),o},provide:o=>Qh.from(o)});const s=Ei.define(o=>new D7(o,t,i,r,n,e.hoverTime||300));return{active:i,extension:[i,s,_7.of(s),N7]}}const z7=on.define(),sS=He.define({combine(t){let e,n;for(let r of t)e=e||r.topContainer,n=n||r.bottomContainer;return{topContainer:e,bottomContainer:n}}}),B7=Ei.fromClass(class{constructor(t){this.input=t.state.facet(Py),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(t));let e=t.state.facet(sS);this.top=new Cd(t,!0,e.topContainer),this.bottom=new Cd(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(t){let e=t.state.facet(sS);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Cd(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Cd(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=t.state.facet(Py);if(n!=this.input){let r=n.filter(a=>a),i=[],s=[],o=[],l=[];for(let a of r){let u=this.specs.indexOf(a),c;u<0?(c=a(t.view),l.push(c)):(c=this.panels[u],c.update&&c.update(t)),i.push(c),(c.top?s:o).push(c)}this.specs=r,this.panels=i,this.top.sync(s),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let r of this.panels)r.update&&r.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>qe.scrollMargins.of(e=>{let n=e.plugin(t);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class Cd{constructor(e,n,r){this.view=e,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let n of this.panels)n.destroy&&e.indexOf(n)<0&&n.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let e=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;e!=n.dom;)e=oS(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=oS(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function oS(t){let e=t.nextSibling;return t.remove(),e}const Py=He.define({enables:B7});class tu extends Nl{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}tu.prototype.elementClass="";tu.prototype.toDOM=void 0;tu.prototype.mapMode=Dr.TrackBefore;tu.prototype.startSide=tu.prototype.endSide=-1;tu.prototype.point=!0;const wM=1024;let j7=0;class Om{constructor(e,n){this.from=e,this.to=n}}class Et{constructor(e={}){this.id=j7++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Hr.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}Et.closedBy=new Et({deserialize:t=>t.split(" ")});Et.openedBy=new Et({deserialize:t=>t.split(" ")});Et.group=new Et({deserialize:t=>t.split(" ")});Et.isolate=new Et({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});Et.contextHash=new Et({perNode:!0});Et.lookAhead=new Et({perNode:!0});Et.mounted=new Et({perNode:!0});class Cc{constructor(e,n,r,i=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=i}static get(e){return e&&e.props&&e.props[Et.mounted.id]}}const H7=Object.create(null);class Hr{constructor(e,n,r,i=0){this.name=e,this.props=n,this.id=r,this.flags=i}static define(e){let n=e.props&&e.props.length?Object.create(null):H7,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new Hr(e.name||"",n,e.id,r);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(i)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(Et.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let i of r.split(" "))n[i]=e[r];return r=>{for(let i=r.prop(Et.group),s=-1;s<(i?i.length:0);s++){let o=n[s<0?r.name:i[s]];if(o)return o}}}}Hr.none=new Hr("",Object.create(null),0,8);class Nw{constructor(e){this.types=e;for(let n=0;n0;for(let a=this.cursor(o|Mn.IncludeAnonymous);;){let u=!1;if(a.from<=s&&a.to>=i&&(!l&&a.type.isAnonymous||n(a)!==!1)){if(a.firstChild())continue;u=!0}for(;u&&r&&(l||!a.type.isAnonymous)&&r(a),!a.nextSibling();){if(!a.parent())return;u=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Lw(Hr.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new Fn(this.type,n,r,i,this.propValues),e.makeTree||((n,r,i)=>new Fn(Hr.none,n,r,i)))}static build(e){return K7(e)}}Fn.empty=new Fn(Hr.none,[],[],0);class _w{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new _w(this.buffer,this.index)}}class Vo{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return Hr.none}toString(){let e=[];for(let n=0;n0));a=o[a+3]);return l}slice(e,n,r){let i=this.buffer,s=new Uint16Array(n-e),o=0;for(let l=e,a=0;l=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function Qc(t,e,n,r){for(var i;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?l.length:-1;e!=u;e+=n){let c=l[e],f=a[e]+o.from,d;if(!(!(s&Mn.EnterBracketed&&c instanceof Fn&&(d=Cc.get(c))&&!d.overlay&&d.bracketed&&r>=f&&r<=f+c.length)&&!bM(i,r,f,f+c.length))){if(c instanceof Vo){if(s&Mn.ExcludeBuffers)continue;let h=c.findChild(0,c.buffer.length,n,r-f,i);if(h>-1)return new Mo(new W7(o,c,e,f),null,h)}else if(s&Mn.IncludeAnonymous||!c.type.isAnonymous||Dw(c)){let h;if(!(s&Mn.IgnoreMounts)&&(h=Cc.get(c))&&!h.overlay)return new Si(h.tree,f,e,o);let p=new Si(c,f,e,o);return s&Mn.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(n<0?c.children.length-1:0,n,r,i,s)}}}if(s&Mn.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let i;if(!(r&Mn.IgnoreOverlays)&&(i=Cc.get(this._tree))&&i.overlay){let s=e-this.from,o=r&Mn.EnterBracketed&&i.bracketed;for(let{from:l,to:a}of i.overlay)if((n>0||o?l<=s:l=s:a>s))return new Si(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function aS(t,e,n,r){let i=t.cursor(),s=[];if(!i.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=i.type.is(n),!i.nextSibling())return s}for(;;){if(r!=null&&i.type.is(r))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return r==null?s:[]}}function Iy(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class W7{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class Mo extends xM{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.context.start,r);return s<0?null:new Mo(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Mn.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new Mo(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Mo(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Mo(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,i=this.index+4,s=r.buffer[this.index+3];if(s>i){let o=r.buffer[this.index+1];e.push(r.slice(i,s,o)),n.push(0)}return new Fn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function kM(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;sn.from||o.to=e){let l=new Si(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(Qc(l,e,n,!1))}}return i?kM(i):r}class Ny{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Mn.EnterBracketed,e instanceof Si)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:i}=this.buffer;return this.type=n||i.set.types[i.buffer[e]],this.from=r+i.buffer[e+1],this.to=r+i.buffer[e+2],!0}yield(e){return e?e instanceof Si?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.buffer.start,r);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&Mn.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Mn.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Mn.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:i}=this;if(i){if(e>0){if(this.index-1)for(let s=n+e,o=e<0?-1:r._tree.children.length;s!=o;s+=e){let l=r._tree.children[s];if(this.mode&Mn.IncludeAnonymous||l instanceof Vo||!l.type.isAnonymous||Dw(l))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;n=o,r=s+1;break e}i=this.stack[--s]}for(let i=r;i=0;s--){if(s<0)return Iy(this._tree,e,i);let o=r[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function Dw(t){return t.children.some(e=>e instanceof Vo||!e.type.isAnonymous||Dw(e))}function K7(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=wM,reused:s=[],minRepeatType:o=r.types.length}=t,l=Array.isArray(n)?new _w(n,n.length):n,a=r.types,u=0,c=0;function f(x,C,T,A,M,I){let{id:D,start:O,end:L,size:_}=l,re=c,ie=u;if(_<0)if(l.next(),_==-1){let N=s[D];T.push(N),A.push(O-x);return}else if(_==-3){u=D;return}else if(_==-4){c=D;return}else throw new RangeError(`Unrecognized record size: ${_}`);let se=a[D],H,X,R=O-x;if(L-O<=i&&(X=b(l.pos-C,M))){let N=new Uint16Array(X.size-X.skip),P=l.pos-X.size,B=N.length;for(;l.pos>P;)B=m(X.start,N,B);H=new Vo(N,L-X.start,r),R=X.start-x}else{let N=l.pos-_;l.next();let P=[],B=[],q=D>=o?D:-1,W=0,ye=L;for(;l.pos>N;)q>=0&&l.id==q&&l.size>=0?(l.end<=ye-i&&(p(P,B,O,W,l.end,ye,q,re,ie),W=P.length,ye=l.end),l.next()):I>2500?d(O,N,P,B):f(O,N,P,B,q,I+1);if(q>=0&&W>0&&W-1&&W>0){let ee=h(se,ie);H=Lw(se,P,B,0,P.length,0,L-O,ee,ee)}else H=g(se,P,B,L-O,re-L,ie)}T.push(H),A.push(R)}function d(x,C,T,A){let M=[],I=0,D=-1;for(;l.pos>C;){let{id:O,start:L,end:_,size:re}=l;if(re>4)l.next();else{if(D>-1&&L=0;_-=3)O[re++]=M[_],O[re++]=M[_+1]-L,O[re++]=M[_+2]-L,O[re++]=re;T.push(new Vo(O,M[2]-L,r)),A.push(L-x)}}function h(x,C){return(T,A,M)=>{let I=0,D=T.length-1,O,L;if(D>=0&&(O=T[D])instanceof Fn){if(!D&&O.type==x&&O.length==M)return O;(L=O.prop(Et.lookAhead))&&(I=A[D]+O.length+L)}return g(x,T,A,M,I,C)}}function p(x,C,T,A,M,I,D,O,L){let _=[],re=[];for(;x.length>A;)_.push(x.pop()),re.push(C.pop()+T-M);x.push(g(r.types[D],_,re,I-M,O-I,L)),C.push(M-T)}function g(x,C,T,A,M,I,D){if(I){let O=[Et.contextHash,I];D=D?[O].concat(D):[O]}if(M>25){let O=[Et.lookAhead,M];D=D?[O].concat(D):[O]}return new Fn(x,C,T,A,D)}function b(x,C){let T=l.fork(),A=0,M=0,I=0,D=T.end-i,O={size:0,start:0,skip:0};e:for(let L=T.pos-x;T.pos>L;){let _=T.size;if(T.id==C&&_>=0){O.size=A,O.start=M,O.skip=I,I+=4,A+=4,T.next();continue}let re=T.pos-_;if(_<0||re=o?4:0,se=T.start;for(T.next();T.pos>re;){if(T.size<0)if(T.size==-3||T.size==-4)ie+=4;else break e;else T.id>=o&&(ie+=4);T.next()}M=se,A+=_,I+=ie}return(C<0||A==x)&&(O.size=A,O.start=M,O.skip=I),O.size>4?O:void 0}function m(x,C,T){let{id:A,start:M,end:I,size:D}=l;if(l.next(),D>=0&&A4){let L=l.pos-(D-4);for(;l.pos>L;)T=m(x,C,T)}C[--T]=O,C[--T]=I-x,C[--T]=M-x,C[--T]=A}else D==-3?u=A:D==-4&&(c=A);return T}let v=[],w=[];for(;l.pos>0;)f(t.start||0,t.bufferStart||0,v,w,-1,0);let k=(e=t.length)!==null&&e!==void 0?e:v.length?w[0]+v[0].length:0;return new Fn(a[t.topID],v.reverse(),w.reverse(),k)}const uS=new WeakMap;function Qd(t,e){if(!t.isAnonymous||e instanceof Vo||e.type!=t)return 1;let n=uS.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof Fn)){n=1;break}n+=Qd(t,r)}uS.set(e,n)}return n}function Lw(t,e,n,r,i,s,o,l,a){let u=0;for(let p=r;p=c)break;C+=T}if(w==k+1){if(C>c){let T=p[k];h(T.children,T.positions,0,T.children.length,g[k]+v);continue}f.push(p[k])}else{let T=g[w-1]+p[w-1].length-x;f.push(Lw(t,p,g,k,w,x,T,null,a))}d.push(x+v-s)}}return h(e,n,r,i,0),(l||a)(f,d,o)}class El{constructor(e,n,r,i,s=!1,o=!1){this.from=e,this.to=n,this.tree=r,this.offset=i,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let i=[new El(0,e.length,e,0,!1,r)];for(let s of n)s.to>e.length&&i.push(s);return i}static applyChanges(e,n,r=128){if(!n.length)return e;let i=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,u=0;;l++){let c=l=r)for(;o&&o.from=d.from||f<=d.to||u){let h=Math.max(d.from,a)-u,p=Math.min(d.to,f)-u;d=h>=p?null:new El(h,p,d.tree,d.offset+u,l>0,!!c)}if(d&&i.push(d),o.to>f)break;o=snew Om(i.from,i.to)):[new Om(0,0)]:[new Om(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let i=this.startParse(e,n,r);for(;;){let s=i.advance();if(s)return s}}}class X7{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new Et({perNode:!0});let G7=0;class gi{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=G7++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof gi&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let i=new gi(r,[],null,[]);if(i.set.push(i),n)for(let s of n.set)i.set.push(s);return i}static defineModifier(e){let n=new Zh(e);return r=>r.modified.indexOf(n)>-1?r:Zh.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let q7=0;class Zh{constructor(e){this.name=e,this.instances=[],this.id=q7++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(l=>l.base==e&&Y7(n,l.modified));if(r)return r;let i=[],s=new gi(e.name,i,e,n);for(let l of n)l.instances.push(s);let o=J7(n);for(let l of e.set)if(!l.modified.length)for(let a of o)i.push(Zh.get(l,a));return s}}function Y7(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function J7(t){let e=[[]];for(let n=0;nr.length-n.length)}function CM(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let s=[],o=2,l=i;for(let f=0;;){if(l=="..."&&f>0&&f+3==i.length){o=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!d)throw new RangeError("Invalid path: "+i);if(s.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),f+=d[0].length,f==i.length)break;let h=i[f++];if(f==i.length&&h=="!"){o=0;break}if(h!="/")throw new RangeError("Invalid path: "+i);l=i.slice(f)}let a=s.length-1,u=s[a];if(!u)throw new RangeError("Invalid path: "+i);let c=new Zc(r,o,a>0?s.slice(0,a):null);e[u]=c.sort(e[u])}}return TM.add(e)}const TM=new Et({combine(t,e){let n,r,i;for(;t||e;){if(!t||e&&t.depth>=e.depth?(i=e,e=e.next):(i=t,t=t.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let s=new Zc(i.tags,i.mode,i.context);n?n.next=s:r=s,n=s}return r}});class Zc{constructor(e,n,r,i){this.tags=e,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=i;for(let l of s)for(let a of l.set){let u=n[a.id];if(u){o=o?o+" "+u:u;break}}return o},scope:r}}function Q7(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function Z7(t,e,n,r=0,i=t.length){let s=new eK(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class eK{constructor(e,n,r){this.at=e,this.highlighters=n,this.span=r,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,r,i,s){let{type:o,from:l,to:a}=e;if(l>=r||a<=n)return;o.isTop&&(s=this.highlighters.filter(h=>!h.scope||h.scope(o)));let u=i,c=tK(e)||Zc.empty,f=Q7(s,c.tags);if(f&&(u&&(u+=" "),u+=f,c.mode==1&&(i+=(i?" ":"")+f)),this.startSpan(Math.max(n,l),u),c.opaque)return;let d=e.tree&&e.tree.prop(Et.mounted);if(d&&d.overlay){let h=e.node.enter(d.overlay[0].from+l,1),p=this.highlighters.filter(b=>!b.scope||b.scope(d.tree.type)),g=e.firstChild();for(let b=0,m=l;;b++){let v=b=w||!e.nextSibling())););if(!v||w>r)break;m=v.to+l,m>n&&(this.highlightRange(h.cursor(),Math.max(n,v.from+l),Math.min(r,m),"",p),this.startSpan(Math.min(r,m),u))}g&&e.parent()}else if(e.firstChild()){d&&(i="");do if(!(e.to<=n)){if(e.from>=r)break;this.highlightRange(e,n,r,i,s),this.startSpan(Math.min(r,e.to),u)}while(e.nextSibling());e.parent()}}}function tK(t){let e=t.type.prop(TM);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const ke=gi.define,Ed=ke(),vo=ke(),cS=ke(vo),fS=ke(vo),wo=ke(),Ad=ke(wo),Pm=ke(wo),ds=ke(),al=ke(ds),cs=ke(),fs=ke(),_y=ke(),Vu=ke(_y),Md=ke(),Ge={comment:Ed,lineComment:ke(Ed),blockComment:ke(Ed),docComment:ke(Ed),name:vo,variableName:ke(vo),typeName:cS,tagName:ke(cS),propertyName:fS,attributeName:ke(fS),className:ke(vo),labelName:ke(vo),namespace:ke(vo),macroName:ke(vo),literal:wo,string:Ad,docString:ke(Ad),character:ke(Ad),attributeValue:ke(Ad),number:Pm,integer:ke(Pm),float:ke(Pm),bool:ke(wo),regexp:ke(wo),escape:ke(wo),color:ke(wo),url:ke(wo),keyword:cs,self:ke(cs),null:ke(cs),atom:ke(cs),unit:ke(cs),modifier:ke(cs),operatorKeyword:ke(cs),controlKeyword:ke(cs),definitionKeyword:ke(cs),moduleKeyword:ke(cs),operator:fs,derefOperator:ke(fs),arithmeticOperator:ke(fs),logicOperator:ke(fs),bitwiseOperator:ke(fs),compareOperator:ke(fs),updateOperator:ke(fs),definitionOperator:ke(fs),typeOperator:ke(fs),controlOperator:ke(fs),punctuation:_y,separator:ke(_y),bracket:Vu,angleBracket:ke(Vu),squareBracket:ke(Vu),paren:ke(Vu),brace:ke(Vu),content:ds,heading:al,heading1:ke(al),heading2:ke(al),heading3:ke(al),heading4:ke(al),heading5:ke(al),heading6:ke(al),contentSeparator:ke(ds),list:ke(ds),quote:ke(ds),emphasis:ke(ds),strong:ke(ds),link:ke(ds),monospace:ke(ds),strikethrough:ke(ds),inserted:ke(),deleted:ke(),changed:ke(),invalid:ke(),meta:Md,documentMeta:ke(Md),annotation:ke(Md),processingInstruction:ke(Md),definition:gi.defineModifier("definition"),constant:gi.defineModifier("constant"),function:gi.defineModifier("function"),standard:gi.defineModifier("standard"),local:gi.defineModifier("local"),special:gi.defineModifier("special")};for(let t in Ge){let e=Ge[t];e instanceof gi&&(e.name=t)}EM([{tag:Ge.link,class:"tok-link"},{tag:Ge.heading,class:"tok-heading"},{tag:Ge.emphasis,class:"tok-emphasis"},{tag:Ge.strong,class:"tok-strong"},{tag:Ge.keyword,class:"tok-keyword"},{tag:Ge.atom,class:"tok-atom"},{tag:Ge.bool,class:"tok-bool"},{tag:Ge.url,class:"tok-url"},{tag:Ge.labelName,class:"tok-labelName"},{tag:Ge.inserted,class:"tok-inserted"},{tag:Ge.deleted,class:"tok-deleted"},{tag:Ge.literal,class:"tok-literal"},{tag:Ge.string,class:"tok-string"},{tag:Ge.number,class:"tok-number"},{tag:[Ge.regexp,Ge.escape,Ge.special(Ge.string)],class:"tok-string2"},{tag:Ge.variableName,class:"tok-variableName"},{tag:Ge.local(Ge.variableName),class:"tok-variableName tok-local"},{tag:Ge.definition(Ge.variableName),class:"tok-variableName tok-definition"},{tag:Ge.special(Ge.variableName),class:"tok-variableName2"},{tag:Ge.definition(Ge.propertyName),class:"tok-propertyName tok-definition"},{tag:Ge.typeName,class:"tok-typeName"},{tag:Ge.namespace,class:"tok-namespace"},{tag:Ge.className,class:"tok-className"},{tag:Ge.macroName,class:"tok-macroName"},{tag:Ge.propertyName,class:"tok-propertyName"},{tag:Ge.operator,class:"tok-operator"},{tag:Ge.comment,class:"tok-comment"},{tag:Ge.meta,class:"tok-meta"},{tag:Ge.invalid,class:"tok-invalid"},{tag:Ge.punctuation,class:"tok-punctuation"}]);var Im;const Ta=new Et;function nK(t){return He.define({combine:t?e=>e.concat(t):void 0})}const rK=new Et;class Xi{constructor(e,n,r=[],i=""){this.data=e,this.name=i,zt.prototype.hasOwnProperty("tree")||Object.defineProperty(zt.prototype,"tree",{get(){return As(this)}}),this.parser=n,this.extension=[ru.of(this),zt.languageData.of((s,o,l)=>{let a=dS(s,o,l),u=a.type.prop(Ta);if(!u)return[];let c=s.facet(u),f=a.type.prop(rK);if(f){let d=a.resolve(o-a.from,l);for(let h of f)if(h.test(d,s)){let p=s.facet(h.facet);return h.type=="replace"?p:p.concat(c)}}return c})].concat(r)}isActiveAt(e,n,r=-1){return dS(e,n,r).type.prop(Ta)==this.data}findRegions(e){let n=e.facet(ru);if((n==null?void 0:n.data)==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(s,o)=>{if(s.prop(Ta)==this.data){r.push({from:o,to:o+s.length});return}let l=s.prop(Et.mounted);if(l){if(l.tree.prop(Ta)==this.data){if(l.overlay)for(let a of l.overlay)r.push({from:a.from+o,to:a.to+o});else r.push({from:o,to:o+s.length});return}else if(l.overlay){let a=r.length;if(i(l.tree,l.overlay[0].from+o),r.length>a)return}}for(let a=0;ar.isTop?n:void 0)]}),e.name)}configure(e,n){return new ep(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function As(t){let e=t.field(Xi.state,!1);return e?e.tree:Fn.empty}class iK{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let r=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Uu=null;class tp{constructor(e,n,r=[],i,s,o,l,a){this.parser=e,this.state=n,this.fragments=r,this.tree=i,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new tp(e,n,[],Fn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new iK(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=Fn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(El.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Uu;Uu=this;try{return e()}finally{Uu=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=hS(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:i,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((u,c,f,d)=>a.push({fromA:u,toA:c,fromB:f,toB:d})),r=El.applyChanges(r,a),i=Fn.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let c=e.mapPos(u.from,1),f=e.mapPos(u.to,-1);ce.from&&(this.fragments=hS(this.fragments,i,s),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends SM{createParse(n,r,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let a=Uu;if(a){for(let u of i)a.tempSkipped.push(u);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new Fn(Hr.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Uu}}function hS(t,e,n){return El.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class nu{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new nu(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=tp.create(e.facet(ru).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new nu(r)}}Xi.state=Os.define({create:nu.init,update(t,e){for(let n of e.effects)if(n.is(Xi.setState))return n.value;return e.startState.facet(ru)!=e.state.facet(ru)?nu.init(e.state):t.apply(e)}});let AM=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(AM=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const Nm=typeof navigator<"u"&&(!((Im=navigator.scheduling)===null||Im===void 0)&&Im.isInputPending)?()=>navigator.scheduling.isInputPending():null,sK=Ei.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(Xi.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(Xi.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=AM(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEndi+1e3,a=s.context.work(()=>Nm&&Nm()||Date.now()>o,i+(l?0:1e5));this.chunkBudget-=Date.now()-n,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Xi.setState.of(new nu(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>vi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),ru=He.define({combine(t){return t.length?t[0]:null},enables:t=>[Xi.state,sK,qe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class oK{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const lK=He.define(),$w=He.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function np(t){let e=t.facet($w);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function rp(t,e){let n="",r=t.tabSize,i=t.facet($w)[0];if(i==" "){for(;e>=r;)n+=" ",e-=r;i=" "}for(let s=0;s=e?aK(t,n,e):null}class Gp{constructor(e,n={}){this.state=e,this.options=n,this.unit=np(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:s}=this.options;return i!=null&&i>=r.from&&i<=r.to?s&&i==e?{text:"",from:e}:(n<0?i-1&&(s+=o-this.countColumn(r,r.search(/\S|$/))),s}countColumn(e,n=e.length){return jp(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:i}=this.lineAt(e,n),s=this.options.overrideIndentation;if(s){let o=s(i);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const RM=new Et;function aK(t,e,n){let r=e.resolveStack(n),i=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let s=[];for(let o=i;o&&!(o.fromr.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)r={node:s[o],next:r}}return OM(r,t,n)}function OM(t,e,n){for(let r=t;r;r=r.next){let i=cK(r.node);if(i)return i(Fw.create(e,n,r))}return 0}function uK(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function cK(t){let e=t.type.prop(RM);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(Et.closedBy))){let i=t.lastChild,s=i&&r.indexOf(i.name)>-1;return o=>pK(o,!0,1,void 0,s&&!uK(o)?i.from:void 0)}return t.parent==null?fK:null}function fK(){return 0}class Fw extends Gp{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new Fw(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(dK(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return OM(this.context.next,this.base,this.pos)}}function dK(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function hK(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let i=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=i==null||i<=s.from?s.to:Math.min(s.to,i);for(let l=n.to;;){let a=e.childAfter(l);if(!a||a==r)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let u=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+u}}l=a.to}}function pK(t,e,n,r,i){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=r&&s.slice(o,o+r.length)==r||i==t.pos+o,a=hK(t);return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*n)}function pS({except:t,units:e=1}={}){return n=>{let r=t&&t.test(n.textAfter);return n.baseIndent+(r?0:e*n.unit)}}const gK=new Et;function mK(t){let e=t.firstChild,n=t.lastChild;return e&&e.tol.prop(Ta)==o.data:o?l=>l==o:void 0,this.style=EM(e.map(l=>({tag:l.tag,class:l.class||i(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=r?new jo(r):null,this.themeType=n.themeType}static define(e,n){return new qp(e,n||{})}}const Dy=He.define(),yK=He.define({combine(t){return t.length?[t[0]]:null}});function _m(t){let e=t.facet(Dy);return e.length?e:t.facet(yK)}function gS(t,e){let n=[wK],r;return t instanceof qp&&(t.module&&n.push(qe.styleModule.of(t.module)),r=t.themeType),r?n.push(Dy.computeN([qe.darkTheme],i=>i.facet(qe.darkTheme)==(r=="dark")?[t]:[])):n.push(Dy.of(t)),n}class vK{constructor(e){this.markCache=Object.create(null),this.tree=As(e.state),this.decorations=this.buildDeco(e,_m(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=As(e.state),r=_m(e.state),i=r!=_m(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);n.length=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(n!=this.tree||e.viewportChanged||i)&&(this.tree=n,this.decorations=this.buildDeco(e.view,r),this.decoratedTo=s.to)}buildDeco(e,n){if(!n||!this.tree.length)return en.none;let r=new Ja;for(let{from:i,to:s}of e.visibleRanges)Z7(this.tree,n,(o,l,a)=>{r.add(o,l,this.markCache[a]||(this.markCache[a]=en.mark({class:a})))},i,s);return r.finish()}}const wK=ww.high(Ei.fromClass(vK,{decorations:t=>t.decorations})),bK=1e4,xK="()[]{}",kK=new Et;function Ly(t,e,n){let r=t.prop(e<0?Et.openedBy:Et.closedBy);if(r)return r;if(t.name.length==1){let i=n.indexOf(t.name);if(i>-1&&i%2==(e<0?1:0))return[n[i+e]]}return null}function $y(t){let e=t.type.prop(kK);return e?e(t.node):t}function Ea(t,e,n,r={}){let i=r.maxScanDistance||bK,s=r.brackets||xK,o=As(t),l=o.resolveInner(e,n);for(let a=l;a;a=a.parent){let u=Ly(a.type,n,s);if(u&&a.from0?e>=c.from&&ec.from&&e<=c.to))return SK(t,e,n,a,c,u,s)}}return CK(t,e,n,o,l.type,i,s)}function SK(t,e,n,r,i,s,o){let l=r.parent,a={from:i.from,to:i.to},u=0,c=l==null?void 0:l.cursor();if(c&&(n<0?c.childBefore(r.from):c.childAfter(r.to)))do if(n<0?c.to<=r.from:c.from>=r.to){if(u==0&&s.indexOf(c.type.name)>-1&&c.from0)return null;let u={from:n<0?e-1:e,to:n>0?e+1:e},c=t.doc.iterRange(e,n>0?t.doc.length:0),f=0;for(let d=0;!c.next().done&&d<=s;){let h=c.value;n<0&&(d+=h.length);let p=e+d*n;for(let g=n>0?0:h.length-1,b=n>0?h.length:-1;g!=b;g+=n){let m=o.indexOf(h[g]);if(!(m<0||r.resolveInner(p+g,1).type!=i))if(m%2==0==n>0)f++;else{if(f==1)return{start:u,end:{from:p+g,to:p+g+1},matched:m>>1==a>>1};f--}}n>0&&(d+=h.length)}return c.done?{start:u,matched:!1}:null}const TK=Object.create(null),mS=[Hr.none],yS=[],vS=Object.create(null),EK=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])EK[t]=AK(TK,e);function Dm(t,e){yS.indexOf(t)>-1||(yS.push(t),console.warn(e))}function AK(t,e){let n=[];for(let l of e.split(" ")){let a=[];for(let u of l.split(".")){let c=t[u]||Ge[u];c?typeof c=="function"?a.length?a=a.map(c):Dm(u,`Modifier ${u} used at start of tag`):a.length?Dm(u,`Tag ${u} used as modifier`):a=Array.isArray(c)?c:[c]:Dm(u,`Unknown highlighting tag ${u}`)}for(let u of a)n.push(u)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),i=r+" "+n.map(l=>l.id),s=vS[i];if(s)return s.id;let o=vS[i]=Hr.define({id:mS.length,name:r,props:[CM({[r]:n})]});return mS.push(o),o.id}Rn.RTL,Rn.LTR;const MK=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=Bw(t.state,n.from);return r.line?RK(t):r.block?PK(t):!1};function zw(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=t(e,n);return i?(r(n.update(i)),!0):!1}}const RK=zw(_K,0),OK=zw(PM,0),PK=zw((t,e)=>PM(t,e,NK(e)),0);function Bw(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Ku=50;function IK(t,{open:e,close:n},r,i){let s=t.sliceDoc(r-Ku,r),o=t.sliceDoc(i,i+Ku),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,u=s.length-l;if(s.slice(u-e.length,u)==e&&o.slice(a,a+n.length)==n)return{open:{pos:r-l,margin:l&&1},close:{pos:i+a,margin:a&&1}};let c,f;i-r<=2*Ku?c=f=t.sliceDoc(r,i):(c=t.sliceDoc(r,r+Ku),f=t.sliceDoc(i-Ku,i));let d=/^\s*/.exec(c)[0].length,h=/\s*$/.exec(f)[0].length,p=f.length-h-n.length;return c.slice(d,d+e.length)==e&&f.slice(p,p+n.length)==n?{open:{pos:r+d+e.length,margin:/\s/.test(c.charAt(d+e.length))?1:0},close:{pos:i-h-n.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function NK(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),i=n.to<=r.to?r:t.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let s=e.length-1;s>=0&&e[s].to>r.from?e[s].to=i.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return e}function PM(t,e,n=e.selection.ranges){let r=n.map(s=>Bw(e,s.from).block);if(!r.every(s=>s))return null;let i=n.map((s,o)=>IK(e,r[o],s.from,s.to));if(t!=2&&!i.every(s=>s))return{changes:e.changes(n.map((s,o)=>i[o]?[]:[{from:s.from,insert:r[o].open+" "},{from:s.to,insert:" "+r[o].close}]))};if(t!=1&&i.some(s=>s)){let s=[];for(let o=0,l;oi&&(s==o||o>f.from)){i=f.from;let d=/^\s*/.exec(f.text)[0].length,h=d==f.length,p=f.text.slice(d,d+u.length)==u?d:-1;ds.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:u,empty:c,single:f}of r)(f||!c)&&s.push({from:l.from+u,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&r.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of r)if(l>=0){let u=o.from+l,c=u+a.length;o.text[c-o.from]==" "&&c++,s.push({from:u,to:c})}return{changes:s}}return null}const Fy=qo.define(),DK=qo.define(),LK=He.define(),IM=He.define({combine(t){return wA(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,i)=>e(r,i)||n(r,i)})}}),NM=Os.define({create(){return xs.empty},update(t,e){let n=e.state.facet(IM),r=e.annotation(Fy);if(r){let a=Fr.fromTransaction(e,r.selection),u=r.side,c=u==0?t.undone:t.done;return a?c=ip(c,c.length,n.minDepth,a):c=LM(c,e.startState.selection),new xs(u==0?r.rest:c,u==0?c:r.rest)}let i=e.annotation(DK);if((i=="full"||i=="before")&&(t=t.isolate()),e.annotation(Gn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=Fr.fromTransaction(e),o=e.annotation(Gn.time),l=e.annotation(Gn.userEvent);return s?t=t.addChanges(s,o,l,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,l,n.newGroupDelay)),(i=="full"||i=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new xs(t.done.map(Fr.fromJSON),t.undone.map(Fr.fromJSON))}});function $K(t={}){return[NM,IM.of(t),qe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?_M:e.inputType=="historyRedo"?zy:null;return r?(e.preventDefault(),r(n)):!1}})]}function Yp(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let i=n.field(NM,!1);if(!i)return!1;let s=i.pop(t,n,e);return s?(r(s),!0):!1}}const _M=Yp(0,!1),zy=Yp(1,!1),FK=Yp(0,!0),zK=Yp(1,!0);class Fr{constructor(e,n,r,i,s){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=i,this.selectionsAfter=s}setSelAfter(e){return new Fr(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new Fr(e.changes&&Vn.fromJSON(e.changes),[],e.mapped&&Es.fromJSON(e.mapped),e.startSelection&&de.fromJSON(e.startSelection),e.selectionsAfter.map(de.fromJSON))}static fromTransaction(e,n){let r=bi;for(let i of e.startState.facet(LK)){let s=i(e);s.length&&(r=r.concat(s))}return!r.length&&e.changes.empty?null:new Fr(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new Fr(void 0,bi,void 0,void 0,e)}}function ip(t,e,n,r){let i=e+1>n+20?e-n-1:0,s=t.slice(i,e);return s.push(r),s}function BK(t,e){let n=[],r=!1;return t.iterChangedRanges((i,s)=>n.push(i,s)),e.iterChangedRanges((i,s,o,l)=>{for(let a=0;a=u&&o<=c&&(r=!0)}}),r}function jK(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function DM(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],HK=200;function LM(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-HK));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),ip(t,t.length-1,1e9,n.setSelAfter(r)))}else return[Fr.selection([e])]}function WK(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Lm(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let i=VK(t[n-1],e,r);if(i.changes&&!i.changes.empty||i.effects.length){let s=t.slice(0,n);return s[n-1]=i,s}else e=i.mapped,n--,r=i.selectionsAfter}return r.length?[Fr.selection(r)]:bi}function VK(t,e,n){let r=DM(t.selectionsAfter.length?t.selectionsAfter.map(l=>l.map(e)):bi,n);if(!t.changes)return Fr.selection(r);let i=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new Fr(i,on.mapEffects(t.effects,e),o,t.startSelection.map(s),r)}const UK=/^(input\.type|delete)($|\.)/;class xs{constructor(e,n,r=0,i=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=i}isolate(){return this.prevTime?new xs(this.done,this.undone):this}addChanges(e,n,r,i,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!r||UK.test(r))&&(!l.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Jp(n,e))}function br(t){return t.textDirectionAt(t.state.selection.main.head)==Rn.LTR}const FM=t=>$M(t,!br(t)),zM=t=>$M(t,br(t));function BM(t,e){return ns(t,n=>n.empty?t.moveByGroup(n,e):Jp(n,e))}const XK=t=>BM(t,!br(t)),GK=t=>BM(t,br(t));function qK(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Qp(t,e,n){let r=As(t).resolveInner(e.head),i=n?Et.closedBy:Et.openedBy;for(let a=e.head;;){let u=n?r.childAfter(a):r.childBefore(a);if(!u)break;qK(t,u,i)?r=u:a=n?u.to:u.from}let s=r.type.prop(i),o,l;return s&&(o=n?Ea(t,r.from,1):Ea(t,r.to,-1))&&o.matched?l=n?o.end.to:o.end.from:l=n?r.to:r.from,de.cursor(l,n?-1:1)}const YK=t=>ns(t,e=>Qp(t.state,e,!br(t))),JK=t=>ns(t,e=>Qp(t.state,e,br(t)));function jM(t,e){return ns(t,n=>{if(!n.empty)return Jp(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const HM=t=>jM(t,!1),WM=t=>jM(t,!0);function VM(t){let e=t.scrollDOM.clientHeighto.empty?t.moveVertically(o,e,n.height):Jp(o,e));if(i.eq(r.selection))return!1;let s;if(n.selfScroll){let o=t.coordsAtPos(r.selection.main.head),l=t.scrollDOM.getBoundingClientRect(),a=l.top+n.marginTop,u=l.bottom-n.marginBottom;o&&o.top>a&&o.bottomUM(t,!1),By=t=>UM(t,!0);function Yo(t,e,n){let r=t.lineBlockAt(e.head),i=t.moveToLineBoundary(e,n);if(i.head==e.head&&i.head!=(n?r.to:r.from)&&(i=t.moveToLineBoundary(e,n,!1)),!n&&i.head==r.from&&r.length){let s=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;s&&e.head!=r.from+s&&(i=de.cursor(r.from+s))}return i}const QK=t=>ns(t,e=>Yo(t,e,!0)),ZK=t=>ns(t,e=>Yo(t,e,!1)),eX=t=>ns(t,e=>Yo(t,e,!br(t))),tX=t=>ns(t,e=>Yo(t,e,br(t))),nX=t=>ns(t,e=>de.cursor(t.lineBlockAt(e.head).from,1)),rX=t=>ns(t,e=>de.cursor(t.lineBlockAt(e.head).to,-1));function iX(t,e,n){let r=!1,i=mu(t.selection,s=>{let o=Ea(t,s.head,-1)||Ea(t,s.head,1)||s.head>0&&Ea(t,s.head-1,1)||s.headiX(t,e);function Ai(t,e,n){let r=mu(t.state.selection,i=>{i.undirectional&&i.head>=i.anchor!=e&&(i=de.range(i.head,i.anchor));let s=n(i);return de.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(ts(t.state,r)),!0)}function KM(t,e){return Ai(t,e,n=>t.moveByChar(n,e))}const XM=t=>KM(t,!br(t)),GM=t=>KM(t,br(t));function qM(t,e){return Ai(t,e,n=>t.moveByGroup(n,e))}const oX=t=>qM(t,!br(t)),lX=t=>qM(t,br(t)),aX=t=>{let e=!br(t);return Ai(t,e,n=>Qp(t.state,n,e))},uX=t=>{let e=br(t);return Ai(t,e,n=>Qp(t.state,n,e))};function YM(t,e){return Ai(t,e,n=>t.moveVertically(n,e))}const JM=t=>YM(t,!1),QM=t=>YM(t,!0);function ZM(t,e){return Ai(t,e,n=>t.moveVertically(n,e,VM(t).height))}const bS=t=>ZM(t,!1),xS=t=>ZM(t,!0),cX=t=>Ai(t,!0,e=>Yo(t,e,!0)),fX=t=>Ai(t,!1,e=>Yo(t,e,!1)),dX=t=>{let e=!br(t);return Ai(t,e,n=>Yo(t,n,e))},hX=t=>{let e=br(t);return Ai(t,e,n=>Yo(t,n,e))},pX=t=>Ai(t,!1,e=>de.cursor(t.lineBlockAt(e.head).from)),gX=t=>Ai(t,!0,e=>de.cursor(t.lineBlockAt(e.head).to)),kS=({state:t,dispatch:e})=>(e(ts(t,{anchor:0})),!0),SS=({state:t,dispatch:e})=>(e(ts(t,{anchor:t.doc.length})),!0),CS=({state:t,dispatch:e})=>(e(ts(t,{anchor:t.selection.main.anchor,head:0})),!0),TS=({state:t,dispatch:e})=>(e(ts(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),mX=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),yX=({state:t,dispatch:e})=>{let n=Zp(t).map(({from:r,to:i})=>de.undirectionalRange(r,Math.min(i+1,t.doc.length)));return e(t.update({selection:de.create(n),userEvent:"select"})),!0},vX=({state:t,dispatch:e})=>{let n=mu(t.selection,r=>{let i=As(t),s=i.resolveStack(r.from,1);if(r.empty){let o=i.resolveStack(r.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from=r.to||l.to>r.to&&l.from<=r.from)&&o.next)return de.undirectionalRange(l.from,l.to)}return r});return n.eq(t.selection)?!1:(e(ts(t,n)),!0)};function eR(t,e){let{state:n}=t,r=n.selection,i=n.selection.ranges.slice();for(let s of n.selection.ranges){let o=n.doc.lineAt(s.head);if(e?o.to0)for(let l=s;;){let a=t.moveVertically(l,e);if(a.heado.to){i.some(u=>u.head==a.head)||i.push(a);break}else{if(a.head==l.head)break;l=a}}}return i.length==r.ranges.length?!1:(t.dispatch(ts(n,de.create(i,i.length-1))),!0)}const wX=t=>eR(t,!1),bX=t=>eR(t,!0),xX=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=de.create([n.main]):n.main.empty||(r=de.create([de.cursor(n.main.head)])),r?(e(ts(t,r)),!0):!1};function bf(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,i=r.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);ao&&(n="delete.forward",a=Rd(t,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Rd(t,o,!1),l=Rd(t,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:de.cursor(o,oi(t)))r.between(e,e,(i,s)=>{ie&&(e=n?s:i)});return e}const tR=(t,e,n)=>bf(t,r=>{let i=r.from,{state:s}=t,o=s.doc.lineAt(i),l,a;if(n&&!e&&i>o.from&&itR(t,!1,!0),nR=t=>tR(t,!0,!1),rR=(t,e)=>bf(t,n=>{let r=n.head,{state:i}=t,s=i.doc.lineAt(r),o=i.charCategorizer(r);for(let l=null;;){if(r==(e?s.to:s.from)){r==n.head&&s.number!=(e?i.doc.lines:1)&&(r+=e?1:-1);break}let a=vr(s.text,r-s.from,e)+s.from,u=s.text.slice(Math.min(r,a)-s.from,Math.max(r,a)-s.from),c=o(u);if(l!=null&&c!=l)break;(u!=" "||r!=n.head)&&(l=c),r=a}return r}),iR=t=>rR(t,!1),kX=t=>rR(t,!0),SX=t=>bf(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headbf(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),TX=t=>bf(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:_t.of(["",""])},range:de.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},AX=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let i=r.from,s=t.doc.lineAt(i),o=i==s.from?i-1:vr(s.text,i-s.from,!1)+s.from,l=i==s.to?i+1:vr(s.text,i-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:t.doc.slice(i,l).append(t.doc.slice(o,i))},range:de.cursor(l)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Zp(t){let e=[],n=-1;for(let r of t.selection.ranges){let i=t.doc.lineAt(r.from),s=t.doc.lineAt(r.to);if(!r.empty&&r.to==s.from&&(s=t.doc.lineAt(r.to-1)),n>=i.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(r)}else e.push({from:i.from,to:s.to,ranges:[r]});n=s.number+1}return e}function sR(t,e,n){if(t.readOnly)return!1;let r=[],i=[];for(let s of Zp(t)){if(n?s.to==t.doc.length:s.from==0)continue;let o=t.doc.lineAt(n?s.to+1:s.from-1),l=o.length+1;if(n){r.push({from:s.to,to:o.to},{from:s.from,insert:o.text+t.lineBreak});for(let a of s.ranges)i.push(de.range(Math.min(t.doc.length,a.anchor+l),Math.min(t.doc.length,a.head+l)))}else{r.push({from:o.from,to:s.from},{from:s.to,insert:t.lineBreak+o.text});for(let a of s.ranges)i.push(de.range(a.anchor-l,a.head-l))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:de.create(i,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MX=({state:t,dispatch:e})=>sR(t,e,!1),RX=({state:t,dispatch:e})=>sR(t,e,!0);function oR(t,e,n){if(t.readOnly)return!1;let r=[];for(let s of Zp(t))n?r.push({from:s.from,insert:t.doc.slice(s.from,s.to)+t.lineBreak}):r.push({from:s.to,insert:t.lineBreak+t.doc.slice(s.from,s.to)});let i=t.changes(r);return e(t.update({changes:i,selection:t.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const OX=({state:t,dispatch:e})=>oR(t,e,!1),PX=({state:t,dispatch:e})=>oR(t,e,!0),IX=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Zp(e).map(({from:i,to:s})=>(i>0?i--:s{let s;if(t.lineWrapping){let o=t.lineBlockAt(i.head),l=t.coordsAtPos(i.head,i.assoc||1);l&&(s=o.bottom+t.documentTop-l.bottom+t.defaultLineHeight/2)}return t.moveVertically(i,!0,s)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function NX(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=As(t).resolveInner(e),r=n.childBefore(e),i=n.childAfter(e),s;return r&&i&&r.to<=e&&i.from>=e&&(s=r.type.prop(Et.closedBy))&&s.indexOf(i.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(i.from).from&&!/\S/.test(t.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}const ES=lR(!1),_X=lR(!0);function lR(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(i=>{let{from:s,to:o}=i,l=e.doc.lineAt(s),a=!t&&s==o&&NX(e,s);t&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let u=new Gp(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=MM(u,s);for(c==null&&(c=jp(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));ol.from&&s{let i=[];for(let o=r.from;o<=r.to;){let l=t.doc.lineAt(o);l.number>n&&(r.empty||r.to>l.from)&&(e(l,i,r),n=l.number),o=l.to+1}let s=t.changes(i);return{changes:i,range:de.range(s.mapPos(r.anchor,1),s.mapPos(r.head,1))}})}const DX=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new Gp(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),i=jw(t,(s,o,l)=>{let a=MM(r,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let u=/^\s*/.exec(s.text)[0],c=rp(t,a);(u!=c||l.fromt.readOnly?!1:(e(t.update(jw(t,(n,r)=>{r.push({from:n.from,insert:t.facet($w)})}),{userEvent:"input.indent"})),!0),uR=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(jw(t,(n,r)=>{let i=/^\s*/.exec(n.text)[0];if(!i)return;let s=jp(i,t.tabSize),o=0,l=rp(t,Math.max(0,s-np(t)));for(;o(t.setTabFocusMode(),!0),$X=[{key:"Ctrl-b",run:FM,shift:XM,preventDefault:!0},{key:"Ctrl-f",run:zM,shift:GM},{key:"Ctrl-p",run:HM,shift:JM},{key:"Ctrl-n",run:WM,shift:QM},{key:"Ctrl-a",run:nX,shift:pX},{key:"Ctrl-e",run:rX,shift:gX},{key:"Ctrl-d",run:nR},{key:"Ctrl-h",run:jy},{key:"Ctrl-k",run:SX},{key:"Ctrl-Alt-h",run:iR},{key:"Ctrl-o",run:EX},{key:"Ctrl-t",run:AX},{key:"Ctrl-v",run:By}],FX=[{key:"ArrowLeft",run:FM,shift:XM,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:XK,shift:oX,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:eX,shift:dX,preventDefault:!0},{key:"ArrowRight",run:zM,shift:GM,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:GK,shift:lX,preventDefault:!0},{mac:"Cmd-ArrowRight",run:tX,shift:hX,preventDefault:!0},{key:"ArrowUp",run:HM,shift:JM,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kS,shift:CS},{mac:"Ctrl-ArrowUp",run:wS,shift:bS},{key:"ArrowDown",run:WM,shift:QM,preventDefault:!0},{mac:"Cmd-ArrowDown",run:SS,shift:TS},{mac:"Ctrl-ArrowDown",run:By,shift:xS},{key:"PageUp",run:wS,shift:bS},{key:"PageDown",run:By,shift:xS},{key:"Home",run:ZK,shift:fX,preventDefault:!0},{key:"Mod-Home",run:kS,shift:CS},{key:"End",run:QK,shift:cX,preventDefault:!0},{key:"Mod-End",run:SS,shift:TS},{key:"Enter",run:ES,shift:ES},{key:"Mod-a",run:mX},{key:"Backspace",run:jy,shift:jy,preventDefault:!0},{key:"Delete",run:nR,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:iR,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:kX,preventDefault:!0},{mac:"Mod-Backspace",run:CX,preventDefault:!0},{mac:"Mod-Delete",run:TX,preventDefault:!0}].concat($X.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),zX=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:YK,shift:aX},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:JK,shift:uX},{key:"Alt-ArrowUp",run:MX},{key:"Shift-Alt-ArrowUp",run:OX},{key:"Alt-ArrowDown",run:RX},{key:"Shift-Alt-ArrowDown",run:PX},{key:"Mod-Alt-ArrowUp",run:wX},{key:"Mod-Alt-ArrowDown",run:bX},{key:"Escape",run:xX},{key:"Mod-Enter",run:_X},{key:"Alt-l",mac:"Ctrl-l",run:yX},{key:"Mod-i",run:vX,preventDefault:!0},{key:"Mod-[",run:uR},{key:"Mod-]",run:aR},{key:"Mod-Alt-\\",run:DX},{key:"Shift-Mod-k",run:IX},{key:"Shift-Mod-\\",run:sX},{key:"Mod-/",run:MK},{key:"Alt-A",mac:"Ctrl-A",run:OK},{key:"Ctrl-m",mac:"Shift-Alt-m",run:LX}].concat(FX),BX={key:"Tab",run:aR,shift:uR};var AS={};class sp{constructor(e,n,r,i,s,o,l,a,u,c=0,f){this.p=e,this.stack=n,this.state=r,this.reducePos=i,this.pos=s,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=u,this.lookAhead=c,this.parent=f}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,r=0){let i=e.parser.context;return new sp(e,[],n,r,r,0,[],0,i?new MS(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let r=e>>19,i=e&65535,{parser:s}=this.p,o=this.reducePos=2e3&&!(!((n=this.p.parser.nodeSet.types[i])===null||n===void 0)&&n.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSizea;)this.stack.pop();this.reduceContext(i,u)}storeNode(e,n,r,i=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(n==r)return;if(this.buffer[o-2]>=n){this.buffer[o-2]=r;return}}}if(!s||this.pos==r)this.buffer.push(e,n,r,i);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>r;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>r;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,i>4&&(i-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=r,this.buffer[o+3]=i}}shift(e,n,r,i){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=i,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,i,4);else{let s=e,{parser:o}=this.p;this.pos=i;let l=o.stateFlag(s,1);!l&&(i>r||n<=o.maxNode)&&(this.reducePos=i),this.pushState(s,l?r:Math.min(r,this.reducePos)),this.shiftContext(n,r),n<=o.maxNode&&this.buffer.push(n,r,i,4)}}apply(e,n,r,i){e&65536?this.reduce(e):this.shift(e,n,r,i)}useNode(e,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(n,i),this.buffer.push(r,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(n&&e.buffer[n-4]==0&&(n-=4);n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let r=e.buffer.slice(n),i=e.bufferBase+n;for(;e&&i==e.bufferBase;)e=e.parent;return new sp(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new jX(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(r==0)return!1;if(!(r&65536))return!0;n.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let i=[];for(let s=0,o;sa&1&&l==o)||i.push(n[s],o)}n=i}let r=[];for(let i=0;i>19,i=n&65535,s=this.stack.length-r*3;if(s<0||e.getGoto(this.stack[s],i,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],r=(i,s)=>{if(!n.includes(i))return n.push(i),e.allActions(i,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-s;if(l>1){let a=o&65535,u=this.stack.length-l*3;if(u>=0&&e.getGoto(this.stack[u],a,!1)>=0)return l<<19|65536|a}}else{let l=r(o,s+1);if(l!=null)return l}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n0&&this.emitLookAhead()}}class MS{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class jX{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,r=e>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=i}}class op{constructor(e,n,r){this.stack=e,this.pos=n,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new op(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new op(this.stack,this.pos,this.index)}}function Od(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let r=0,i=0;r=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),s+=a,l)break;s*=46}n?n[i++]=s:n=new e(s)}return n}class Zd{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const RS=new Zd;class HX{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=RS,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let r=this.range,i=this.rangeIndex,s=this.pos+e;for(;sr.to:s>=r.to;){if(i==this.ranges.length-1)return null;let o=this.ranges[++i];s+=o.from-r.to,r=o}return s}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,r,i;if(n>=0&&n=this.chunk2Pos&&rl.to&&(this.chunk2=this.chunk2.slice(0,l.to-r)),i=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),i}acceptToken(e,n=0){let r=n?this.resolveOffset(n,-1):this.pos;if(r==null||r=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=RS,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let r="";for(let i of this.ranges){if(i.from>=n)break;i.to>e&&(r+=this.input.read(Math.max(i.from,e),Math.min(i.to,n)))}return r}}class za{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;WX(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}za.prototype.contextual=za.prototype.fallback=za.prototype.extend=!1;za.prototype.fallback=za.prototype.extend=!1;function WX(t,e,n,r,i,s){let o=0,l=1<0){let p=t[h];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||VX(p,e.token.value,i,s))){e.acceptToken(p);break}}let c=e.next,f=0,d=t[o+2];if(e.next<0&&d>f&&t[u+d*3-3]==65535){o=t[u+d*3-1];continue e}for(;f>1,p=u+h+(h<<1),g=t[p],b=t[p+1]||65536;if(c=b)f=h+1;else{o=t[p+2],e.advance();continue e}}break}}function OS(t,e,n){for(let r=e,i;(i=t[r])!=65535;r++)if(i==n)return r-e;return-1}function VX(t,e,n,r){let i=OS(n,r,e);return i<0||OS(n,r,t)e)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(t.length,Math.max(r.from+1,e+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:t.length}}class UX{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?PS(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?PS(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(s instanceof Fn){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class KX{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new Zd)}getActions(e){let n=0,r=null,{parser:i}=e.p,{tokenizers:s}=i,o=i.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let u=0;uf.end+25&&(a=Math.max(f.lookAhead,a)),f.value!=0)){let d=n;if(f.extended>-1&&(n=this.addActions(e,f.extended,f.end,n)),n=this.addActions(e,f.value,f.end,n),!c.extend&&(r=f,n>d))break}}for(;this.actions.length>n;)this.actions.pop();return a&&e.setLookAhead(a),!r&&e.pos==this.stream.end&&(r=new Zd,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,n=this.addActions(e,r.value,r.end,n)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new Zd,{pos:r,p:i}=e;return n.start=r,n.end=Math.min(r+1,i.stream.end),n.value=r==i.stream.end?i.parser.eofTerm:0,n}updateCachedToken(e,n,r){let i=this.stream.clipPos(r.pos);if(n.token(this.stream.reset(i,e),r),e.value>-1){let{parser:s}=r.p;for(let o=0;o=0&&r.p.parser.dialect.allows(l>>1)){l&1?e.extended=l>>1:e.value=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,n,r,i){for(let s=0;se.bufferLength*4?new UX(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,r=this.stacks=[],i,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;on)r.push(l);else{if(this.advanceStack(l,r,e))continue;{i||(i=[],s=[]),i.push(l);let a=this.tokens.getMainToken(l);s.push(a.value,a.end)}}break}}if(!r.length){let o=i&&qX(i);if(o)return qr&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw qr&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&i){let o=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,s,r);if(o)return qr&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(r.length>o)for(r.sort((l,a)=>a.score-l.score);r.length>o;)r.pop();r.some(l=>l.reducePos>n)&&this.recovering--}else if(r.length>1){e:for(let o=0;o500&&u.buffer.length>500)if((l.score-u.score||l.buffer.length-u.buffer.length)>0)r.splice(a--,1);else{r.splice(o--,1);continue e}}}r.length>12&&(r.sort((o,l)=>l.score-o.score),r.splice(12,r.length-12))}this.minStackPos=r[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,c=u?e.curContext.hash:0;for(let f=this.fragments.nodeAt(i);f;){let d=this.parser.nodeSet.types[f.type.id]==f.type?s.getGoto(e.state,f.type.id):-1;if(d>-1&&f.length&&(!u||(f.prop(Et.contextHash)||0)==c))return e.useNode(f,d),qr&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof Fn)||f.children.length==0||f.positions[0]>0)break;let h=f.children[0];if(h instanceof Fn&&f.positions[0]==0)f=h;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),qr&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let u=0;ui?n.push(p):r.push(p)}return!1}advanceFully(e,n){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return IS(e,n),!0}}runRecovery(e,n,r){let i=null,s=!1;for(let o=0;o ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),qr&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,r))))continue;let f=l.split(),d=c;for(let h=0;h<10&&f.forceReduce()&&(qr&&console.log(d+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,r));h++)qr&&(d=this.stackID(f)+" -> ");for(let h of l.recoverByInsert(a))qr&&console.log(c+this.stackID(h)+" (via recover-insert)"),this.advanceFully(h,r);this.stream.end>l.pos?(u==l.pos&&(u++,a=0),l.recoverByDelete(a,u),qr&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),IS(l,r)):(!i||i.scoree.topRules[l][1]),i=[];for(let l=0;l=0)s(c,a,l[u++]);else{let f=l[u+-c];for(let d=-c;d>0;d--)s(l[u++],a,f);u++}}}this.nodeSet=new Nw(n.map((l,a)=>Hr.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:i[a],top:r.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=wM;let o=Od(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;ltypeof l=="number"?new za(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,r){let i=new XX(this,e,n,r);for(let s of this.wrappers)i=s(i,e,n,r);return i}getGoto(e,n,r=!1){let i=this.goto;if(n>=i[0])return-1;for(let s=i[n+1];;){let o=i[s++],l=o&1,a=i[s++];if(l&&r)return a;for(let u=s+(o>>1);s0}validAction(e,n){return!!this.allActions(e,r=>r==n?!0:null)}allActions(e,n){let r=this.stateSlot(e,4),i=r?n(r):void 0;for(let s=this.stateSlot(e,1);i==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=$s(this.data,s+2);else break;i=n($s(this.data,s+1))}return i}nextStates(e){let n=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=$s(this.data,r+2);else break;if(!(this.data[r+2]&1)){let i=this.data[r+1];n.some((s,o)=>o&1&&s==i)||n.push(this.data[r],i)}}return n}configure(e){let n=Object.assign(Object.create(lp.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=r}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let i=e.tokenizers.find(s=>s.from==r);return i?i.to:r})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,i)=>{let s=e.specializers.find(l=>l.from==r.external);if(!s)return r;let o=Object.assign(Object.assign({},r),{external:s.to});return n.specializers[i]=NS(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(r[o]=!0)}let i=null;for(let s=0;sr)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.scoret.external(n,r)<<1|e}return t.get}const YX=CM({String:Ge.string,Number:Ge.number,"True False":Ge.bool,PropertyName:Ge.propertyName,Null:Ge.null,", :":Ge.separator,"[ ]":Ge.squareBracket,"{ }":Ge.brace}),JX=lp.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[YX],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),QX=()=>t=>{try{JSON.parse(t.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const n=ZX(e,t.state.doc);return[{from:n,message:e.message,severity:"error",to:n}]}return[]};function ZX(t,e){let n;return(n=t.message.match(/at position (\d+)/))?Math.min(+n[1],e.length):(n=t.message.match(/at line (\d+) column (\d+)/))?Math.min(e.line(+n[1]).from+ +n[2]-1,e.length):0}const eG=ep.define({name:"json",parser:JX.configure({props:[RM.add({Object:pS({except:/^\s*\}/}),Array:pS({except:/^\s*\]/})}),gK.add({"Object Array":mK})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function _S(){return new oK(eG)}class DS{constructor(e,n,r){this.from=e,this.to=n,this.diagnostic=r}}class yl{constructor(e,n,r){this.diagnostics=e,this.panel=n,this.selected=r}static init(e,n,r){let i=r.facet(ks).markerFilter;i&&(e=i(e,r));let s=e.slice().sort((h,p)=>h.from-p.from||h.to-p.to),o=new Ja,l=[],a=0,u=r.doc.iter(),c=0,f=r.doc.length;for(let h=0;;){let p=h==s.length?null:s[h];if(!p&&!l.length)break;let g,b;if(l.length)g=a,b=l.reduce((w,k)=>Math.min(w,k.to),p&&p.from>g?p.from:1e8);else{if(g=p.from,g>f)break;b=p.to,l.push(p),h++}for(;hw.from||w.to==g))l.push(w),h++,b=Math.min(w.to,b);else{b=Math.min(w.from,b);break}}b=Math.min(b,f);let m=!1;if(l.some(w=>w.from==g&&(w.to==b||b==f))&&(m=g==b,!m&&b-g<10)){let w=g-(c+u.value.length);w>0&&(u.next(w),c=g);for(let k=g;;){if(k>=b){m=!0;break}if(!u.lineBreak&&c+u.value.length>k)break;k=c+u.value.length,c+=u.value.length,u.next()}}let v=pG(l);if(m)o.add(g,g,en.widget({widget:new cG(v),diagnostics:l.slice()}));else{let w=l.reduce((k,x)=>x.markClass?k+" "+x.markClass:k,"");o.add(g,b,en.mark({class:"cm-lintRange cm-lintRange-"+v+w,diagnostics:l.slice(),inclusiveEnd:l.some(k=>k.to>b)}))}if(a=b,a==f)break;for(let w=0;w{if(!(e&&o.diagnostics.indexOf(e)<0))if(!r)r=new DS(i,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new DS(r.from,s,r.diagnostic)}}),r}function tG(t,e){let n=e.pos,r=e.end||n,i=t.state.facet(ks).hideOn(t,n,r);if(i!=null)return i;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(Hw))||t.changes.touchesRange(s.from,Math.max(s.to,r)))}function nG(t,e){return t.field(Gi,!1)?e:e.concat(on.appendConfig.of(pR))}function rG(t,e){return{effects:nG(t,[Hw.of(e)])}}const Hw=on.define(),cR=on.define(),fR=on.define(),Gi=Os.define({create(){return new yl(en.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),r=null,i=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);r=iu(n,t.selected.diagnostic,s)||iu(n,null,s)}!n.size&&i&&e.state.facet(ks).autoPanel&&(i=null),t=new yl(n,i,r)}for(let n of e.effects)if(n.is(Hw)){let r=e.state.facet(ks).autoPanel?n.value.length?ap.open:null:t.panel;t=yl.init(n.value,r,e.state)}else n.is(cR)?t=new yl(t.diagnostics,n.value?ap.open:null,t.selected):n.is(fR)&&(t=new yl(t.diagnostics,t.panel,n.value));return t},provide:t=>[Py.from(t,e=>e.panel),qe.decorations.from(t,e=>e.diagnostics)]}),iG=en.mark({class:"cm-lintRange cm-lintRange-active"});function sG(t,e,n){let{diagnostics:r}=t.state.field(Gi),i,s=-1,o=-1;r.between(e-(n<0?1:0),e+(n>0?1:0),(a,u,{spec:c})=>{if(e>=a&&e<=u&&(a==u||(e>a||n>0)&&(ehR(t,n,!1)))}const LS=t=>{let e=t.state.field(Gi,!1);return!e||!e.panel?!1:(t.dispatch({effects:cR.of(!1)}),!0)},lG=Ei.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(ks);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let t=Date.now();if(tPromise.resolve(r(this.view))),r=>{this.view.state.doc==e.doc&&this.view.dispatch(rG(this.view.state,r.reduce((i,s)=>i.concat(s))))},r=>{vi(this.view.state,r)})}}update(t){let e=t.state.facet(ks);(t.docChanged||e!=t.startState.facet(ks)||e.needsRefresh&&e.needsRefresh(t))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function aG(t,e,n){let r=[],i=-1;for(let s of t)s.then(o=>{r.push(o),clearTimeout(i),r.length==t.length?e(r):i=setTimeout(()=>e(r),200)},n)}const ks=He.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...wA(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:$S,tooltipFilter:$S,needsRefresh:(e,n)=>e?n?r=>e(r)||n(r):e:n,hideOn:(e,n)=>e?n?(r,i,s)=>e(r,i,s)||n(r,i,s):e:n,autoPanel:(e,n)=>e||n})}}});function $S(t,e){return t?e?(n,r)=>e(t(n,r),r):t:e}function uG(t,e={}){return[ks.of({source:t,config:e}),lG,pR]}function dR(t){let e=[];if(t)e:for(let{name:n}of t){for(let r=0;rs.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function hR(t,e,n){var r;let i=n?dR(e.actions):[];return ms("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},ms("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((s,o)=>{let l=!1,a=h=>{if(h.preventDefault(),l)return;l=!0;let p=iu(t.state.field(Gi).diagnostics,e);p&&s.apply(t,p.from,p.to)},{name:u}=s,c=i[o]?u.indexOf(i[o]):-1,f=c<0?u:[u.slice(0,c),ms("u",u.slice(c,c+1)),u.slice(c+1)],d=s.markClass?" "+s.markClass:"";return ms("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:a,onmousedown:a,"aria-label":` Action: ${u}${c<0?"":` (access key "${i[o]})"`}.`},f)}),e.source&&ms("div",{class:"cm-diagnosticSource"},e.source))}class cG extends gu{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return ms("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class FS{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=hR(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class ap{constructor(e){this.view=e,this.items=[];let n=i=>{if(!(i.ctrlKey||i.altKey||i.metaKey)){if(i.keyCode==27)LS(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=dR(s.actions);for(let l=0;l{for(let s=0;sLS(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Gi).selected;if(!e)return-1;for(let n=0;n{for(let c of u.diagnostics){if(o.has(c))continue;o.add(c);let f=-1,d;for(let h=r;hr&&(this.items.splice(r,f-r),i=!0)),n&&d.diagnostic==n.diagnostic?d.dom.hasAttribute("aria-selected")||(d.dom.setAttribute("aria-selected","true"),s=d):d.dom.hasAttribute("aria-selected")&&d.dom.removeAttribute("aria-selected"),r++}});r({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let u=a.height/this.list.offsetHeight;l.topa.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function n(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)n();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(Gi),r=iu(n.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:fR.of(r)})}static open(e){return new ap(e)}}function fG(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(t)}')`}function Pd(t){return fG(``,'width="6" height="3"')}const dG=qe.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Pd("#f11")},".cm-lintRange-warning":{backgroundImage:Pd("orange")},".cm-lintRange-info":{backgroundImage:Pd("#999")},".cm-lintRange-hint":{backgroundImage:Pd("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function hG(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function pG(t){let e="hint",n=1;for(let r of t){let i=hG(r.severity);i>n&&(n=i,e=r.severity)}return e}const gG=F7(sG,{hideOn:tG}),pR=[Gi,qe.decorations.compute([Gi],t=>{let{selected:e,panel:n}=t.field(Gi);return!e||!n||e.from==e.to?en.none:en.set([iG.range(e.from,e.to)])}),gG,dG],mG=512*1024,zS=512*1024,gR=2e6;function yG(t,e){if(t.length<=e)return t;const n=t.lastIndexOf(` +`,e);return n>e*.5?t.slice(0,n):t.slice(0,e)}const vG=t=>t.state.doc.length>mG?[]:QX()(t);function BS(t){return qp.define([{tag:Ge.propertyName,color:t?"#7dd3fc":"#0369a1"},{tag:Ge.string,color:t?"#86efac":"#15803d"},{tag:Ge.number,color:t?"#fcd34d":"#b45309"},{tag:Ge.bool,color:t?"#d8b4fe":"#7e22ce"},{tag:Ge.null,color:t?"#a1a1aa":"#71717a"}])}const wG=qe.theme({"&":{height:"100%",fontSize:"13px",backgroundColor:"transparent"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:"inherit",lineHeight:"1.5rem",overflow:"auto"},".cm-gutters":{display:"none"},".cm-activeLine":{backgroundColor:"transparent"},".cm-content":{caretColor:"currentColor",fontFamily:"inherit",letterSpacing:"-0.025em"},".cm-placeholder":{color:"var(--color-muted-foreground)"}});function mR({value:t,onChange:e,editable:n,lintJson:r=!0,dark:i,placeholder:s,testId:o="json-editor",className:l,onReady:a}){const u=y.useRef(null),c=y.useRef(null),f=y.useRef(e);f.current=e;const d=y.useRef(i),h=y.useRef(null),p=y.useRef(null),g=y.useRef(null),b=n??e!==void 0,m=y.useRef(b),v=y.useRef(r),w=t.length>zS,k=y.useRef(w),x=!b&&t.length>gR,C=x?yG(t,zS):t,T=y.useRef(!1),A=y.useCallback((M,I,D)=>M?[qe.updateListener.of(O=>{var L;O.docChanged&&!T.current&&((L=f.current)==null||L.call(f,O.state.doc.toString()))}),...I||!D?[]:[uG(vG,{delay:300})]]:[zt.readOnly.of(!0),qe.editable.of(!1)],[]);return y.useEffect(()=>{const M=u.current;if(!M)return;const I=new Tl,D=new Tl,O=new Tl,L=zt.create({doc:C,extensions:[O.of(w||!r?[]:_S()),qe.lineWrapping,$K(),gM.of([...zX,...KK,BX]),wG,I.of(gS(BS(i))),D.of(A(b,w,r)),...s?[R7(s)]:[]]}),_=new qe({state:L,parent:M});return h.current=I,p.current=D,g.current=O,a==null||a(_),c.current=_,()=>{_.destroy(),c.current=null}},[]),y.useEffect(()=>{const M=c.current;if(!M)return;const I=g.current,D=p.current,O=[];(w!==k.current||r!==v.current)&&(k.current=w,v.current=r,I&&O.push(I.reconfigure(w||!r?[]:_S())),D&&O.push(D.reconfigure(A(b,w,r))));const L=M.state.doc.toString();if(!(L===C&&O.length===0)){T.current=!0;try{M.dispatch({...L!==C?{changes:{from:0,to:M.state.doc.length,insert:C}}:{},...O.length>0?{effects:O}:{}})}finally{T.current=!1}}},[C,w,r,b,A]),y.useEffect(()=>{const M=c.current,I=p.current;!M||!I||b!==m.current&&(m.current=b,M.dispatch({effects:I.reconfigure(A(b,w,r))}))},[b,w,r,A]),y.useEffect(()=>{const M=c.current;if(!M||i===d.current)return;d.current=i;const I=h.current;I&&M.dispatch({effects:I.reconfigure(gS(BS(i)))})},[i]),E.jsxs("div",{"data-testid":o,className:Un("flex min-h-0 flex-1 flex-col overflow-hidden font-mono",l),children:[x?E.jsx("div",{"data-testid":"large-output-preview-banner",role:"status",className:"border-b border-border bg-muted/40 px-5 py-1.5 font-sans text-xs text-muted-foreground",children:"Showing first 512 KB preview in editor — Copy and Download include the full output"}):null,E.jsx("div",{ref:u,className:"min-h-0 flex-1 overflow-hidden px-5 py-4"})]})}function yR({title:t,meta:e,actions:n,status:r,children:i}){return E.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[E.jsxs("div",{className:"flex min-h-[42px] flex-shrink-0 flex-wrap items-center justify-between gap-x-2 gap-y-1.5 border-b border-border px-3.5 py-2 max-md:gap-2 md:min-h-12 md:py-1.5 md:pr-2.5 md:pl-3.5 lg:gap-x-3 lg:pr-3 lg:pl-5",children:[E.jsxs("div",{className:"flex items-center gap-2 lg:gap-3",children:[E.jsx("span",{className:"font-mono text-[11px] font-semibold tracking-[0.18em] text-muted-foreground",children:t}),e?E.jsx("span",{"data-testid":"pane-meta",className:"text-xs tabular-nums text-muted-foreground/70",children:e}):null]}),E.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-0.5 max-md:gap-1",children:n})]}),E.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:i}),r?E.jsxs("div",{"data-testid":"pane-status",className:r.kind==="error"?"flex-shrink-0 px-3.5 pb-2 text-xs text-destructive":"flex-shrink-0 whitespace-pre-line px-3.5 pb-2 text-xs text-muted-foreground",role:"status",children:[r.message,r.action]}):null]})}const kl="inline-flex h-7 cursor-pointer items-center gap-1.5 rounded-md px-2 text-[13px] font-medium text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-40 [&_svg]:size-3.5";var Hy={exports:{}};(function(t,e){(function(){var n="We could not detect the separator.",r="Empty CSV. Please provide something.",i="Could not detect header. Ensure first row cotains your column headers.",s=[",",";"," "],o=!0,l={",":"comma",";":"semicolon"," ":"tab","|":"pipe"};function a(d){var h={},p;return s.forEach(function(g,b){var m=new RegExp(g,"g");h[g]=(d.match(m)||[]).length,p=!p||h[g]>h[p]?g:p}),p}function u(d){for(var h={},p=0;p=0;p--){var g=d[p];h[g]>0&&(g=g+"__"+h[g]--),b.unshift(g)}return b}function c(d,h){if(h||(h={}),d.length==0)throw r;var p=h.separator||a(d);if(!p)throw n;var g=[];try{o=h.trim!==!1;var g=f.parse(d,l[p])}catch(se){var b=d.lastIndexOf(` +`,se.offset),m=d.indexOf(` +`,se.offset),v=d.substring(b>=-1?b:0,m>-1?m:d.length);throw se.message+" On line "+se.line+" and column "+se.column+`. +`+v}if(h.transpose){for(var w=0,k=0;kw&&(w=g[k].length);for(var x=new Array(w),C=0;Cv&&(v=m,w=[]),w.push(R))}function x(){var R,N,P,B;return P=m,B=m,R=function(q){return re=","}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,m=B)):(R=null,m=B),R!==null&&(R=function(q,W){return W}(P,R[1])),R===null&&(m=P),R}function C(){var R,N,P,B;return P=m,B=m,R=function(q){return re=";"}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,m=B)):(R=null,m=B),R!==null&&(R=function(q,W){return W}(P,R[1])),R===null&&(m=P),R}function T(){var R,N,P,B;return P=m,B=m,R=function(q){return re="|"}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,m=B)):(R=null,m=B),R!==null&&(R=function(q,W){return W}(P,R[1])),R===null&&(m=P),R}function A(){var R,N,P,B;return P=m,B=m,R=function(q){return re=" "}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,m=B)):(R=null,m=B),R!==null&&(R=function(q,W){return W}(P,R[1])),R===null&&(m=P),R}function M(){var R,N,P,B,q,W,ye,ee,me;for(W=m,ye=m,R=[],/^[\n\r]/.test(p.charAt(m))?(N=p.charAt(m),m++):(N=null,k("[\\n\\r]"));N!==null;)R.push(N),/^[\n\r]/.test(p.charAt(m))?(N=p.charAt(m),m++):(N=null,k("[\\n\\r]"));if(R!==null)if(N=I(),N!==null){if(P=[],ee=m,me=m,/^[\n\r]/.test(p.charAt(m))?(q=p.charAt(m),m++):(q=null,k("[\\n\\r]")),q!==null)for(B=[];q!==null;)B.push(q),/^[\n\r]/.test(p.charAt(m))?(q=p.charAt(m),m++):(q=null,k("[\\n\\r]"));else B=null;for(B!==null?(q=I(),q!==null?B=[B,q]:(B=null,m=me)):(B=null,m=me),B!==null&&(B=function(Le,Ue){return Ue}(ee,B[1])),B===null&&(m=ee);B!==null;){if(P.push(B),ee=m,me=m,/^[\n\r]/.test(p.charAt(m))?(q=p.charAt(m),m++):(q=null,k("[\\n\\r]")),q!==null)for(B=[];q!==null;)B.push(q),/^[\n\r]/.test(p.charAt(m))?(q=p.charAt(m),m++):(q=null,k("[\\n\\r]"));else B=null;B!==null?(q=I(),q!==null?B=[B,q]:(B=null,m=me)):(B=null,m=me),B!==null&&(B=function(Le,Ue){return Ue}(ee,B[1])),B===null&&(m=ee)}if(P!==null){for(B=[],/^[\n\r]/.test(p.charAt(m))?(q=p.charAt(m),m++):(q=null,k("[\\n\\r]"));q!==null;)B.push(q),/^[\n\r]/.test(p.charAt(m))?(q=p.charAt(m),m++):(q=null,k("[\\n\\r]"));B!==null?R=[R,N,P,B]:(R=null,m=ye)}else R=null,m=ye}else R=null,m=ye;else R=null,m=ye;return R!==null&&(R=function(Le,Ue,ze){return ze.unshift(Ue),ze}(W,R[1],R[2])),R===null&&(m=W),R}function I(){var R,N,P,B,q,W,ye,ee,me;if(W=m,ye=m,R=D(),R!==null){for(N=[],ee=m,me=m,p.length>m?(P=p.charAt(m),m++):(P=null,k("any character")),P!==null?(B=function(Le,Ue){return Ue==re}(m,P)?"":null,B!==null?(q=D(),q!==null?P=[P,B,q]:(P=null,m=me)):(P=null,m=me)):(P=null,m=me),P!==null&&(P=function(Le,Ue,ze){return ze}(ee,P[0],P[2])),P===null&&(m=ee);P!==null;)N.push(P),ee=m,me=m,p.length>m?(P=p.charAt(m),m++):(P=null,k("any character")),P!==null?(B=function(Le,Ue){return Ue==re}(m,P)?"":null,B!==null?(q=D(),q!==null?P=[P,B,q]:(P=null,m=me)):(P=null,m=me)):(P=null,m=me),P!==null&&(P=function(Le,Ue,ze){return ze}(ee,P[0],P[2])),P===null&&(m=ee);N!==null?(P=function(Le,Ue,ze){return!!Ue||ze.length}(m,R,N)?"":null,P!==null?R=[R,N,P]:(R=null,m=ye)):(R=null,m=ye)}else R=null,m=ye;return R!==null&&(R=function(Le,Ue,ze){return ze.unshift(Ue),ze}(W,R[0],R[1])),R===null&&(m=W),R}function D(){var R,N,P,B,q,W;if(B=m,q=m,p.charCodeAt(m)===34?(R='"',m++):(R=null,k('"\\""')),R!==null){for(N=[],P=O();P!==null;)N.push(P),P=O();N!==null?(p.charCodeAt(m)===34?(P='"',m++):(P=null,k('"\\""')),P!==null?R=[R,N,P]:(R=null,m=q)):(R=null,m=q)}else R=null,m=q;if(R!==null&&(R=function(ye,ee){return ee.join("")}(B,R[1])),R===null&&(m=B),R===null){for(B=m,R=[],q=m,W=m,/^[^\n\r]/.test(p.charAt(m))?(N=p.charAt(m),m++):(N=null,k("[^\\n\\r]")),N!==null?(P=function(ye,ee){return ee!=re}(m,N)?"":null,P!==null?N=[N,P]:(N=null,m=W)):(N=null,m=W),N!==null&&(N=function(ye,ee){return ee}(q,N[0])),N===null&&(m=q);N!==null;)R.push(N),q=m,W=m,/^[^\n\r]/.test(p.charAt(m))?(N=p.charAt(m),m++):(N=null,k("[^\\n\\r]")),N!==null?(P=function(ye,ee){return ee!=re}(m,N)?"":null,P!==null?N=[N,P]:(N=null,m=W)):(N=null,m=W),N!==null&&(N=function(ye,ee){return ee}(q,N[0])),N===null&&(m=q);R!==null&&(R=function(ye,ee){return(o?ee.join("").trim():ee.join("")).replace(/(^")|("$)/g,"")}(B,R)),R===null&&(m=B)}return R}function O(){var R,N,P,B;return P=m,B=m,p.charCodeAt(m)===34?(R='"',m++):(R=null,k('"\\""')),R!==null?(p.charCodeAt(m)===34?(N='"',m++):(N=null,k('"\\""')),N!==null?R=[R,N]:(R=null,m=B)):(R=null,m=B),R!==null&&(R=function(q){return'"'}()),R===null&&(m=P),R===null&&(/^[^"]/.test(p.charAt(m))?(R=p.charAt(m),m++):(R=null,k('[^"]'))),R}function L(R){R.sort();for(var N=null,P=[],B=0;B=2)try{return{ok:!0,value:JSON.parse(e)}}catch{return{ok:!1}}return{ok:!1}}function qi(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function RG(t){return t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function OG(t){const e=(r,i,s)=>{for(const[o,l]of Object.entries(r)){const a=i?`${i}.${o}`:o;qi(l)&&Object.keys(l).length>0?e(l,a,s):Array.isArray(l)?s[a]=l.map(n):s[a]=l}},n=r=>{if(!qi(r))return r;const i={};return e(r,"",i),i};return Array.isArray(t)?t.map(n):qi(t)?n(t):t}function PG(t){const e=n=>{if(!qi(n))return n;const r={};for(const[i,s]of Object.entries(n))Array.isArray(s)&&s.length>0&&s.every(RG)?r[i]=s.join(", "):Array.isArray(s)?r[i]=s.map(e):r[i]=s;return r};return Array.isArray(t)?t.map(e):qi(t)?e(t):t}function IG(t){const e=t.trim().toLowerCase();return e==="true"||e==="1"||e==="yes"?!0:e==="false"||e==="0"||e==="no"?!1:t}function NG(t,e,n){if(n==="string")return t;if(n==="number")return HS(t);if(n==="boolean")return IG(t);if(e.parseJSON){const r=MG(t);if(r.ok&&typeof r.value!="number")return r.value}return e.parseNumbers?HS(t):t}function _G(t,e){const n=i=>{var o;const s={};for(const l of Object.keys(i)){const a=i[l];if(typeof a!="string"){s[l]=a;continue}if(e.emptyFields==="skip"&&a==="")continue;if(e.nullLiterals==="null"&&a==="NULL"){s[l]=null;continue}const u=(o=e.columnTypes)==null?void 0:o[l],c=NG(a,e,u);s[l]=c}return s};if(Array.isArray(t))return t.map(i=>qi(i)?n(i):i);const r={};for(const[i,s]of Object.entries(t))r[i]=qi(s)?n(s):s;return r}const DG=/^([^.[\]]+)(?:\.(0|[1-9]\d*)|\[(0|[1-9]\d*)\])(?:\.(.+))?$/;function wR(t){const e=DG.exec(t);if(!e)return null;const n=e[1],r=e[2],i=e[3],s=e[4],o=Number(r??i);return Number.isSafeInteger(o)?{column:t,prefix:n,index:o,notation:r!==void 0?"dot":"bracket",...s!==void 0?{subKey:s}:{}}:null}function Vy(t){const e=new Set(t),n=new Map;for(const i of t){const s=wR(i);if(!s)continue;const o=n.get(s.prefix);o?o.push(s):n.set(s.prefix,[s])}const r=[];for(const[i,s]of n.entries()){if(e.has(i))continue;const o=s[0].subKey!==void 0,l=s[0].notation;if(s.some(h=>h.subKey!==void 0!==o||h.notation!==l))continue;const a=new Set;let u=!1;for(const h of s){const p=`${h.index}:${h.subKey??""}`;if(a.has(p)){u=!0;break}a.add(p)}if(u)continue;const c=Array.from(new Set(s.map(h=>h.index))).sort((h,p)=>h-p);if(c.length<2)continue;const f=c[0];f!==0&&f!==1||!c.every((h,p)=>h===f+p)||r.push({prefix:i,indices:c,columns:s.map(h=>h.column)})}return r}function WS(t,e){return t===void 0||t===""||e==="skip"&&t===null}function VS(t,e,n,r){const i=new Map,s=new Set,o=new Map;for(const a of n)if(a.columns.length!==0){i.set(a.columns[0],a);for(const u of a.columns)s.add(u);o.set(a.prefix,a.columns.map(u=>wR(u)).filter(u=>u!==null))}const l={};for(const a of e){const u=i.get(a);if(u){const c=o.get(u.prefix)??[];if(c.some(d=>d.subKey!==void 0)){const d=new Map;for(const p of c){const g=d.get(p.index);g?g.push(p):d.set(p.index,[p])}const h=[];for(const p of u.indices){const g=d.get(p)??[],b={};for(const m of g){if(!m.subKey)continue;const v=t[m.column];WS(v,r)||(b[m.subKey]=v)}Object.keys(b).length>0&&h.push(b)}if(h.length===0&&r==="skip")continue;l[u.prefix]=h}else{const d=new Map;for(const p of c)d.set(p.index,p.column);const h=[];for(const p of u.indices){const g=d.get(p);if(!g)continue;const b=t[g];WS(b,r)||h.push(b)}if(h.length===0&&r==="skip")continue;l[u.prefix]=h}continue}s.has(a)||Object.prototype.hasOwnProperty.call(t,a)&&(l[a]=t[a])}return l}function LG(t,e,n){if(Array.isArray(t)&&Array.isArray(e)){const r=t[0];if(!qi(r))return e;const i=Object.keys(r),s=Vy(i);return s.length===0?e:e.map(o=>qi(o)?VS(o,i,s,n):o)}if(!Array.isArray(t)&&!Array.isArray(e)){const r=Object.values(t)[0];if(!qi(r))return e;const i=Object.keys(r),s=Vy(i);if(s.length===0)return e;const o={};for(const[l,a]of Object.entries(e))o[l]=qi(a)?VS(a,i,s,n):a;return o}return e}function US(t,e={}){const n={parseNumbers:e.parseNumbers??!0,parseJSON:e.parseJSON??!1,emptyFields:e.emptyFields??"keep",nullLiterals:e.nullLiterals??"string",columnTypes:e.columnTypes},r=t.startsWith(jS)?t.slice(jS.length):t,i=e.separator===void 0?Bp(r,e.markdownTableIndex??0):null,s=i?i.cleanedCsv:r;try{const o=xG(s,{...e,parseNumbers:!1,parseJSON:!1,trim:!1}),l=_G(o,n);return e.collapseIndexedArrays!==!1&&!e.transpose?LG(o,l,n.emptyFields):l}catch(o){throw new Error(vR(o))}}function $G(t,e={}){try{const n=e.flatten?PG(OG(t)):t;return SG(n,e)}catch(n){const r=vR(n);throw EG.some(i=>r.startsWith(i))?new CG(TG(r,e.flatten??!1)):new Error(r)}}function FG(t,e={}){return JSON.stringify(t,null,e.minify?void 0:2)}const Yr={separator:"auto",parseNumbers:!0,parseJSON:!0,emptyFields:"keep",nullLiterals:"string",transpose:!1,hash:!1,minify:!1,flatten:!1,collapseIndexedArrays:!0},KS=["data","items","results","records","rows"];function Tc(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function bR(t){const e=t.trim();if(e===""||!e.startsWith("{"))return[];let n;try{n=JSON.parse(e)}catch{return[]}if(!Tc(n))return[];const r=Object.keys(n),i=new Set(KS),s=[...KS.filter(l=>r.includes(l)),...r.filter(l=>!i.has(l))],o=[];for(const l of s){const a=n[l];Array.isArray(a)&&a.length>0&&a.every(u=>Tc(u))&&o.push({key:l,rowCount:a.length,unwrappedJson:JSON.stringify(a,null,2)})}return o}function Ww(t){const e=t.split(/\r?\n/).map(r=>r.trim()).filter(r=>r.length>0);if(e.length<2)return null;const n=[];for(const r of e)try{const i=JSON.parse(r);if(typeof i!="object"||i===null)return null;n.push(i)}catch{return null}return n}function zG(t){const e=t.trim();if(e==="")return null;let n;try{n=JSON.parse(e)}catch{const i=Ww(e);if(i===null)return null;n=i}const r=JSON.stringify(n,null,2);return e===r?{label:"Minify",nextInput:JSON.stringify(n)}:{label:"Format",nextInput:r}}function BG(t){const e=t.trim();if(e==="")return[];let n;try{n=JSON.parse(e)}catch{const o=Ww(e);if(o===null)return[];n=o}let r=[];if(Array.isArray(n)){if(n.length===0||!n.every(o=>Tc(o)))return[];r=n}else if(Tc(n)){if(bR(e).length>0)return[];r=[n]}else return[];const i=new Set,s=r.slice(0,50);for(const o of s)for(const[l,a]of Object.entries(o))(Tc(a)||Array.isArray(a)&&a.length>0)&&i.add(l);return Array.from(i)}function jG(t){const e=n=>{const r=new Set;for(const i of n)i&&typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).forEach(s=>r.add(s));return r};if(Array.isArray(t))return{rows:t.length,cols:e(t).size};if(t&&typeof t=="object"){const n=Object.values(t);return{rows:n.length,cols:e(n).size}}return{rows:0,cols:0}}const XS=t=>t==="auto"?void 0:t;function HG(t){let e=!1,n=1;for(let r=0;r0;return i.rowWidths.forEach((o,l)=>{if(s&&l===i.rowWidths.length-1)return;const a=i.rows[l];o===1&&a[0]===""||o!==i.headers.length&&n.push(o0?{warnings:f}:{}}}let r;try{r=JSON.parse(e)}catch(l){const a=Ww(e);if(a!==null)r=a;else return{ok:!1,error:`Invalid JSON — ${l instanceof Error?l.message:String(l)}`}}const i=XS(n.separator),s=$G(r,{separator:i,flatten:n.flatten}),o=mf(s,i);return{ok:!0,text:s,rows:o.rows.length,cols:o.headers.length}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}}function UG(){return E.jsx("svg",{"data-testid":"reading-spinner",className:"animate-spin",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,"aria-label":"Reading file",children:E.jsx("path",{d:"M21 12a9 9 0 1 1-6.2-8.56",strokeLinecap:"round"})})}function Xu({label:t,testId:e,onClick:n,disabled:r,Icon:i,keepLabelOnMobile:s=!1}){return E.jsxs("button",{type:"button","data-testid":e,"aria-label":t,disabled:r,onClick:n,title:t,className:kl,children:[i?E.jsx(i,{"aria-hidden":"true"}):null,i&&!s?E.jsx("span",{className:"hidden xl:inline",children:t}):t]})}function KG(t){const e=Math.min(t.length,65536);let n=!1,r=0;for(let i=0;i=3))return t.slice(0,i+1)}return t.slice(0,e)}function XG(t){const e=t.slice(0,3).map(r=>`.${r}`).join(", "),n=t.length-3;return n>0?`${e}, +${n} more`:e}function GG({format:t,input:e,onInputChange:n,onFile:r,onTryExample:i,onClear:s,onCopy:o,onCopySelection:l,onDownload:a,filename:u,reading:c,meta:f,error:d,notice:h,dark:p,delimiter:g,onCellCommit:b,canUndo:m=!1,canRedo:v=!1,onUndo:w,onRedo:k,onProjectedCsvChange:x,collapseIndexedArrays:C=!0,onToggleCollapseIndexedArrays:T,columnTypes:A,onChangeColumnTypes:M,flatten:I=!1,onToggleFlatten:D,selectedMarkdownTableIndex:O,onSelectMarkdownTableIndex:L}){const[_,re]=y.useState(!1),[ie,se]=y.useState(!1),[H,X]=y.useState({forInput:"",index:0}),R=y.useRef(0),N=y.useRef(null),P=e.trim()==="",B=t==="CSV",q=y.useMemo(()=>!B||P||g!==void 0?[]:QE(e),[B,P,e,g]),W=O!==void 0?O:H.forInput===e?H.index:0,ye=q.length===0?0:Math.min(Math.max(0,W),q.length-1),ee=q[ye]??null,me=Y=>{X({forInput:e,index:Y}),L==null||L(Y)},Le=y.useMemo(()=>{if(!B||P)return[];const Y=ee?ee.cleanedCsv:e,Se=KG(Y),Ie=mf(Se,g);return Vy(Ie.headers.map(Ce=>Ce.trim()))},[B,P,e,g,ee]),Ue=y.useMemo(()=>B||P?[]:bR(e),[B,P,e]),ze=y.useMemo(()=>B||P?[]:BG(e),[B,P,e]),Mt=y.useMemo(()=>B||P?null:zG(e),[B,P,e]),tt=Y=>{var Se;Y.preventDefault(),Array.from(((Se=Y.dataTransfer)==null?void 0:Se.types)??[]).includes("Files")&&(R.current++,se(!0))},Be=()=>{R.current=Math.max(0,R.current-1),R.current===0&&se(!1)},ue=Y=>{var Ie,Ce;Y.preventDefault(),R.current=0,se(!1);const Se=(Ce=(Ie=Y.dataTransfer)==null?void 0:Ie.files)==null?void 0:Ce[0];Se&&r(Se,"drop")},It=Y=>{var Ie;if(!P||Y.defaultPrevented||Y.target instanceof HTMLTextAreaElement||Y.target instanceof HTMLInputElement)return;const Se=(Ie=Y.clipboardData)==null?void 0:Ie.getData("text/plain");Se&&(Y.preventDefault(),n(Se))},be=B?E.jsxs("span",{"data-testid":"view-mode",role:"group","aria-label":"View mode",className:"inline-flex items-center gap-0.5 rounded-lg border border-border bg-muted/60 p-0.5",children:[E.jsxs("button",{type:"button","data-testid":"view-table","aria-pressed":!_,onClick:()=>re(!1),className:Un("inline-flex cursor-pointer items-center gap-1 rounded-[7px] px-2 py-1 text-xs font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50 lg:px-2.5",_?"text-muted-foreground hover:text-foreground":"bg-background text-foreground shadow-sm"),children:[E.jsx(PN,{"aria-hidden":"true",className:"size-3.5 md:hidden lg:inline"}),"Table"]}),E.jsxs("button",{type:"button","data-testid":"raw-toggle","aria-pressed":_,onClick:()=>re(!0),className:Un("inline-flex cursor-pointer items-center gap-1 rounded-[7px] px-2 py-1 text-xs font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50 lg:px-2.5",_?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[E.jsx(bb,{"aria-hidden":"true",className:"size-3.5 md:hidden lg:inline"}),"Raw"]})]}):null,xe=c&&u?E.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[E.jsx(UG,{})," ",u]}):u?f?`${u} · ${f}`:u:f;return E.jsx("div",{"data-testid":"input-pane",onDragEnter:tt,onDragOver:Y=>Y.preventDefault(),onDragLeave:Be,onDrop:ue,onPaste:It,"data-drag-over":ie||void 0,className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:E.jsxs(yR,{title:t,meta:xe,actions:E.jsxs(E.Fragment,{children:[be,B&&(m||v)?E.jsxs(E.Fragment,{children:[E.jsx("button",{type:"button","data-testid":"csv-undo-button","aria-label":"Undo",title:"Undo",disabled:!m,onClick:()=>w==null?void 0:w(),className:kl,children:E.jsx(FN,{"aria-hidden":"true"})}),E.jsx("button",{type:"button","data-testid":"csv-redo-button","aria-label":"Redo",title:"Redo",disabled:!v,onClick:()=>k==null?void 0:k(),className:kl,children:E.jsx(bN,{"aria-hidden":"true"})})]}):null,Mt?E.jsx(Xu,{label:Mt.label,testId:"json-format-toggle",onClick:()=>n(Mt.nextInput),Icon:bb,keepLabelOnMobile:!0}):null,E.jsx("input",{ref:N,type:"file","data-testid":"file-input",accept:B?".csv,.tsv,.txt,text/csv,text/tab-separated-values":".json,.txt,application/json",className:"hidden",onChange:Y=>{var Ie;const Se=(Ie=Y.target.files)==null?void 0:Ie[0];Se&&r(Se,"picker"),Y.target.value=""}}),E.jsx(Xu,{label:"Upload",testId:"upload",onClick:()=>{var Y;return(Y=N.current)==null?void 0:Y.click()},Icon:AT}),E.jsx(Xu,{label:"Copy",testId:"copy-input",onClick:o,Icon:Wv}),E.jsx(Xu,{label:"Clear",testId:"clear-input",onClick:s,disabled:P,Icon:Eh}),E.jsx(Xu,{label:"Download",testId:"download-input",onClick:a,disabled:P,Icon:ET})]}),status:d?{kind:"error",message:d}:h?{kind:"notice",message:h}:null,children:[P?E.jsx(dV,{format:t,onIngest:n,onBrowse:()=>{var Y;return(Y=N.current)==null?void 0:Y.click()},onTryExample:i}):B?E.jsxs(E.Fragment,{children:[ee?E.jsxs("div",{"data-testid":"csv-markdown-table-bar",className:"flex flex-shrink-0 flex-wrap items-center justify-between gap-1.5 border-b border-border bg-muted/30 px-3.5 py-1.5",children:[q.length>=2?E.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[E.jsx("span",{className:"text-xs text-muted-foreground",children:`${q.length} tables detected:`}),q.map(Y=>{const Se=Y.index===ye,Ie=Y.title??Y.headers.slice(0,2).join(", ");return E.jsx("button",{type:"button","data-testid":`csv-markdown-table-select-${Y.index}`,"aria-pressed":Se,onClick:()=>me(Y.index),className:Un("inline-flex cursor-pointer items-center gap-1 rounded-md border px-2 py-0.5 font-mono text-xs font-medium shadow-2xs transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50",Se?"border-foreground/30 bg-background text-foreground ring-1 ring-foreground/15":"border-border bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground"),children:`${Y.index+1}. ${Ie} (${Y.rows}×${Y.cols})`},Y.index)})]}):E.jsx("span",{className:"text-xs text-muted-foreground",children:ee.kind==="box"?"ASCII CLI box table detected:":"Markdown pipe table detected:"}),E.jsx("button",{type:"button","data-testid":"csv-clean-markdown-pill",onClick:()=>n(ee.cleanedCsv),className:"inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background px-2 py-0.5 font-mono text-xs font-medium text-foreground shadow-2xs transition-colors hover:bg-muted outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:q.length>=2?`Use only this table (${ee.rows} ${ee.rows===1?"row":"rows"})`:ee.kind==="box"?`Clean CLI table (${ee.rows} ${ee.rows===1?"row":"rows"})`:`Clean Markdown table (${ee.rows} ${ee.rows===1?"row":"rows"})`})]}):null,Le.length>0?E.jsxs("div",{"data-testid":"csv-indexed-array-bar",className:"flex flex-shrink-0 flex-wrap items-center justify-between gap-1.5 border-b border-border bg-muted/30 px-3.5 py-1.5",children:[E.jsx("span",{className:"text-xs text-muted-foreground",children:`Indexed columns (${Le.map(Y=>`${Y.prefix}[${Y.indices.length}]`).join(", ")}):`}),E.jsx("button",{type:"button","data-testid":"csv-indexed-array-pill","aria-pressed":C,onClick:()=>T==null?void 0:T(),className:Un("inline-flex cursor-pointer items-center gap-1 rounded-md border px-2 py-0.5 font-mono text-xs font-medium shadow-2xs transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50",C?"border-border bg-background text-foreground hover:bg-muted":"border-border bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground"),children:C?"Arrays: .0, .1 → []":"Keep flat keys (.0, .1)"})]}):null,_?E.jsx("textarea",{"data-testid":"input-editor",value:e,onChange:Y=>n(Y.target.value),spellCheck:!1,className:"min-h-0 flex-1 resize-none bg-transparent px-5 py-4 font-mono text-[13px] leading-6 tracking-tight focus:outline-none"}):E.jsx(tA,{text:ee?ee.cleanedCsv:e,delimiter:g,testId:"input-table",dark:p,onCellCommit:b,onUndo:w,onRedo:k,onCopySelection:l,columnTypes:A,onChangeColumnTypes:M,onProjectedCsvChange:x})]}):E.jsxs(E.Fragment,{children:[Ue.length>0?E.jsxs("div",{"data-testid":"json-unwrap-bar",className:"flex flex-shrink-0 flex-wrap items-center gap-1.5 border-b border-border bg-muted/30 px-3.5 py-1.5",children:[E.jsx("span",{className:"text-xs text-muted-foreground",children:"Nested array detected:"}),Ue.map(Y=>E.jsx("button",{type:"button","data-testid":`json-unwrap-pill-${Y.key}`,onClick:()=>n(Y.unwrappedJson),className:"inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background px-2 py-0.5 font-mono text-xs font-medium text-foreground shadow-2xs transition-colors outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50",children:`Unwrap .${Y.key} (${Y.rowCount} ${Y.rowCount===1?"row":"rows"})`},Y.key))]}):null,ze.length>0?E.jsxs("div",{"data-testid":"json-flatten-bar",className:"flex flex-shrink-0 flex-wrap items-center justify-between gap-1.5 border-b border-border bg-muted/30 px-3.5 py-1.5",children:[E.jsx("span",{className:"text-xs text-muted-foreground",children:`Nested keys (${ze.length}):`}),E.jsx("button",{type:"button","data-testid":"json-flatten-pill","aria-pressed":I,onClick:()=>D==null?void 0:D(),className:Un("inline-flex cursor-pointer items-center gap-1 rounded-md border px-2 py-0.5 font-mono text-xs font-medium shadow-2xs transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50",I?"border-border bg-background text-foreground hover:bg-muted":"border-border bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground"),children:`${I?"Flattened":"Flatten"} nested keys (${XG(ze)})`})]}):null,E.jsx(mR,{value:e,onChange:n,dark:p,testId:"input-editor"})]}),ie?E.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-3 z-10 flex items-center justify-center rounded-xl border-2 border-dashed border-primary/50 bg-background/80 backdrop-blur-sm",children:E.jsx("p",{className:"text-sm font-medium text-foreground",children:"Drop file to import"})}):null]})})}const qG=/\.(csv|tsv|txt|json|ndjson|md|log)$/i;function YG(t){return t.type.startsWith("text/")||t.type==="application/json"?!0:qG.test(t.name)}const JG=[{value:"utf-8",label:"UTF-8"},{value:"windows-1252",label:"Windows-1252"}];async function GS(t,e){const n=t.stream().getReader();let r="";try{const i=[];let s=0;for(;s<2;){const{done:u,value:c}=await n.read();if(u)break;c&&c.byteLength>0&&(i.push(c),s+=c.byteLength)}let o=null;if(i.length===1)o=i[0];else if(i.length>1){o=new Uint8Array(s);let u=0;for(const c of i)o.set(c,u),u+=c.byteLength}let l=e;e==="utf-8"&&o&&o.byteLength>=2&&(o[0]===255&&o[1]===254?l="utf-16le":o[0]===254&&o[1]===255&&(l="utf-16be"));const a=new TextDecoder(l,{fatal:!1});for(o&&(r+=a.decode(o,{stream:!0}));;){const{done:u,value:c}=await n.read();if(u)break;r+=a.decode(c,{stream:!0})}return r+a.decode()}finally{n.releaseLock()}}function xR(t){const[e,n]=y.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(t).matches);return y.useEffect(()=>{if(typeof window.matchMedia!="function")return;const r=window.matchMedia(t),i=s=>n(s.matches);return n(r.matches),r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[t]),e}const kR=[{value:"auto",label:"Auto-detect"},{value:",",label:"Comma"},{value:";",label:"Semicolon"},{value:" ",label:"Tab"},{value:"|",label:"Pipe"}];function qS(){return E.jsx("div",{className:"hidden h-5 w-px shrink-0 bg-border fit:block","aria-hidden":"true"})}function QG(t,e){var i;const r=[e.separator==="auto"?"Auto":((i=kR.find(s=>s.value===e.separator))==null?void 0:i.label)??"Auto"];return t==="csv2json"?(e.parseNumbers&&r.push("Parse numbers"),e.parseJSON&&r.push("Parse JSON"),e.emptyFields==="skip"&&r.push("Skip empty"),e.nullLiterals==="null"&&r.push("NULL→null"),e.transpose&&r.push("Transpose"),e.hash&&r.push("Hash"),e.minify&&r.push("Minify")):e.flatten&&r.push("Flatten"),r.join(" · ")}function YS(){return"h-7 cursor-pointer appearance-none rounded-md border border-border bg-background py-0 pl-2.5 pr-6 text-[13px] font-medium text-foreground transition-colors outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50"}function JS(){return E.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"pointer-events-none absolute top-1/2 right-1.5 size-3.5 -translate-y-1/2 text-muted-foreground",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:E.jsx("path",{d:"m4 6 4 4 4-4",strokeLinecap:"round",strokeLinejoin:"round"})})}function QS({children:t}){return E.jsx("span",{className:"font-mono text-[11px] font-semibold tracking-[0.14em] whitespace-nowrap text-muted-foreground/70 uppercase",children:t})}function po({label:t,checked:e,onChange:n,hint:r}){return E.jsxs("span",{className:"inline-flex items-center gap-1",children:[E.jsxs("label",{className:"flex cursor-pointer items-center gap-2 whitespace-nowrap text-[13px] text-muted-foreground transition-colors hover:text-foreground",children:[E.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":t,onClick:()=>n(!e),className:"flex h-6 shrink-0 cursor-pointer items-center rounded-full outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:E.jsx("span",{className:Un("relative inline-flex h-[18px] w-8 items-center rounded-full border transition-colors",e?"border-primary bg-primary":"border-border bg-muted"),children:E.jsx("span",{className:Un("pointer-events-none inline-block size-3 rounded-full bg-background shadow-sm transition-transform",e?"translate-x-[15px]":"translate-x-[2px]")})})}),E.jsx("span",{className:"select-none",children:t})]}),r?E.jsx(Uy,{text:r}):null]})}function Uy({text:t}){const e=y.useId(),[n,r]=y.useState(!1);return E.jsxs("span",{className:"relative inline-flex items-center",children:[E.jsx("button",{type:"button","aria-label":"What does this option do?","aria-expanded":n,"aria-describedby":e,title:"What does this option do?",onClick:()=>r(i=>!i),className:"flex h-4 w-4 cursor-pointer items-center justify-center rounded-full border border-border text-[9px] font-semibold leading-none text-muted-foreground hover:text-foreground",children:"i"}),E.jsx("span",{"data-hint":!0,id:e,hidden:!n,className:"ml-1 text-muted-foreground",children:t})]})}function ZG({direction:t,options:e,onChange:n,notice:r,uploadEncoding:i,onUploadEncodingChange:s}){const[o,l]=y.useState(!1),a=y.useRef(null),u=y.useRef(null),c=xR("(min-width: 98.5rem)"),f=t==="csv2json",d=QG(t,e),h=y.useCallback(()=>{var g;l(!1),(g=a.current)==null||g.focus()},[]);y.useEffect(()=>{if(!o)return;const g=m=>{m.key==="Escape"&&h()},b=m=>{const v=u.current;v===null||!(m.target instanceof Node)||v.contains(m.target)||h()};return document.addEventListener("keydown",g),document.addEventListener("click",b),()=>{document.removeEventListener("keydown",g),document.removeEventListener("click",b)}},[o,h]);const p=E.jsxs(E.Fragment,{children:[E.jsxs("span",{className:"inline-flex items-center gap-2",children:[E.jsxs("label",{className:"flex items-center gap-2",children:[E.jsx(QS,{children:"Separator"}),E.jsxs("span",{className:"relative inline-flex",children:[E.jsx("select",{"data-testid":"opt-separator",value:e.separator,onChange:g=>n({separator:g.target.value}),className:YS(),children:kR.map(g=>E.jsx("option",{value:g.value,children:g.label},g.value))}),E.jsx(JS,{})]})]}),E.jsx(Uy,{text:"Auto-detect is conservative — it only picks comma, semicolon, or tab. Pipe never auto-detects because normal prose is full of pipes, so pipe-separated text must be selected explicitly."})]}),i&&s?E.jsxs(E.Fragment,{children:[E.jsx(qS,{}),E.jsxs("span",{className:"inline-flex items-center gap-2",children:[E.jsxs("label",{className:"flex items-center gap-2",children:[E.jsx(QS,{children:"Encoding"}),E.jsxs("span",{className:"relative inline-flex",children:[E.jsx("select",{"data-testid":"opt-encoding",value:i,onChange:g=>s(g.target.value),className:YS(),children:JG.map(g=>E.jsx("option",{value:g.value,children:g.label},g.value))}),E.jsx(JS,{})]})]}),E.jsx(Uy,{text:"Applies to file uploads and drops only — pasted or typed text is always read as UTF-8. Switch to Windows-1252 for CSVs saved by legacy Excel to fix mangled accents like ü and ö."})]})]}):null,E.jsx(qS,{}),f?E.jsxs(E.Fragment,{children:[E.jsx(po,{label:"Parse numbers",checked:e.parseNumbers,onChange:g=>n({parseNumbers:g}),hint:"On by default — plain numbers like 5 or 19.99 become real JSON numbers; leading-zero values like 00721 and very long IDs stay strings. Uncheck to keep numeric cells as strings — booleans, null, and containers still convert while Parse JSON is on."}),E.jsx(po,{label:"Parse JSON",checked:e.parseJSON,onChange:g=>n({parseJSON:g}),hint:"Turns null, true, false, [] and {} into real JSON values instead of strings."}),E.jsx(po,{label:"Skip empty fields",checked:e.emptyFields==="skip",onChange:g=>n({emptyFields:g?"skip":"keep"}),hint:'Empty cells are dropped from the output instead of becoming "" — a column that is empty in every row disappears from the output and the counts.'}),E.jsx(po,{label:"NULL as null",checked:e.nullLiterals==="null",onChange:g=>n({nullLiterals:g?"null":"string"}),hint:"The string NULL becomes JSON null. Matching is exact and case-sensitive — SQL exports write uppercase NULL; Null and nULL are untouched, and lowercase null already converts when Parse JSON is on."}),E.jsx(po,{label:"Transpose",checked:e.transpose,onChange:g=>n({transpose:g}),hint:"Flip rows and columns — the first column becomes the header row."}),E.jsx(po,{label:"Hash output",checked:e.hash,onChange:g=>n({hash:g}),hint:"The first column becomes the object key instead of a field."}),E.jsx(po,{label:"Minify",checked:e.minify,onChange:g=>n({minify:g}),hint:"Remove indentation from the JSON output. Data is untouched."})]}):E.jsx(po,{label:"Flatten nested arrays",checked:e.flatten,onChange:g=>n({flatten:g}),hint:"Explode nested arrays into extra rows with dotted keys — needed when the JSON isn't a flat table."})]});return c?E.jsx("div",{"data-testid":"options-row",className:"flex flex-shrink-0 flex-row items-center gap-5 border-t border-border bg-panel px-5 py-2.5 text-[13px] text-muted-foreground",children:E.jsxs("div",{"data-testid":"options-settings-menu",role:"group","aria-label":"Parse settings",className:"flex flex-1 flex-wrap items-center gap-x-4 gap-y-2.5",children:[p,r?E.jsxs(E.Fragment,{children:[E.jsx("div",{className:"flex-1"}),E.jsx("span",{"data-testid":"options-notice",children:r})]}):null]})}):E.jsxs("div",{"data-testid":"options-row",ref:u,className:"relative flex flex-shrink-0 flex-col border-t border-border bg-panel px-3.5 py-2 text-[13px] text-muted-foreground md:px-4",children:[E.jsxs("div",{className:"flex w-full items-center gap-2",children:[E.jsxs("button",{type:"button",ref:a,"data-testid":"options-settings-toggle","aria-expanded":o,"aria-haspopup":"true",onClick:()=>o?h():l(!0),className:"inline-flex shrink-0 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-md py-0.5 text-[13px] font-medium text-foreground outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:["Parse settings",E.jsx(lN,{"aria-hidden":"true",className:Un("size-3.5 shrink-0 transition-transform",o&&"rotate-180")})]}),E.jsx("span",{"data-testid":"options-settings-summary",className:"min-w-0 truncate",children:d}),r?E.jsx("span",{"data-testid":"options-notice",className:"ml-auto shrink-0 text-right",children:r}):null]}),E.jsx("div",{"data-testid":"options-settings-menu",role:"group","aria-label":"Parse settings",hidden:!o,className:Un("absolute bottom-full left-0 z-50 mb-2 w-full items-center gap-x-4 gap-y-2.5 rounded-md border border-border bg-panel p-3 shadow-md",o?"flex flex-wrap":"hidden"),children:p})]})}const eq=[{format:"json",label:"JSON",extension:"json",mime:"application/json"},{format:"jsonl",label:"JSONL",extension:"jsonl",mime:"application/x-ndjson"},{format:"sql",label:"SQL",extension:"sql",mime:"application/sql"},{format:"ts",label:"TS",extension:"ts",mime:"text/typescript"}],tq=new Set(["csv","tsv","txt","json","jsonl","sql","ts"]),nq=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function eh(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Vw(t){if(Array.isArray(t))return t.map(e=>eh(e)?e:{value:e});if(eh(t)){const e=Object.entries(t);return e.length===0?[]:e.every(([,n])=>eh(n))?e.map(([n,r])=>{const i=r;return"key"in i?i:{key:n,...i}}):[t]}return[]}function SR(t){const e=new Set,n=[];for(const r of t)for(const i of Object.keys(r))e.has(i)||(e.add(i),n.push(i));return n}function rq(t){if(!t)return"data";let e=t.trim();const n=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));for(n>=0&&(e=e.slice(n+1));;){const i=e.lastIndexOf(".");if(i<=0)break;if(i===e.length-1){e=e.slice(0,i);continue}const s=e.slice(i+1).toLowerCase();if(!tq.has(s))break;e=e.slice(0,i)}const r=e.replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,"");return r.length>0?r:"data"}function Fm(t){return`"${t.replace(/"/g,'""')}"`}function iq(t){const e=t.filter(n=>n!=null);return e.length===0?"TEXT":e.every(n=>typeof n=="boolean")?"BOOLEAN":e.every(n=>typeof n=="number"&&Number.isFinite(n))?e.every(n=>Number.isInteger(n))?"INTEGER":"NUMERIC":"TEXT"}function sq(t){return t==null?"NULL":typeof t=="boolean"?t?"TRUE":"FALSE":typeof t=="number"?Number.isFinite(t)?String(t):"NULL":typeof t=="string"?`'${t.replace(/'/g,"''")}'`:`'${JSON.stringify(t).replace(/'/g,"''")}'`}function oq(t){const e=t.trim();if(e==="")return"";let n;try{n=JSON.parse(e)}catch{return t}return Vw(n).map(i=>JSON.stringify(i)).join(` +`)}function lq(t,e){const n=t.trim();if(n==="")return"";let r;try{r=JSON.parse(n)}catch{return t}const i=Vw(r),s=SR(i),o=Fm(rq(e));if(s.length===0)return`CREATE TABLE ${o} ();`;const l=s.map(d=>{const h=i.map(g=>g[d]),p=iq(h);return` ${Fm(d)} ${p}`}),a=`CREATE TABLE ${o} ( +${l.join(`, +`)} +);`;if(i.length===0)return a;const u=s.map(Fm).join(", "),c=i.map(d=>` (${s.map(p=>sq(d[p])).join(", ")})`),f=`INSERT INTO ${o} (${u}) VALUES +${c.join(`, +`)};`;return`${a} + +${f}`}function CR(t){if(t===null)return"null";if(typeof t=="string")return"string";if(typeof t=="number")return"number";if(typeof t=="boolean")return"boolean";if(Array.isArray(t)){if(t.length===0)return"unknown[]";const e=TR(Array.from(new Set(t.map(n=>CR(n)))));return e.length===1?`${e[0]}[]`:`(${e.join(" | ")})[]`}return eh(t)?"Record":"unknown"}const ZS={string:1,number:2,boolean:3,"Record":4,unknown:90,null:100};function TR(t){return[...t].sort((e,n)=>{const r=ZS[e]??50,i=ZS[n]??50;return r!==i?r-i:e.localeCompare(n)})}function aq(t){return nq.test(t)?t:JSON.stringify(t)}function uq(t){const e=t.trim();if(e==="")return"";let n;try{n=JSON.parse(e)}catch{return t}const r=Vw(n),s=SR(r).map(l=>{let a=!1;const u=new Set;for(const h of r){if(!Object.prototype.hasOwnProperty.call(h,l)||h[l]===void 0){a=!0;continue}u.add(CR(h[l]))}const c=TR(Array.from(u)),f=c.length>0?c.join(" | "):"unknown",d=a?"?":"";return` ${aq(l)}${d}: ${f};`});return`${s.length>0?`export interface DataRow { +${s.join(` +`)} +}`:"export interface DataRow {}"} + +export const data: DataRow[] = ${JSON.stringify(r,null,2)};`}function cq(t,e,n,r){const i=typeof t=="string"?t:t.text,s=typeof n=="string"||n===null?n:r??null;switch(e){case"json":return i;case"jsonl":return oq(i);case"sql":return lq(i,s);case"ts":return uq(i)}}const fq=3;function dq(t){const e=t.slice(0,fq),n=t.length-e.length;return(n>0?[...e,`+${n} more`]:e).join(` +`)}function hq({format:t,inputEmpty:e,outputText:n,error:r,meta:i,staleNotice:s,warnings:o,edited:l,editable:a,egressFormat:u="json",delimiter:c,dark:f,onCopy:d,onCopySelection:h,onProjectedCsvChange:p,onNativeCopy:g,onDownload:b,onEgressFormatChange:m,onOutputChange:v,onRevert:w,onDiscardReconvert:k}){const x=t==="JSON",C=u==="json";return E.jsx("div",{"data-testid":"output-pane","data-surface":"output",className:"flex min-h-0 min-w-0 flex-1 flex-col bg-muted/30",children:E.jsx(yR,{title:t,meta:e?null:l?E.jsxs("span",{className:"flex items-center gap-1.5",children:[E.jsx("span",{"data-testid":"edited-badge",role:"status","aria-label":"Output edited",className:"rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.08em] text-amber-700 dark:bg-amber-400/15 dark:text-amber-400",children:"Edited"}),E.jsxs("button",{type:"button","data-testid":"revert-output",onClick:w,className:kl,children:[E.jsx(xb,{"aria-hidden":"true"}),"Revert"]})]}):s?E.jsx("span",{"data-testid":"stale-notice",className:"text-xs text-amber-600 dark:text-amber-400",children:s}):i,actions:E.jsxs(E.Fragment,{children:[x?E.jsx("span",{"data-testid":"output-format-switcher",role:"group","aria-label":"Output format",className:"inline-flex items-center gap-0.5 rounded-lg border border-border bg-muted/60 p-0.5",children:eq.map(T=>{const A=u===T.format;return E.jsx("button",{type:"button","data-testid":`output-format-option-${T.format}`,"aria-pressed":A,onClick:()=>m==null?void 0:m(T.format),className:Un("inline-flex cursor-pointer items-center rounded-[7px] px-1.5 py-0.5 font-mono text-[11px] font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50 sm:px-2 sm:py-1",A?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:T.label},T.format)})}):null,E.jsxs("button",{type:"button","data-testid":"copy-output","aria-label":"Copy",title:"Copy",onClick:d,disabled:!n,className:kl,children:[E.jsx(Wv,{"aria-hidden":"true"}),E.jsx("span",{className:"hidden xl:inline",children:"Copy"})]}),E.jsxs("button",{type:"button","data-testid":"download-output","aria-label":"Download",title:"Download",onClick:b,disabled:!n,className:kl,children:[E.jsx(ET,{"aria-hidden":"true"}),E.jsx("span",{className:"hidden xl:inline",children:"Download"})]})]}),status:l?{kind:"notice",message:"Output edited — CSV and option changes aren't applied.",action:k?E.jsxs("button",{type:"button","data-testid":"discard-reconvert",onClick:k,className:kl+" ml-2",children:[E.jsx(xb,{"aria-hidden":"true"}),"Discard edits & reconvert"]}):void 0}:r?{kind:"error",message:r}:o&&o.length>0?{kind:"notice",message:dq(o)}:null,children:e?E.jsxs("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:["Your ",t," appears here."]}):n?x?E.jsx("div",{className:"flex min-h-0 flex-1 flex-col",onCopy:()=>g==null?void 0:g(),children:E.jsx(mR,{value:n,editable:a&&C&&n.length<=gR,lintJson:C,onChange:v,dark:f,testId:"output-view"})}):E.jsx(tA,{text:n,delimiter:c,testId:"output-table",dark:f,onCopySelection:h,onProjectedCsvChange:p}):r?E.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"Resolve the error to see output."}):E.jsx("div",{"data-testid":"output-converting-placeholder",className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"Converting…"})})})}function pq({phase:t,message:e,onRetry:n}){return t==="loading"?E.jsx("div",{role:"status","aria-busy":"true","data-testid":"permalink-loading",className:"mx-4 mt-3 rounded-md border border-border bg-muted px-4 py-2 text-sm text-muted-foreground",children:"Loading shared data…"}):t==="not-found"?E.jsxs("div",{role:"alert","data-testid":"permalink-notice",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-2 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[E.jsx("span",{children:"This data doesn't exist (or was deleted)."}),E.jsx("a",{href:"/",className:"font-medium underline underline-offset-2",children:"Go to the converter"})]}):t==="unsupported"?E.jsxs("div",{role:"alert","data-testid":"permalink-unsupported",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-2 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[E.jsx("span",{children:"This link's saved data can't be shown in the new converter."}),E.jsx("a",{href:"/",className:"font-medium underline underline-offset-2",children:"Go to the converter"})]}):E.jsxs("div",{role:"alert","data-testid":"permalink-notice",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-3 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[E.jsx("span",{children:e||"Couldn't load this data."}),E.jsx("button",{type:"button","data-testid":"permalink-retry",onClick:n,className:"rounded-md border border-border bg-background px-2 py-1 text-sm font-medium hover:bg-accent",children:"Retry"})]})}const Uw="csvjson:recent.v1",ER=10,AR=1e5,eC=80;function gq(t){return t==="csv2json"||t==="json2csv"}function mq(t){if(!t||typeof t!="object"||Array.isArray(t))return;const e={};for(const[n,r]of Object.entries(t))(r==="string"||r==="number"||r==="boolean"||r==="auto")&&(e[n]=r);return Object.keys(e).length>0?e:void 0}function MR(t){if(typeof t!="object"||t===null)return{...Yr};const e=t,n=e.separator,r=n==="auto"||n===","||n===";"||n===" "||n==="|"?n:Yr.separator,i=e.emptyFields==="keep"||e.emptyFields==="skip"?e.emptyFields:Yr.emptyFields,s=e.nullLiterals==="string"||e.nullLiterals==="null"?e.nullLiterals:Yr.nullLiterals,o=mq(e.columnTypes);return{separator:r,parseNumbers:typeof e.parseNumbers=="boolean"?e.parseNumbers:Yr.parseNumbers,parseJSON:typeof e.parseJSON=="boolean"?e.parseJSON:Yr.parseJSON,emptyFields:i,nullLiterals:s,transpose:typeof e.transpose=="boolean"?e.transpose:Yr.transpose,hash:typeof e.hash=="boolean"?e.hash:Yr.hash,minify:typeof e.minify=="boolean"?e.minify:Yr.minify,flatten:typeof e.flatten=="boolean"?e.flatten:Yr.flatten,collapseIndexedArrays:typeof e.collapseIndexedArrays=="boolean"?e.collapseIndexedArrays:Yr.collapseIndexedArrays,...o?{columnTypes:o}:{}}}function RR(t){const n=(t.split(/\r?\n/).map(r=>r.trim()).find(r=>r.length>0)??"").replace(/\s+/g," ");return n.length<=eC?n:`${n.slice(0,eC-1)}…`}function yq(t){if(typeof t!="object"||t===null)return!1;const e=t;return!(typeof e.id!="string"||e.id.trim()===""||typeof e.createdAt!="number"||!Number.isFinite(e.createdAt)||!gq(e.direction)||typeof e.input!="string"||e.input.trim()===""||e.input.length>AR||e.filename!==null&&typeof e.filename!="string"||typeof e.rows!="number"||!Number.isInteger(e.rows)||e.rows<0||typeof e.cols!="number"||!Number.isInteger(e.cols)||e.cols<0||typeof e.preview!="string")}function vq(t){return{id:t.id,createdAt:t.createdAt,direction:t.direction,input:t.input,options:MR(t.options),filename:t.filename,rows:t.rows,cols:t.cols,preview:t.preview||RR(t.input)}}function OR(t){try{if(typeof window>"u")return;window.localStorage.setItem(Uw,JSON.stringify(t))}catch{}}function wq(t){var e;return typeof((e=globalThis.crypto)==null?void 0:e.randomUUID)=="function"?globalThis.crypto.randomUUID():`snap-${t}-${Math.random().toString(36).slice(2,10)}`}function Kw(){try{if(typeof window>"u")return[];const t=window.localStorage.getItem(Uw);if(t===null)return[];const e=JSON.parse(t);return Array.isArray(e)?e.filter(yq).map(vq).sort((r,i)=>i.createdAt-r.createdAt).slice(0,ER):[]}catch{return[]}}function tC(t){const e=Kw(),n=t.input.trim();if(n===""||t.input.length>AR||t.rows<=0&&t.cols<=0)return e;const r=t.createdAt??Date.now(),i=e.find(a=>a.direction===t.direction&&a.input.trim()===n),s={id:(i==null?void 0:i.id)??wq(r),createdAt:r,direction:t.direction,input:t.input,options:MR(t.options),filename:t.filename,rows:t.rows,cols:t.cols,preview:RR(t.input)},o=e.filter(a=>!(a.direction===t.direction&&a.input.trim()===n)),l=[s,...o].slice(0,ER);return OR(l),l}function bq(t){const n=Kw().filter(r=>r.id!==t);return OR(n),n}function xq(){try{if(typeof window>"u")return;window.localStorage.removeItem(Uw)}catch{}}function kq(t,e=Date.now()){const n=Math.max(0,e-t),r=Math.floor(n/1e3);if(r<45)return"just now";const i=Math.floor(r/60);if(i<60)return`${i}m ago`;const s=Math.floor(i/60);if(s<24)return`${s}h ago`;const o=Math.floor(s/24);return o===1?"yesterday":o<7?`${o}d ago`:new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Sq(t){return t==="csv2json"?"CSV→JSON":"JSON→CSV"}function Cq(t,e){return t>0&&e>0?`${t} rows · ${e} cols`:t>0?`${t} rows`:e>0?`${e} cols`:"0 rows"}function Tq({snapshots:t,onSelect:e,onRemove:n,onClear:r}){const[i,s]=y.useState(!1),o=y.useRef(null),l=y.useRef(null),a=y.useCallback(()=>{s(!1)},[]),u=y.useRef(!1);y.useEffect(()=>{var f;u.current&&!i&&((f=l.current)==null||f.focus()),u.current=i},[i]),y.useEffect(()=>{if(!i)return;const f=h=>{h.key==="Escape"&&a()},d=h=>{const p=o.current;p===null||!(h.target instanceof Node)||p.contains(h.target)||a()};return document.addEventListener("keydown",f),document.addEventListener("click",d),()=>{document.removeEventListener("keydown",f),document.removeEventListener("click",d)}},[i,a]);const c=t.length;return E.jsxs("div",{"data-testid":"recent-history",ref:o,className:"relative max-sm:static",children:[E.jsxs("button",{type:"button","data-testid":"recent-history-toggle",ref:l,onClick:()=>s(f=>!f),"aria-expanded":i,"aria-haspopup":"dialog","aria-label":"Recent conversions",title:"Recent conversions",className:"relative inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg border border-border bg-panel px-2.5 text-xs font-medium text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[E.jsx(fN,{size:14,strokeWidth:2,"aria-hidden":"true"}),E.jsx("span",{className:"hidden sm:inline",children:"Recent"}),c>0&&E.jsx("span",{"data-testid":"recent-history-count",className:"rounded-full bg-muted px-1.5 py-px text-[10px] font-semibold tabular-nums text-foreground",children:c})]}),i&&E.jsxs("div",{"data-testid":"recent-history-popout",role:"dialog","aria-label":"Recent conversions",className:"absolute right-0 top-9 z-50 w-80 rounded-md border border-border bg-panel shadow-md max-sm:inset-x-2 max-sm:top-14 max-sm:w-auto",children:[E.jsxs("div",{className:"flex items-center justify-between border-b border-border py-1.5 pl-3 pr-1.5",children:[E.jsx("span",{className:"text-xs font-semibold tracking-tight text-foreground",children:"Recent conversions"}),E.jsxs("div",{className:"flex items-center gap-1",children:[c>0&&E.jsx("button",{type:"button","data-testid":"recent-history-clear",onClick:()=>{r()},className:"cursor-pointer rounded-md px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:"Clear history"}),E.jsx("button",{type:"button","data-testid":"recent-history-close",onClick:a,"aria-label":"Close recent conversions",className:"flex size-6 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:E.jsx(Ah,{size:14,strokeWidth:2,"aria-hidden":"true"})})]})]}),c===0?E.jsx("div",{"data-testid":"recent-history-empty",className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No recent conversions saved on this device yet."}):E.jsx("div",{className:"max-h-96 divide-y divide-border overflow-y-auto",children:t.map(f=>E.jsxs("div",{className:"flex items-start justify-between gap-1 px-2 py-2 transition-colors hover:bg-muted/50",children:[E.jsxs("button",{type:"button","data-testid":`recent-history-item-${f.id}`,onClick:()=>{e(f),a()},className:"flex min-w-0 flex-1 cursor-pointer flex-col items-start text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/50 rounded-sm px-1 py-0.5",children:[E.jsxs("div",{className:"mb-1 flex w-full items-center gap-1.5",children:[E.jsx("span",{className:"rounded-full border border-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:Sq(f.direction)}),E.jsx("span",{className:"text-[11px] text-muted-foreground",children:Cq(f.rows,f.cols)}),E.jsx("span",{className:"ml-auto text-[11px] text-muted-foreground",children:kq(f.createdAt)})]}),E.jsx("span",{className:"w-full truncate font-mono text-xs text-foreground",children:f.filename??f.preview})]}),E.jsx("button",{type:"button","data-testid":`recent-history-delete-${f.id}`,onClick:d=>{d.stopPropagation(),n(f.id)},"aria-label":`Delete recent snapshot ${f.filename??f.preview}`,title:"Delete snapshot",className:"mt-0.5 flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:E.jsx(Eh,{size:13,strokeWidth:2,"aria-hidden":"true"})})]},f.id))})]})]})}const Ky=20,Xy=80,nC=50;function zm(t){return Math.min(Xy,Math.max(Ky,t))}function Eq({layout:t,split:e,onSplitChange:n,left:r,right:i,children:s}){const o=y.useRef(null),[l,a]=y.useState(!1),u=t==="stacked";y.useEffect(()=>{if(!l)return;const f=h=>{var b;const p=(b=o.current)==null?void 0:b.getBoundingClientRect();if(!p||p.width===0||p.height===0)return;const g=u?(h.clientY-p.top)/p.height:(h.clientX-p.left)/p.width;n(zm(g*100))},d=()=>a(!1);return window.addEventListener("pointermove",f),window.addEventListener("pointerup",d),window.addEventListener("pointercancel",d),()=>{window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",d)}},[l,u,n]);const c=f=>{const d=f.shiftKey?5:1;switch(f.key){case"ArrowLeft":case"ArrowUp":f.preventDefault(),n(zm(e-d));break;case"ArrowRight":case"ArrowDown":f.preventDefault(),n(zm(e+d));break;case"Home":f.preventDefault(),n(Ky);break;case"End":f.preventDefault(),n(Xy);break;case"Enter":case" ":f.preventDefault(),n(nC);break}};return E.jsxs("div",{ref:o,className:Un("relative flex min-h-0 flex-1","flex-col md:flex-row",l&&"select-none"),children:[E.jsx("div",{"data-testid":"pane-left",style:{"--split":`${e}%`},className:Un("flex min-h-0 min-w-0 flex-col overflow-hidden border-border bg-panel max-md:min-h-[280px] max-md:max-h-[360px]","h-[var(--split)] border-b","md:h-auto md:w-[var(--split)] md:border-b-0 md:border-r"),children:r}),E.jsxs("div",{"data-testid":"seam",role:"separator",tabIndex:0,"aria-orientation":u?"horizontal":"vertical","aria-valuenow":Math.round(e),"aria-valuemin":Ky,"aria-valuemax":Xy,"aria-label":"Resize panes",title:"Drag to resize · double-click to reset",onPointerDown:f=>{var d,h;f.target instanceof Element&&f.target.closest("button")||(f.preventDefault(),(h=(d=f.currentTarget).setPointerCapture)==null||h.call(d,f.pointerId),a(!0))},onPointerUp:()=>a(!1),onDoubleClick:()=>n(nC),onKeyDown:c,style:{"--split":`${e}%`,touchAction:"none"},className:Un("relative z-10 flex h-9 flex-shrink-0 items-center justify-center border-b border-border bg-muted/20 cursor-row-resize","md:absolute md:top-0 md:right-auto md:bottom-0 md:left-[var(--split)] md:h-auto md:w-0 md:border-b-0 md:bg-transparent md:cursor-col-resize"),children:[E.jsx("div",{className:Un("absolute","inset-0","md:inset-auto md:top-0 md:right-auto md:bottom-0 md:-left-1.5 md:h-auto md:w-3")}),s?E.jsx("div",{className:"relative z-10 md:absolute md:left-1/2 md:top-1/2 md:-translate-x-1/2 md:-translate-y-1/2",children:s}):null]}),E.jsx("div",{"data-testid":"pane-right",className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-panel max-md:min-h-[240px] max-md:max-h-[340px]",children:i})]})}function Aq({theme:t}){return t==="dark"?E.jsx(RN,{size:15,strokeWidth:2,"aria-hidden":"true"}):E.jsx(vN,{size:15,strokeWidth:2,"aria-hidden":"true"})}function Mq({theme:t,onToggleTheme:e,slot:n}){return E.jsxs("header",{"data-testid":"topbar",className:"relative flex h-14 flex-shrink-0 items-center gap-3 border-b border-border bg-panel px-5",children:[E.jsxs("div",{className:"flex items-baseline gap-2",children:[E.jsx("span",{className:"text-[15px] font-semibold tracking-tight text-foreground whitespace-nowrap",children:"csvjson"}),E.jsx("span",{className:"hidden text-[13px] font-medium text-muted-foreground sm:inline",children:"CSV → JSON converter"})]}),E.jsx("div",{className:"flex-1"}),E.jsx("div",{"data-testid":"topbar-slot",children:n}),E.jsx("button",{type:"button","data-testid":"theme-toggle",onClick:e,"aria-label":t==="dark"?"Switch to light mode":"Switch to dark mode",title:t==="dark"?"Switch to light mode":"Switch to dark mode",className:"inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border bg-panel text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:E.jsx(Aq,{theme:t})})]})}function Rq(t){return[...t].sort((e,n)=>n.id-e.id)}const PR=[{id:23,date:"2026-10-20",tag:"new",title:"Extract and switch between multiple tables in pasted Markdown",summary:"Paste an entire ChatGPT response or Markdown document containing prose and multiple Markdown or CLI box tables into CSV → JSON: every table is detected in order with interactive chooser pills to switch which table is previewed and converted, or keep only the selected table as clean CSV."},{id:22,date:"2026-10-20",tag:"new",title:"Column visibility picker and Apply view to output",summary:"Use the new Columns menu in any data table to hide or restore columns without touching your raw input. When a search filter, sort order, or column subset is active, toggle Apply view to output to project that exact table view into the converted output, Copy, and Download."},{id:21,date:"2026-10-20",tag:"new",title:"Paste Markdown & CLI box tables directly into CSV → JSON",summary:"Paste GitHub/ChatGPT Markdown pipe tables or psql/MySQL ASCII box tables directly into CSV → JSON: divider rows, outer pipes, and (N rows) footers are stripped automatically, with a one-click Clean table action to normalize the raw CSV in place."},{id:20,date:"2026-10-20",tag:"new",title:"One-click nested JSON flattening in JSON → CSV",summary:"When JSON → CSV input contains nested objects or arrays, a contextual Flatten nested keys pill appears above the editor to expand deep objects into dotted CSV column headers (like user.profile.name) and join scalar arrays in one click."},{id:19,date:"2026-10-20",tag:"new",title:"Pin per-column types in the CSV grid",summary:"Select any column in the CSV table to pin its JSON output type to String, Number, Boolean, or Auto — keeping postal codes and IDs as strings or coercing yes/no/1/0 columns to booleans without changing global parse settings."},{id:18,date:"2026-10-20",tag:"new",title:"Live spreadsheet selection aggregates in the table toolbar",summary:"Select any range of cells, rows, or columns in the data table to see instant cell, distinct, and empty counts alongside numeric Sum, Avg, Min, and Max aggregates. Range selections also expose one-click Copy as CSV right from the toolbar."},{id:17,date:"2026-10-20",tag:"new",title:"Export CSV as JSONL, SQL INSERTs, or TypeScript",summary:"Switch the CSV → JSON output header between JSON, JSONL, SQL, and TS to generate newline-delimited records, CREATE TABLE and INSERT statements with inferred types, or a typed TypeScript DataRow interface and array ready to copy or download."},{id:16,date:"2026-10-20",tag:"new",title:"Restore recent conversions from the top bar",summary:"The new Recent menu in the top bar saves up to 10 valid conversions locally on your device so you can jump back to an earlier dataset in one click. Fresh page loads still start on a clean empty dropzone."},{id:15,date:"2026-10-18",tag:"improvement",title:"Options fold into a Parse settings menu",summary:"On narrower screens the converter's options bar no longer wraps onto extra lines — it collapses to a single Parse settings line showing your active options, with the full control set in a drop-up above it. Small screens lose the accordion that squeezed the panes."},{id:14,date:"2026-10-17",tag:"improvement",title:"Polished mobile stacked panes and collapsible options bar",summary:"Small screens now stack the input and output panes with an in-flow direction switch and compact icon actions so nothing overlaps. The options bar collapses into a one-tap summary on phones while keeping every setting a tap away."},{id:13,date:"2026-10-15",tag:"fix",title:"Faster large CSV uploads without page freezes",summary:"Uploading large CSV files now converts in a single pass without freezing the tab or flashing a false error state, previews multi-megabyte JSON outputs smoothly while keeping full Copy and Download, and decodes UTF-16 CSV exports automatically."},{id:12,date:"2026-10-15",tag:"improvement",title:"Table undo, header rename, and smarter JSON input",summary:"Undo or redo CSV table edits, double-click any column header to rename it in place, and collapse .0, .1 indexed columns into JSON arrays. JSON → CSV now formats or minifies JSON in one click, unwraps nested record arrays, parses JSONL, and previews pipe-delimited output accurately."},{id:11,date:"2026-10-03",tag:"improvement",title:"The switch names the direction",summary:"The ⇄ switch now labels the active conversion, and legacy /json2csv links land you in JSON → CSV mode again — it never left."},{id:10,date:"2026-09-08",tag:"new",title:"Delete rows and columns from the table",summary:"Select rows or columns in the input table and delete them by button or the Delete key — the raw CSV updates and reconverts in place, with at least one column always kept. Selected column headers are also readable again in both themes."},{id:9,date:"2026-09-08",tag:"new",title:"Spreadsheet-grade data table",summary:"The rebuilt data table adds drag-to-select ranges, Shift+Arrow range extension, fill, and spreadsheet-style cell editing — with copy/paste always producing clean CSV."},{id:8,date:"2026-09-07",tag:"new",title:"Search, sort, and select in the data table",summary:"The CSV table now has a search bar with a live row count, click-to-sort columns, and row selection with copy-as-CSV — on both the input and output tables."},{id:7,date:"2026-09-07",tag:"fix",title:"No more layout flash on load",summary:"The converter now renders side-by-side immediately on desktop, instead of stacking the panes and snapping into columns as the page loads."},{id:6,date:"2026-09-07",tag:"new",title:"Introducing the changelog",summary:"This changelog keeps you posted on what's new — recent updates appear here with an unseen dot when you come back. Feel free to vote on what you find useful."},{id:5,date:"2026-09-05",tag:"improvement",title:"Icons match the design",summary:"Action buttons, view toggle, and the empty state now use the same crisp icon set as the rest of the interface."},{id:4,date:"2026-09-05",tag:"new",title:"Edit the JSON output in place",summary:"The output pane is now an editor. Hand edits survive until you reconvert; revert and discard keep you safe."},{id:3,date:"2026-09-05",tag:"fix",title:"Pastes land where they belong",summary:"Paste anywhere on the page and your data routes to the input — including pastes over the read-only output pane."},{id:2,date:"2026-09-04",tag:"improvement",title:"A calmer empty state",summary:"Empty panes now open on a compact paste field with a Choose file button, so starting is obvious on any screen."},{id:1,date:"2026-09-04",tag:"improvement",title:"Smarter number handling",summary:"Numbers convert sensibly out of the box: leading-zero values like 00721 and very long IDs stay strings so nothing gets silently mangled."}],Oq=864e5;function rC(t){return Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())}function Pq(t,e=Date.now()){const n=new Date(`${t}T00:00:00Z`),r=new Date(e),i=Math.round((rC(r)-rC(n))/Oq);if(i<=0)return"today";if(i===1)return"yesterday";if(i<7)return`${i} days ago`;const s=n.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:"UTC"});return n.getUTCFullYear()===r.getUTCFullYear()?s:`${s}, ${n.getUTCFullYear()}`}const IR="csvjson:changelog.v1",th=Math.max(...PR.map(t=>t.id),0),Iq=Rq(PR);function Nq(t){if(typeof t!="object"||t===null)return!1;const e=t;if(e.lastSeenId!==null&&typeof e.lastSeenId!="number"||typeof e.votes!="object"||e.votes===null)return!1;for(const[n,r]of Object.entries(e.votes))if(!/^\d+$/.test(n)||r!==1&&r!==-1)return!1;return!(e.clientId!==void 0&&!_q(e.clientId)||e.pendingIds!==void 0&&(!Array.isArray(e.pendingIds)||e.pendingIds.some(n=>typeof n!="number"||!Number.isInteger(n)||n<1)))}function _q(t){return typeof t=="string"&&/^[0-9a-fA-F-]{8,64}$/.test(t)}function NR(t){return t===void 0?[]:[...new Set(t)].filter(e=>e>=1&&e<=th).sort((e,n)=>e-n)}function iC(t,e,n){const r=NR(t.pendingIds),i=n?[...new Set([...r,e])].sort((s,o)=>s-o):r.filter(s=>s!==e);return{...t,pendingIds:i}}function Dq(){try{const t=window.localStorage.getItem(IR);if(t===null)return{lastSeenId:null,votes:{}};const e=JSON.parse(t);return Nq(e)?{...e,pendingIds:NR(e.pendingIds)}:{lastSeenId:null,votes:{}}}catch{return{lastSeenId:null,votes:{}}}}function Lq(t){try{window.localStorage.setItem(IR,JSON.stringify(t))}catch{}}function $q(){var n,r,i;if(typeof((n=globalThis.crypto)==null?void 0:n.randomUUID)=="function")return globalThis.crypto.randomUUID();const t=(i=(r=globalThis.crypto)==null?void 0:r.getRandomValues)==null?void 0:i.call(r,new Uint8Array(16));if(t===void 0)throw new Error("no secure randomness available");t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=Array.from(t,s=>s.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}async function Fq(t,e,n){try{return(await fetch("/api/changelog-vote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:t,entryId:e,vote:n})})).ok?"ok":"failed"}catch{return"failed"}}function sC(t){return["flex h-6 w-7 cursor-pointer items-center justify-center rounded-md transition-colors",t?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"].join(" ")}function zq({entry:t,vote:e,queued:n,inFlight:r,onVote:i}){return E.jsxs("article",{className:"px-3 py-2.5","data-testid":`changelog-entry-${t.id}`,children:[E.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[t.tag!==void 0&&E.jsx("span",{className:"rounded-full border border-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:t.tag}),E.jsx("span",{className:"text-[11px] text-muted-foreground",children:Pq(t.date)})]}),E.jsx("h3",{className:"text-xs font-semibold text-foreground",children:t.title}),E.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:t.summary}),E.jsxs("div",{className:"mt-1.5 flex gap-1",children:[E.jsx("button",{type:"button","data-testid":`changelog-up-${t.id}`,onClick:()=>i(t.id,1),"aria-pressed":e===1,"aria-label":`Upvote: ${t.title}`,title:"Good change",className:sC(e===1),children:E.jsx(DN,{size:13,strokeWidth:2,"aria-hidden":"true"})}),E.jsx("button",{type:"button","data-testid":`changelog-down-${t.id}`,onClick:()=>i(t.id,-1),"aria-pressed":e===-1,"aria-label":`Downvote: ${t.title}`,title:"Not for me",className:sC(e===-1),children:E.jsx(NN,{size:13,strokeWidth:2,"aria-hidden":"true"})})]}),n&&!r&&E.jsx("p",{"data-testid":`changelog-queued-${t.id}`,role:"status",className:"mt-1.5 rounded-sm border border-dashed border-border px-2 py-1 text-[11px] text-muted-foreground",children:"Vote queued — it will retry on your next interaction."})]})}function Bq(){const[t,e]=y.useState(Dq),[n,r]=y.useState(!1),i=y.useRef(t),s=y.useCallback(x=>{Lq(x),i.current=x,e(x)},[]),[o,l]=y.useState(()=>new Set),a=y.useRef(new Set),u=y.useRef(null),c=y.useRef(null),f=y.useRef(new Map),d=t.lastSeenId!==null&&th>t.lastSeenId,h=y.useCallback((x,C)=>{l(T=>{const A=new Set(T);return C?A.add(x):A.delete(x),A})},[]),p=y.useCallback((x,C,T,A)=>{const M=(f.current.get(x)??0)+1;f.current.set(x,M),a.current.add(x),A&&h(x,!0),Fq(T,x,C).then(I=>{f.current.get(x)===M&&(a.current.delete(x),I==="ok"&&(HI({entry_id:x,vote:C}),s(iC(i.current,x,!1))),A&&h(x,!1))})},[s,h]),g=y.useCallback(x=>{const{clientId:C,pendingIds:T,votes:A}=i.current,M=T??[];if(M.length!==0&&C!==void 0)for(const I of M){if(I===x||a.current.has(I))continue;const D=A[I];D!==void 0&&p(I,D,C,!1)}},[p]),b=(x,C)=>{if(t.votes[x]===C){g();return}const T=t.clientId??$q();s(iC({...t,votes:{...t.votes,[x]:C},clientId:T},x,!0)),p(x,C,T,!0),g(x)},m=()=>{r(!0),jI(),t.lastSeenId!==th&&s({...t,lastSeenId:th}),g()},v=y.useCallback(()=>{r(!1)},[]),w=y.useRef(!1);y.useEffect(()=>{var x;w.current&&!n&&((x=c.current)==null||x.focus()),w.current=n},[n]);const k=y.useRef(!1);return y.useEffect(()=>{k.current||(k.current=!0,g())},[g]),y.useEffect(()=>{if(!n)return;const x=T=>{T.key==="Escape"&&v()},C=T=>{const A=u.current;A===null||!(T.target instanceof Node)||A.contains(T.target)||v()};return document.addEventListener("keydown",x),document.addEventListener("click",C),()=>{document.removeEventListener("keydown",x),document.removeEventListener("click",C)}},[n,v]),E.jsxs("div",{"data-testid":"changelog",ref:u,className:"relative max-sm:static",children:[E.jsxs("button",{type:"button","data-testid":"changelog-toggle",ref:c,onClick:()=>n?v():m(),"aria-expanded":n,"aria-haspopup":"dialog","aria-label":"Changelog",title:"What's new",className:"relative inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border bg-panel text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[E.jsx(kN,{size:15,strokeWidth:2,"aria-hidden":"true"}),d&&E.jsx("span",{"data-testid":"changelog-dot","aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-foreground"})]}),n&&E.jsxs("div",{"data-testid":"changelog-popout",role:"dialog","aria-label":"Changelog",className:"absolute right-0 top-9 z-50 w-80 rounded-md border border-border bg-panel shadow-md max-sm:inset-x-2 max-sm:top-14 max-sm:w-auto",children:[E.jsxs("div",{className:"flex items-center justify-between border-b border-border py-1.5 pl-3 pr-1.5",children:[E.jsx("span",{className:"text-xs font-semibold tracking-tight text-foreground",children:"What's new"}),E.jsx("button",{type:"button","data-testid":"changelog-close",onClick:v,"aria-label":"Close changelog",className:"flex size-6 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:E.jsx(Ah,{size:14,strokeWidth:2,"aria-hidden":"true"})})]}),E.jsx("div",{className:"max-h-96 divide-y divide-border overflow-y-auto",children:Iq.map(x=>{var C;return E.jsx(zq,{entry:x,vote:t.votes[x.id],queued:((C=t.pendingIds)==null?void 0:C.includes(x.id))??!1,inFlight:o.has(x.id),onVote:b},x.id)})})]})]})}function jq(t,e){const[n,r]=y.useState(t);return y.useEffect(()=>{const i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}const Hq={},Wq=["csv2json","json2csv","json_validator","json_beautifier","sql2json","csvjson2json","datajanitor"],Vq=["csv2json","json2csv","csvjson2json"];function Uq(t){return Vq.includes(t)}const Kq=/^[0-9a-f]{32}$/i,Xq=/^\/([a-z0-9_]+)\/([0-9a-f]{32})\/?$/i,Bm=Hq,Gq=((Bm==null?void 0:Bm.VITE_S3_DATA_URL)??"https://csvjson.s3.us-east-2.amazonaws.com/data/").replace(/\/*$/,"/");function qq(t){const e=Xq.exec(t);if(!e)return null;const n=e[1].toLowerCase();return Wq.includes(n)?{tool:n,id:e[2].toLowerCase()}:null}class Gy extends Error{constructor(){super("This data doesn't exist (or was deleted)"),this.name="PermalinkNotFoundError"}}class jm extends Error{constructor(e,n){super(e,n),this.name="PermalinkFetchError"}}const Hm={csv:(t,e)=>{t.direction="csv2json",t.input=up(e)},json:(t,e)=>{t.input=up(e),t.direction="json2csv"},parseNumbers:(t,e)=>{const n=sa(e);n!==void 0&&(t.options.parseNumbers=n)},parseJSON:(t,e)=>{const n=sa(e);n!==void 0&&(t.options.parseJSON=n)},transpose:(t,e)=>{const n=sa(e);n!==void 0&&(t.options.transpose=n)},"output-array":(t,e)=>{const n=sa(e);n!==void 0&&(t.options.hash=!n)},"output-hash":(t,e)=>{const n=sa(e);n!==void 0&&(t.options.hash=n)},flatten:(t,e)=>{const n=sa(e);n!==void 0&&(t.options.flatten=n)},output_csvjson_variant:()=>{}};function up(t){return typeof t=="string"?t:typeof t=="number"?String(t):""}function oC(t){return typeof t=="string"&&t.trim()!==""}function sa(t){if(t===!0||t==="true")return!0;if(t===!1||t==="false")return!1}function Yq(t){return t===null||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(e=>typeof e=="string"||typeof e=="boolean")}function Jq(t){var i;if(!Yq(t))return null;const e=oC(t.csv),n=oC(t.json);if(!e&&!n)return null;const r={direction:e?"csv2json":"json2csv",input:"",options:{}};for(const[s,o]of Object.entries(t))(i=Hm[s])==null||i.call(Hm,r,o);return r.input=up(e?t.csv:t.json),r}async function Qq(t){if(!Kq.test(t))throw new Gy;let e;try{e=await fetch(`${Gq}${t}`,{mode:"cors"})}catch(r){throw new jm("Network error while loading this data",{cause:r})}if(e.status===403||e.status===404)throw new Gy;if(!e.ok)throw new jm(`Unexpected response while loading this data (HTTP ${e.status})`);let n;try{const r=await e.text();if(r.trim()==="")throw new Error("empty body");n=JSON.parse(r)}catch{throw new jm("Stored data for this link is malformed")}return n}function Zq(t){const e=y.useMemo(()=>t&&Uq(t.tool)?t.id:null,[t]),[n,r]=y.useState(0),[i,s]=y.useState(e?"loading":"idle"),[o,l]=y.useState(null),[a,u]=y.useState("");return y.useEffect(()=>{if(!e)return;let c=!1;return Qq(e).then(f=>{if(c)return;const d=Jq(f);d?(l(d),s("hydrated")):s("unsupported")}).catch(f=>{c||(f instanceof Gy?s("not-found"):(u(f instanceof Error?f.message:"Couldn't load this data"),s("error")))}),()=>{c=!0}},[e,n]),{phase:i,hydrated:o,message:a,retry:()=>{i==="error"&&(s("loading"),r(c=>c+1))}}}async function lC(t){try{if(typeof navigator<"u"&&navigator.clipboard)return await navigator.clipboard.writeText(t),!0}catch{}try{const e=document.createElement("textarea");e.value=t,e.setAttribute("readonly",""),e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select();const n=document.execCommand("copy");return e.remove(),n}catch{return!1}}const eY="\uFEFF";function tY(t,e){return e?eY+t:t}function nY(t,e,n){const r=tY(t,n);return new Blob([r],{type:`${e};charset=utf-8`})}const rY=new Set(["csv","tsv","json","jsonl","sql","ts","txt"]);function iY(t){let e=t;for(;;){const n=e.lastIndexOf(".");if(n<=0)break;if(n===e.length-1){e=e.slice(0,n);continue}if(!rY.has(e.slice(n+1).toLowerCase()))break;e=e.slice(0,n)}return e}function sY(t,e,n="json"){const r=e==="csv2json"?n:"csv";return t?`${iY(t)}.${r}`:`data.${r}`}function oY(t,e="json"){if(t==="json2csv")return"text/csv";switch(e){case"json":return"application/json";case"jsonl":return"application/x-ndjson";case"sql":return"application/sql";case"ts":return"text/typescript"}}function aC(t,e,{mime:n="text/plain",bom:r=!1}={}){const i=nY(t,n,r),s=URL.createObjectURL(i),o=document.createElement("a");return o.href=s,o.download=e,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(s),0),e}function lY(t){if(!(t instanceof HTMLElement))return!1;if(t.isContentEditable)return!0;const e=t.tagName;return e==="INPUT"||e==="TEXTAREA"?!0:t.closest('[contenteditable="true"]')!==null}const aY=`album,year,US_peak_chart_post +The White Stripes,1999, +De Stijl,2000, +White Blood Cells,2001,61 +Elephant,2003,6 +Get Behind Me Satan,2005,3 +Icky Thump,2007,2`,uY=`[ + { + "album": "Elephant", + "year": 2003, + "label": "XL Recordings" + }, + { + "album": "Icky Thump", + "year": 2007, + "label": "XL Recordings" + } +]`,_R="csvjson-theme";function cY(){try{const t=localStorage.getItem(_R);return t==="dark"||t==="light"?t:null}catch{return null}}function fY(){try{if(typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}catch{}return"light"}function dY(){return cY()??fY()}function hY(t){try{localStorage.setItem(_R,t)}catch{}}function pY(t){return new URLSearchParams(t).get("direction")==="json2csv"?"json2csv":"csv2json"}const uC=2*1024*1024,gY=150,mY=1e3,yY=2e3,vY=2e3;function wY(t,e){return t===0?null:e>0?`${t} rows · ${e} cols`:`${t} rows`}function cC(t){try{return JSON.parse(t),!0}catch{return!1}}function bY(){var Ut;const[t,e]=y.useState(dY);y.useEffect(()=>{document.documentElement.classList.toggle("dark",t==="dark")},[t]);const n=()=>e(J=>{const st=J==="dark"?"light":"dark";return hY(st),st}),[r,i]=y.useState(()=>typeof window>"u"?"csv2json":pY(window.location.search)),[s,o]=y.useState(()=>sl("")),l=s.present,[a,u]=y.useState(Yr),[c,f]=y.useState("json"),[d,h]=y.useState(50),[p,g]=y.useState(null),[b,m]=y.useState(!1),[v,w]=y.useState(null),[k,x]=y.useState("utf-8"),[C,T]=y.useState(Kw),[A,M]=y.useState(null),[I,D]=y.useState(null),[O,L]=y.useState({forInput:"",index:0}),_=O.forInput===l?O.index:0,re=y.useCallback(J=>{L({forInput:l,index:J})},[l]),ie=y.useMemo(()=>_>0?{...a,markdownTableIndex:_}:a,[a,_]),se=y.useRef({direction:r,options:a,input:l,resultOk:!0}),H=y.useRef(null);H.current||(H.current=YI({settleMs:yY,minWindowMs:vY,isValid:(J,st)=>{const lt=se.current;return st===lt.input?lt.resultOk:ho(J==="csv_to_json"?"csv2json":"json2csv",st,lt.options).ok}}));const X=H.current;y.useEffect(()=>()=>X.cancel(),[X]);const N=xR("(min-width: 48rem)")?"side-by-side":"stacked",P=r==="csv2json",B=P?"CSV":"JSON",q=P?"JSON":"CSV",W=l.trim()==="",ye=l.length>uC?mY:gY,ee=jq(l,W?0:ye),me=y.useRef(null),Le=y.useRef(null),ze=l!==""&&((Ut=me.current)==null?void 0:Ut.text)===l?l:ee,Mt=P&&A!==null&&ze.trim()!==""?A:ze,tt=y.useMemo(()=>typeof window>"u"?null:qq(window.location.pathname),[]),Be=Zq(tt),ue=y.useMemo(()=>ho(r,Mt,ie),[r,Mt,ie]);se.current={direction:r,options:ie,input:ze,resultOk:ue.ok},y.useEffect(()=>{const J=Le.current;!J||J.text!==ze||(Le.current=null,X.discrete(J.direction,J.via,J.text))},[ze,ue,X]);const[It,be]=y.useState(null);y.useEffect(()=>{ze.trim()!==""&&ue.ok&&be(ue.text)},[ue,ze]),y.useEffect(()=>{ze.trim()!==""&&(!ue.ok||ue.rows<=0&&ue.cols<=0||T(tC({direction:r,input:ze,options:a,filename:p,rows:ue.rows,cols:ue.cols})))},[r,ze,p,a,ue]);const xe=ze.trim()!==""&&ue.ok?ue.text:It,[Y,Se]=y.useState(!1),[Ie,Ce]=y.useState(null),xt=Y?Ie:xe,$e=y.useMemo(()=>{if(!P||xt===null||c==="json")return xt;const J=Y&&Ie!==null&&cC(Ie)?Ie:xe;return J===null?null:cq(J,c,a,p)},[P,xt,c,Y,Ie,xe,a,p]),nt=P&&c==="json"&&!W&&$e!==null&&(Y||ue.ok),ge=y.useCallback(J=>{if(J===xe){Se(!1),Ce(null);return}Se(!0),Ce(J)},[xe]),ot=y.useCallback(()=>{const J=P&&A!==null&&l.trim()!==""?A:l,st=ho(r,J,ie);st.ok&&be(st.text),Se(!1),Ce(null)},[P,r,ie,l,A]),rt=y.useCallback(J=>{o(st=>P?lk(st,J):sl(J))},[P]),Ke=P&&s.past.length>0,an=P&&s.future.length>0,mt=y.useCallback(()=>{if(!P||s.past.length===0)return;const J=X9(s);w(null),o(J),X.edit("csv_to_json",J.present)},[P,s,X]),it=y.useCallback(()=>{if(!P||s.future.length===0)return;const J=G9(s);w(null),o(J),X.edit("csv_to_json",J.present)},[P,s,X]),dt=y.useCallback(J=>{w(null),me.current=null,i(J.direction),u({...J.options}),g(J.filename),Se(!1),Ce(null),o(st=>J.direction==="csv2json"&&r==="csv2json"?lk(st,J.input):sl(J.input)),T(tC({direction:J.direction,input:J.input,options:J.options,filename:J.filename,rows:J.rows,cols:J.cols}))},[r]),Yt=y.useCallback(J=>{T(bq(J))},[]),mn=y.useCallback(()=>{xq(),T([])},[]),qn=()=>{const J=r==="csv2json"?"json2csv":"csv2json";if(Y){const st=Ie??"",lt=cC(st)?st:l;o(sl(lt)),i(J),Se(!1),Ce(null),lt.trim()!==""&&(se.current={direction:J,options:a,input:lt,resultOk:ho(J,lt,a).ok},X.discrete(J==="csv2json"?"csv_to_json":"json_to_csv","flip",lt));return}if(i(J),W)o(sl(""));else{const st=ho(r,l,ie),lt=st.ok?st.text:l;o(sl(lt)),lt.trim()!==""&&(se.current={direction:J,options:a,input:lt,resultOk:ho(J,lt,a).ok},X.discrete(J==="csv2json"?"csv_to_json":"json_to_csv","flip",lt))}},Jt=Be.hydrated;y.useEffect(()=>{if(Jt===null)return;const J={...se.current.options,...Jt.options};se.current={direction:Jt.direction,options:J,input:Jt.input,resultOk:ho(Jt.direction,Jt.input,J).ok},i(Jt.direction),o(sl(Jt.input)),u(st=>({...st,...Jt.options})),Se(!1),Ce(null),BI(),X.discrete(Jt.direction==="csv2json"?"csv_to_json":"json_to_csv","permalink",Jt.input)},[Jt,X]);const jt=async(J,st)=>{if(!YG(J)){w(`Can't read "${J.name}" as text — drop a ${P?".csv / .tsv":".json"} file.`);return}w(null),m(!0);try{const lt=await GS(J,k);me.current={file:J,source:st,text:lt},Le.current={direction:P?"csv_to_json":"json_to_csv",via:st==="drop"?"drag":"file",text:lt},rt(lt),g(J.name),m(!1)}catch{m(!1),w(`Couldn't read "${J.name}".`)}},Hn=async J=>{const st=k;x(J);const lt=me.current;if(!(!lt||l!==lt.text)){m(!0);try{const Jn=await GS(lt.file,J);me.current={...lt,text:Jn},Le.current={direction:P?"csv_to_json":"json_to_csv",via:lt.source==="drop"?"drag":"file",text:Jn},o(Vr=>({...Vr,present:Jn})),m(!1)}catch{m(!1),x(st),w(`Couldn't read "${lt.file.name}".`)}}},bn=y.useCallback(J=>{w(null),J.trim()===""&&u(st=>{if(!st.columnTypes)return st;const lt={...st};return delete lt.columnTypes,lt}),rt(J),X.edit(P?"csv_to_json":"json_to_csv",J)},[rt,P,X]);y.useEffect(()=>{const J=st=>{var Jn;const lt=(Jn=st.clipboardData)==null?void 0:Jn.getData("text/plain");!lt||lY(st.target)||(st.preventDefault(),st.stopPropagation(),g(null),bn(lt))};return document.addEventListener("paste",J,!0),()=>document.removeEventListener("paste",J,!0)},[bn]);const Yn=ue.ok?wY(ue.rows,ue.cols):null,Wr=!ue.ok&&It?"Last valid result — input has errors":null,Ht=ue.ok&&ue.warnings&&ue.warnings.length>0?ue.warnings:null,Qe=l.length>uC,We=P?"csv_to_json":"json_to_csv",Lt=P?c:"csv",Qt=()=>{nl({via:"copy",format:P?"csv":"json",pane:"input",direction:We}),lC(l)},Zt=!P&&I!==null?I:$e,Tn=()=>{nl({via:"copy",format:Lt,pane:"output",direction:We}),Zt&&lC(Zt)},er=()=>{nl({via:"download",format:P?"csv":"json",pane:"input",direction:We}),aC(l,p??(P?"data.csv":"data.json"),{mime:P?"text/csv":"application/json",bom:P})},pt=()=>{nl({via:"download",format:Lt,pane:"output",direction:We}),aC(Zt??"",sY(p,P?"csv2json":"json2csv",c),{mime:oY(P?"csv2json":"json2csv",c),bom:!P})},Wt=y.useCallback(()=>{nl({via:"copy",format:"csv",pane:"input",direction:We})},[We]),Rt=y.useCallback(()=>{nl({via:"copy",format:"csv",pane:"output",direction:We})},[We]),Ft=y.useCallback(()=>{nl({via:"copy",format:Lt,pane:"output",direction:We})},[Lt,We]),tn=E.jsx(GG,{format:B,input:l,onInputChange:bn,onCellCommit:bn,onFile:jt,onTryExample:()=>{w(null);const J=P?aY:uY;se.current={direction:r,options:a,input:J,resultOk:ho(r,J,a).ok},rt(J),X.discrete(We,"example",J)},onClear:()=>{rt(""),g(null),u(J=>{if(!J.columnTypes)return J;const st={...J};return delete st.columnTypes,st}),Se(!1),Ce(null),X.cancel()},onCopy:Qt,onCopySelection:Wt,onProjectedCsvChange:M,onDownload:er,canUndo:Ke,canRedo:an,onUndo:mt,onRedo:it,collapseIndexedArrays:a.collapseIndexedArrays??!0,onToggleCollapseIndexedArrays:()=>u(J=>({...J,collapseIndexedArrays:!(J.collapseIndexedArrays??!0)})),columnTypes:a.columnTypes??{},onChangeColumnTypes:J=>u(st=>{const lt={...st};return Object.keys(J).length>0?lt.columnTypes=J:delete lt.columnTypes,lt}),flatten:a.flatten,onToggleFlatten:()=>u(J=>({...J,flatten:!J.flatten})),selectedMarkdownTableIndex:_,onSelectMarkdownTableIndex:re,filename:p,reading:b,meta:Yn,error:null,notice:v,delimiter:a.separator==="auto"?void 0:a.separator,dark:t==="dark"}),Vt=E.jsx(hq,{format:q,inputEmpty:W,outputText:$e,error:ue.ok?null:ue.error,meta:Yn,staleNotice:Wr,warnings:Ht,edited:Y,editable:nt,egressFormat:c,delimiter:a.separator==="auto"?void 0:a.separator,dark:t==="dark",onCopy:Tn,onCopySelection:Rt,onProjectedCsvChange:D,onNativeCopy:Ft,onDownload:pt,onEgressFormatChange:f,onOutputChange:ge,onRevert:ot,onDiscardReconvert:ot});return E.jsxs("div",{className:"flex min-h-svh flex-col bg-background text-foreground",children:[E.jsx("h1",{className:"sr-only",children:"CSV to JSON and JSON to CSV converter"}),E.jsxs("div",{className:"flex min-h-svh flex-col md:h-svh md:min-h-0",children:[E.jsx(C_,{}),E.jsx(Mq,{theme:t,onToggleTheme:n,slot:E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx(Tq,{snapshots:C,onSelect:dt,onRemove:Yt,onClear:mn}),E.jsx(Bq,{}),E.jsx(R_,{})]})}),tt&&(Be.phase==="loading"||Be.phase==="not-found"||Be.phase==="unsupported"||Be.phase==="error")?E.jsx(pq,{phase:Be.phase,message:Be.phase==="error"?Be.message:void 0,onRetry:Be.retry}):null,E.jsx(Eq,{layout:N,split:d,onSplitChange:h,left:tn,right:Vt,children:E.jsx(b_,{direction:r,onFlip:qn})}),E.jsx(ZG,{direction:r,options:a,onChange:J=>u(st=>({...st,...J})),uploadEncoding:k,onUploadEncodingChange:Hn,notice:Qe?"Large file — converting on pause":null})]}),E.jsx(k_,{})]})}ST(document.getElementById("root")).render(E.jsx(y.StrictMode,{children:E.jsx(bY,{})}));document.getElementById("root").removeAttribute("inert");FI();zI();export{v6 as C,Kn as R,W4 as T,xa as a,g$ as b,LI as c,oa as i,H4 as m,y as r,ai as s}; diff --git a/app/dist/assets/index-DfgoDwrH.css b/app/dist/assets/index-DfgoDwrH.css deleted file mode 100644 index 9a881cc..0000000 --- a/app/dist/assets/index-DfgoDwrH.css +++ /dev/null @@ -1 +0,0 @@ -/*! tailwindcss v4.3.3 | 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-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial}}}@layer theme{:root,:host{--font-sans:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;--color-amber-100:oklch(96.2% .059 95.617);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-600:oklch(66.6% .179 58.318);--color-amber-700:oklch(55.5% .163 48.998);--color-sky-400:oklch(74.6% .16 232.661);--color-sky-600:oklch(58.8% .158 241.966);--spacing:.25rem;--container-sm:24rem;--container-md:28rem;--container-3xl:48rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--font-weight-medium:500;--font-weight-semibold:600;--tracking-tight:-.025em;--tracking-wide:.025em;--tracking-wider:.05em;--leading-relaxed:1.625;--radius-xl:.75rem;--animate-spin:spin 1s linear infinite;--blur-sm:8px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;--color-background:hsl(var(--background));--color-foreground:hsl(var(--foreground));--color-muted-foreground:hsl(var(--muted-foreground));--breakpoint-fit:98.5rem}}@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;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-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{.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.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}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.inset-3{inset:calc(var(--spacing) * 3)}.inset-x-0{inset-inline:0}.top-0{top:0}.top-1{top:var(--spacing)}.top-1\/2{top:50%}.top-7{top:calc(var(--spacing) * 7)}.top-9{top:calc(var(--spacing) * 9)}.right-0{right:0}.right-1{right:var(--spacing)}.right-1\.5{right:calc(var(--spacing) * 1.5)}.bottom-full{bottom:100%}.left-0{left:0}.left-1\.5{left:calc(var(--spacing) * 1.5)}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-50{z-index:50}.row-0{grid-row:0}.row-10{grid-row:10}.row-59{grid-row:59}.row-60{grid-row:60}.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}}@media (min-width:98.5rem){.container{max-width:98.5rem}}.mx-4{margin-inline:calc(var(--spacing) * 4)}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1\.5{margin-top:calc(var(--spacing) * 1.5)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mb-0\.5{margin-bottom:calc(var(--spacing) * .5)}.mb-1{margin-bottom:var(--spacing)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.ml-1{margin-left:var(--spacing)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-auto{margin-left:auto}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.size-1\.5{width:calc(var(--spacing) * 1.5);height:calc(var(--spacing) * 1.5)}.size-3{width:calc(var(--spacing) * 3);height:calc(var(--spacing) * 3)}.size-3\.5{width:calc(var(--spacing) * 3.5);height:calc(var(--spacing) * 3.5)}.size-4{width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.size-6{width:calc(var(--spacing) * 6);height:calc(var(--spacing) * 6)}.size-8{width:calc(var(--spacing) * 8);height:calc(var(--spacing) * 8)}.size-9{width:calc(var(--spacing) * 9);height:calc(var(--spacing) * 9)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-9{height:calc(var(--spacing) * 9)}.h-14{height:calc(var(--spacing) * 14)}.h-\[18px\]{height:18px}.h-\[var\(--split\)\]{height:var(--split)}.h-svh{height:100svh}.max-h-56{max-height:calc(var(--spacing) * 56)}.max-h-96{max-height:calc(var(--spacing) * 96)}.min-h-0{min-height:0}.min-h-11{min-height:calc(var(--spacing) * 11)}.min-h-12{min-height:calc(var(--spacing) * 12)}.min-h-\[42px\]{min-height:42px}.min-h-svh{min-height:100svh}.w-3{width:calc(var(--spacing) * 3)}.w-4{width:calc(var(--spacing) * 4)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-72{width:calc(var(--spacing) * 72)}.w-80{width:calc(var(--spacing) * 80)}.w-full{width:100%}.w-px{width:1px}.max-w-3xl{max-width:var(--container-3xl)}.max-w-44{max-width:calc(var(--spacing) * 44)}.max-w-64{max-width:calc(var(--spacing) * 64)}.max-w-md{max-width:var(--container-md)}.max-w-sm{max-width:var(--container-sm)}.min-w-0{min-width:0}.min-w-32{min-width:calc(var(--spacing) * 32)}.min-w-44{min-width:calc(var(--spacing) * 44)}.flex-1{flex:1}.flex-none{flex:none}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.grow{flex-grow:1}.translate-x-\[2px\]{--tw-translate-x:2px;translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-x-\[15px\]{--tw-translate-x:15px;translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-spin{animation:var(--animate-spin)}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.cursor-row-resize{cursor:row-resize}.resize{resize:both}.resize-none{resize:none}.appearance-none{-webkit-appearance:none;-moz-appearance:none;appearance:none}.flex-col{flex-direction:column}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-5{gap:calc(var(--spacing) * 5)}.gap-x-2{column-gap:calc(var(--spacing) * 2)}.gap-x-3{column-gap:calc(var(--spacing) * 3)}.gap-x-4{column-gap:calc(var(--spacing) * 4)}.gap-y-1\.5{row-gap:calc(var(--spacing) * 1.5)}.gap-y-2\.5{row-gap:calc(var(--spacing) * 2.5)}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px * var(--tw-divide-y-reverse));border-bottom-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-border>:not(:last-child)){border-color:hsl(var(--border))}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-\[7px\]{border-radius:7px}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-sm{border-radius:calc(var(--radius) - 4px)}.rounded-xl{border-radius:var(--radius-xl)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-border{border-color:hsl(var(--border))}.border-foreground,.border-foreground\/30{border-color:hsl(var(--foreground))}@supports (color:color-mix(in lab,red,red)){.border-foreground\/30{border-color:color-mix(in oklab,hsl(var(--foreground)) 30%,transparent)}}.border-primary,.border-primary\/50{border-color:hsl(var(--primary))}@supports (color:color-mix(in lab,red,red)){.border-primary\/50{border-color:color-mix(in oklab,hsl(var(--primary)) 50%,transparent)}}.border-ring{border-color:hsl(var(--ring))}.bg-amber-100{background-color:var(--color-amber-100)}.bg-background,.bg-background\/80{background-color:hsl(var(--background))}@supports (color:color-mix(in lab,red,red)){.bg-background\/80{background-color:color-mix(in oklab,hsl(var(--background)) 80%,transparent)}}.bg-border{background-color:hsl(var(--border))}.bg-foreground{background-color:hsl(var(--foreground))}.bg-muted,.bg-muted\/20{background-color:hsl(var(--muted))}@supports (color:color-mix(in lab,red,red)){.bg-muted\/20{background-color:color-mix(in oklab,hsl(var(--muted)) 20%,transparent)}}.bg-muted\/30{background-color:hsl(var(--muted))}@supports (color:color-mix(in lab,red,red)){.bg-muted\/30{background-color:color-mix(in oklab,hsl(var(--muted)) 30%,transparent)}}.bg-muted\/40{background-color:hsl(var(--muted))}@supports (color:color-mix(in lab,red,red)){.bg-muted\/40{background-color:color-mix(in oklab,hsl(var(--muted)) 40%,transparent)}}.bg-muted\/50{background-color:hsl(var(--muted))}@supports (color:color-mix(in lab,red,red)){.bg-muted\/50{background-color:color-mix(in oklab,hsl(var(--muted)) 50%,transparent)}}.bg-muted\/60{background-color:hsl(var(--muted))}@supports (color:color-mix(in lab,red,red)){.bg-muted\/60{background-color:color-mix(in oklab,hsl(var(--muted)) 60%,transparent)}}.bg-panel{background-color:hsl(var(--panel))}.bg-primary{background-color:hsl(var(--primary))}.bg-secondary{background-color:hsl(var(--secondary))}.bg-transparent{background-color:#0000}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-1\.5{padding:calc(var(--spacing) * 1.5)}.p-3{padding:calc(var(--spacing) * 3)}.p-6{padding:calc(var(--spacing) * 6)}.px-1{padding-inline:var(--spacing)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-3\.5{padding-inline:calc(var(--spacing) * 3.5)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-5{padding-inline:calc(var(--spacing) * 5)}.py-0{padding-block:0}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-6{padding-block:calc(var(--spacing) * 6)}.py-px{padding-block:1px}.pr-1\.5{padding-right:calc(var(--spacing) * 1.5)}.pr-6{padding-right:calc(var(--spacing) * 6)}.pb-1{padding-bottom:var(--spacing)}.pb-2{padding-bottom:calc(var(--spacing) * 2)}.pb-4{padding-bottom:calc(var(--spacing) * 4)}.pl-2\.5{padding-left:calc(var(--spacing) * 2.5)}.pl-3{padding-left:calc(var(--spacing) * 3)}.pl-6{padding-left:calc(var(--spacing) * 6)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:ui-monospace,SF Mono,SFMono-Regular,Menlo,Consolas,Liberation Mono,monospace}.font-sans{font-family:var(--font-sans)}.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}.text-\[11px\]{font-size:11px}.text-\[12\.5px\]{font-size:12.5px}.text-\[13px\]{font-size:13px}.text-\[15px\]{font-size:15px}.leading-6{--tw-leading:calc(var(--spacing) * 6);line-height:calc(var(--spacing) * 6)}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-\[0\.1em\]{--tw-tracking:.1em;letter-spacing:.1em}.tracking-\[0\.08em\]{--tw-tracking:.08em;letter-spacing:.08em}.tracking-\[0\.14em\]{--tw-tracking:.14em;letter-spacing:.14em}.tracking-\[0\.18em\]{--tw-tracking:.18em;letter-spacing:.18em}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-line{white-space:pre-line}.text-amber-600{color:var(--color-amber-600)}.text-amber-700{color:var(--color-amber-700)}.text-background{color:hsl(var(--background))}.text-destructive{color:hsl(var(--destructive))}.text-foreground{color:hsl(var(--foreground))}.text-muted-foreground,.text-muted-foreground\/60{color:hsl(var(--muted-foreground))}@supports (color:color-mix(in lab,red,red)){.text-muted-foreground\/60{color:color-mix(in oklab,hsl(var(--muted-foreground)) 60%,transparent)}}.text-muted-foreground\/70{color:hsl(var(--muted-foreground))}@supports (color:color-mix(in lab,red,red)){.text-muted-foreground\/70{color:color-mix(in oklab,hsl(var(--muted-foreground)) 70%,transparent)}}.text-panel{color:hsl(var(--panel))}.lowercase{text-transform:lowercase}.uppercase{text-transform:uppercase}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.underline{text-decoration-line:underline}.decoration-border{-webkit-text-decoration-color:hsl(var(--border));text-decoration-color:hsl(var(--border))}.underline-offset-2{text-underline-offset:2px}.accent-foreground{accent-color:hsl(var(--foreground))}.opacity-60{opacity:.6}.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-2xs{--tw-shadow:0 1px var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a), 0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-ring\/50{--tw-ring-color:hsl(var(--ring))}@supports (color:color-mix(in lab,red,red)){.ring-ring\/50{--tw-ring-color:color-mix(in oklab, hsl(var(--ring)) 50%, transparent)}}.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,)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-300{--tw-duration:.3s;transition-duration:.3s}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.placeholder\:text-muted-foreground::placeholder,.placeholder\:text-muted-foreground\/50::placeholder{color:hsl(var(--muted-foreground))}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-muted-foreground\/50::placeholder{color:color-mix(in oklab,hsl(var(--muted-foreground)) 50%,transparent)}}.placeholder\:text-muted-foreground\/60::placeholder{color:hsl(var(--muted-foreground))}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-muted-foreground\/60::placeholder{color:color-mix(in oklab,hsl(var(--muted-foreground)) 60%,transparent)}}.last\:mb-0:last-child{margin-bottom:0}@media (hover:hover){.hover\:border-foreground:hover{border-color:hsl(var(--foreground))}.hover\:border-muted-foreground\/50:hover{border-color:hsl(var(--muted-foreground))}@supports (color:color-mix(in lab,red,red)){.hover\:border-muted-foreground\/50:hover{border-color:color-mix(in oklab,hsl(var(--muted-foreground)) 50%,transparent)}}.hover\:bg-foreground\/90:hover{background-color:hsl(var(--foreground))}@supports (color:color-mix(in lab,red,red)){.hover\:bg-foreground\/90:hover{background-color:color-mix(in oklab,hsl(var(--foreground)) 90%,transparent)}}.hover\:bg-muted:hover,.hover\:bg-muted\/50:hover{background-color:hsl(var(--muted))}@supports (color:color-mix(in lab,red,red)){.hover\:bg-muted\/50:hover{background-color:color-mix(in oklab,hsl(var(--muted)) 50%,transparent)}}.hover\:text-foreground:hover{color:hsl(var(--foreground))}.hover\:decoration-foreground:hover{-webkit-text-decoration-color:hsl(var(--foreground));text-decoration-color:hsl(var(--foreground))}}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\:border-sky-600:focus-visible{border-color:var(--color-sky-600)}.focus-visible\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-3:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-ring\/50:focus-visible{--tw-ring-color:hsl(var(--ring))}@supports (color:color-mix(in lab,red,red)){.focus-visible\:ring-ring\/50:focus-visible{--tw-ring-color:color-mix(in oklab, hsl(var(--ring)) 50%, transparent)}}.focus-visible\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\:outline-offset-1:focus-visible{outline-offset:1px}.focus-visible\:outline-offset-2:focus-visible{outline-offset:2px}.focus-visible\:outline-ring:focus-visible{outline-color:hsl(var(--ring))}.focus-visible\:outline-none:focus-visible{--tw-outline-style:none;outline-style:none}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}@media not all and (min-width:48rem){.max-md\:max-h-\[340px\]{max-height:340px}.max-md\:max-h-\[360px\]{max-height:360px}.max-md\:min-h-\[240px\]{min-height:240px}.max-md\:min-h-\[280px\]{min-height:280px}.max-md\:gap-1{gap:var(--spacing)}.max-md\:gap-2{gap:calc(var(--spacing) * 2)}}@media not all and (min-width:40rem){.max-sm\:static{position:static}.max-sm\:inset-x-2{inset-inline:calc(var(--spacing) * 2)}.max-sm\:top-14{top:calc(var(--spacing) * 14)}.max-sm\:w-auto{width:auto}}@media (min-width:40rem){.sm\:inline{display:inline}.sm\:max-w-64{max-width:calc(var(--spacing) * 64)}.sm\:max-w-none{max-width:none}.sm\:px-2{padding-inline:calc(var(--spacing) * 2)}.sm\:px-4{padding-inline:calc(var(--spacing) * 4)}.sm\:py-1{padding-block:var(--spacing)}.sm\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}}@media (min-width:48rem){.md\:absolute{position:absolute}.md\:inset-auto{inset:auto}.md\:top-0{top:0}.md\:top-1\/2{top:50%}.md\:right-auto{right:auto}.md\:bottom-0{bottom:0}.md\:-left-1\.5{left:calc(var(--spacing) * -1.5)}.md\:left-1\/2{left:50%}.md\:left-\[var\(--split\)\]{left:var(--split)}.md\:block{display:block}.md\:hidden{display:none}.md\:size-5{width:calc(var(--spacing) * 5);height:calc(var(--spacing) * 5)}.md\:size-11{width:calc(var(--spacing) * 11);height:calc(var(--spacing) * 11)}.md\:h-8{height:calc(var(--spacing) * 8)}.md\:h-12{height:calc(var(--spacing) * 12)}.md\:h-auto{height:auto}.md\:h-svh{height:100svh}.md\:min-h-0{min-height:0}.md\:min-h-12{min-height:calc(var(--spacing) * 12)}.md\:w-0{width:0}.md\:w-3{width:calc(var(--spacing) * 3)}.md\:w-\[var\(--split\)\]{width:var(--split)}.md\:-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.md\:-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.md\:cursor-col-resize{cursor:col-resize}.md\:flex-row{flex-direction:row}.md\:gap-1{gap:var(--spacing)}.md\:gap-3{gap:calc(var(--spacing) * 3)}.md\:border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.md\:border-b-0{border-bottom-style:var(--tw-border-style);border-bottom-width:0}.md\:bg-transparent{background-color:#0000}.md\:p-6{padding:calc(var(--spacing) * 6)}.md\:px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.md\:px-4{padding-inline:calc(var(--spacing) * 4)}.md\:px-16{padding-inline:calc(var(--spacing) * 16)}.md\:py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.md\:pr-2\.5{padding-right:calc(var(--spacing) * 2.5)}.md\:pl-3\.5{padding-left:calc(var(--spacing) * 3.5)}.md\:text-\[11px\]{font-size:11px}}@media (min-width:64rem){.lg\:inline{display:inline}.lg\:gap-3{gap:calc(var(--spacing) * 3)}.lg\:gap-x-3{column-gap:calc(var(--spacing) * 3)}.lg\:px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.lg\:pr-3{padding-right:calc(var(--spacing) * 3)}.lg\:pl-5{padding-left:calc(var(--spacing) * 5)}}@media (min-width:80rem){.xl\:block{display:block}.xl\:inline{display:inline}}@media (min-width:98.5rem){.fit\:block{display:block}}.dark\:bg-amber-400\/15:is(.dark *){background-color:#fcbb0026}@supports (color:color-mix(in lab,red,red)){.dark\:bg-amber-400\/15:is(.dark *){background-color:color-mix(in oklab,var(--color-amber-400) 15%,transparent)}}.dark\:text-amber-400:is(.dark *){color:var(--color-amber-400)}.dark\:focus-visible\:border-sky-400:is(.dark *):focus-visible{border-color:var(--color-sky-400)}.\[\&_svg\]\:size-3\.5 svg{width:calc(var(--spacing) * 3.5);height:calc(var(--spacing) * 3.5)}}:root{--panel:0 0% 100%;--background:0 0% 100%;--foreground:240 10% 3.9%;--muted:240 4.8% 95.9%;--muted-foreground:240 3.8% 46.1%;--border:240 5.9% 90%;--primary:240 5.9% 10%;--primary-foreground:0 0% 98%;--secondary:240 4.8% 95.9%;--secondary-foreground:240 5.9% 10%;--accent:240 4.8% 95.9%;--accent-foreground:240 5.9% 10%;--destructive:0 84.2% 60.2%;--destructive-foreground:0 0% 98%;--ring:240 5% 64.9%;--radius:.625rem}.dark{--background:240 10% 3.9%;--panel:240 6% 7%;--foreground:0 0% 98%;--muted:240 3.7% 15.9%;--muted-foreground:240 5% 64.9%;--border:240 3.7% 15.9%;--primary:0 0% 98%;--primary-foreground:240 5.9% 10%;--secondary:240 3.7% 15.9%;--secondary-foreground:0 0% 98%;--destructive:0 62.8% 30.6%;--destructive-foreground:0 0% 98%;--ring:240 4.9% 83.9%}body{background-color:var(--color-background);color:var(--color-foreground)}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-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-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}.gdg-mnuv029{word-break:break-word;-webkit-touch-callout:default;padding-top:6px}.gdg-mnuv029>*{margin:0}.gdg-mnuv029 *:last-child{margin-bottom:0}.gdg-mnuv029 p img{width:100%}.gdg-d19meir1{position:absolute;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;overflow:hidden;box-sizing:border-box;--overlay-top:var(--d19meir1-0);left:var(--d19meir1-1);top:var(--d19meir1-0);min-width:var(--d19meir1-2);min-height:var(--d19meir1-3);width:-webkit-max-content;width:-moz-max-content;width:max-content;max-width:400px;max-height:calc(100vh - var(--d19meir1-4));font-family:var(--gdg-font-family);font-size:var(--gdg-editor-font-size);text-align:start}@-webkit-keyframes glide_fade_in-gdg-d19meir1{0%{opacity:0%}to{opacity:100%}}@keyframes glide_fade_in-gdg-d19meir1{0%{opacity:0%}to{opacity:100%}}.gdg-d19meir1.gdg-style{border-radius:2px;background-color:var(--gdg-bg-cell);box-shadow:0 0 0 1px var(--gdg-accent-color),0 0 1px #3e415666,0 6px 12px #3e415626;-webkit-animation:glide_fade_in-gdg-d19meir1 60ms 1;animation:glide_fade_in-gdg-d19meir1 60ms 1}.gdg-d19meir1.gdg-pad{padding:var(--d19meir1-5) 8.5px 3px}.gdg-d19meir1 .gdg-clip-region{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;overflow-y:auto;overflow-x:hidden;border-radius:2px;-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1}.gdg-d19meir1 .gdg-clip-region .gdg-growing-entry{height:100%}.gdg-d19meir1 .gdg-clip-region input.gdg-input{width:100%;border:none;border-width:0;outline:none}.gdg-d19meir1 .gdg-clip-region textarea.gdg-input{border:none;border-width:0;outline:none}.gdg-b1ygi5by{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;margin-top:auto;margin-bottom:auto}.gdg-b1ygi5by .boe-bubble{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;border-radius:var(--gdg-rounding-radius,10px);padding:0 8px;height:20px;background-color:var(--gdg-bg-bubble);color:var(--gdg-text-dark);margin:2px}.gdg-b1ygi5by textarea{position:absolute;top:0;left:0;width:0px;height:0px;opacity:0}.gdg-n15fjm3e{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;margin:6px 0 3px;color:var(--gdg-text-dark)}.gdg-n15fjm3e>input{font-size:var(--gdg-editor-font-size);padding:0;font-family:var(--gdg-font-family);color:var(--gdg-text-dark);background-color:var(--gdg-bg-cell)}.gdg-d4zsq0x{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap}.gdg-d4zsq0x .doe-bubble{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:0 8px;height:24px;background-color:var(--gdg-bg-cell);color:var(--gdg-text-dark);margin:2px;border-radius:var(--gdg-rounding-radius,6px);box-shadow:0 0 1px #3e415666,0 1px 3px #3e415666}.gdg-d4zsq0x .doe-bubble img{height:16px;object-fit:contain;margin-right:4px}.gdg-d4zsq0x textarea{position:absolute;top:0;left:0;width:0px;height:0px;opacity:0}.gdg-i2iowwq{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;height:100%}.gdg-i2iowwq .gdg-centering-container{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;height:100%}.gdg-i2iowwq .gdg-centering-container img,.gdg-i2iowwq .gdg-centering-container canvas{max-height:calc(100vh - var(--overlay-top) - 20px);object-fit:contain;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.gdg-i2iowwq .gdg-centering-container canvas{max-width:380px}.gdg-i2iowwq .gdg-edit-icon{position:absolute;top:12px;right:0;width:48px;height:48px;color:var(--gdg-accent-color);cursor:pointer;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.gdg-i2iowwq .gdg-edit-icon>*{width:24px;height:24px}.gdg-i2iowwq textarea{position:absolute;top:0;left:0;width:0px;height:0px;opacity:0}.gdg-u1rrojo{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;min-height:21px}.gdg-u1rrojo .gdg-link-area{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;-webkit-flex-shrink:1;-ms-flex-negative:1;flex-shrink:1;cursor:pointer;margin-right:8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--gdg-link-color);-webkit-text-decoration:underline!important;text-decoration:underline!important}.gdg-u1rrojo .gdg-edit-icon{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;width:32px;color:var(--gdg-accent-color);cursor:pointer;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.gdg-u1rrojo .gdg-edit-icon>*{width:24px;height:24px}.gdg-u1rrojo textarea{position:absolute;top:0;left:0;width:0px;height:0px;opacity:0}.gdg-m1pnx84e{min-width:var(--m1pnx84e-0);width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:flex-start;-webkit-box-align:flex-start;-ms-flex-align:flex-start;align-items:flex-start;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;position:relative;color:var(--gdg-text-dark)}.gdg-m1pnx84e .gdg-g1y0xocz{-webkit-flex-shrink:1;-ms-flex-negative:1;flex-shrink:1;min-width:0}.gdg-m1pnx84e .gdg-spacer{-webkit-flex:1;-ms-flex:1;flex:1}.gdg-m1pnx84e .gdg-edit-icon{position:relative;cursor:pointer;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:var(--gdg-accent-color);padding:0;height:24px;width:24px;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;-webkit-transition:all "0.125s ease";transition:all "0.125s ease";border-radius:6px}.gdg-m1pnx84e .gdg-edit-icon>*{width:16px;height:16px}.gdg-m1pnx84e .gdg-edit-hover:hover{background-color:var(--gdg-accent-light);-webkit-transition:background-color .15s;transition:background-color .15s}.gdg-m1pnx84e .gdg-checkmark-hover:hover{color:#fff;background-color:var(--gdg-accent-color)}.gdg-m1pnx84e .gdg-md-edit-textarea{position:relative;top:0;left:0;width:0px;height:0px;margin-top:25px;opacity:0;padding:0}.gdg-m1pnx84e .gdg-ml-6{margin-left:6px}.gdg-s1dgczr6 .dvn-scroller{overflow:var(--s1dgczr6-0);-webkit-transform:translate3d(0,0,0);-ms-transform:translate3d(0,0,0);transform:translateZ(0)}.gdg-s1dgczr6 .dvn-hidden{visibility:hidden}.gdg-s1dgczr6 .dvn-scroll-inner{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;pointer-events:none}.gdg-s1dgczr6 .dvn-scroll-inner>*{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0}.gdg-s1dgczr6 .dvn-scroll-inner .dvn-spacer{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1}.gdg-s1dgczr6 .dvn-scroll-inner .dvn-stack{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column}.gdg-s1dgczr6 .dvn-underlay>*{position:absolute;left:0;top:0}.gdg-s1dgczr6 canvas{outline:none}.gdg-s1dgczr6 canvas *{height:0}.gdg-izpuzkl{position:absolute;left:0;right:0;top:0;bottom:0;width:100%;height:100%;border-radius:0;resize:none;white-space:pre-wrap;min-width:100%;overflow:hidden;border:0;background-color:transparent;font-size:var(--gdg-editor-font-size);line-height:16px;font-family:var(--gdg-font-family);-webkit-text-fill-color:var(--gdg-text-dark);color:var(--gdg-text-dark);padding:0;margin:0}.gdg-izpuzkl::-webkit-input-placeholder{color:var(--gdg-text-light)}.gdg-izpuzkl::-moz-placeholder{color:var(--gdg-text-light)}.gdg-izpuzkl:-ms-input-placeholder{color:var(--gdg-text-light)}.gdg-izpuzkl::placeholder{color:var(--gdg-text-light)}.gdg-invalid .gdg-izpuzkl{-webkit-text-decoration:underline;text-decoration:underline;-webkit-text-decoration-color:#d60606;text-decoration-color:#d60606}.gdg-s69h75o{visibility:hidden;white-space:pre-wrap;word-wrap:break-word;width:-webkit-max-content;width:-moz-max-content;width:max-content;max-width:100%;min-width:100%;font-size:var(--gdg-editor-font-size);line-height:16px;font-family:var(--gdg-font-family);color:var(--gdg-text-dark);padding:0 0 2px;margin:0}.gdg-g1y0xocz{position:relative;margin-top:6px}.gdg-seveqep{position:absolute;top:4px;right:20px;background-color:var(--gdg-bg-cell);color:var(--gdg-text-dark);padding:8px;border:1px solid var(--gdg-border-color);border-radius:6px;font-size:var(--gdg-editor-font-size);-webkit-animation:gdg-search-fadein-gdg-seveqep .15s forwards;animation:gdg-search-fadein-gdg-seveqep .15s forwards}.gdg-seveqep.out{-webkit-animation:gdg-search-fadeout-gdg-seveqep .15s forwards;animation:gdg-search-fadeout-gdg-seveqep .15s forwards}.gdg-seveqep .gdg-search-bar-inner{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.gdg-seveqep .gdg-search-status{padding-top:4px;font-size:11px}.gdg-seveqep .gdg-search-progress{position:absolute;height:4px;left:0;bottom:0;background-color:var(--gdg-text-light)}.gdg-seveqep input{width:220px;color:var(--gdg-textDark);background-color:var(--gdg-bg-cell);border:none;border-width:0;outline:none}.gdg-seveqep button{width:24px;height:24px;padding:0;border:none;outline:none;background:none;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;cursor:pointer;color:var(--gdg-text-medium)}.gdg-seveqep button:hover{color:var(--gdg-text-dark)}.gdg-seveqep button .button-icon{width:16px;height:16px}.gdg-seveqep button:disabled{opacity:.4;pointer-events:none}@-webkit-keyframes gdg-search-fadeout-gdg-seveqep{0%{-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translate(0)}to{-webkit-transform:translateX(400px);-ms-transform:translateX(400px);transform:translate(400px)}}@keyframes gdg-search-fadeout-gdg-seveqep{0%{-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translate(0)}to{-webkit-transform:translateX(400px);-ms-transform:translateX(400px);transform:translate(400px)}}@-webkit-keyframes gdg-search-fadein-gdg-seveqep{0%{-webkit-transform:translateX(400px);-ms-transform:translateX(400px);transform:translate(400px)}to{-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translate(0)}}@keyframes gdg-search-fadein-gdg-seveqep{0%{-webkit-transform:translateX(400px);-ms-transform:translateX(400px);transform:translate(400px)}to{-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translate(0)}}.gdg-wmyidgi{position:relative;min-width:10px;min-height:10px;max-width:100%;max-height:100%;width:var(--wmyidgi-0);height:var(--wmyidgi-1);overflow:hidden;overflow:clip;direction:ltr}.gdg-wmyidgi>:first-child{position:absolute;left:0;top:0;width:100%;height:100%}.gdg-r17m35ur{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;border:none;outline:none;background-color:var(--gdg-bg-header-has-focus);border-radius:9px;padding:0 8px;box-shadow:0 0 0 1px var(--gdg-border-color);color:var(--gdg-text-group-header);min-height:var(--r17m35ur-0);font:var(--gdg-header-font-style) var(--gdg-font-family)}.gdg-c1tqibwd{padding:0 8px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;background-color:var(--gdg-bg-header)} diff --git a/app/dist/assets/number-overlay-editor-B1A_c6JJ.js b/app/dist/assets/number-overlay-editor-HYC-Cz64.js similarity index 99% rename from app/dist/assets/number-overlay-editor-B1A_c6JJ.js rename to app/dist/assets/number-overlay-editor-HYC-Cz64.js index 702fb99..ddea89f 100644 --- a/app/dist/assets/number-overlay-editor-B1A_c6JJ.js +++ b/app/dist/assets/number-overlay-editor-HYC-Cz64.js @@ -1,4 +1,4 @@ -import{s as Be,R as Y,r as O}from"./index-BtPygL0s.js";const Fe=Be("div")({name:"NumberOverlayEditorStyle",class:"gdg-n15fjm3e",propsAsIs:!1});function pe(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a=p?a=a+ge("0",f-p):a=(a.substring(0,f)||"0")+"."+a.substring(f),r+a}function me(e,t,r){if(["","-"].indexOf(e)!==-1)return e;var n=(e.indexOf(".")!==-1||r)&&t,a=se(e),i=a.beforeDecimal,f=a.afterDecimal,p=a.hasNegation,m=parseFloat("0."+(f||"0")),x=f.length<=t?"0."+f:m.toFixed(t),h=x.split("."),s=i;i&&Number(h[0])&&(s=i.split("").reverse().reduce(function(I,C,g){return I.length>g?(Number(I[0])+Number(C)).toString()+I.substring(1,I.length):C+I},h[0]));var S=be(h[1]||"",t,r),y=p?"-":"",l=n?".":"";return""+y+s+l+S}function J(e,t){if(e.value=e.value,e!==null){if(e.createTextRange){var r=e.createTextRange();return r.move("character",t),r.select(),!0}return e.selectionStart||e.selectionStart===0?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}}var Ne=_e(function(e,t){for(var r=0,n=0,a=e.length,i=t.length;e[r]===t[r]&&rr&&a-n>r;)n++;return{from:{start:r,end:a-n},to:{start:r,end:i-n}}}),Pe=function(e,t){var r=Math.min(e.selectionStart,t);return{from:{start:r,end:e.selectionEnd},to:{start:r,end:t}}};function Ke(e,t,r){return Math.min(Math.max(e,t),r)}function ce(e){return Math.max(e.selectionStart,e.selectionEnd)}function We(){return typeof navigator<"u"&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}function Ue(e){return{from:{start:0,end:0},to:{start:0,end:e.length},lastValue:""}}function $e(e){var t=e.currentValue,r=e.formattedValue,n=e.currentValueIndex,a=e.formattedValueIndex;return t[n]===r[a]}function Ge(e,t,r,n,a,i,f){f===void 0&&(f=$e);var p=a.findIndex(function(k){return k}),m=e.slice(0,p);!t&&!r.startsWith(m)&&(t=m,r=m+r,n=n+m.length);for(var x=r.length,h=e.length,s={},S=new Array(x),y=0;y0&&S[g]===-1;)g--;var F=g===-1||S[g]===-1?0:S[g]+1;return F>B?B:n-F=0&&!r[t];)t--;t===-1&&(t=r.indexOf(!0))}else{for(;t<=a&&!r[t];)t++;t>a&&(t=r.lastIndexOf(!0))}return t===-1&&(t=a),t}function Ze(e){for(var t=Array.from({length:e.length+1}).map(function(){return!0}),r=0,n=t.length;rP.length-f.length||HL||s>e.length-f.length)&&(W=s),e=e.substring(0,W),e=Je(F?"-"+e:e,a),e=(e.match(Qe(l))||[]).join("");var U=e.indexOf(l);e=e.replace(new RegExp(ye(l),"g"),function(c,N){return N===U?".":""});var $=se(e,a),Q=$.beforeDecimal,te=$.afterDecimal,d=$.addNegation;return x.end-x.start=p?a=a+ge("0",f-p):a=(a.substring(0,f)||"0")+"."+a.substring(f),r+a}function me(e,t,r){if(["","-"].indexOf(e)!==-1)return e;var n=(e.indexOf(".")!==-1||r)&&t,a=se(e),i=a.beforeDecimal,f=a.afterDecimal,p=a.hasNegation,m=parseFloat("0."+(f||"0")),x=f.length<=t?"0."+f:m.toFixed(t),h=x.split("."),s=i;i&&Number(h[0])&&(s=i.split("").reverse().reduce(function(I,C,g){return I.length>g?(Number(I[0])+Number(C)).toString()+I.substring(1,I.length):C+I},h[0]));var S=be(h[1]||"",t,r),y=p?"-":"",l=n?".":"";return""+y+s+l+S}function J(e,t){if(e.value=e.value,e!==null){if(e.createTextRange){var r=e.createTextRange();return r.move("character",t),r.select(),!0}return e.selectionStart||e.selectionStart===0?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}}var Ne=_e(function(e,t){for(var r=0,n=0,a=e.length,i=t.length;e[r]===t[r]&&rr&&a-n>r;)n++;return{from:{start:r,end:a-n},to:{start:r,end:i-n}}}),Pe=function(e,t){var r=Math.min(e.selectionStart,t);return{from:{start:r,end:e.selectionEnd},to:{start:r,end:t}}};function Ke(e,t,r){return Math.min(Math.max(e,t),r)}function ce(e){return Math.max(e.selectionStart,e.selectionEnd)}function We(){return typeof navigator<"u"&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}function Ue(e){return{from:{start:0,end:0},to:{start:0,end:e.length},lastValue:""}}function $e(e){var t=e.currentValue,r=e.formattedValue,n=e.currentValueIndex,a=e.formattedValueIndex;return t[n]===r[a]}function Ge(e,t,r,n,a,i,f){f===void 0&&(f=$e);var p=a.findIndex(function(k){return k}),m=e.slice(0,p);!t&&!r.startsWith(m)&&(t=m,r=m+r,n=n+m.length);for(var x=r.length,h=e.length,s={},S=new Array(x),y=0;y0&&S[g]===-1;)g--;var F=g===-1||S[g]===-1?0:S[g]+1;return F>B?B:n-F=0&&!r[t];)t--;t===-1&&(t=r.indexOf(!0))}else{for(;t<=a&&!r[t];)t++;t>a&&(t=r.lastIndexOf(!0))}return t===-1&&(t=a),t}function Ze(e){for(var t=Array.from({length:e.length+1}).map(function(){return!0}),r=0,n=t.length;rP.length-f.length||HL||s>e.length-f.length)&&(W=s),e=e.substring(0,W),e=Je(F?"-"+e:e,a),e=(e.match(Qe(l))||[]).join("");var U=e.indexOf(l);e=e.replace(new RegExp(ye(l),"g"),function(c,N){return N===U?".":""});var $=se(e,a),Q=$.beforeDecimal,te=$.afterDecimal,d=$.addNegation;return x.end-x.start - - + + diff --git a/app/src/changelog/entries.ts b/app/src/changelog/entries.ts index 22ae01c..69b4132 100644 --- a/app/src/changelog/entries.ts +++ b/app/src/changelog/entries.ts @@ -34,6 +34,14 @@ export function newestFirst(entries: ChangelogEntry[]): ChangelogEntry[] { } export const changelogEntries: ChangelogEntry[] = [ + { + id: 23, + date: "2026-10-20", + tag: "new", + title: "Extract and switch between multiple tables in pasted Markdown", + summary: + "Paste an entire ChatGPT response or Markdown document containing prose and multiple Markdown or CLI box tables into CSV → JSON: every table is detected in order with interactive chooser pills to switch which table is previewed and converted, or keep only the selected table as clean CSV.", + }, { id: 22, date: "2026-10-20",

    CSV to JSON and JSON to CSV converter

    csvjson
    CSV

    Paste CSV or TSV here

    or drag & drop a file anywhere in this pane — you can also paste anywhere on the page (⌘V / Ctrl+V)

    JSON
    Your JSON appears here.
    Auto · Parse numbers · Parse JSON