export { useLottie } from './chunk-6JTB2X72.mjs';
export { Player as AudioPlayer } from './chunk-FX2QFYWF.mjs';
export { NativeProvider, StreamProvider, VideoControls, VideoErrorFallback, VideoPlayer, VideoPlayerProvider, VidstackProvider, createVideoErrorFallback, isSimpleStreamSource, resolveFileSource, resolvePlayerMode, resolveStreamSource, useVideoPlayerContext } from './chunk-EUADAUBQ.mjs';
export { ImageViewer } from './chunk-GGKGH5PM.mjs';
export { generateContentKey, useAudioCache, useBlobUrlCleanup, useImageCache, useMediaCacheStore, useVideoCache, useVideoPlayerSettings } from './chunk-5LBDYFWH.mjs';
export { CronSchedulerProvider, CustomInput, DayChips, MonthDayGrid, SchedulePreview, ScheduleTypeSelector, TimeSelector, buildCron, humanizeCron, isValidCron, parseCron, useCronCustom, useCronMonthDays, useCronPreview, useCronScheduler, useCronSchedulerContext, useCronTime, useCronType, useCronWeekDays } from './chunk-PZKAH7WQ.mjs';
export { TreeError, TreeSkeleton, createDemoTree } from './chunk-KR6B3LVY.mjs';
export { DEFAULT_TREE_APPEARANCE, DEFAULT_TREE_LABELS, TreeRoot as Tree, TreeChevron, TreeContent, TreeEmpty, TreeIcon, TreeIndentGuides, TreeLabel, TreeProvider, TreeRoot, TreeRow, TreeSearchInput, appearanceToStyle, clearTreeState, createChildCache, flattenTree, loadTreeState, resolveAppearance, resolveChildren, saveTreeState, useTreeActions, useTreeContext, useTreeExpansion, useTreeFocus, useTreeKeyboard, useTreeLabels, useTreeRows, useTreeSearch, useTreeSelection, useTreeTypeAhead } from './chunk-NFIMVYJU.mjs';
import { PlaygroundProvider } from './chunk-GBLQTHWT.mjs';
export { MarkdownMessage, Mermaid_default as Mermaid, PrettyCode_default as PrettyCode, extractTextFromChildren, useCollapsibleContent } from './chunk-GBLQTHWT.mjs';
export { JsonTree_default as JsonTree } from './chunk-LFWQ36LJ.mjs';
import './chunk-SSUOENAZ.mjs';
export { ArrayFieldItemTemplate, ArrayFieldTemplate, BaseInputTemplate, CheckboxWidget, ColorWidget, ErrorListTemplate, FieldTemplate, JsonSchemaForm, NumberWidget, ObjectFieldTemplate, SelectWidget, SliderWidget, SwitchWidget, TextWidget, getRequiredFields, hasRequiredFields, mergeDefaults, normalizeFormData, safeJsonParse, safeJsonStringify, validateRequiredFields, validateSchema } from './chunk-JUGQNNDC.mjs';
import { __name } from './chunk-CGILA3WO.mjs';
import * as React from 'react';
import { lazy, forwardRef, useRef, useState, useCallback, useImperativeHandle, useEffect, createContext, Suspense, useContext, useMemo } from 'react';
import { cn } from '@djangocfg/ui-core/lib';
import { useAppT } from '@djangocfg/i18n';
import { jsx, jsxs } from 'react/jsx-runtime';
import { useResolvedTheme } from '@djangocfg/ui-core/hooks';
import { ReactRenderer, useEditor as useEditor$1, EditorContent } from '@tiptap/react';
import StarterKit from '@tiptap/starter-kit';
import Placeholder from '@tiptap/extension-placeholder';
import Mention from '@tiptap/extension-mention';
import { Markdown } from '@tiptap/markdown';
import { Bold, Italic, Strikethrough, Code, Heading1, Heading2, Heading3, List, ListOrdered, Quote, Minus } from 'lucide-react';
import { autoUpdate, computePosition, offset, flip, shift } from '@floating-ui/dom';

function Spinner({ className }) {
  const t = useAppT();
  const loadingLabel = t("ui.states.loading");
  return /* @__PURE__ */ jsx(
    "div",
    {
      className: cn(
        "inline-block h-8 w-8 animate-spin rounded-full",
        "border-4 border-solid border-current border-r-transparent",
        "align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]",
        className
      ),
      role: "status",
      "aria-label": loadingLabel
    }
  );
}
__name(Spinner, "Spinner");
function LoadingFallback({
  minHeight = 200,
  showText = true,
  text,
  className
}) {
  const t = useAppT();
  const loadingText = text ?? t("ui.form.loading");
  const height = typeof minHeight === "number" ? `${minHeight}px` : minHeight;
  return /* @__PURE__ */ jsx(
    "div",
    {
      className: cn(
        "flex items-center justify-center bg-muted/30 rounded-lg",
        className
      ),
      style: { minHeight: height },
      children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
        /* @__PURE__ */ jsx(Spinner, { className: "text-primary" }),
        showText && /* @__PURE__ */ jsx("p", { className: "mt-3 text-sm text-muted-foreground", children: loadingText })
      ] })
    }
  );
}
__name(LoadingFallback, "LoadingFallback");
function CardLoadingFallback({
  title,
  description,
  minHeight = 200,
  className
}) {
  const t = useAppT();
  const cardTitle = title ?? t("ui.states.loading");
  const height = typeof minHeight === "number" ? `${minHeight}px` : minHeight;
  return /* @__PURE__ */ jsxs(
    "div",
    {
      className: cn(
        "relative bg-card rounded-lg border border-border overflow-hidden",
        className
      ),
      children: [
        /* @__PURE__ */ jsxs("div", { className: "p-4 border-b border-border bg-muted/50", children: [
          /* @__PURE__ */ jsx("h6", { className: "text-sm font-semibold text-foreground", children: cardTitle }),
          description && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-1", children: description })
        ] }),
        /* @__PURE__ */ jsx("div", { className: "p-4", children: /* @__PURE__ */ jsx(
          "div",
          {
            className: "flex justify-center items-center",
            style: { minHeight: height },
            children: /* @__PURE__ */ jsx(Spinner, { className: "text-primary" })
          }
        ) })
      ]
    }
  );
}
__name(CardLoadingFallback, "CardLoadingFallback");
function MapLoadingFallback({
  minHeight = 400,
  className
}) {
  const t = useAppT();
  const loadingText = t("ui.form.loading");
  const height = typeof minHeight === "number" ? `${minHeight}px` : minHeight;
  return /* @__PURE__ */ jsx(
    "div",
    {
      className: cn(
        "relative bg-muted/50 rounded-lg overflow-hidden",
        "flex items-center justify-center",
        className
      ),
      style: { minHeight: height },
      children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
        /* @__PURE__ */ jsxs("div", { className: "relative", children: [
          /* @__PURE__ */ jsx(Spinner, { className: "text-primary h-10 w-10" }),
          /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsxs(
            "svg",
            {
              className: "h-5 w-5 text-muted-foreground",
              fill: "none",
              viewBox: "0 0 24 24",
              stroke: "currentColor",
              children: [
                /* @__PURE__ */ jsx(
                  "path",
                  {
                    strokeLinecap: "round",
                    strokeLinejoin: "round",
                    strokeWidth: 2,
                    d: "M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"
                  }
                ),
                /* @__PURE__ */ jsx(
                  "path",
                  {
                    strokeLinecap: "round",
                    strokeLinejoin: "round",
                    strokeWidth: 2,
                    d: "M15 11a3 3 0 11-6 0 3 3 0 016 0z"
                  }
                )
              ]
            }
          ) })
        ] }),
        /* @__PURE__ */ jsx("p", { className: "mt-3 text-sm text-muted-foreground", children: loadingText })
      ] })
    }
  );
}
__name(MapLoadingFallback, "MapLoadingFallback");
function LazyWrapper({
  children,
  fallback,
  card = false,
  cardTitle,
  cardDescription,
  minHeight = 200,
  className
}) {
  const defaultFallback = card ? /* @__PURE__ */ jsx(
    CardLoadingFallback,
    {
      title: cardTitle,
      description: cardDescription,
      minHeight,
      className
    }
  ) : /* @__PURE__ */ jsx(LoadingFallback, { minHeight, className });
  return /* @__PURE__ */ jsx(Suspense, { fallback: fallback ?? defaultFallback, children });
}
__name(LazyWrapper, "LazyWrapper");
function createLazyComponent(loader, options = {}) {
  const LazyComponent = React.lazy(loader);
  const WrappedComponent = /* @__PURE__ */ __name((props) => {
    const fallback = typeof options.fallback === "function" ? options.fallback(props) : options.fallback ?? /* @__PURE__ */ jsx(LoadingFallback, {});
    return /* @__PURE__ */ jsx(Suspense, { fallback, children: /* @__PURE__ */ jsx(LazyComponent, { ...props }) });
  }, "WrappedComponent");
  WrappedComponent.displayName = options.displayName ?? "LazyComponent";
  return WrappedComponent;
}
__name(createLazyComponent, "createLazyComponent");
var LazyMapContainer = createLazyComponent(
  () => import('./MapContainer-GXQLP5WY.mjs').then((mod) => ({ default: mod.MapContainer })),
  {
    displayName: "LazyMapContainer",
    fallback: /* @__PURE__ */ jsx(MapLoadingFallback, { minHeight: 400 })
  }
);
var LazyMapView = createLazyComponent(
  () => import('./MapContainer-GXQLP5WY.mjs').then((mod) => ({ default: mod.MapView })),
  {
    displayName: "LazyMapView",
    fallback: /* @__PURE__ */ jsx(MapLoadingFallback, { minHeight: 400 })
  }
);
var LazyMermaid = createLazyComponent(
  () => import('./Mermaid.client-SXRRI2YW.mjs'),
  {
    displayName: "LazyMermaid",
    fallback: /* @__PURE__ */ jsx(
      CardLoadingFallback,
      {
        title: "Diagram",
        description: "Loading...",
        minHeight: 200
      }
    )
  }
);
function CodeLoadingFallback() {
  return /* @__PURE__ */ jsx("div", { className: "relative rounded-sm border border-border overflow-hidden bg-muted dark:bg-zinc-900", children: /* @__PURE__ */ jsx("div", { className: "p-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
    /* @__PURE__ */ jsx("div", { className: "animate-pulse h-4 w-4 rounded-full bg-muted-foreground/20" }),
    /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "Loading code..." })
  ] }) }) });
}
__name(CodeLoadingFallback, "CodeLoadingFallback");
var LazyPrettyCode = createLazyComponent(
  () => import('./PrettyCode.client-SPMTQEG4.mjs'),
  {
    displayName: "LazyPrettyCode",
    fallback: /* @__PURE__ */ jsx(CodeLoadingFallback, {})
  }
);
function OpenapiLoadingFallback() {
  return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center min-h-[400px] bg-muted/30 rounded-lg", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
    /* @__PURE__ */ jsx("div", { className: "inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-primary border-r-transparent" }),
    /* @__PURE__ */ jsx("p", { className: "mt-3 text-sm text-muted-foreground", children: "Loading API Playground..." })
  ] }) });
}
__name(OpenapiLoadingFallback, "OpenapiLoadingFallback");
var LazyDocsLayout = createLazyComponent(
  () => import('./DocsLayout-ESVQZO3V.mjs').then((mod) => ({ default: mod.DocsLayout })),
  {
    displayName: "LazyDocsLayout",
    fallback: /* @__PURE__ */ jsx(OpenapiLoadingFallback, {})
  }
);
var LazyOpenapiViewer = /* @__PURE__ */ __name(({ config }) => {
  return /* @__PURE__ */ jsx(PlaygroundProvider, { config, children: /* @__PURE__ */ jsx(LazyDocsLayout, {}) });
}, "LazyOpenapiViewer");
LazyOpenapiViewer.displayName = "LazyOpenapiViewer";
var LazyJsonSchemaForm = createLazyComponent(
  () => import('./JsonSchemaForm-RN3XWSWX.mjs').then((mod) => ({ default: mod.JsonSchemaForm })),
  {
    displayName: "LazyJsonSchemaForm",
    fallback: /* @__PURE__ */ jsx(
      CardLoadingFallback,
      {
        title: "Form",
        description: "Loading form schema...",
        minHeight: 200
      }
    )
  }
);
function LottieLoadingFallback() {
  return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-2", children: [
    /* @__PURE__ */ jsx("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-muted border-t-primary" }),
    /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: "Loading animation..." })
  ] }) });
}
__name(LottieLoadingFallback, "LottieLoadingFallback");
var LazyLottiePlayer = createLazyComponent(
  () => import('./LottiePlayer.client-B4I6WNZM.mjs').then((mod) => ({ default: mod.LottiePlayer })),
  {
    displayName: "LazyLottiePlayer",
    fallback: /* @__PURE__ */ jsx(LottieLoadingFallback, {})
  }
);
var LazyPlayer = createLazyComponent(
  () => import('./Player-M3GC3VPE.mjs').then((mod) => ({ default: mod.Player })),
  {
    displayName: "LazyAudioPlayer",
    fallback: /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-border/60 bg-card px-4 py-6 text-sm text-muted-foreground", children: "Loading audio player\u2026" })
  }
);
function VideoLoadingFallback() {
  return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center bg-black/90 rounded-lg aspect-video", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-2", children: [
    /* @__PURE__ */ jsxs("div", { className: "relative", children: [
      /* @__PURE__ */ jsx("div", { className: "h-10 w-10 animate-spin rounded-full border-4 border-white/20 border-t-white" }),
      /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsx(
        "svg",
        {
          className: "h-5 w-5 text-white/60",
          fill: "currentColor",
          viewBox: "0 0 24 24",
          children: /* @__PURE__ */ jsx("path", { d: "M8 5v14l11-7z" })
        }
      ) })
    ] }),
    /* @__PURE__ */ jsx("span", { className: "text-sm text-white/60", children: "Loading video player..." })
  ] }) });
}
__name(VideoLoadingFallback, "VideoLoadingFallback");
var LazyVideoPlayer = createLazyComponent(
  () => import('./components-ZAGG2PBO.mjs').then((mod) => ({ default: mod.VideoPlayer })),
  {
    displayName: "LazyVideoPlayer",
    fallback: /* @__PURE__ */ jsx(VideoLoadingFallback, {})
  }
);
var LazyJsonTree = createLazyComponent(
  () => import('./JsonTree-QTJYSHCV.mjs'),
  {
    displayName: "LazyJsonTree",
    fallback: /* @__PURE__ */ jsx(LoadingFallback, { minHeight: 100, text: "Loading JSON viewer..." })
  }
);
var LazyImageViewer = createLazyComponent(
  () => import('./components-CFXOEVPN.mjs').then((mod) => ({ default: mod.ImageViewer })),
  {
    displayName: "LazyImageViewer",
    fallback: /* @__PURE__ */ jsx(LoadingFallback, { minHeight: 200, text: "Loading image viewer..." })
  }
);
var LazyCronScheduler = createLazyComponent(
  () => import('./CronScheduler.client-3O3VU4CI.mjs'),
  {
    displayName: "LazyCronScheduler",
    fallback: /* @__PURE__ */ jsx(
      LoadingFallback,
      {
        minHeight: 120,
        showText: false,
        className: "rounded-lg"
      }
    )
  }
);
var LazyTree = createLazyComponent(
  () => import('./TreeRoot-HBRJEHBH.mjs'),
  {
    displayName: "LazyTree",
    fallback: /* @__PURE__ */ jsx(LoadingFallback, { minHeight: 200, text: "Loading tree\u2026" })
  }
);
var LottiePlayerClient = lazy(
  () => import('./LottiePlayer.client-B4I6WNZM.mjs').then((mod) => ({ default: mod.LottiePlayer }))
);
var LoadingFallback5 = /* @__PURE__ */ __name(() => /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-2", children: [
  /* @__PURE__ */ jsx("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-gray-300 border-t-gray-900" }),
  /* @__PURE__ */ jsx("span", { className: "text-sm text-gray-500", children: "Loading player..." })
] }) }), "LoadingFallback");
function LottiePlayer(props) {
  return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingFallback5, {}), children: /* @__PURE__ */ jsx(LottiePlayerClient, { ...props }) });
}
__name(LottiePlayer, "LottiePlayer");
var DocsLayout = lazy(
  () => import('./DocsLayout-ESVQZO3V.mjs').then((mod) => ({ default: mod.DocsLayout }))
);
var LoadingFallback6 = /* @__PURE__ */ __name(() => /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center min-h-[400px]", children: /* @__PURE__ */ jsx("div", { className: "text-muted-foreground", children: "Loading API Playground..." }) }), "LoadingFallback");
var Playground = /* @__PURE__ */ __name(({ config }) => {
  return /* @__PURE__ */ jsx(PlaygroundProvider, { config, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingFallback6, {}), children: /* @__PURE__ */ jsx(DocsLayout, {}) }) });
}, "Playground");
var OpenapiViewer_default = Playground;
var CronSchedulerClient = lazy(() => import('./CronScheduler.client-3O3VU4CI.mjs'));
function CronScheduler(props) {
  return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(CronSchedulerFallback, {}), children: /* @__PURE__ */ jsx(CronSchedulerClient, { ...props }) });
}
__name(CronScheduler, "CronScheduler");
function CronSchedulerFallback() {
  return /* @__PURE__ */ jsx(
    LoadingFallback,
    {
      minHeight: 120,
      showText: false,
      className: "rounded-lg"
    }
  );
}
__name(CronSchedulerFallback, "CronSchedulerFallback");

// src/tools/CodeEditor/workers/setup.ts
var isSetup = false;
function setupMonacoWorkers(getWorker) {
  if (isSetup || typeof window === "undefined") return;
  if (getWorker) {
    self.MonacoEnvironment = {
      getWorker: /* @__PURE__ */ __name((_workerId, label) => getWorker(label), "getWorker")
    };
  }
  isSetup = true;
}
__name(setupMonacoWorkers, "setupMonacoWorkers");

// src/tools/CodeEditor/hooks/useMonaco.ts
function useMonaco() {
  const [monaco, setMonaco] = useState(null);
  const [isLoading, setIsLoading] = useState(true);
  const [error, setError] = useState(null);
  useEffect(() => {
    let mounted = true;
    async function loadMonaco() {
      try {
        setupMonacoWorkers();
        const monacoModule = await import('monaco-editor');
        if (mounted) {
          setMonaco(monacoModule);
          setIsLoading(false);
        }
      } catch (err) {
        if (mounted) {
          setError(err instanceof Error ? err : new Error("Failed to load Monaco Editor"));
          setIsLoading(false);
        }
      }
    }
    __name(loadMonaco, "loadMonaco");
    loadMonaco();
    return () => {
      mounted = false;
    };
  }, []);
  return { monaco, isLoading, error };
}
__name(useMonaco, "useMonaco");
function useEditorTheme(monaco, themeOverride) {
  const appTheme = useResolvedTheme();
  const registered = useRef(false);
  useEffect(() => {
    if (!monaco || registered.current) return;
    try {
      const colors = _readCSSColors();
      monaco.editor.defineTheme("app-dark", {
        base: "vs-dark",
        inherit: true,
        rules: [
          { token: "comment", foreground: "6A9955", fontStyle: "italic" },
          { token: "keyword", foreground: "C586C0" },
          { token: "string", foreground: "CE9178" },
          { token: "number", foreground: "B5CEA8" },
          { token: "type", foreground: "4EC9B0" },
          { token: "function", foreground: "DCDCAA" },
          { token: "variable", foreground: "9CDCFE" }
        ],
        colors: {
          "editor.background": colors.background,
          "editor.foreground": colors.foreground,
          "editor.lineHighlightBackground": colors.lineHighlight,
          "editor.selectionBackground": colors.selection,
          "editorCursor.foreground": colors.foreground,
          "editorLineNumber.foreground": colors.mutedForeground,
          "editorWidget.background": colors.card,
          "editorWidget.border": colors.border,
          "input.background": colors.card,
          "dropdown.background": colors.card
        }
      });
      monaco.editor.defineTheme("app-light", {
        base: "vs",
        inherit: true,
        rules: [
          { token: "comment", foreground: "008000", fontStyle: "italic" },
          { token: "keyword", foreground: "AF00DB" },
          { token: "string", foreground: "A31515" },
          { token: "number", foreground: "098658" },
          { token: "type", foreground: "267F99" },
          { token: "function", foreground: "795E26" },
          { token: "variable", foreground: "001080" }
        ],
        colors: {
          "editor.background": colors.backgroundLight,
          "editor.foreground": colors.foregroundLight,
          "editor.lineHighlightBackground": colors.lineHighlightLight,
          "editor.selectionBackground": colors.selectionLight,
          "editorLineNumber.foreground": colors.mutedForegroundLight,
          "editorWidget.background": colors.cardLight,
          "editorWidget.border": colors.borderLight
        }
      });
      registered.current = true;
    } catch {
    }
  }, [monaco]);
  if (themeOverride) return themeOverride;
  if (registered.current) {
    return appTheme === "dark" ? "app-dark" : "app-light";
  }
  return appTheme === "dark" ? "vs-dark" : "vs";
}
__name(useEditorTheme, "useEditorTheme");
function _readCSSColors() {
  const get = /* @__PURE__ */ __name((varName) => {
    if (typeof document === "undefined") return "";
    return getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
  }, "get");
  const hslToHex = /* @__PURE__ */ __name((hsl) => {
    if (!hsl) return "";
    const parts = hsl.split(/\s+/).map((s2) => parseFloat(s2.replace("%", "")));
    if (parts.length < 3 || parts.some(isNaN)) return "";
    const [h, s, l] = [parts[0], parts[1] / 100, parts[2] / 100];
    const a = s * Math.min(l, 1 - l);
    const f = /* @__PURE__ */ __name((n) => {
      const k = (n + h / 30) % 12;
      const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
      return Math.round(255 * color).toString(16).padStart(2, "0");
    }, "f");
    return `#${f(0)}${f(8)}${f(4)}`;
  }, "hslToHex");
  const background = hslToHex(get("--background")) || "#0a0a0a";
  const foreground = hslToHex(get("--foreground")) || "#f5f5f5";
  const card = hslToHex(get("--card")) || "#141414";
  const border = hslToHex(get("--border")) || "#262626";
  const mutedForeground = hslToHex(get("--muted-foreground")) || "#858585";
  const lineHighlight = _adjustBrightness(background, 10);
  const primary = hslToHex(get("--primary"));
  const selection = primary ? _adjustBrightness(primary, -40) : "#264F78";
  return {
    background,
    foreground,
    card,
    border,
    mutedForeground,
    lineHighlight,
    selection,
    // Light variants
    backgroundLight: "#ffffff",
    foregroundLight: "#1a1a1a",
    cardLight: "#ffffff",
    borderLight: "#e5e5e5",
    mutedForegroundLight: "#737373",
    lineHighlightLight: "#f5f5f5",
    selectionLight: "#ADD6FF"
  };
}
__name(_readCSSColors, "_readCSSColors");
function _adjustBrightness(hex, amount) {
  const num = parseInt(hex.replace("#", ""), 16);
  const r = Math.min(255, Math.max(0, (num >> 16 & 255) + amount));
  const g = Math.min(255, Math.max(0, (num >> 8 & 255) + amount));
  const b = Math.min(255, Math.max(0, (num & 255) + amount));
  return `#${(r << 16 | g << 8 | b).toString(16).padStart(6, "0")}`;
}
__name(_adjustBrightness, "_adjustBrightness");
var Editor = forwardRef(/* @__PURE__ */ __name(function Editor2({
  value = "",
  language = "plaintext",
  onChange,
  onMount,
  options = {},
  className = "",
  height = "100%",
  width = "100%",
  autoHeight = false,
  minHeight = 100,
  maxHeight = 600
}, ref) {
  const containerRef = useRef(null);
  const editorRef = useRef(null);
  const { monaco, isLoading } = useMonaco();
  const resolvedTheme = useEditorTheme(monaco, options.theme);
  const [contentHeight, setContentHeight] = useState(null);
  const updateContentHeight = useCallback((editor) => {
    if (!autoHeight) return;
    const h = editor.getContentHeight();
    setContentHeight(Math.min(Math.max(h, minHeight), maxHeight));
  }, [autoHeight, minHeight, maxHeight]);
  const isInternalChangeRef = useRef(false);
  useImperativeHandle(ref, () => ({
    getEditor: /* @__PURE__ */ __name(() => editorRef.current, "getEditor"),
    getValue: /* @__PURE__ */ __name(() => editorRef.current?.getValue() || "", "getValue"),
    setValue: /* @__PURE__ */ __name((val) => editorRef.current?.setValue(val), "setValue"),
    focus: /* @__PURE__ */ __name(() => editorRef.current?.focus(), "focus")
  }));
  useEffect(() => {
    if (!monaco || !containerRef.current || editorRef.current) return;
    const editor = monaco.editor.create(containerRef.current, {
      value,
      language,
      theme: resolvedTheme,
      fontSize: options.fontSize || 14,
      fontFamily: options.fontFamily || "'Fira Code', 'Consolas', monospace",
      tabSize: options.tabSize || 2,
      insertSpaces: options.insertSpaces !== false,
      wordWrap: options.wordWrap || "on",
      minimap: { enabled: options.minimap !== false },
      lineNumbers: options.lineNumbers || "on",
      readOnly: options.readOnly || false,
      automaticLayout: true,
      scrollBeyondLastLine: autoHeight ? false : false,
      scrollbar: autoHeight ? { vertical: "hidden", horizontal: "auto" } : void 0,
      overviewRulerLanes: autoHeight ? 0 : void 0,
      padding: { top: 16, bottom: 16 },
      renderLineHighlight: "all",
      cursorBlinking: "smooth",
      cursorSmoothCaretAnimation: "on",
      smoothScrolling: true,
      bracketPairColorization: { enabled: true },
      guides: {
        bracketPairs: true,
        indentation: true
      }
    });
    editorRef.current = editor;
    if (onChange) {
      editor.onDidChangeModelContent(() => {
        isInternalChangeRef.current = true;
        onChange(editor.getValue());
      });
    }
    if (autoHeight) {
      editor.onDidContentSizeChange(() => updateContentHeight(editor));
      updateContentHeight(editor);
    }
    onMount?.(editor);
    return () => {
      editor.dispose();
      editorRef.current = null;
    };
  }, [monaco]);
  useEffect(() => {
    const editor = editorRef.current;
    if (!editor) return;
    if (isInternalChangeRef.current) {
      isInternalChangeRef.current = false;
      return;
    }
    const currentValue = editor.getValue();
    if (value !== currentValue) {
      const position = editor.getPosition();
      const selections = editor.getSelections();
      editor.setValue(value);
      if (position) {
        editor.setPosition(position);
      }
      if (selections && selections.length > 0) {
        editor.setSelections(selections);
      }
    }
  }, [value]);
  useEffect(() => {
    const editor = editorRef.current;
    if (!editor || !monaco) return;
    const model = editor.getModel();
    if (model) {
      monaco.editor.setModelLanguage(model, language);
    }
  }, [language, monaco]);
  useEffect(() => {
    const editor = editorRef.current;
    if (!editor) return;
    editor.updateOptions({
      theme: resolvedTheme,
      fontSize: options.fontSize,
      readOnly: options.readOnly,
      minimap: { enabled: options.minimap !== false },
      wordWrap: options.wordWrap,
      lineNumbers: options.lineNumbers
    });
  }, [options, resolvedTheme]);
  if (isLoading) {
    return /* @__PURE__ */ jsx(
      "div",
      {
        className,
        style: {
          width,
          height,
          display: "flex",
          alignItems: "center",
          justifyContent: "center",
          backgroundColor: "#1e1e1e",
          color: "#666"
        },
        children: "Loading editor..."
      }
    );
  }
  const resolvedHeight = autoHeight && contentHeight != null ? contentHeight : height;
  return /* @__PURE__ */ jsx(
    "div",
    {
      ref: containerRef,
      className,
      style: {
        width,
        height: resolvedHeight,
        ...autoHeight && { minHeight, maxHeight, overflow: "hidden" }
      }
    }
  );
}, "Editor"));
function DiffEditor({
  original,
  modified,
  language = "plaintext",
  options = {},
  className = "",
  height = "100%"
}) {
  const containerRef = useRef(null);
  const editorRef = useRef(null);
  const { monaco, isLoading } = useMonaco();
  const resolvedTheme = useEditorTheme(monaco, options.theme);
  useEffect(() => {
    if (!monaco || !containerRef.current || editorRef.current) return;
    const editor = monaco.editor.createDiffEditor(containerRef.current, {
      theme: resolvedTheme,
      fontSize: options.fontSize || 14,
      fontFamily: options.fontFamily || "'Fira Code', 'Consolas', monospace",
      readOnly: true,
      automaticLayout: true,
      renderSideBySide: true,
      scrollBeyondLastLine: false,
      minimap: { enabled: false }
    });
    const originalModel = monaco.editor.createModel(original, language);
    const modifiedModel = monaco.editor.createModel(modified, language);
    editor.setModel({
      original: originalModel,
      modified: modifiedModel
    });
    editorRef.current = editor;
    return () => {
      originalModel.dispose();
      modifiedModel.dispose();
      editor.dispose();
      editorRef.current = null;
    };
  }, [monaco]);
  useEffect(() => {
    const editor = editorRef.current;
    if (!editor || !monaco) return;
    const model = editor.getModel();
    if (model) {
      model.original.setValue(original);
      model.modified.setValue(modified);
    }
  }, [original, modified, monaco]);
  useEffect(() => {
    const editor = editorRef.current;
    if (!editor || !monaco) return;
    const model = editor.getModel();
    if (model) {
      monaco.editor.setModelLanguage(model.original, language);
      monaco.editor.setModelLanguage(model.modified, language);
    }
  }, [language, monaco]);
  if (isLoading) {
    return /* @__PURE__ */ jsx(
      "div",
      {
        className,
        style: {
          width: "100%",
          height,
          display: "flex",
          alignItems: "center",
          justifyContent: "center",
          backgroundColor: "#1e1e1e",
          color: "#666"
        },
        children: "Loading diff editor..."
      }
    );
  }
  return /* @__PURE__ */ jsx(
    "div",
    {
      ref: containerRef,
      className,
      style: {
        width: "100%",
        height
      }
    }
  );
}
__name(DiffEditor, "DiffEditor");

// src/tools/CodeEditor/lib/languages.ts
var LANGUAGE_MAP = {
  // Web
  ".html": "html",
  ".htm": "html",
  ".xhtml": "html",
  ".vue": "html",
  ".svelte": "html",
  // CSS
  ".css": "css",
  ".scss": "scss",
  ".sass": "scss",
  ".less": "less",
  // JavaScript/TypeScript
  ".js": "javascript",
  ".mjs": "javascript",
  ".cjs": "javascript",
  ".jsx": "javascript",
  ".ts": "typescript",
  ".tsx": "typescript",
  ".mts": "typescript",
  ".cts": "typescript",
  // Data formats
  ".json": "json",
  ".jsonc": "json",
  ".json5": "json",
  ".yaml": "yaml",
  ".yml": "yaml",
  ".toml": "ini",
  ".xml": "xml",
  ".svg": "xml",
  ".xsl": "xml",
  ".xsd": "xml",
  // Markdown & Documentation
  ".md": "markdown",
  ".mdx": "markdown",
  ".markdown": "markdown",
  ".rst": "restructuredtext",
  ".txt": "plaintext",
  ".text": "plaintext",
  // Programming languages
  ".py": "python",
  ".pyw": "python",
  ".pyi": "python",
  ".rb": "ruby",
  ".rake": "ruby",
  ".gemspec": "ruby",
  ".php": "php",
  ".phtml": "php",
  ".java": "java",
  ".kt": "kotlin",
  ".kts": "kotlin",
  ".scala": "scala",
  ".go": "go",
  ".rs": "rust",
  ".swift": "swift",
  ".c": "c",
  ".h": "c",
  ".cpp": "cpp",
  ".cc": "cpp",
  ".cxx": "cpp",
  ".hpp": "cpp",
  ".hxx": "cpp",
  ".cs": "csharp",
  ".fs": "fsharp",
  ".fsx": "fsharp",
  ".vb": "vb",
  ".lua": "lua",
  ".r": "r",
  ".R": "r",
  ".m": "objective-c",
  ".mm": "objective-c",
  ".pl": "perl",
  ".pm": "perl",
  ".ex": "elixir",
  ".exs": "elixir",
  ".erl": "erlang",
  ".hrl": "erlang",
  ".clj": "clojure",
  ".cljs": "clojure",
  ".cljc": "clojure",
  ".hs": "haskell",
  ".lhs": "haskell",
  ".ml": "fsharp",
  ".mli": "fsharp",
  ".dart": "dart",
  ".groovy": "groovy",
  ".gradle": "groovy",
  ".jl": "julia",
  // Shell & Scripts
  ".sh": "shell",
  ".bash": "shell",
  ".zsh": "shell",
  ".fish": "shell",
  ".ps1": "powershell",
  ".psm1": "powershell",
  ".psd1": "powershell",
  ".bat": "bat",
  ".cmd": "bat",
  // Config files
  ".ini": "ini",
  ".cfg": "ini",
  ".conf": "ini",
  ".properties": "ini",
  ".env": "ini",
  ".gitignore": "ini",
  ".gitattributes": "ini",
  ".editorconfig": "ini",
  ".npmrc": "ini",
  // Database
  ".sql": "sql",
  ".mysql": "mysql",
  ".pgsql": "pgsql",
  ".plsql": "plsql",
  ".redis": "redis",
  // Templates
  ".hbs": "handlebars",
  ".handlebars": "handlebars",
  ".mustache": "handlebars",
  ".ejs": "html",
  ".pug": "pug",
  ".jade": "pug",
  ".twig": "twig",
  ".liquid": "liquid",
  // GraphQL
  ".graphql": "graphql",
  ".gql": "graphql",
  // Docker
  ".dockerfile": "dockerfile",
  // Other
  ".diff": "diff",
  ".patch": "diff",
  ".log": "log",
  ".tex": "latex",
  ".cls": "latex",
  ".sty": "latex",
  ".proto": "protobuf",
  ".sol": "sol",
  ".asm": "mips",
  ".s": "mips",
  ".wasm": "wasm"
};
var FILENAME_MAP = {
  Dockerfile: "dockerfile",
  "docker-compose.yml": "yaml",
  "docker-compose.yaml": "yaml",
  Makefile: "makefile",
  makefile: "makefile",
  Gemfile: "ruby",
  Rakefile: "ruby",
  Jenkinsfile: "groovy",
  Vagrantfile: "ruby",
  ".bashrc": "shell",
  ".bash_profile": "shell",
  ".zshrc": "shell",
  ".profile": "shell",
  ".vimrc": "plaintext",
  ".gitconfig": "ini",
  ".htaccess": "ini",
  "nginx.conf": "ini",
  "package.json": "json",
  "tsconfig.json": "json",
  "jsconfig.json": "json",
  ".prettierrc": "json",
  ".eslintrc": "json",
  "composer.json": "json",
  "Cargo.toml": "ini",
  "go.mod": "go",
  "go.sum": "plaintext",
  "requirements.txt": "plaintext",
  "pyproject.toml": "ini",
  "setup.py": "python",
  "setup.cfg": "ini"
};
function getLanguageByFilename(filename) {
  if (FILENAME_MAP[filename]) {
    return FILENAME_MAP[filename];
  }
  const lastDot = filename.lastIndexOf(".");
  if (lastDot === -1) {
    return "plaintext";
  }
  const extension = filename.slice(lastDot).toLowerCase();
  return LANGUAGE_MAP[extension] || "plaintext";
}
__name(getLanguageByFilename, "getLanguageByFilename");
var EditorContext = createContext(null);
function useEditorContext() {
  const context = useContext(EditorContext);
  if (!context) {
    throw new Error("useEditorContext must be used within EditorProvider");
  }
  return context;
}
__name(useEditorContext, "useEditorContext");
function EditorProvider({ children, onSave }) {
  const { monaco } = useMonaco();
  const [editor, setEditor] = useState(null);
  const [openFiles, setOpenFiles] = useState([]);
  const [activeFilePath, setActiveFilePath] = useState(null);
  const activeFile = useMemo(
    () => openFiles.find((f) => f.path === activeFilePath) || null,
    [openFiles, activeFilePath]
  );
  const openFile = useCallback(
    (path, content, language) => {
      setOpenFiles((files) => {
        const existing = files.find((f) => f.path === path);
        if (existing) {
          return files;
        }
        const basename = path.split("/").pop() || path;
        const detectedLanguage = language || getLanguageByFilename(basename);
        const newFile = {
          path,
          content,
          language: detectedLanguage,
          isDirty: false
        };
        return [...files, newFile];
      });
      setActiveFilePath(path);
    },
    []
  );
  const closeFile = useCallback(
    (path) => {
      setOpenFiles((files) => {
        const index = files.findIndex((f) => f.path === path);
        if (index === -1) return files;
        const newFiles = files.filter((f) => f.path !== path);
        if (activeFilePath === path && newFiles.length > 0) {
          const newIndex = Math.min(index, newFiles.length - 1);
          setActiveFilePath(newFiles[newIndex].path);
        } else if (newFiles.length === 0) {
          setActiveFilePath(null);
        }
        return newFiles;
      });
    },
    [activeFilePath]
  );
  const setActiveFile = useCallback((path) => {
    setActiveFilePath(path);
  }, []);
  const updateContent = useCallback((path, content) => {
    setOpenFiles(
      (files) => files.map(
        (f) => f.path === path ? { ...f, content, isDirty: true } : f
      )
    );
  }, []);
  const saveFile = useCallback(
    async (path) => {
      const file = openFiles.find((f) => f.path === path);
      if (!file) return;
      if (onSave) {
        await onSave(path, file.content);
      }
      setOpenFiles(
        (files) => files.map(
          (f) => f.path === path ? { ...f, isDirty: false } : f
        )
      );
    },
    [openFiles, onSave]
  );
  const isDirty = useCallback(
    (path) => {
      const file = openFiles.find((f) => f.path === path);
      return file?.isDirty || false;
    },
    [openFiles]
  );
  const getContent = useCallback(
    (path) => {
      const file = openFiles.find((f) => f.path === path);
      return file?.content || null;
    },
    [openFiles]
  );
  const getFile = useCallback(
    (path) => {
      return openFiles.find((f) => f.path === path) || null;
    },
    [openFiles]
  );
  const value = {
    openFiles,
    activeFile,
    monaco,
    editor,
    isReady: monaco !== null && editor !== null,
    openFile,
    closeFile,
    setActiveFile,
    updateContent,
    saveFile,
    isDirty,
    getContent,
    getFile
  };
  return /* @__PURE__ */ jsx(EditorContext.Provider, { value, children });
}
__name(EditorProvider, "EditorProvider");
function useEditor() {
  const [editor, setEditorState] = useState(null);
  const setEditor = useCallback((editorInstance) => {
    setEditorState(editorInstance);
  }, []);
  return {
    editor,
    isReady: editor !== null,
    setEditor
  };
}
__name(useEditor, "useEditor");
function useLanguage(filename) {
  return useMemo(() => {
    if (!filename) return "plaintext";
    const basename = filename.split("/").pop() || filename;
    return getLanguageByFilename(basename);
  }, [filename]);
}
__name(useLanguage, "useLanguage");
var MentionList = forwardRef(
  ({ items, command }, ref) => {
    const [selectedIndex, setSelectedIndex] = useState(0);
    useEffect(() => setSelectedIndex(0), [items]);
    const select = useCallback(
      (index) => {
        const item = items[index];
        if (item) command(item);
      },
      [items, command]
    );
    useImperativeHandle(ref, () => ({
      onKeyDown: /* @__PURE__ */ __name((event) => {
        if (event.key === "ArrowUp") {
          setSelectedIndex((i) => (i + items.length - 1) % items.length);
          return true;
        }
        if (event.key === "ArrowDown") {
          setSelectedIndex((i) => (i + 1) % items.length);
          return true;
        }
        if (event.key === "Enter") {
          select(selectedIndex);
          return true;
        }
        return false;
      }, "onKeyDown")
    }));
    if (items.length === 0) return null;
    return /* @__PURE__ */ jsx("div", { className: "markdown-mention-list", children: items.map((item, i) => {
      const isSelected = i === selectedIndex;
      const cls = `markdown-mention-item ${isSelected ? "selected" : ""}`;
      return /* @__PURE__ */ jsxs("button", { type: "button", className: cls, onClick: () => select(i), children: [
        item.thumbnail && /* @__PURE__ */ jsx("img", { src: item.thumbnail, alt: "", className: "markdown-mention-avatar" }),
        /* @__PURE__ */ jsxs("div", { className: "markdown-mention-info", children: [
          /* @__PURE__ */ jsx("span", { className: "markdown-mention-name", children: item.label }),
          item.description && /* @__PURE__ */ jsx("span", { className: "markdown-mention-desc", children: item.description })
        ] })
      ] }, item.id);
    }) });
  }
);
MentionList.displayName = "MentionList";

// src/tools/MarkdownEditor/createMentionSuggestion.ts
function createMentionSuggestion(config) {
  const { maxItems = 5, trigger = "@" } = config;
  return {
    char: trigger,
    items: /* @__PURE__ */ __name(({ query }) => {
      const q = query.toLowerCase();
      return config.items.filter((item) => item.label.toLowerCase().includes(q)).slice(0, maxItems);
    }, "items"),
    render: /* @__PURE__ */ __name(() => {
      let component = null;
      let popup = null;
      let cleanupAutoUpdate = null;
      let getReferenceRect = null;
      const buildVirtualElement = /* @__PURE__ */ __name(() => ({
        getBoundingClientRect: /* @__PURE__ */ __name(() => {
          const rect = getReferenceRect?.();
          return rect ?? new DOMRect(0, 0, 0, 0);
        }, "getBoundingClientRect")
      }), "buildVirtualElement");
      const updatePosition = /* @__PURE__ */ __name(() => {
        if (!popup) return;
        const virtualEl = buildVirtualElement();
        void computePosition(virtualEl, popup, {
          placement: "bottom-start",
          middleware: [
            offset(4),
            flip({ fallbackPlacements: ["top-start"] }),
            shift({ padding: 8 })
          ]
        }).then(({ x, y }) => {
          if (!popup) return;
          popup.style.transform = `translate3d(${Math.round(x)}px, ${Math.round(y)}px, 0)`;
        });
      }, "updatePosition");
      const teardown = /* @__PURE__ */ __name(() => {
        cleanupAutoUpdate?.();
        cleanupAutoUpdate = null;
        popup?.remove();
        popup = null;
        component?.destroy();
        component = null;
        getReferenceRect = null;
      }, "teardown");
      return {
        onStart: /* @__PURE__ */ __name((props) => {
          component = new ReactRenderer(MentionList, {
            props: {
              items: props.items,
              command: /* @__PURE__ */ __name((item) => {
                props.command({ id: item.id, label: item.label });
              }, "command")
            },
            editor: props.editor
          });
          popup = document.createElement("div");
          popup.style.cssText = "position: absolute; top: 0; left: 0; z-index: 99999;";
          popup.appendChild(component.element);
          document.body.appendChild(popup);
          getReferenceRect = /* @__PURE__ */ __name(() => props.clientRect?.() ?? null, "getReferenceRect");
          const virtualEl = buildVirtualElement();
          cleanupAutoUpdate = autoUpdate(virtualEl, popup, updatePosition);
        }, "onStart"),
        onUpdate: /* @__PURE__ */ __name((props) => {
          component?.updateProps({
            items: props.items,
            command: /* @__PURE__ */ __name((item) => {
              props.command({ id: item.id, label: item.label });
            }, "command")
          });
          getReferenceRect = /* @__PURE__ */ __name(() => props.clientRect?.() ?? null, "getReferenceRect");
          updatePosition();
        }, "onUpdate"),
        onKeyDown: /* @__PURE__ */ __name((props) => {
          if (props.event.key === "Escape") {
            teardown();
            return true;
          }
          return component?.ref?.onKeyDown(props.event) ?? false;
        }, "onKeyDown"),
        onExit: /* @__PURE__ */ __name(() => {
          teardown();
        }, "onExit")
      };
    }, "render")
  };
}
__name(createMentionSuggestion, "createMentionSuggestion");

// src/tools/MarkdownEditor/mentionPresets.ts
var escapeMd = /* @__PURE__ */ __name((s) => s.replace(/([\\\[\]()_*~`])/g, "\\$1"), "escapeMd");
var mentionPresets = {
  /** "@Label" — default, ideal for chat where LLMs read the text. */
  plainAt: /* @__PURE__ */ __name((({ label, id }) => `@${label || id}`), "plainAt"),
  /** "Label" — bare label, no @ prefix. */
  plainLabel: /* @__PURE__ */ __name((({ label, id }) => label || id), "plainLabel"),
  /** "[@Label](baseUrl/id)" — clickable markdown link. */
  markdownLink: /* @__PURE__ */ __name((baseUrl) => ({ label, id }) => `[@${escapeMd(label || id)}](${baseUrl}${encodeURIComponent(id)})`, "markdownLink"),
  /** "@[Label](scheme://kind/id)" — Notion / Linear-style custom URI. */
  customUri: /* @__PURE__ */ __name((scheme, kind) => ({ label, id }) => `@[${escapeMd(label || id)}](${scheme}://${kind}/${encodeURIComponent(id)})`, "customUri"),
  /** "<@id>" — Slack-style id-only reference (label dropped — receivers resolve it). */
  slackStyle: /* @__PURE__ */ __name((({ id }) => `<@${id}>`), "slackStyle"),
  /** Inline HTML span — for products that consume markdown with raw HTML allowed. */
  htmlSpan: /* @__PURE__ */ __name((className = "mention") => ({ label, id }) => `<span class="${className}" data-mention-id="${encodeURIComponent(id)}">@${escapeMd(label || id)}</span>`, "htmlSpan")
};
function getMarkdown(editor) {
  const storage = editor.storage.markdown;
  if (!storage?.manager) return editor.getText();
  return storage.manager.serialize(editor.getJSON());
}
__name(getMarkdown, "getMarkdown");
function extractMentionIds(editor) {
  const ids = [];
  editor.state.doc.descendants((node) => {
    if (node.type.name === "mention" && node.attrs.id) {
      ids.push(node.attrs.id);
    }
  });
  return [...new Set(ids)];
}
__name(extractMentionIds, "extractMentionIds");
function MarkdownEditor({
  value,
  onChange,
  placeholder = "Write markdown...",
  minHeight = 120,
  className = "",
  disabled = false,
  showToolbar = true,
  mentions,
  onMentionIdsChange
}) {
  const isExternalUpdate = useRef(false);
  const initialMentionsDefinedRef = useRef(mentions !== void 0);
  const warnedRef = useRef(false);
  if (process.env.NODE_ENV !== "production" && !initialMentionsDefinedRef.current && mentions !== void 0 && !warnedRef.current) {
    warnedRef.current = true;
    console.warn(
      "[MarkdownEditor] `mentions` flipped from undefined to a config after mount. Tiptap only installs the Mention extension on first render \u2014 the @-popover will NOT work for this editor instance. Pass `{ items: [] }` from the very first render and mutate `.items` in place instead."
    );
  }
  const extensions = useMemo(() => {
    const exts = [
      StarterKit.configure({ heading: { levels: [1, 2, 3] } }),
      Placeholder.configure({ placeholder }),
      Markdown
    ];
    if (mentions) {
      const renderMarkdown = mentions.renderMarkdown ?? mentionPresets.plainAt;
      exts.push(
        Mention.extend({
          renderMarkdown(node) {
            const raw = node.attrs;
            const attrs = {
              id: raw?.id ?? "",
              label: raw?.label ?? ""
            };
            if (!attrs.id && !attrs.label) return "";
            return renderMarkdown(attrs);
          }
        }).configure({
          HTMLAttributes: { class: "markdown-mention" },
          suggestion: createMentionSuggestion(mentions),
          renderText: /* @__PURE__ */ __name(({ node }) => `@${node.attrs.label}`, "renderText")
        })
      );
    }
    return exts;
  }, [placeholder, mentions]);
  const editor = useEditor$1({
    immediatelyRender: false,
    editable: !disabled,
    extensions,
    content: value,
    onUpdate: /* @__PURE__ */ __name(({ editor: editor2 }) => {
      if (isExternalUpdate.current) return;
      onChange(getMarkdown(editor2));
      if (onMentionIdsChange) {
        onMentionIdsChange(extractMentionIds(editor2));
      }
    }, "onUpdate"),
    editorProps: {
      attributes: {
        class: "markdown-editor-content focus:outline-none text-sm",
        style: `min-height: ${minHeight}px`
      }
    }
  });
  useEffect(() => {
    if (!editor) return;
    const current = getMarkdown(editor);
    if (current !== value) {
      isExternalUpdate.current = true;
      editor.commands.setContent(value);
      isExternalUpdate.current = false;
    }
  }, [value, editor]);
  const wrapperClass = `markdown-editor rounded-md border border-input bg-background ${disabled ? "opacity-60" : ""} ${className}`.trim();
  return /* @__PURE__ */ jsxs("div", { className: wrapperClass, children: [
    showToolbar && editor && /* @__PURE__ */ jsx(MarkdownToolbar, { editor }),
    /* @__PURE__ */ jsx("div", { className: "px-3 py-2", children: /* @__PURE__ */ jsx(EditorContent, { editor }) })
  ] });
}
__name(MarkdownEditor, "MarkdownEditor");
function MarkdownToolbar({ editor }) {
  const items = useMemo(() => [
    { icon: Bold, title: "Bold", action: /* @__PURE__ */ __name(() => editor.chain().focus().toggleBold().run(), "action"), active: editor.isActive("bold") },
    { icon: Italic, title: "Italic", action: /* @__PURE__ */ __name(() => editor.chain().focus().toggleItalic().run(), "action"), active: editor.isActive("italic") },
    { icon: Strikethrough, title: "Strike", action: /* @__PURE__ */ __name(() => editor.chain().focus().toggleStrike().run(), "action"), active: editor.isActive("strike") },
    { icon: Code, title: "Code", action: /* @__PURE__ */ __name(() => editor.chain().focus().toggleCode().run(), "action"), active: editor.isActive("code") },
    null,
    { icon: Heading1, title: "H1", action: /* @__PURE__ */ __name(() => editor.chain().focus().toggleHeading({ level: 1 }).run(), "action"), active: editor.isActive("heading", { level: 1 }) },
    { icon: Heading2, title: "H2", action: /* @__PURE__ */ __name(() => editor.chain().focus().toggleHeading({ level: 2 }).run(), "action"), active: editor.isActive("heading", { level: 2 }) },
    { icon: Heading3, title: "H3", action: /* @__PURE__ */ __name(() => editor.chain().focus().toggleHeading({ level: 3 }).run(), "action"), active: editor.isActive("heading", { level: 3 }) },
    null,
    { icon: List, title: "Bullet list", action: /* @__PURE__ */ __name(() => editor.chain().focus().toggleBulletList().run(), "action"), active: editor.isActive("bulletList") },
    { icon: ListOrdered, title: "Ordered list", action: /* @__PURE__ */ __name(() => editor.chain().focus().toggleOrderedList().run(), "action"), active: editor.isActive("orderedList") },
    { icon: Quote, title: "Quote", action: /* @__PURE__ */ __name(() => editor.chain().focus().toggleBlockquote().run(), "action"), active: editor.isActive("blockquote") },
    { icon: Minus, title: "Divider", action: /* @__PURE__ */ __name(() => editor.chain().focus().setHorizontalRule().run(), "action"), active: false }
  ], [editor]);
  return /* @__PURE__ */ jsx("div", { className: "flex items-center gap-0.5 px-2 py-1.5 border-b border-border", children: items.map((item, i) => {
    if (!item) return /* @__PURE__ */ jsx("div", { className: "w-px h-4 bg-border mx-1" }, i);
    const Icon = item.icon;
    const btnClass = `markdown-toolbar-btn ${item.active ? "active" : ""}`;
    return /* @__PURE__ */ jsx("button", { type: "button", onClick: item.action, title: item.title, className: btnClass, children: /* @__PURE__ */ jsx(Icon, { style: { width: 14, height: 14 } }) }, i);
  }) });
}
__name(MarkdownToolbar, "MarkdownToolbar");

export { CardLoadingFallback, CronScheduler, DiffEditor, Editor, EditorProvider, LazyPlayer as LazyAudioPlayer, LazyCronScheduler, LazyImageViewer, LazyJsonSchemaForm, LazyJsonTree, LazyLottiePlayer, LazyMapContainer, LazyMapView, LazyMermaid, LazyOpenapiViewer, LazyPrettyCode, LazyTree, LazyVideoPlayer, LazyWrapper, LoadingFallback, LottiePlayer, MapLoadingFallback, MarkdownEditor, OpenapiViewer_default as OpenapiViewer, Spinner, createLazyComponent, mentionPresets, useEditor, useEditorContext, useLanguage, useMonaco };
//# sourceMappingURL=index.mjs.map
//# sourceMappingURL=index.mjs.map