UNPKG

expressive-code-twoslash

Version:

Add Twoslash support to your Expressive Code TypeScript code blocks.

969 lines (948 loc) 81.6 kB
// src/index.ts import { definePlugin } from "@expressive-code/core"; import { ExpressiveCode } from "expressive-code"; import { createTwoslasher } from "twoslash"; import ts from "typescript"; // src/annotations/completion.ts import { ExpressiveCodeAnnotation } from "@expressive-code/core"; import { h as h3 } from "@expressive-code/core/hast"; // src/helpers/rendering.ts import { h } from "@expressive-code/core/hast"; import { fromMarkdown } from "mdast-util-from-markdown"; import { gfmFromMarkdown } from "mdast-util-gfm"; import { toHast } from "mdast-util-to-hast"; // src/helpers/regex.ts var twoslashDefaultTags = ["annotate", "log", "warn", "error"]; var reTrigger = /\btwoslash\b/; var reTypeCleanup = /^[A-Z]\w*(<[^>]*>)?:/; var reFunctionCleanup = /^\w*\(/; var reLeadingPropertyMethod = /^\(([\w-]+)\)\s+/gm; var reImportStatement = /\nimport .*$/; var reInterfaceOrNamespace = /^(interface|namespace) \w+$/gm; var reJsDocLink = /\{@link ([^}]*)\}/g; var reJsDocTagFilter = /\b(example|description)\b/; var jsdocTags = [ "abstract", "access", "alias", "async", "augments", "author", "borrows", "callback", "class", "classdesc", "constant", "constructs", "copyright", "default", "deprecated", "description", "enum", "event", "example", "exports", "external", "file", "fires", "function", "generator", "global", "hideconstructor", "ignore", "implements", "inheritdoc", "inner", "instance", "interface", "kind", "lends", "license", "listens", "member", "memberof", "mixes", "mixin", "module", "name", "namespace", "override", "package", "param", "private", "property", "protected", "public", "readonly", "requires", "returns", "see", "since", "static", "summary", "this", "throws", "todo", "tutorial", "type", "typedef", "variation", "version", "yields" ]; // src/helpers/rendering.ts async function renderMarkdownWithCodeBlocks(md, ec) { const mdast = fromMarkdown( md.replace(reJsDocLink, "$1"), // replace jsdoc links { mdastExtensions: [gfmFromMarkdown()] } ); const nodes = toHast(mdast, { handlers: { code: (_, node) => { const lang = node.lang || "plaintext"; return { type: "element", tagName: "div", properties: { class: "expressive-code", "data-lang": lang }, children: [ { type: "text", value: node.value } ] }; } } }); const codeBlocks = nodes.children ? nodes.children.filter( (node) => node.type === "element" && node.tagName === "div" && node.properties.class === "expressive-code" ) : []; for (const codeBlock of codeBlocks) { if (codeBlock.type === "element") { codeBlock.children = codeBlock.type === "element" && codeBlock.children[0].type === "text" ? ( // Render the code block using ExpressiveCode (await ec.render({ code: codeBlock.children[0].value, language: codeBlock.properties["data-lang"] }).then((res) => { codeBlock.properties["data-lang"] = null; return res; })).renderedGroupAst.children ) : []; } } return nodes.children; } async function renderMDInline(md, ec) { const children = await renderMarkdownWithCodeBlocks(md, ec); if (children.length === 1 && children[0].type === "element" && children[0].tagName === "p") return children[0].children; return children; } async function checkIfSingleParagraph(md, filterTags2, ec) { const children = await renderMDInline(md, ec); if (filterTags2) { return !(children.length === 1 && children[0].type === "element" && children[0].tagName === "p"); } return false; } function defaultHoverInfoProcessor(type) { let content = type.replace(reLeadingPropertyMethod, "").replace(reImportStatement, "").replace(reInterfaceOrNamespace, "").trim(); if (content.match(reTypeCleanup)) content = `type ${content}`; else if (content.match(reFunctionCleanup)) content = `function ${content}`; if (content.length === 0) { return false; } return content; } function filterTags(tag) { return !reJsDocTagFilter.test(tag); } async function renderType(text, ec) { const info = defaultHoverInfoProcessor(text); if (typeof info === "string") { const { renderedGroupAst: renderedGroupAst2 } = await ec.render({ code: info, language: "ts", meta: "" }); return renderedGroupAst2; } const { renderedGroupAst } = await ec.render({ code: text, language: "ts", meta: "" }); return renderedGroupAst; } async function renderJSDocs(hover, includeJsDoc, ec, allowNonStandardJsDocTags) { if (!includeJsDoc) return { docs: [], tags: [] }; return { docs: hover.docs ? h("div.twoslash-popup-docs", [ h( "p", hover.docs ? await renderMarkdownWithCodeBlocks(hover.docs, ec) : [] ) ]) : [], tags: hover.tags ? h("div.twoslash-popup-docs.twoslash-popup-docs-tags", [ ...await Promise.all( hover.tags ? hover.tags.map( async (tag) => (allowNonStandardJsDocTags ? true : jsdocTags.includes(tag[0])) ? h("p.twoslash-popup-docs-tagline", [ h("span.twoslash-popup-docs-tag-name", `@${tag[0]}`), tag[1] ? [ await checkIfSingleParagraph( tag[1], filterTags(tag[0]), ec ) ? " \u2015 " : " ", h( "span.twoslash-popup-docs-tag-value", await renderMDInline(tag[1], ec) ) ] : [] ]) : [] ) : [] ) ]) : [] }; } // src/helpers/string-gen.ts function getCustomTagString(tag) { switch (tag) { case "warn": return "Warning"; case "annotate": return "Message"; case "log": return "Log"; default: return "Error"; } } function getCustomTagClass(tag) { switch (tag) { case "warn": return "twoslash-custom-level-warning"; case "annotate": return "twoslash-custom-level-suggestion"; case "log": return "twoslash-custom-level-message"; default: return "twoslash-custom-level-error"; } } function getErrorLevelClass(error) { switch (error.level) { case "warning": return "twoslash-error-level-warning"; case "suggestion": return "twoslash-error-level-suggestion"; case "message": return "twoslash-error-level-message"; default: return "twoslash-error-level-error"; } } function getErrorLevelString(error) { switch (error.level) { case "warning": return "Warning"; case "suggestion": return "Suggestion"; case "message": return "Message"; default: return "Error"; } } // src/helpers/ec-config.ts var ecConfig = (config) => { return { cascadeLayer: config.cascadeLayer, customizeTheme: config.customizeTheme, defaultLocale: config.defaultLocale, defaultProps: config.defaultProps, logger: config.logger, minSyntaxHighlightingColorContrast: config.minSyntaxHighlightingColorContrast, styleOverrides: config.styleOverrides, themeCssRoot: config.themeCssRoot, themeCssSelector: config.themeCssSelector, themes: config.themes, useDarkModeMediaQuery: config.useDarkModeMediaQuery, useStyleReset: config.useStyleReset, useThemedScrollbars: config.useThemedScrollbars, useThemedSelectionColors: config.useThemedSelectionColors, frames: { showCopyToClipboardButton: false, extractFileNameFromCode: false } }; }; // src/icons/completionIcons.ts import { h as h2 } from "@expressive-code/core/hast"; var completionIcons = { module: h2("svg", { viewBox: "0 0 32 32", width: "1rem", height: "auto" }, [ h2("path", { fill: "currentColor", d: "M11 2H2v9h2V4h7V2z" }, []), h2("path", { fill: "currentColor", d: "M2 21v9h9v-2H4v-7H2z" }, []), h2("path", { fill: "currentColor", d: "M30 11V2h-9v2h7v7h2z" }, []), h2("path", { fill: "currentColor", d: "M21 30h9v-9h-2v7h-7v2z" }, []), h2( "path", { fill: "currentColor", d: "M25.49 10.13l-9-5a1 1 0 0 0-1 0l-9 5A1 1 0 0 0 6 11v10a1 1 0 0 0 .51.87l9 5a1 1 0 0 0 1 0l9-5A1 1 0 0 0 26 21V11a1 1 0 0 0-.51-.87zM16 7.14L22.94 11L16 14.86L9.06 11zM8 12.7l7 3.89v7.71l-7-3.89zm9 11.6v-7.71l7-3.89v7.71z" }, [] ) ]), class: h2("svg", { viewBox: "0 0 32 32", width: "1rem", height: "auto" }, [ h2( "path", { fill: "currentColor", d: "M26 16a3.961 3.961 0 0 0-2.02.566l-2.859-2.859l2.293-2.293a2 2 0 0 0 0-2.828l-6-6a2 2 0 0 0-2.828 0l-6 6a2 2 0 0 0 0 2.828l2.293 2.293l-2.859 2.859a4.043 4.043 0 1 0 1.414 1.414l2.859-2.859l2.293 2.293a1.977 1.977 0 0 0 .414.31V22h-3v8h8v-8h-3v-4.277a1.977 1.977 0 0 0 .414-.309l2.293-2.293l2.859 2.859A3.989 3.989 0 1 0 26 16M8 20a2 2 0 1 1-2-2a2.002 2.002 0 0 1 2 2m10 4v4h-4v-4zm-2-8l-6-6l6-6l6 6Zm10 6a2 2 0 1 1 2-2a2.002 2.002 0 0 1-2 2" }, [] ) ]), method: h2("svg", { viewBox: "0 0 32 32", width: "1rem", height: "auto" }, [ h2( "path", { fill: "currentColor", d: "m19.626 29.526l-.516-1.933a12.004 12.004 0 0 0 6.121-19.26l1.538-1.28a14.003 14.003 0 0 1-7.143 22.473" }, [] ), h2( "path", { fill: "currentColor", d: "M10 29H8v-3.82l.804-.16C10.262 24.727 12 23.62 12 20v-1.382l-4-2v-2.236l4-2V12c0-5.467 3.925-9 10-9h2v3.82l-.804.16C21.738 7.273 20 8.38 20 12v.382l4 2v2.236l-4 2V20c0 5.467-3.925 9-10 9m0-2c4.935 0 8-2.682 8-7v-2.618l3.764-1.882L18 13.618V12c0-4.578 2.385-6.192 4-6.76V5c-4.935 0-8 2.682-8 7v1.618L10.236 15.5L14 17.382V20c0 4.578-2.385 6.192-4 6.76Z" }, [] ), h2( "path", { fill: "currentColor", d: "M5.231 24.947a14.003 14.003 0 0 1 7.147-22.474l.516 1.932a12.004 12.004 0 0 0-6.125 19.263Z" }, [] ) ]), property: h2("svg", { viewBox: "0 0 32 32", width: "1rem", height: "auto" }, [ h2( "path", { fill: "currentColor", d: "M12.1 2a9.8 9.8 0 0 0-5.4 1.6l6.4 6.4a2.1 2.1 0 0 1 .2 3a2.1 2.1 0 0 1-3-.2L3.7 6.4A9.84 9.84 0 0 0 2 12.1a10.14 10.14 0 0 0 10.1 10.1a10.9 10.9 0 0 0 2.6-.3l6.7 6.7a5 5 0 0 0 7.1-7.1l-6.7-6.7a10.9 10.9 0 0 0 .3-2.6A10 10 0 0 0 12.1 2m8 10.1a7.61 7.61 0 0 1-.3 2.1l-.3 1.1l.8.8l6.7 6.7a2.88 2.88 0 0 1 .9 2.1A2.72 2.72 0 0 1 27 27a2.9 2.9 0 0 1-4.2 0l-6.7-6.7l-.8-.8l-1.1.3a7.61 7.61 0 0 1-2.1.3a8.27 8.27 0 0 1-5.7-2.3A7.63 7.63 0 0 1 4 12.1a8.33 8.33 0 0 1 .3-2.2l4.4 4.4a4.14 4.14 0 0 0 5.9.2a4.14 4.14 0 0 0-.2-5.9L10 4.2a6.45 6.45 0 0 1 2-.3a8.27 8.27 0 0 1 5.7 2.3a8.49 8.49 0 0 1 2.4 5.9" }, [] ) ]), constructor: h2( "svg", { viewBox: "0 0 32 32", width: "1rem", height: "auto" }, [ h2( "path", { fill: "currentColor", d: "M21.49 13.115l-9-5a1 1 0 0 0-1 0l-9 5A1.008 1.008 0 0 0 2 14v9.995a1 1 0 0 0 .52.87l9 5A1.004 1.004 0 0 0 12 30a1.056 1.056 0 0 0 .49-.135l9-5A.992.992 0 0 0 22 24V14a1.008 1.008 0 0 0-.51-.885zM11 27.295l-7-3.89v-7.72l7 3.89zm1-9.45L5.06 14L12 10.135l6.94 3.86zm8 5.56l-7 3.89v-7.72l7-3.89z" }, [] ), h2( "path", { fill: "currentColor", d: "M30 6h-4V2h-2v4h-4v2h4v4h2V8h4V6z" }, [] ) ] ), interface: h2("svg", { viewBox: "0 0 32 32", width: "1rem", height: "auto" }, [ h2( "path", { fill: "currentColor", d: "M23 16.01a7 7 0 0 0-4.18 1.39l-4.22-4.22A6.86 6.86 0 0 0 16 9.01a7 7 0 1 0-2.81 5.59l4.21 4.22a7 7 0 1 0 5.6-2.81m-19-7a5 5 0 1 1 5 5a5 5 0 0 1-5-5" }, [] ) ]), function: h2("svg", { viewBox: "0 0 32 32", width: "1rem", height: "auto" }, [ h2( "path", { fill: "currentColor", d: "m19.626 29.526l-.516-1.933a12.004 12.004 0 0 0 6.121-19.26l1.538-1.28a14.003 14.003 0 0 1-7.143 22.473" }, [] ), h2( "path", { fill: "currentColor", d: "M10 29H8v-3.82l.804-.16C10.262 24.727 12 23.62 12 20v-1.382l-4-2v-2.236l4-2V12c0-5.467 3.925-9 10-9h2v3.82l-.804.16C21.738 7.273 20 8.38 20 12v.382l4 2v2.236l-4 2V20c0 5.467-3.925 9-10 9m0-2c4.935 0 8-2.682 8-7v-2.618l3.764-1.882L18 13.618V12c0-4.578 2.385-6.192 4-6.76V5c-4.935 0-8 2.682-8 7v1.618L10.236 15.5L14 17.382V20c0 4.578-2.385 6.192-4 6.76Z" }, [] ), h2( "path", { fill: "currentColor", d: "M5.231 24.947a14.003 14.003 0 0 1 7.147-22.474l.516 1.932a12.004 12.004 0 0 0-6.125 19.263Z" }, [] ) ]), string: h2("svg", { viewBox: "0 0 32 32", width: "1rem", height: "auto" }, [ h2( "path", { fill: "currentColor", d: "M29 22h-5a2.003 2.003 0 0 1-2-2v-6a2.002 2.002 0 0 1 2-2h5v2h-5v6h5zM18 12h-4V8h-2v14h6a2.003 2.003 0 0 0 2-2v-6a2.002 2.002 0 0 0-2-2m-4 8v-6h4v6zm-6-8H3v2h5v2H4a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h6v-8a2.002 2.002 0 0 0-2-2m0 8H4v-2h4z" }, [] ) ]) }; // src/helpers/processors.ts function splitCodeToLines(code) { return code.split("\n").map((line, index) => ({ index, line })); } function processTwoslashCodeBlock(codeBlock, codeWithIncludes, twoslashCode) { const ecCodeBlock = splitCodeToLines(codeWithIncludes); const twoslashCodeBlock = splitCodeToLines(twoslashCode); for (const line of twoslashCodeBlock) { const ln = codeBlock.getLine(line.index); if (ln) ln.editText(0, ln.text.length, line.line); } if (twoslashCodeBlock.length < ecCodeBlock.length) { for (let i = twoslashCodeBlock.length; i < ecCodeBlock.length; i++) { codeBlock.deleteLine(twoslashCodeBlock.length); } } } function processCompletion(completion) { const items = completion.completions.map((c) => { const kind = c.kind || "property"; const isDeprecated = "kindModifiers" in c && typeof c.kindModifiers === "string" && c.kindModifiers.split(",").includes("deprecated"); const icon = completionIcons[kind]; return { name: c.name, kind, icon, isDeprecated }; }).slice(0, 5); const { character, start, completionsPrefix } = completion; const length = start - character; return { startCharacter: character, completionsPrefix, start, length, items }; } // src/helpers/comparisons.ts function isNodeCompletion(node) { return node.type === "completion"; } function compareNodes(node1, node2, checks) { if (checks.line && node1.line !== node2.line) { return false; } if (checks.start && node1.start !== node2.start) { return false; } if (checks.character && node1.character !== node2.character) { return false; } if (checks.length && node1.length !== node2.length) { return false; } if (!isNodeCompletion(node1) && !isNodeCompletion(node2) && checks.text && node1.text !== node2.text) { return false; } return true; } // src/helpers/utils.ts function getTextWidthInPixels(textLoc, fontSize = 16, charWidth = 8) { return textLoc * charWidth * (fontSize / 16); } function checkForCustomTagsAndMerge(twoslashOptions) { const customTags = twoslashOptions?.customTags ?? []; const defaultTags = twoslashDefaultTags; const allTags = [...defaultTags]; for (const tag of customTags) { if (!allTags.includes(tag)) { allTags.push(tag); } } return { ...twoslashOptions, customTags: allTags }; } function buildMetaChecker(languages, explicitTrigger) { const trigger = explicitTrigger instanceof RegExp ? explicitTrigger : reTrigger; return function shouldTransform(codeBlock) { return languages.includes(codeBlock.language) && (!explicitTrigger || trigger.test(codeBlock.meta)); }; } // src/helpers/includes.ts var TwoslashIncludesManager = class { constructor(map = /* @__PURE__ */ new Map()) { this.map = map; } add(name, code) { const lines = []; code.split("\n").forEach((l, _i) => { const trimmed = l.trim(); if (trimmed.startsWith("// - ")) { const key = trimmed.split("// - ")[1].split(" ")[0]; this.map.set(`${name}-${key}`, lines.join("\n")); } else { lines.push(l); } }); this.map.set(name, lines.join("\n")); } applyInclude(code) { const reMarker = /\/\/ @include: (.*)$/gm; const toReplace = []; for (const match of code.matchAll(reMarker)) { const key = match[1]; const replaceWith = this.map.get(key); if (!replaceWith) { const msg = `Could not find an include with the key: '${key}'. There is: ${Array.from(this.map.keys())}.`; throw new Error(msg); } toReplace.push([match.index, match[0].length, replaceWith]); } let newCode = code.toString(); for (const [index, length, replacementCode] of toReplace.reverse()) { newCode = newCode.slice(0, index) + replacementCode + newCode.slice(index + length); } return newCode; } }; var INCLUDE_META_REGEX = /include\s+([\w-]+)\b.*/; function parseIncludeMeta(meta) { if (!meta) return null; const match = meta.match(INCLUDE_META_REGEX); return match?.[1] ?? null; } // src/annotations/completion.ts var TwoslashCompletionAnnotation = class extends ExpressiveCodeAnnotation { /** * Creates an instance of TwoslashCompletionAnnotation. * * @param completion - The completion item to be annotated. * @param query - The node completion query. */ constructor(completion, query, line) { super({ inlineRange: { columnStart: completion.startCharacter, columnEnd: completion.startCharacter + line.text.length } }); this.completion = completion; this.query = query; this.line = line; } name = "twoslash-completion-annotation"; /** * Renders the completion annotation. * @param nodesToTransform - The nodes to transform with the error box annotation. * @returns An array of transformed nodes with the error box annotation. */ render({ nodesToTransform }) { return nodesToTransform.map((node) => { return h3("span.twoslash-noline", [ h3("span.twoslash-cursor", [" "]), node, h3( "div.twoslash-completion", { style: { "margin-left": `${getTextWidthInPixels(this.completion.startCharacter)}px` } }, [ h3("div.twoslash-completion-container", [ ...this.completion.items.map((item, index) => { return h3( "div.twoslash-completion-item", { class: ` ${item.isDeprecated ? "twoslash-completion-item-deprecated" : ""} ${index === 0 ? "" : "twoslash-completion-item-separator"}` }, [ h3( "span.twoslash-completion-icon", { class: item.kind }, item.icon ), h3("span.twoslash-completion-name", [ h3("span.twoslash-completion-name-matched", [ item.name.startsWith(this.query.completionsPrefix) ? this.query.completionsPrefix : "" ]), h3("span.twoslash-completion-name-unmatched", [ item.name.startsWith(this.query.completionsPrefix) ? item.name.slice( this.query.completionsPrefix.length || 0 ) : item.name ]) ]) ] ); }) ]) ] ) ]); }); } }; // src/annotations/customTags.ts import { ExpressiveCodeAnnotation as ExpressiveCodeAnnotation2 } from "@expressive-code/core"; import { h as h5 } from "@expressive-code/core/hast"; // src/icons/customTagsIcons.ts import { h as h4 } from "@expressive-code/core/hast"; var customTagsIcons = { log: h4("svg", { viewBox: "0 0 32 32", width: "1rem", height: "auto" }, [ h4( "path", { fill: "currentColor", d: "M17 22v-8h-4v2h2v6h-3v2h8v-2zM16 8a1.5 1.5 0 1 0 1.5 1.5A1.5 1.5 0 0 0 16 8" }, [] ), h4( "path", { fill: "currentColor", d: "M26 28H6a2.002 2.002 0 0 1-2-2V6a2.002 2.002 0 0 1 2-2h20a2.002 2.002 0 0 1 2 2v20a2.002 2.002 0 0 1-2 2M6 6v20h20V6Z" }, [] ) ]), warn: h4("svg", { viewBox: "0 0 32 32", width: "1rem", height: "auto" }, [ h4( "path", { fill: "currentColor", d: "M16 23a1.5 1.5 0 1 0 1.5 1.5A1.5 1.5 0 0 0 16 23m-1-11h2v9h-2z" }, [] ), h4( "path", { fill: "currentColor", d: "M29 30H3a1 1 0 0 1-.887-1.461l13-25a1 1 0 0 1 1.774 0l13 25A1 1 0 0 1 29 30M4.65 28h22.7l.001-.003L16.002 6.17h-.004L4.648 27.997Z" }, [] ) ]), error: h4("svg", { viewBox: "0 0 32 32", width: "1rem", height: "auto" }, [ h4( "path", { fill: "currentColor", d: "M16 2a14 14 0 1 0 14 14A14 14 0 0 0 16 2m0 26a12 12 0 1 1 12-12a12 12 0 0 1-12 12" }, [] ), h4( "path", { fill: "currentColor", d: "M15 8h2v11h-2zm1 14a1.5 1.5 0 1 0 1.5 1.5A1.5 1.5 0 0 0 16 22" }, [] ) ]), annotate: h4("svg", { viewBox: "0 0 32 32", width: "1rem", height: "auto" }, [ h4( "path", { fill: "currentColor", d: "M11 24h10v2H11zm2 4h6v2h-6zm3-26A10 10 0 0 0 6 12a9.19 9.19 0 0 0 3.46 7.62c1 .93 1.54 1.46 1.54 2.38h2c0-1.84-1.11-2.87-2.19-3.86A7.2 7.2 0 0 1 8 12a8 8 0 0 1 16 0a7.2 7.2 0 0 1-2.82 6.14c-1.07 1-2.18 2-2.18 3.86h2c0-.92.53-1.45 1.54-2.39A9.18 9.18 0 0 0 26 12A10 10 0 0 0 16 2" }, [] ) ]) }; // src/annotations/customTags.ts var TwoslashCustomTagsAnnotation = class extends ExpressiveCodeAnnotation2 { /** * Creates an instance of TwoslashCustomTagsAnnotation. * @param tag - The NodeTag object representing the Twoslash tag. */ constructor(tag, line) { super({ inlineRange: { columnStart: 0, columnEnd: line.text.length } }); this.tag = tag; this.line = line; } name = "twoslash-custom-tags"; render({ nodesToTransform }) { const tag = this.tag; const customTagClass = getCustomTagClass(tag.name); return nodesToTransform.map((node) => { return h5("span.twoslash.twocustom", [ h5( "div.twoslash-custom-box", { class: customTagClass }, [ h5("span.twoslash-custom-box-icon", [ customTagsIcons[tag.name] ]), h5("span.twoslash-custom-box-content", [ h5("span.twoslash-custom-box-content-title", [ `${getCustomTagString(tag.name)}:` ]), h5("span.twoslash-custom-box-content-message", [` ${tag.text}`]) ]) ] ), node ]); }); } }; // src/annotations/errors.ts import { ExpressiveCodeAnnotation as ExpressiveCodeAnnotation3 } from "@expressive-code/core"; import { h as h6 } from "@expressive-code/core/hast"; var TwoslashErrorUnderlineAnnotation = class extends ExpressiveCodeAnnotation3 { constructor(error) { super({ inlineRange: { columnStart: error.character, columnEnd: error.character + error.length } }); this.error = error; } name = "twoslash-error-underline"; render({ nodesToTransform }) { return nodesToTransform.map((node) => { return h6("span.twoslash.twoslash-error-underline", [node]); }); } }; var TwoslashErrorBoxAnnotation = class extends ExpressiveCodeAnnotation3 { /** * Creates an instance of `TwoslashErrorBoxAnnotation`. * * @param error - The error object containing error details. * @param line - The line of code where the error occurred. */ constructor(error, line) { super({ inlineRange: { columnStart: line.text.length, columnEnd: line.text.length + error.length } }); this.error = error; this.line = line; } name = "twoslash-error-box"; /** * Renders the error box annotation. * * @param nodesToTransform - The nodes to transform with the error box annotation. * @returns An array of transformed nodes with the error box annotation. */ render({ nodesToTransform }) { const error = this.error; const errorLevelClass = getErrorLevelClass(error); return nodesToTransform.map((node) => { return h6("span.twoslash.twoerror", [ node, h6( "div.twoslash-error-box", { class: errorLevelClass }, [ h6("span.twoslash-error-box-icon"), h6("span.twoslash-error-box-content", [ h6("span.twoslash-error-box-content-title", [ `${getErrorLevelString(error)} ${error.code && `ts(${error.code}) `} \u2015 ` ]), h6("span.twoslash-error-box-content-message", [error.text]) ]) ] ) ]); }); } }; // src/annotations/highlight.ts import { ExpressiveCodeAnnotation as ExpressiveCodeAnnotation4 } from "@expressive-code/core"; import { h as h7 } from "@expressive-code/core/hast"; var TwoslashHighlightAnnotation = class extends ExpressiveCodeAnnotation4 { /** * Creates an instance of `TwoslashHighlightAnnotation`. * @param highlight - The highlight details including start position and length. */ constructor(highlight) { super({ inlineRange: { columnStart: highlight.start, columnEnd: highlight.start + highlight.length } }); this.highlight = highlight; } name = "twoslash-highlight-annotation"; /** * Renders the highlight annotation. * @param nodesToTransform - The nodes to be transformed. * @returns An array of transformed nodes wrapped in a span with the class `twoslash-highlighted`. */ render({ nodesToTransform }) { return nodesToTransform.map((node) => { return h7("span.twoslash-highlighted", [node]); }); } }; // src/annotations/hover.ts import { ExpressiveCodeAnnotation as ExpressiveCodeAnnotation5 } from "@expressive-code/core"; import { h as h8 } from "@expressive-code/core/hast"; var TwoslashHoverAnnotation = class extends ExpressiveCodeAnnotation5 { /** * Creates an instance of `TwoslashHoverAnnotation`. * @param hover - The hover information including character position and text. */ constructor(hover, codeType, renderedDocs) { super({ inlineRange: { columnStart: hover.character, columnEnd: hover.character + hover.length } }); this.hover = hover; this.codeType = codeType; this.renderedDocs = renderedDocs; } name = "twoslash-hover-annotation"; /** * Renders the hover annotation. * @param nodesToTransform - The nodes to be transformed with hover annotations. * @returns The transformed nodes with hover annotations. */ render({ nodesToTransform }) { return nodesToTransform.map((node) => { if (node.type === "element") { return h8("span.twoslash", node.properties, [ h8("span.twoslash-hover", [ h8( "div.twoslash-popup-container.not-content", [ h8("code.twoslash-popup-code", [ h8("span.twoslash-popup-code-type", this.codeType) ]), this.renderedDocs.docs, this.renderedDocs.tags ] ), node ]) ]); } return node; }); } }; // src/annotations/static.ts import { ExpressiveCodeAnnotation as ExpressiveCodeAnnotation6 } from "@expressive-code/core"; import { h as h9 } from "@expressive-code/core/hast"; var TwoslashStaticAnnotation = class extends ExpressiveCodeAnnotation6 { /** * Creates an instance of TwoslashStaticAnnotation. * * @param hover - The hover information for the node. * @param line - The line of code associated with the annotation. * @param includeJsDoc - A flag indicating whether to include JSDoc comments. * @param query - The query information for the node. */ constructor(query, line, codeType, renderedDocs) { super({ inlineRange: { columnStart: line.text.length, columnEnd: line.text.length + query.length } }); this.query = query; this.line = line; this.codeType = codeType; this.renderedDocs = renderedDocs; } name = "twoslash-static-annotation"; /** * Renders the static annotation. * @param nodesToTransform - The nodes to transform with the error box annotation. * @returns An array of transformed nodes with the error box annotation. */ render({ nodesToTransform }) { return nodesToTransform.map((node) => { return h9("span.twoslash-noline", [ node, h9( "div.twoslash-static", { style: { "margin-left": `${getTextWidthInPixels(this.query.character)}px` } }, [ h9("div.twoslash-static-container.not-content", [ h9("code.twoslash-popup-code", [ h9("span.twoslash-popup-code-type", this.codeType) ]), this.renderedDocs.docs, this.renderedDocs.tags ]) ] ) ]); }); } }; // src/module-code/floating-ui-core.min.js var floating_ui_core_min_default = '!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FloatingUICore={})}(this,(function(t){"use strict";const e=["top","right","bottom","left"],n=["start","end"],i=e.reduce(((t,e)=>t.concat(e,e+"-"+n[0],e+"-"+n[1])),[]),o=Math.min,r=Math.max,a={left:"right",right:"left",bottom:"top",top:"bottom"},l={start:"end",end:"start"};function s(t,e,n){return r(t,o(e,n))}function f(t,e){return"function"==typeof t?t(e):t}function c(t){return t.split("-")[0]}function u(t){return t.split("-")[1]}function m(t){return"x"===t?"y":"x"}function d(t){return"y"===t?"height":"width"}function g(t){return["top","bottom"].includes(c(t))?"y":"x"}function p(t){return m(g(t))}function h(t,e,n){void 0===n&&(n=!1);const i=u(t),o=p(t),r=d(o);let a="x"===o?i===(n?"end":"start")?"right":"left":"start"===i?"bottom":"top";return e.reference[r]>e.floating[r]&&(a=w(a)),[a,w(a)]}function y(t){return t.replace(/start|end/g,(t=>l[t]))}function w(t){return t.replace(/left|right|bottom|top/g,(t=>a[t]))}function x(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function v(t){const{x:e,y:n,width:i,height:o}=t;return{width:i,height:o,top:n,left:e,right:e+i,bottom:n+o,x:e,y:n}}function b(t,e,n){let{reference:i,floating:o}=t;const r=g(e),a=p(e),l=d(a),s=c(e),f="y"===r,m=i.x+i.width/2-o.width/2,h=i.y+i.height/2-o.height/2,y=i[l]/2-o[l]/2;let w;switch(s){case"top":w={x:m,y:i.y-o.height};break;case"bottom":w={x:m,y:i.y+i.height};break;case"right":w={x:i.x+i.width,y:h};break;case"left":w={x:i.x-o.width,y:h};break;default:w={x:i.x,y:i.y}}switch(u(e)){case"start":w[a]-=y*(n&&f?-1:1);break;case"end":w[a]+=y*(n&&f?-1:1)}return w}async function A(t,e){var n;void 0===e&&(e={});const{x:i,y:o,platform:r,rects:a,elements:l,strategy:s}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:m="floating",altBoundary:d=!1,padding:g=0}=f(e,t),p=x(g),h=l[d?"floating"===m?"reference":"floating":m],y=v(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(h)))||n?h:h.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:s})),w="floating"===m?{x:i,y:o,width:a.floating.width,height:a.floating.height}:a.reference,b=await(null==r.getOffsetParent?void 0:r.getOffsetParent(l.floating)),A=await(null==r.isElement?void 0:r.isElement(b))&&await(null==r.getScale?void 0:r.getScale(b))||{x:1,y:1},R=v(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:b,strategy:s}):w);return{top:(y.top-R.top+p.top)/A.y,bottom:(R.bottom-y.bottom+p.bottom)/A.y,left:(y.left-R.left+p.left)/A.x,right:(R.right-y.right+p.right)/A.x}}function R(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function P(t){return e.some((e=>t[e]>=0))}function D(t){const e=o(...t.map((t=>t.left))),n=o(...t.map((t=>t.top)));return{x:e,y:n,width:r(...t.map((t=>t.right)))-e,height:r(...t.map((t=>t.bottom)))-n}}t.arrow=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:i,placement:r,rects:a,platform:l,elements:c,middlewareData:m}=e,{element:g,padding:h=0}=f(t,e)||{};if(null==g)return{};const y=x(h),w={x:n,y:i},v=p(r),b=d(v),A=await l.getDimensions(g),R="y"===v,P=R?"top":"left",D=R?"bottom":"right",T=R?"clientHeight":"clientWidth",O=a.reference[b]+a.reference[v]-w[v]-a.floating[b],E=w[v]-a.reference[v],L=await(null==l.getOffsetParent?void 0:l.getOffsetParent(g));let k=L?L[T]:0;k&&await(null==l.isElement?void 0:l.isElement(L))||(k=c.floating[T]||a.floating[b]);const C=O/2-E/2,B=k/2-A[b]/2-1,H=o(y[P],B),S=o(y[D],B),F=H,j=k-A[b]-S,z=k/2-A[b]/2+C,M=s(F,z,j),V=!m.arrow&&null!=u(r)&&z!==M&&a.reference[b]/2-(z<F?H:S)-A[b]/2<0,W=V?z<F?z-F:z-j:0;return{[v]:w[v]+W,data:{[v]:M,centerOffset:z-M-W,...V&&{alignmentOffset:W}},reset:V}}}),t.autoPlacement=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,o,r;const{rects:a,middlewareData:l,placement:s,platform:m,elements:d}=e,{crossAxis:g=!1,alignment:p,allowedPlacements:w=i,autoAlignment:x=!0,...v}=f(t,e),b=void 0!==p||w===i?function(t,e,n){return(t?[...n.filter((e=>u(e)===t)),...n.filter((e=>u(e)!==t))]:n.filter((t=>c(t)===t))).filter((n=>!t||u(n)===t||!!e&&y(n)!==n))}(p||null,x,w):w,R=await A(e,v),P=(null==(n=l.autoPlacement)?void 0:n.index)||0,D=b[P];if(null==D)return{};const T=h(D,a,await(null==m.isRTL?void 0:m.isRTL(d.floating)));if(s!==D)return{reset:{placement:b[0]}};const O=[R[c(D)],R[T[0]],R[T[1]]],E=[...(null==(o=l.autoPlacement)?void 0:o.overflows)||[],{placement:D,overflows:O}],L=b[P+1];if(L)return{data:{index:P+1,overflows:E},reset:{placement:L}};const k=E.map((t=>{const e=u(t.placement);return[t.placement,e&&g?t.overflows.slice(0,2).reduce(((t,e)=>t+e),0):t.overflows[0],t.overflows]})).sort(((t,e)=>t[1]-e[1])),C=(null==(r=k.filter((t=>t[2].slice(0,u(t[0])?2:3).every((t=>t<=0))))[0])?void 0:r[0])||k[0][0];return C!==s?{data:{index:P+1,overflows:E},reset:{placement:C}}:{}}}},t.computePosition=async(t,e,n)=>{const{placement:i="bottom",strategy:o="absolute",middleware:r=[],platform:a}=n,l=r.filter(Boolean),s=await(null==a.isRTL?void 0:a.isRTL(e));let f=await a.getElementRects({reference:t,floating:e,strategy:o}),{x:c,y:u}=b(f,i,s),m=i,d={},g=0;for(let n=0;n<l.length;n++){const{name:r,fn:p}=l[n],{x:h,y:y,data:w,reset:x}=await p({x:c,y:u,initialPlacement:i,placement:m,strategy:o,middlewareData:d,rects:f,platform:a,elements:{reference:t,floating:e}});c=null!=h?h:c,u=null!=y?y:u,d={...d,[r]:{...d[r],...w}},x&&g<=50&&(g++,"object"==typeof x&&(x.placement&&(m=x.placement),x.rects&&(f=!0===x.rects?await a.getElementRects({reference:t,floating:e,strategy:o}):x.rects),({x:c,y:u}=b(f,m,s))),n=-1)}return{x:c,y:u,placement:m,strategy:o,middlewareData:d}},t.detectOverflow=A,t.flip=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,i;const{placement:o,middlewareData:r,rects:a,initialPlacement:l,platform:s,elements:m}=e,{mainAxis:d=!0,crossAxis:p=!0,fallbackPlacements:x,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:R=!0,...P}=f(t,e);if(null!=(n=r.arrow)&&n.alignmentOffset)return{};const D=c(o),T=g(l),O=c(l)===l,E=await(null==s.isRTL?void 0:s.isRTL(m.floating)),L=x||(O||!R?[w(l)]:function(t){const e=w(t);return[y(t),e,y(e)]}(l)),k="none"!==b;!x&&k&&L.push(...function(t,e,n,i){const o=u(t);let r=function(t,e,n){const i=["left","right"],o=["right","left"],r=["top","bottom"],a=["bottom","top"];switch(t){case"top":case"bottom":return n?e?o:i:e?i:o;case"left":case"right":return e?r:a;default:return[]}}(c(t),"start"===n,i);return o&&(r=r.map((t=>t+"-"+o)),e&&(r=r.concat(r.map(y)))),r}(l,R,b,E));const C=[l,...L],B=await A(e,P),H=[];let S=(null==(i=r.flip)?void 0:i.overflows)||[];if(d&&H.push(B[D]),p){const t=h(o,a,E);H.push(B[t[0]],B[t[1]])}if(S=[...S,{placement:o,overflows:H}],!H.every((t=>t<=0))){var F,j;const t=((null==(F=r.flip)?void 0:F.index)||0)+1,e=C[t];if(e)return{data:{index:t,overflows:S},reset:{placement:e}};let n=null==(j=S.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:j.placement;if(!n)switch(v){case"bestFit":{var z;const t=null==(z=S.filter((t=>{if(k){const e=g(t.placement);return e===T||"y"===e}return!0})).map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:z[0];t&&(n=t);break}case"initialPlacement":n=l}if(o!==n)return{reset:{placement:n}}}return{}}}},t.hide=function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:i="referenceHidden",...o}=f(t,e);switch(i){case"referenceHidden":{const t=R(await A(e,{...o,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:t,referenceHidden:P(t)}}}case"escaped":{const t=R(await A(e,{...o,altBoundary:!0}),n.floating);return{data:{escapedOffsets:t,escaped:P(t)}}}default:return{}}}}},t.inline=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:i,rects:a,platform:l,strategy:s}=e,{padding:u=2,x:m,y:d}=f(t,e),p=Array.from(await(null==l.getClientRects?void 0:l.getClientRects(i.reference))||[]),h=function(t){const e=t.slice().sort(((t,e)=>t.y-e.y)),n=[];let i=null;for(let t=0;t<e.length;t++){const o=e[t];!i||o.y-i.y>i.height/2?n.push([o]):n[n.length-1].push(o),i=o}return n.map((t=>v(D(t))))}(p),y=v(D(p)),w=x(u);const b=await l.getElementRects({reference:{getBoundingClientRect:function(){if(2===h.length&&h[0].left>h[1].right&&null!=m&&null!=d)return h.find((t=>m>t.left-w.left&&m<t.right+w.right&&d>t.top-w.top&&d<t.bottom+w.bottom))||y;if(h.length>=2){if("y"===g(n)){const t=h[0],e=h[h.length-1],i="top"===c(n),o=t.top,r=e.bottom,a=i?t.left:e.left,l=i?t.right:e.right;return{top:o,bottom:r,left:a,right:l,width:l-a,height:r-o,x:a,y:o}}const t="left"===c(n),e=r(...h.map((t=>t.right))),i=o(...h.map((t=>t.left))),a=h.filter((n=>t?n.left===i:n.right===e)),l=a[0].top,s=a[a.length-1].bottom;return{top:l,bottom:s,left:i,right:e,width:e-i,height:s-l,x:i,y:l}}return y}},floating:i.floating,strategy:s});return a.reference.x!==b.reference.x||a.reference.y!==b.reference.y||a.reference.width!==b.reference.width||a.reference.height!==b.reference.height?{reset:{rects:b}}:{}}}},t.limitShift=function(t){return void 0===t&&(t={}),{options:t,fn(e){const{x:n,y:i,placement:o,rects:r,middlewareData:a}=e,{offset:l=0,mainAxis:s=!0,crossAxis:u=!0}=f(t,e),d={x:n,y:i},p=g(o),h=m(p);let y=d[h],w=d[p];const x=f(l,e),v="number"==typeof x?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(s){const t="y"===h?"height":"width",e=r.reference[h]-r.floating[t]+v.mainAxis,n=r.reference[h]+r.reference[t]-v.mainAxis;y<e?y=e:y>n&&(y=n)}if(u){var b,A;const t="y"===h?"width":"height",e=["top","left"].includes(c(o)),n=r.reference[p]-r.floating[t]+(e&&(null==(b=a.offset)?void 0:b[p])||0)+(e?0:v.crossAxis),i=r.reference[p]+r.reference[t]+(e?0:(null==(A=a.offset)?void 0:A[p])||0)-(e?v.crossAxis:0);w<n?w=n:w>i&&(w=i)}return{[h]:y,[p]:w}}}},t.offset=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,i;const{x:o,y:r,placement:a,middlewareData:l}=e,s=await async function(t,e){const{placement:n,platform:i,elements:o}=t,r=await(null==i.isRTL?void 0:i.isRTL(o.floating)),a=c(n),l=u(n),s="y"===g(n),m=["left","top"].includes(a)?-1:1,d=r&&s?-1:1,p=f(e,t);let{mainAxis:h,crossAxis:y,alignmentAxis:w}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&"number"==typeof w&&(y="end"===l?-1*w:w),s?{x:y*d,y:h*m}:{x:h*m,y:y*d}}(e,t);return a===(null==(n=l.offset)?void 0:n.placement)&&null!=(i=l.arrow)&&i.alignmentOffset?{}:{x:o+s.x,y:r+s.y,data:{...s,placement:a}}}}},t.rectToClientRect=v,t.shift=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:i,placement:o}=e,{mainAxis:r=!0,crossAxis:a=!1,limiter:l={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...u}=f(t,e),d={x:n,y:i},p=await A(e,u),h=g(c(o)),y=m(h);let w=d[y],x=d[h];if(r){const t="y"===y?"bottom":"right";w=s(w+p["y"===y?"top":"left"],w,w-p[t])}if(a){const t="y"===h?"bottom":"right";x=s(x+p["y"===h?"top":"left"],x,x-p[t])}const v=l.fn({...e,[y]:w,[h]:x});return{...v,data:{x:v.x-n,y:v.y-i,enabled:{[y]:r,[h]:a}}}}}},t.size=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){var n,i;const{placement:a,rects:l,platform:s,elements:m}=e,{apply:d=(()=>{}),...p}=f(t,e),h=await A(e,p),y=c(a),w=u(a),x="y"===g(a),{width:v,height:b}=l.floating;let R,P;"top"===y||"bottom"===y?(R=y,P=w===(await(null==s.isRTL?void 0:s.isRTL(m.floating))?"start":"end")?"left":"right"):(P=y,R="end"===w?"top":"bottom");const D=b-h.top-h.bottom,T=v-h.left-h.right,O=o(b-h[R],D),E=o(v-h[P],T),L=!e.middlewareData.shift;let k=O,C=E;if(null!=(n=e.middlewareData.shift)&&n.enabled.x&&(C=T),null!=(i=e.middlewareData.shift)&&i.enabled.y&&(k=D),L&&!w){const t=r(h.left,0),e=r(h.right,0),n=r(h.top,0),i=r(h.bottom,0);x?C=v-2*(0!==t||0!==e?t+e:r(h.left,h.right)):k=b-2*(0!==n||0!==i?n+i:r(h.top,h.bottom))}await d({...e,availableWidth:C,availableHeight:k});const B=await s.getDimensions(m.floating);return v!==B.width||b!==B.height?{reset:{rects:!0}}:{}}}}}));'; // src/module-code/floating-ui-dom.min.js var floating_ui_dom_min_default = '!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@floating-ui/core")):"function"==typeof define&&define.amd?define(["exports","@floating-ui/core"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FloatingUIDOM={},t.FloatingUICore)}(this,(function(t,e){"use strict";const n=Math.min,o=Math.max,i=Math.round,r=Math.floor,c=t=>({x:t,y:t});function l(){return"undefined"!=typeof window}function s(t){return d(t)?(t.nodeName||"").toLowerCase():"#document"}function f(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function u(t){var e;return null==(e=(d(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function d(t){return!!l()&&(t instanceof Node||t instanceof f(t).Node)}function a(t){return!!l()&&(t instanceof Element||t instanceof f(t).Element)}function h(t){return!!l()&&(t instanceof HTMLElement||t instanceof f(t).HTMLElement)}function p(t){return!(!l()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof f(t).ShadowRoot)}function g(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=b(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(i)}function m(t){return["table","td","th"].includes(s(t))}function y(t){return[":popover-open",":modal"].some((e=>{try{return t.matches(e)}catch(t){return!1}}))}function w(t){const e=x(),n=a(t)?b(t):t;return"none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!e&&!!n.backdropFilter&&"none"!==n.backdropFilter||!e&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some((t=>(n.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(n.contain||"").includes(t)))}function x(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function v(t){return["html","body","#document"].includes(s(t))}function b(t){return f(t).getComputedStyle(t)}function T(t){return a(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function L(t){if("html"===s(t))return t;const e=t.assignedSlot||t.parentNode||p(t)&&t.host||u(t);return p(e)?e.host:e}function R(t){const e=L(t);return v(e)?t.ownerDocument?t.ownerDocument.body:t.body:h(e)&&g(e)?e:R(e)}function C(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=R(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),c=f(i);if(r){const t=E(c);return e.concat(c,c.visualViewport||[],g(i)?i:[],t&&n?C(t):[])}return e.concat(i,C(i,[],n))}function E(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function S(t){const e=b(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const r=h(t),c=r?t.offsetWidth:n,l=r?t.offsetHeight:o,s=i(n)!==c||i(o)!==l;return s&&(n=c,o=l),{width:n,height:o,$:s}}function F(t){return a(t)?t:t.contextElement}function O(t){const e=F(t);if(!h(e))return c(1);const n=e.getBoundingClientRect(),{width:o,height:r,$:l}=S(e);let s=(l?i(n.width):n.width)/o,f=(l?i(n.height):n.height)/r;return s&&Number.isFinite(s)||(s=1),f&&Number.isFinite(f)||(f=1),{x:s,y:f}}const D=c(0);function H(t){const e=f(t);return x()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:D}function P(t,n,o,i){void 0===n&&(n=!1),void 0===o&&(o=!1);const r=t.getBoundingClientRect(),l=F(t);let s=c(1);n&&(i?a(i)&&(s=O(i)):s=O(t));const u=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==f(t))&&e}(l,o,i)?H(l):c(0);let d=(r.left+u.x)/s.x,h=(r.top+u.y)/s.y,p=r.width/s.x,g=r.height/s.y;if(l){const t=f(l),e=i&&a(i)?f(i):i;let n=t,o=E(n);for(;o&&i&&e!==n;){const t=O(o),e=o.getBoundingClientRect(),i=b(o),r=e.left+(o.clientLeft+parseFloat(i.paddingLeft))*t.x,c=e.top+(o.clientTop+parseFloat(i.paddingTop))*t.y;d*=t.x,h*=t.y,p*=t.x,g*=t.y,d+=r,h+=c,n=f(o),o=E(n)}}return e.rectToClientRect({width:p,height:g,x:d,y:h})}function W(t,e){const n=T(t).scrollLeft;return e?e.left+n:P(u(t)).left+n}function M(t,e,n){void 0===n&&(n=!1);const o=t.getBoundingClientRect();return{x:o.left+e.scrollLeft-(n?0:W(t,o)),y:o.top+e.scrollTop}}function z(t,n,i){let r;if("viewport"===n)r=function(t,e){const n=f(t),o=u(t),i=n.visualViewport;let r=o.clientWidth,c=o.clientHeight,l=0,s=0;if(i){r=i.width,c=i.height;const t=x();(!t||t&&"fixed"===e)&&(l=i.offsetLeft,s=i.offsetTop)}return{width:r,height:c,x:l,y:s}}(t,i);else if("document"===n)r=function(t){const e=u(t),n=T(t),i=t.ownerDocument.body,r=o(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),c=o(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let l=-n.scrollLeft+W(t);const s=-n.scrollTop;return"rtl"===b(i).direction&&(l+=o(e.clientWidth,i.clientWidth)-r),{width:r,height:c,x:l,y:s}}(u(t));else if(a(n))r=function(t,e){const n=P(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=h(t)?O(t):c(1);return{width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:o*r.y}}(n,i);else{const e=H(t);r={x:n.x-e.x,y:n.y-e.y,width:n.width,height:n.height}}return e.rectToClientRect(r)}function A(t,e){const n=L(t);return!(n===e||!a(n)||v(n))&&("fixed"===b(n).position||A(n,e))}function V(t,e,n){const o=h(e),i=u(e),r="fixed"===n,l=P(t,!0,r,e);let f={scrollLeft:0,scrollTop:0};const d=c(0);if(o||!o&&!r)if(("body"!==s(e)||g(i))&&(f=T(e)),o){const t=P(e,!0,r,e);d.x=t.x+e.clientLeft,d.y=t.y+e.clientTop}else i&&(d.x=W(i));const a=!i||o||r?c(0):M(i,f);return{x:l.left+f.scrollLeft-d.x-a.x,y:l.top+f.scrollTop-d.y-a.y,width:l.width,height:l.height}}function B(t){return"static"===b(t).position}function N(t,e){if(!h(t)||"fixed"===b(t).position)return null;if(e)return e(t);let n=t.offsetParent;return u(t)===n&&(n=n.ownerDocument.body),n}function I(t,e){const n=f(t);if(y(t))return n;if(!h(t)){let e=L(t);for(;e&&!v(e);){if(a(e)&&!B(e))return e;e=L(e)}return n}let o=N(t,e);for(;o&&m(o)&&B(o);)o=N(o,e);return o&&v(o)&&B(o)&&!w(o)?n:o||function(t){let e=L(t);for(;h(e)&&!v(e);){if(w(e))return e;if(y(e))return null;e=L(e)}return null}(t)||n}const k={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:n,offsetParent:o,strategy:i}=t;const r="fixed"===i,l=u(o),f=!!e&&y(e.floating);if(o===l||f&&r)return n;let d={scrollLeft:0,scrollTop:0},a=c(1);const p=c(0),m=h(o);if((m||!m&&!r)&&(("body"!==s(o)||g(l))&&(d=T(o)),h(o))){const t=P(o);a=O(o),p.x=t.x+o.clientLeft,p.y=t.y+o.clientTop}const w=!l||m||r?c(0):M(l,d,!0);return{width:n.width*a.x,height:n.height*a.y,x:n.x*a.x-d.scrollLeft*a.x+p.x+w.x,y:n.y*a.y-d.scrollTop*a.y+p.y+w.y}},getDocumentElement:u,getClippingRect:function(t){let{element:e,boundary:i,rootBoundary:r,strategy:c}=t;const l=[..."clippingAncestors"===i?y(e)?[]:function(t,e){const n=e.get(t);if(n)return n;let o=C(t,[],!1).filter((t=>a(t)&&"body"!==s(t))),i=null;const r="fixed"===b(t).position;let c=r?L(t):t;for(;a(c)&&!v(c);){const e=b(c),n=w(c);n||"fixed"!==e.position||(i=null),(r?!n&&!i:!n&&"static"===e.position&&i&&["absolute","fixed"].includes(i.position)||g(c)&&!n&&A(t,c))?o=o.filter((t=>t!==c)):i=e,c=L(c)}return e.set(t,o),o}(e,this._c):[].concat(i),r],f=l[0],u=l.reduce(((t,i)=>{const r=z(e,i,c);return t.top=o(r.top,t.top),t.right=n(r.right,t.right),t.bottom=n(r.bottom,t.bottom),t.left=o(r.left,t.left),t}),z(e,f,c));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}},getOffsetParent:I,getElementRects:async function(t){const e=this.getOffsetParent||I,n=this.getDimensions,o=await n(t.floating);return{reference:V(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:e,height:n}=S(t);return{width:e,height:n}},getScale:O,isElement:a,isRTL:function(t){return"rtl"===b(t).direction}};const q=e.detectOver