@noirmd/previewer 1.1.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/NReditor.cjs +950 -913
  2. package/dist/NReditor.cjs.map +1 -1
  3. package/dist/NReditor.d.cts +6 -1
  4. package/dist/NReditor.d.ts +6 -1
  5. package/dist/NReditor.js +951 -914
  6. package/dist/NReditor.js.map +1 -1
  7. package/dist/admonition.css +55 -0
  8. package/dist/{markdown.css → base.css} +96 -126
  9. package/dist/blockquote.css +16 -0
  10. package/dist/button.css +32 -0
  11. package/dist/card.css +143 -0
  12. package/dist/codeblock.css +59 -0
  13. package/dist/core.cjs +9 -1
  14. package/dist/core.cjs.map +1 -1
  15. package/dist/core.js +9 -1
  16. package/dist/core.js.map +1 -1
  17. package/dist/details.css +45 -0
  18. package/dist/editor.css +226 -0
  19. package/dist/fonts/material-icons-round.woff2 +0 -0
  20. package/dist/index.cjs +852 -883
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +41 -70
  23. package/dist/index.d.ts +41 -70
  24. package/dist/index.js +851 -877
  25. package/dist/index.js.map +1 -1
  26. package/dist/list.css +18 -0
  27. package/dist/modal.css +82 -0
  28. package/dist/react.cjs +852 -886
  29. package/dist/react.cjs.map +1 -1
  30. package/dist/react.d.cts +44 -73
  31. package/dist/react.d.ts +44 -73
  32. package/dist/react.js +851 -880
  33. package/dist/react.js.map +1 -1
  34. package/dist/slide.css +21 -0
  35. package/dist/table.css +36 -0
  36. package/dist/toc.css +45 -0
  37. package/dist/vanilla.cjs +42 -28
  38. package/dist/vanilla.cjs.map +1 -1
  39. package/dist/vanilla.css +32 -677
  40. package/dist/vanilla.d.cts +8 -2
  41. package/dist/vanilla.d.ts +8 -2
  42. package/dist/vanilla.js +41 -28
  43. package/dist/vanilla.js.map +1 -1
  44. package/dist/variables.css +53 -0
  45. package/dist/vue.cjs +931 -1121
  46. package/dist/vue.cjs.map +1 -1
  47. package/dist/vue.d.cts +63 -214
  48. package/dist/vue.d.ts +63 -214
  49. package/dist/vue.js +930 -1120
  50. package/dist/vue.js.map +1 -1
  51. package/editor.css +226 -0
  52. package/package.json +6 -9
  53. package/markdown.css +0 -344
package/dist/NReditor.cjs CHANGED
@@ -33,7 +33,7 @@ __export(NReditor_exports, {
33
33
  default: () => NReditor_default
34
34
  });
35
35
  module.exports = __toCommonJS(NReditor_exports);
36
- var import_react11 = __toESM(require("react"), 1);
36
+ var import_react4 = __toESM(require("react"), 1);
37
37
  var import_react_codemirror = __toESM(require("@uiw/react-codemirror"), 1);
38
38
  var import_view = require("@codemirror/view");
39
39
 
@@ -347,8 +347,64 @@ function useDebounce(value, delay) {
347
347
  return debouncedValue;
348
348
  }
349
349
 
350
+ // react/useTailwindCDN.ts
351
+ var import_react2 = require("react");
352
+ var CDN_URL = "https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4";
353
+ var SCRIPT_ID = "tailwind-cdn-v4-runtime";
354
+ var CONFIG_ID = "tailwind-cdn-v4-config";
355
+ var TAILWIND_CDN_CONFIG = `
356
+ window.tailwind = window.tailwind || {};
357
+ window.tailwind.config = {
358
+ corePlugins: {
359
+ preflight: false,
360
+ },
361
+ };
362
+ `;
363
+ function useLazyTailwindCDN(enabled) {
364
+ const loadedRef = (0, import_react2.useRef)(false);
365
+ (0, import_react2.useEffect)(() => {
366
+ if (!enabled) {
367
+ window.__twCDNRefs = (window.__twCDNRefs ?? 1) - 1;
368
+ if ((window.__twCDNRefs ?? 0) <= 0) {
369
+ document.getElementById(SCRIPT_ID)?.remove();
370
+ document.getElementById(CONFIG_ID)?.remove();
371
+ window.__twCDNRefs = 0;
372
+ loadedRef.current = false;
373
+ }
374
+ return;
375
+ }
376
+ window.__twCDNRefs = (window.__twCDNRefs ?? 0) + 1;
377
+ if (!document.getElementById(CONFIG_ID)) {
378
+ const configScript = document.createElement("script");
379
+ configScript.id = CONFIG_ID;
380
+ configScript.textContent = TAILWIND_CDN_CONFIG;
381
+ document.head.appendChild(configScript);
382
+ }
383
+ if (!document.getElementById(SCRIPT_ID)) {
384
+ const script = document.createElement("script");
385
+ script.id = SCRIPT_ID;
386
+ script.src = CDN_URL;
387
+ document.head.appendChild(script);
388
+ loadedRef.current = true;
389
+ }
390
+ return () => {
391
+ window.__twCDNRefs = (window.__twCDNRefs ?? 1) - 1;
392
+ if ((window.__twCDNRefs ?? 0) <= 0) {
393
+ document.getElementById(SCRIPT_ID)?.remove();
394
+ document.getElementById(CONFIG_ID)?.remove();
395
+ window.__twCDNRefs = 0;
396
+ loadedRef.current = false;
397
+ }
398
+ };
399
+ }, [enabled]);
400
+ }
401
+ function scanTailwindCDN() {
402
+ const tw = window.tailwind;
403
+ if (tw?.scan) tw.scan();
404
+ }
405
+
350
406
  // react/CustomMarkdownRenderer.tsx
351
- var import_react10 = __toESM(require("react"), 1);
407
+ var import_react3 = require("react");
352
408
 
353
409
  // core/utils.ts
354
410
  function parseCssString(cssText) {
@@ -394,9 +450,6 @@ function extractAttributes(text) {
394
450
  return { text: cleanedText, classes: classList.join(" "), id };
395
451
  }
396
452
  var _scopeCounter = 0;
397
- function resetScopeCounter() {
398
- _scopeCounter = 0;
399
- }
400
453
  function generateScopeId() {
401
454
  return `scope-${++_scopeCounter}`;
402
455
  }
@@ -444,6 +497,7 @@ function parseMarkdown(markdown2) {
444
497
  if (!markdown2) return [];
445
498
  const lines = markdown2.replace(/\r\n/g, "\n").replace(/\r/g, "").split("\n");
446
499
  const result = [];
500
+ const usedIds = /* @__PURE__ */ new Set();
447
501
  let i = 0;
448
502
  while (i < lines.length) {
449
503
  const line = lines[i];
@@ -453,7 +507,14 @@ function parseMarkdown(markdown2) {
453
507
  const level = match[1].length;
454
508
  const rawText = match[2];
455
509
  const { text: text2, classes: classes2, id: customId } = extractAttributes(rawText);
456
- const id2 = customId || generateId(text2.replace(/->|<-/g, ""));
510
+ const baseId = customId || generateId(text2.replace(/->|<-/g, ""));
511
+ let id2 = baseId;
512
+ let n = 1;
513
+ while (usedIds.has(id2)) {
514
+ n++;
515
+ id2 = `${baseId}-${n}`;
516
+ }
517
+ usedIds.add(id2);
457
518
  result.push({ type: "header", level, text: text2, id: id2, classes: classes2 || void 0 });
458
519
  i++;
459
520
  continue;
@@ -768,10 +829,7 @@ function splitSlots(rawContent) {
768
829
  return slots;
769
830
  }
770
831
 
771
- // react/ui-components.tsx
772
- var import_react2 = require("react");
773
-
774
- // react/highlightSetup.ts
832
+ // vanilla/highlightSetup.ts
775
833
  var import_core = __toESM(require("highlight.js/lib/core"), 1);
776
834
  var import_javascript = __toESM(require("highlight.js/lib/languages/javascript"), 1);
777
835
  var import_typescript = __toESM(require("highlight.js/lib/languages/typescript"), 1);
@@ -820,1000 +878,947 @@ import_core.default.registerLanguage("java", import_java.default);
820
878
  import_core.default.registerLanguage("csharp", import_csharp.default);
821
879
  import_core.default.registerLanguage("cs", import_csharp.default);
822
880
  import_core.default.registerLanguage("cpp", import_cpp.default);
823
- import_core.default.registerLanguage("c", import_cpp.default);
824
881
  import_core.default.registerLanguage("go", import_go.default);
825
882
  import_core.default.registerLanguage("rust", import_rust.default);
826
- import_core.default.registerLanguage("rs", import_rust.default);
827
883
  import_core.default.registerLanguage("php", import_php.default);
828
884
  import_core.default.registerLanguage("ruby", import_ruby.default);
829
- import_core.default.registerLanguage("rb", import_ruby.default);
830
885
  import_core.default.registerLanguage("swift", import_swift.default);
831
886
  import_core.default.registerLanguage("kotlin", import_kotlin.default);
832
- import_core.default.registerLanguage("kt", import_kotlin.default);
833
887
  import_core.default.registerLanguage("dart", import_dart.default);
834
888
  import_core.default.registerLanguage("yaml", import_yaml.default);
835
- import_core.default.registerLanguage("yml", import_yaml.default);
836
889
  import_core.default.registerLanguage("toml", import_ini.default);
837
- import_core.default.registerLanguage("ini", import_ini.default);
838
890
  import_core.default.registerLanguage("dockerfile", import_dockerfile.default);
839
- import_core.default.registerLanguage("docker", import_dockerfile.default);
840
891
  import_core.default.registerLanguage("diff", import_diff.default);
841
892
  import_core.default.registerLanguage("shell", import_shell.default);
842
893
  var highlightSetup_default = import_core.default;
843
894
 
844
- // react/ui-components.tsx
845
- var import_dialog = require("@base-ui/react/dialog");
846
- var import_jsx_runtime = require("react/jsx-runtime");
847
- var IconRenderer = ({ iconName, extraClasses = "" }) => {
848
- if (!iconName) return null;
849
- const baseClass = `material-symbols-rounded !text-[1em] leading-none align-top ${extraClasses}`;
895
+ // vanilla/components.ts
896
+ function createIcon(iconName, extraClasses) {
897
+ const span = document.createElement("span");
898
+ const cls = `nr-icon material-icons-round${extraClasses ? ` ${extraClasses}` : ""}`;
899
+ span.className = cls;
900
+ span.setAttribute("aria-hidden", "true");
850
901
  const isCodepoint = /^[eE][0-9a-fA-F]{3,4}$/.test(iconName);
851
902
  if (isCodepoint) {
852
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
853
- "span",
854
- {
855
- className: baseClass,
856
- dangerouslySetInnerHTML: { __html: `&#x${iconName};` },
857
- "aria-hidden": "true"
858
- }
859
- );
903
+ span.innerHTML = `&#x${iconName};`;
904
+ } else {
905
+ span.textContent = iconName;
860
906
  }
861
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: baseClass, "aria-hidden": "true", children: iconName });
862
- };
863
- var CodeBlock = ({ code, language, title }) => {
864
- const [copied, setCopied] = (0, import_react2.useState)(false);
865
- const timerRef = (0, import_react2.useRef)(null);
907
+ return span;
908
+ }
909
+ function createCodeBlock(code, language, title) {
910
+ const wrapper = document.createElement("div");
911
+ wrapper.className = "nr-codeblock";
866
912
  const lang = language?.split(/[\s{]/)[0]?.trim() || "";
867
- let html;
913
+ if (title) {
914
+ const header = document.createElement("div");
915
+ header.className = "nr-codeblock__header";
916
+ header.appendChild(createIcon("description"));
917
+ const titleSpan = document.createElement("span");
918
+ titleSpan.textContent = title;
919
+ header.appendChild(titleSpan);
920
+ wrapper.appendChild(header);
921
+ }
922
+ const pre = document.createElement("pre");
923
+ pre.className = "nr-codeblock__pre";
924
+ const codeEl = document.createElement("code");
925
+ codeEl.className = `language-${lang || "plaintext"}`;
868
926
  try {
869
927
  if (lang && highlightSetup_default.getLanguage(lang)) {
870
- html = highlightSetup_default.highlight(code, { language: lang }).value;
928
+ codeEl.innerHTML = highlightSetup_default.highlight(code, { language: lang }).value;
871
929
  } else {
872
- html = highlightSetup_default.highlightAuto(code).value;
930
+ codeEl.innerHTML = highlightSetup_default.highlightAuto(code).value;
873
931
  }
874
932
  } catch {
875
- html = "";
933
+ codeEl.textContent = code;
876
934
  }
877
- const handleCopy = () => {
935
+ pre.appendChild(codeEl);
936
+ wrapper.appendChild(pre);
937
+ const copyBtn = document.createElement("button");
938
+ copyBtn.className = "nr-codeblock__copy";
939
+ copyBtn.title = "Copy code";
940
+ const copyIcon = createIcon("content_copy");
941
+ copyIcon.style.fontSize = "1rem";
942
+ copyBtn.appendChild(copyIcon);
943
+ let timer = null;
944
+ copyBtn.addEventListener("click", () => {
878
945
  navigator.clipboard.writeText(code);
879
- setCopied(true);
880
- if (timerRef.current) clearTimeout(timerRef.current);
881
- timerRef.current = setTimeout(() => setCopied(false), 1800);
882
- };
883
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "not-prose my-4 rounded-2xl border border-border overflow-hidden bg-background-secondary-solid/5", children: [
884
- title && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2 px-4 py-2 border-b border-border bg-background-secondary-solid/10 text-xs sm:text-sm font-mono text-text-secondary", children: [
885
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "material-symbols-rounded text-base", children: "description" }),
886
- title
887
- ] }),
888
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "overflow-auto [&_pre]:m-0 [&_pre]:p-4 [&_pre]:text-xs sm:[&_pre]:text-sm", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "m-0", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { className: `language-${lang || "plaintext"}`, dangerouslySetInnerHTML: { __html: html } }) }) }),
889
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "absolute top-2 right-2 p-1.5 rounded-lg bg-background-secondary-solid/20 hover:bg-background-secondary-solid/40 transition-colors cursor-pointer border-none text-text-secondary hover:text-text-primary", onClick: handleCopy, title: "Copy code", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "material-symbols-rounded", style: { fontSize: "1rem" }, children: copied ? "check" : "content_copy" }) })
890
- ] });
891
- };
892
- var defaultIcons = {
946
+ copyIcon.textContent = "check";
947
+ if (timer) clearTimeout(timer);
948
+ timer = setTimeout(() => {
949
+ copyIcon.textContent = "content_copy";
950
+ }, 1800);
951
+ });
952
+ wrapper.appendChild(copyBtn);
953
+ return wrapper;
954
+ }
955
+ var DEFAULT_ADMONITION_ICONS = {
893
956
  note: "info",
894
957
  info: "lightbulb",
895
958
  warning: "warning",
896
959
  danger: "report",
897
- greentext: "subdirectory_play_arrow"
898
- };
899
- var typeClasses = {
900
- note: "border-info/20 bg-info/5 text-info",
901
- info: "border-info/30 bg-info/10 text-info",
902
- warning: "border-amber-500/30 bg-amber-500/10 text-amber-500",
903
- danger: "border-danger/30 bg-danger/10 text-danger",
904
- greentext: "border-success/30 bg-success/10 text-success"
905
- };
906
- var Admonition = ({ type, title, icon, className = "", style, children }) => {
907
- const iconToRender = icon || defaultIcons[type] || "info";
908
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
909
- "div",
910
- {
911
- className: `not-prose rounded-2xl mb-6 border shadow-xs p-4 ${typeClasses[type] || typeClasses.note} ${className}`,
912
- style,
913
- children: [
914
- title && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h5", { className: "font-bold text-base mb-2 m-0 flex items-center gap-2", children: [
915
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconRenderer, { iconName: iconToRender, extraClasses: "shrink-0" }),
916
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: title })
917
- ] }),
918
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-sm leading-relaxed opacity-90", children })
919
- ]
920
- }
921
- );
922
- };
923
- var Details = ({
924
- title,
925
- icon,
926
- defaultOpen = false,
927
- className = "",
928
- style,
929
- children
930
- }) => {
931
- const [isOpen, setIsOpen] = (0, import_react2.useState)(defaultOpen);
932
- const iconToRender = icon || "play_arrow";
933
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
934
- "details",
935
- {
936
- className: `not-prose rounded-2xl border border-border mb-4 bg-background-primary/5 ${className}`,
937
- open: isOpen,
938
- style,
939
- children: [
940
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
941
- "summary",
942
- {
943
- className: "cursor-pointer p-4 font-bold flex items-center gap-2 list-none [&::-webkit-details-marker]:hidden hover:text-accent-primary transition-colors",
944
- onClick: (e) => {
945
- e.preventDefault();
946
- setIsOpen((prev) => !prev);
947
- },
948
- children: [
949
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
950
- IconRenderer,
951
- {
952
- iconName: iconToRender,
953
- extraClasses: `transition-transform ${isOpen ? "rotate-90" : ""}`
954
- }
955
- ),
956
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: title })
957
- ]
958
- }
959
- ),
960
- isOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "px-4 pb-4 border-t border-border pt-3 text-sm leading-relaxed opacity-90 overflow-hidden min-w-0", children })
961
- ]
962
- }
963
- );
960
+ greentext: "subdirectory_arrow_right"
964
961
  };
965
- var Modal = ({ title, isOpen, onClose, children }) => {
966
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog.Root, { open: isOpen, onOpenChange: (open) => {
967
- if (!open) onClose();
968
- }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dialog.Dialog.Portal, { children: [
969
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog.Backdrop, { className: "fixed inset-0 z-[9999] bg-black/60" }),
970
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog.Viewport, { className: "fixed inset-0 z-[9999] flex items-center justify-center p-4", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dialog.Dialog.Popup, { className: "bg-background-primary border border-border shadow-2xl rounded-3xl w-full max-w-3xl max-h-[85vh] flex flex-col overflow-hidden", children: [
971
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex justify-between items-center p-4 border-b border-border bg-background-secondary-solid/20", children: [
972
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog.Title, { className: "text-lg font-bold !m-0", children: title }),
973
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog.Close, { className: "w-8 h-8 rounded-full hover:bg-white/10 flex items-center justify-center transition-colors cursor-pointer border-none bg-transparent", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "material-symbols-rounded text-base", children: "close" }) })
974
- ] }),
975
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "p-6 overflow-auto min-h-0 text-text-primary [&_h1:first-child]:mt-0 [&_h2:first-child]:mt-0 [&_h3:first-child]:mt-0 [&_h4:first-child]:mt-0 [&_h5:first-child]:mt-0 [&_h6:first-child]:mt-0", children })
976
- ] }) })
977
- ] }) });
978
- };
979
-
980
- // react/renderers.tsx
981
- var import_jsx_runtime2 = require("react/jsx-runtime");
982
- function renderInline(text) {
983
- if (!text) return text;
984
- const parsePart = (part, key) => {
985
- let match2;
986
- if (match2 = part.match(/^\|\[([^\]]+)\]\|$/)) {
987
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IconRenderer, { iconName: match2[1] }, key);
988
- }
989
- if (match2 = part.match(/^!~(.+?)~!$/)) {
990
- const content = match2[1];
991
- const parts = content.split(";");
992
- let color = "currentColor";
993
- let decorationStyle = "solid";
994
- let type = "underline";
995
- let textIndex = 0;
996
- if (parts[textIndex]?.match(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/) || ["red", "blue", "green", "purple", "orange", "yellow", "pink"].includes(parts[textIndex])) {
997
- color = parts[textIndex++];
998
- }
999
- if (["solid", "double", "dotted", "dashed", "wavy"].includes(parts[textIndex])) {
1000
- decorationStyle = parts[textIndex++];
1001
- }
1002
- if (["underline", "line-through", "overline", "both"].includes(parts[textIndex])) {
1003
- type = parts[textIndex] === "both" ? "underline line-through" : parts[textIndex++];
1004
- }
1005
- const innerText = parts.slice(textIndex).join(";");
1006
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1007
- "span",
1008
- {
1009
- style: {
1010
- textDecoration: `${type} ${decorationStyle} ${color}`,
1011
- textDecorationThickness: "auto"
1012
- },
1013
- children: renderInline(innerText)
1014
- },
1015
- key
1016
- );
1017
- }
1018
- if (match2 = part.match(/%([^%\s]+?)%([\s\S]+?)%%/)) {
1019
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { color: match2[1] }, children: renderInline(match2[2]) }, key);
1020
- }
1021
- if (match2 = part.match(/^!>([^<]+?)<!$/)) {
1022
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "bg-text-primary text-bg-primary px-1 rounded hover:bg-transparent transition-colors cursor-pointer", children: renderInline(match2[1]) }, key);
1023
- }
1024
- if (match2 = part.match(/^==(.+?)==$/)) {
1025
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("mark", { className: "bg-yellow-500/20 text-inherit px-0.5 rounded", children: renderInline(match2[1]) }, key);
1026
- }
1027
- if (match2 = part.match(/^\*\*\*(.+?)\*\*\*$/)) {
1028
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("em", { children: renderInline(match2[1]) }) }, key);
1029
- }
1030
- if (match2 = part.match(/^\*\*(.+?)\*\*$/)) {
1031
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: renderInline(match2[1]) }, key);
1032
- }
1033
- if (match2 = part.match(/^_(.+?)_$/)) {
1034
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("em", { children: renderInline(match2[1]) }, key);
1035
- }
1036
- if (match2 = part.match(/^~~(.+?)~~$/)) {
1037
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("del", { children: renderInline(match2[1]) }, key);
1038
- }
1039
- if (match2 = part.match(/^`([^`]+)`$/)) {
1040
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("code", { className: "text-[0.875em] font-mono bg-background-secondary/50 px-1.5 py-0.5 rounded text-text-primary", children: match2[1] }, key);
1041
- }
1042
- if (match2 = part.match(/^\[([^\]]+?)\]\(([^)]+?)\)$/)) {
1043
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1044
- "a",
1045
- {
1046
- href: match2[2],
1047
- className: "text-accent-primary underline decoration-accent-primary/40 hover:decoration-accent-primary transition-colors",
1048
- target: "_blank",
1049
- rel: "noopener noreferrer",
1050
- children: renderInline(match2[1])
1051
- },
1052
- key
1053
- );
1054
- }
1055
- if (part.startsWith("<") && part.endsWith(">")) {
1056
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { dangerouslySetInnerHTML: { __html: part } }, key);
1057
- }
1058
- return part;
1059
- };
1060
- const regex = /(\|\[[^\]]+\]\||\*\*\*.+?\*\*\*|\*\*.+?\*\*|_.+?_|~~.+?~~|`[^`]+?`|!~.+?~!|%[^%\s]+?%[\s\S]+?%%|!>.+?<!|==.+?==|\[[^\]]+?\]\([^)]+?\)|<[^>]+>)/g;
1061
- const elements = [];
1062
- let lastIndex = 0;
1063
- let match;
1064
- let keyCounter = 0;
1065
- while ((match = regex.exec(text)) !== null) {
1066
- if (match.index > lastIndex) {
1067
- elements.push(text.slice(lastIndex, match.index));
1068
- }
1069
- elements.push(parsePart(match[0], `inline-${keyCounter++}`));
1070
- lastIndex = regex.lastIndex;
1071
- }
1072
- if (lastIndex < text.length) {
1073
- elements.push(text.slice(lastIndex));
962
+ function createAdmonition(type, title, icon) {
963
+ const el = document.createElement("div");
964
+ el.className = `nr-admonition nr-admonition--${type || "note"}`;
965
+ if (title) {
966
+ const header = document.createElement("h5");
967
+ header.className = "nr-admonition__title";
968
+ const iconToRender = icon || DEFAULT_ADMONITION_ICONS[type] || "info";
969
+ header.appendChild(createIcon(iconToRender, "nr-admonition__icon"));
970
+ const titleSpan = document.createElement("span");
971
+ titleSpan.textContent = title;
972
+ header.appendChild(titleSpan);
973
+ el.appendChild(header);
1074
974
  }
1075
- return elements;
975
+ const body = document.createElement("div");
976
+ body.className = "nr-admonition__body";
977
+ el.appendChild(body);
978
+ return el;
1076
979
  }
1077
- function renderTable(content) {
980
+ function createDetails(title, icon, defaultOpen) {
981
+ const details = document.createElement("details");
982
+ details.className = "nr-details";
983
+ if (defaultOpen) details.open = true;
984
+ const summary = document.createElement("summary");
985
+ summary.className = "nr-details__summary";
986
+ const iconToRender = icon || "play_arrow";
987
+ const iconEl = createIcon(iconToRender, "nr-details__icon");
988
+ summary.appendChild(iconEl);
989
+ const titleSpan = document.createElement("span");
990
+ titleSpan.textContent = title || "Details";
991
+ summary.appendChild(titleSpan);
992
+ details.addEventListener("toggle", () => {
993
+ iconEl.classList.toggle("nr-details__icon--open", details.open);
994
+ });
995
+ details.appendChild(summary);
996
+ const body = document.createElement("div");
997
+ body.className = "nr-details__body";
998
+ details.appendChild(body);
999
+ return details;
1000
+ }
1001
+ function createModal(title) {
1002
+ const dialog = document.createElement("dialog");
1003
+ dialog.className = "nr-modal";
1004
+ dialog.addEventListener("click", (e) => {
1005
+ if (e.target === dialog) {
1006
+ dialog.close();
1007
+ }
1008
+ });
1009
+ const popup = document.createElement("div");
1010
+ popup.className = "nr-modal__popup";
1011
+ const header = document.createElement("div");
1012
+ header.className = "nr-modal__header";
1013
+ const titleEl = document.createElement("h2");
1014
+ titleEl.className = "nr-modal__title";
1015
+ titleEl.textContent = title;
1016
+ header.appendChild(titleEl);
1017
+ const closeBtn = document.createElement("button");
1018
+ closeBtn.className = "nr-modal__close";
1019
+ closeBtn.appendChild(createIcon("close"));
1020
+ closeBtn.addEventListener("click", () => dialog.close());
1021
+ header.appendChild(closeBtn);
1022
+ popup.appendChild(header);
1023
+ const body = document.createElement("div");
1024
+ body.className = "nr-modal__body";
1025
+ popup.appendChild(body);
1026
+ dialog.appendChild(popup);
1027
+ return dialog;
1028
+ }
1029
+ function createTable(content, renderInline2) {
1078
1030
  const rows = content.split("\n").filter((r) => r.trim());
1079
- if (rows.length < 2) return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: content });
1031
+ if (rows.length < 2) {
1032
+ const p = document.createElement("p");
1033
+ p.textContent = content;
1034
+ return p;
1035
+ }
1080
1036
  const parseRow = (row) => row.split("|").map((c) => c.trim()).filter(Boolean);
1081
1037
  const headerCells = parseRow(rows[0]);
1082
1038
  const bodyRows = rows.slice(2).map(parseRow);
1083
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("table", { className: "w-full text-sm sm:text-base border-collapse my-4", children: [
1084
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tr", { children: headerCells.map((cell, ci) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("th", { className: "border border-border px-3 py-2 bg-background-secondary-solid/10 text-left font-bold", children: renderInline(cell) }, ci)) }) }),
1085
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tbody", { children: bodyRows.map((cells, ri) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tr", { children: cells.map((cell, ci) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { className: "border border-border px-3 py-2", children: renderInline(cell) }, ci)) }, ri)) })
1086
- ] }) });
1039
+ const wrapper = document.createElement("div");
1040
+ wrapper.className = "nr-table-wrap";
1041
+ const table = document.createElement("table");
1042
+ table.className = "nr-table";
1043
+ const thead = document.createElement("thead");
1044
+ const tr = document.createElement("tr");
1045
+ for (const cell of headerCells) {
1046
+ const th = document.createElement("th");
1047
+ th.className = "nr-table__th";
1048
+ th.appendChild(renderInline2(cell));
1049
+ tr.appendChild(th);
1050
+ }
1051
+ thead.appendChild(tr);
1052
+ table.appendChild(thead);
1053
+ const tbody = document.createElement("tbody");
1054
+ for (const cells of bodyRows) {
1055
+ const tr2 = document.createElement("tr");
1056
+ for (const cell of cells) {
1057
+ const td = document.createElement("td");
1058
+ td.className = "nr-table__td";
1059
+ td.appendChild(renderInline2(cell));
1060
+ tr2.appendChild(td);
1061
+ }
1062
+ tbody.appendChild(tr2);
1063
+ }
1064
+ table.appendChild(tbody);
1065
+ wrapper.appendChild(table);
1066
+ return wrapper;
1087
1067
  }
1088
- function renderList(content) {
1068
+ function createList(content, renderInline2) {
1089
1069
  const lines = content.split("\n");
1090
1070
  const items = [];
1091
1071
  for (const line of lines) {
1092
1072
  if (!line.trim()) continue;
1093
1073
  const match = line.match(/^(\s*)([-*+]|\d+\.)\s+(.+)$/);
1094
1074
  if (match) {
1095
- items.push({
1096
- indent: match[1].length,
1097
- marker: match[2],
1098
- text: match[3]
1099
- });
1075
+ items.push({ indent: match[1].length, marker: match[2], text: match[3] });
1100
1076
  }
1101
1077
  }
1102
- if (items.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: content });
1078
+ if (items.length === 0) {
1079
+ const p = document.createElement("p");
1080
+ p.textContent = content;
1081
+ return p;
1082
+ }
1103
1083
  const isOrdered = /^\d+\.$/.test(items[0].marker);
1104
- const Tag = isOrdered ? "ol" : "ul";
1105
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Tag, { className: `${isOrdered ? "list-decimal" : "list-disc"} pl-6 my-3 space-y-1 text-sm sm:text-base`, children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { className: "leading-relaxed", children: renderInline(item.text) }, index)) });
1084
+ const list = document.createElement(isOrdered ? "ol" : "ul");
1085
+ list.className = "nr-list";
1086
+ for (const item of items) {
1087
+ const li = document.createElement("li");
1088
+ li.className = "nr-list__item";
1089
+ li.appendChild(renderInline2(item.text));
1090
+ list.appendChild(li);
1091
+ }
1092
+ return list;
1093
+ }
1094
+ function createTOC(headers, renderInline2) {
1095
+ const nav = document.createElement("nav");
1096
+ nav.className = "nr-toc";
1097
+ const title = document.createElement("div");
1098
+ title.className = "nr-toc__title";
1099
+ title.textContent = "Table of Contents";
1100
+ nav.appendChild(title);
1101
+ const ul = document.createElement("ul");
1102
+ ul.className = "nr-toc__list";
1103
+ for (const h of headers) {
1104
+ const li = document.createElement("li");
1105
+ li.className = `nr-toc__item nr-toc__item--h${h.level}`;
1106
+ const a = document.createElement("a");
1107
+ a.className = "nr-toc__link";
1108
+ a.href = `#${h.id}`;
1109
+ a.appendChild(renderInline2(h.text.replace(/->|<-/g, "").trim()));
1110
+ a.addEventListener("click", (e) => {
1111
+ e.preventDefault();
1112
+ const target = document.getElementById(h.id);
1113
+ if (target) target.scrollIntoView({ behavior: "smooth", block: "start" });
1114
+ });
1115
+ li.appendChild(a);
1116
+ ul.appendChild(li);
1117
+ }
1118
+ nav.appendChild(ul);
1119
+ return nav;
1106
1120
  }
1107
- function extractHeaders(elements) {
1108
- return elements.filter((el) => el.type === "header");
1121
+ function createBlockquote(content, classes, renderInline2) {
1122
+ const el = document.createElement("blockquote");
1123
+ el.className = `nr-blockquote${classes ? ` ${classes}` : ""}`;
1124
+ el.appendChild(renderInline2(content));
1125
+ return el;
1109
1126
  }
1110
1127
 
1111
- // react/directives/AdmonitionDirective.tsx
1112
- var import_jsx_runtime3 = require("react/jsx-runtime");
1113
- var AdmonitionDirective = ({
1114
- directiveType,
1115
- props,
1116
- renderSlot
1117
- }) => {
1118
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1119
- Admonition,
1120
- {
1121
- type: directiveType,
1122
- title: props.title,
1123
- icon: props.icon,
1124
- className: props.class,
1125
- style: props.style ? parseCssString(props.style) : void 0,
1126
- children: renderSlot("default")
1128
+ // vanilla/inline.ts
1129
+ function renderInline(text) {
1130
+ const fragment = document.createDocumentFragment();
1131
+ if (!text) return fragment;
1132
+ const regex = /(\|\[[^\]]+\]\||\*\*\*.+?\*\*\*|\*\*.+?\*\*|_.+?_|~~.+?~~|`[^`]+?`|!~.+?~!|%[^%\s]+?%[\s\S]+?%%|!>.+?<!|==.+?==|\[[^\]]+?\]\([^)]+?\)|<[^>]+>)/g;
1133
+ let lastIndex = 0;
1134
+ let match;
1135
+ while ((match = regex.exec(text)) !== null) {
1136
+ if (match.index > lastIndex) {
1137
+ fragment.appendChild(document.createTextNode(text.slice(lastIndex, match.index)));
1127
1138
  }
1128
- );
1129
- };
1130
- var AdmonitionDirective_default = AdmonitionDirective;
1139
+ fragment.appendChild(parseInlinePart(match[0]));
1140
+ lastIndex = regex.lastIndex;
1141
+ }
1142
+ if (lastIndex < text.length) {
1143
+ fragment.appendChild(document.createTextNode(text.slice(lastIndex)));
1144
+ }
1145
+ return fragment;
1146
+ }
1147
+ function parseInlinePart(part) {
1148
+ let match;
1149
+ if (match = part.match(/^\|\[([^\]]+)\]\|$/)) {
1150
+ return createIcon(match[1]);
1151
+ }
1152
+ if (match = part.match(/^!~(.+?)~!$/)) {
1153
+ const content = match[1];
1154
+ const parts = content.split(";");
1155
+ let color = "currentColor";
1156
+ let decorationStyle = "solid";
1157
+ let type = "underline";
1158
+ let textIndex = 0;
1159
+ if (parts[textIndex]?.match(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/) || ["red", "blue", "green", "purple", "orange", "yellow", "pink"].includes(parts[textIndex])) {
1160
+ color = parts[textIndex++];
1161
+ }
1162
+ if (["solid", "double", "dotted", "dashed", "wavy"].includes(parts[textIndex])) {
1163
+ decorationStyle = parts[textIndex++];
1164
+ }
1165
+ if (["underline", "line-through", "overline", "both"].includes(parts[textIndex])) {
1166
+ type = parts[textIndex] === "both" ? "underline line-through" : parts[textIndex++];
1167
+ }
1168
+ const innerText = parts.slice(textIndex).join(";");
1169
+ const span = document.createElement("span");
1170
+ span.className = "nr-underline";
1171
+ span.style.textDecoration = `${type} ${decorationStyle} ${color}`;
1172
+ span.style.textDecorationThickness = "auto";
1173
+ span.appendChild(renderInline(innerText));
1174
+ return span;
1175
+ }
1176
+ if (match = part.match(/%([^%\s]+?)%([\s\S]+?)%%/)) {
1177
+ const span = document.createElement("span");
1178
+ span.style.color = match[1];
1179
+ span.appendChild(renderInline(match[2]));
1180
+ return span;
1181
+ }
1182
+ if (match = part.match(/^!>([^<]+?)<!$/)) {
1183
+ const span = document.createElement("span");
1184
+ span.className = "nr-spoiler";
1185
+ span.appendChild(renderInline(match[1]));
1186
+ return span;
1187
+ }
1188
+ if (match = part.match(/^==(.+?)==$/)) {
1189
+ const mark = document.createElement("mark");
1190
+ mark.className = "nr-highlight";
1191
+ mark.appendChild(renderInline(match[1]));
1192
+ return mark;
1193
+ }
1194
+ if (match = part.match(/^\*\*\*(.+?)\*\*\*$/)) {
1195
+ const strong = document.createElement("strong");
1196
+ const em = document.createElement("em");
1197
+ em.appendChild(renderInline(match[1]));
1198
+ strong.appendChild(em);
1199
+ return strong;
1200
+ }
1201
+ if (match = part.match(/^\*\*(.+?)\*\*$/)) {
1202
+ const strong = document.createElement("strong");
1203
+ strong.appendChild(renderInline(match[1]));
1204
+ return strong;
1205
+ }
1206
+ if (match = part.match(/^_(.+?)_$/)) {
1207
+ const em = document.createElement("em");
1208
+ em.appendChild(renderInline(match[1]));
1209
+ return em;
1210
+ }
1211
+ if (match = part.match(/^~~(.+?)~~$/)) {
1212
+ const del = document.createElement("del");
1213
+ del.appendChild(renderInline(match[1]));
1214
+ return del;
1215
+ }
1216
+ if (match = part.match(/^`([^`]+)`$/)) {
1217
+ const code = document.createElement("code");
1218
+ code.className = "nr-inline-code";
1219
+ code.textContent = match[1];
1220
+ return code;
1221
+ }
1222
+ if (match = part.match(/^\[([^\]]+?)\]\(([^)]+?)\)$/)) {
1223
+ const a = document.createElement("a");
1224
+ a.className = "nr-link";
1225
+ a.href = match[2];
1226
+ a.target = "_blank";
1227
+ a.rel = "noopener noreferrer";
1228
+ a.appendChild(renderInline(match[1]));
1229
+ return a;
1230
+ }
1231
+ if (part.startsWith("<") && part.endsWith(">")) {
1232
+ const span = document.createElement("span");
1233
+ span.innerHTML = part;
1234
+ return span;
1235
+ }
1236
+ return document.createTextNode(part);
1237
+ }
1131
1238
 
1132
- // react/directives/CardDirective.tsx
1133
- var import_react3 = __toESM(require("react"), 1);
1134
- var import_jsx_runtime4 = require("react/jsx-runtime");
1135
- var CardDirective = ({
1136
- directiveType,
1137
- props,
1138
- slots,
1139
- renderSlot,
1140
- context,
1141
- options = {}
1142
- }) => {
1143
- const stableId = (0, import_react3.useId)();
1144
- const { title, image, icon, class: customClass, url, target } = props;
1145
- const hasDescription = !!slots.description;
1146
- const { isSingleCard } = options;
1147
- const isModal = directiveType === "card-m";
1148
- const isLink = directiveType === "card-b";
1149
- const modalId = `modal-card-${props.id || stableId}`;
1150
- const wrapperClass = customClass || "";
1151
- const inlineStyles = props.style ? parseCssString(props.style) : {};
1152
- const description = hasDescription ? renderSlot("description") : null;
1153
- const content = renderSlot("content") || renderSlot("default");
1154
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react3.default.Fragment, { children: [
1155
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1156
- "div",
1157
- {
1158
- className: `flex flex-col h-full rounded-3xl transition-all relative overflow-hidden group border min-w-[18rem] w-[18rem] max-w-[20rem] ${isModal || isLink ? "cursor-pointer !border-accent-primary/10 hover:border-accent-primary/50" : "border-border"} ${wrapperClass}`,
1159
- style: inlineStyles,
1160
- onClick: isModal ? (e) => {
1161
- e.preventDefault();
1162
- e.stopPropagation();
1163
- context.setModals((prev) => ({ ...prev, [modalId]: true }));
1164
- } : isLink && url ? () => window.open(url, "_blank") : void 0,
1165
- role: isModal ? "button" : void 0,
1166
- tabIndex: isModal ? 0 : void 0,
1167
- onKeyDown: isModal ? (e) => {
1168
- if (e.key === "Enter" || e.key === " ") context.setModals((prev) => ({ ...prev, [modalId]: true }));
1169
- } : void 0,
1170
- children: [
1171
- image && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: `w-full ${isSingleCard ? "h-[240px]" : "h-[160px]"} overflow-hidden relative transition-all duration-500`, children: [
1172
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { src: image, alt: title || "", className: "w-full h-full object-cover !m-0" }),
1173
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "absolute inset-0 bg-gradient-to-t from-background-primary/40 to-transparent" })
1174
- ] }),
1175
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: `flex flex-col flex-1 bg-background-primary/80 rounded-t-xl p-6 relative ${image ? "-mt-10" : ""} border-t border-white/5 shadow-2xl`, children: [
1176
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center gap-3 mb-3", children: [
1177
- icon && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "w-10 h-10 text-[1.6em] rounded-xl bg-accent-primary/20 flex items-center justify-center shrink-0 text-accent-primary", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(IconRenderer, { iconName: icon }) }),
1178
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h3", { className: "text-base font-black tracking-tight leading-tight !m-0", children: title })
1179
- ] }),
1180
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex-1 flex flex-col gap-2", children: [
1181
- description && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "text-sm opacity-80 leading-relaxed font-medium", children: description }),
1182
- directiveType === "card" && content && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "mt-2", children: content })
1183
- ] }),
1184
- (isModal || isLink) && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "mt-6 flex justify-end", children: isLink && url ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1185
- "a",
1186
- {
1187
- href: url,
1188
- target: "_blank",
1189
- rel: "noopener noreferrer",
1190
- className: "bg-accent-primary/20 hover:bg-accent-primary/30 px-4 py-2 rounded-xl flex items-center gap-1.5 text-[10px] font-black uppercase tracking-widest opacity-50 group-hover:opacity-100 group-hover:text-accent-primary transition-all no-underline",
1191
- onClick: (e) => e.stopPropagation(),
1192
- children: [
1193
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(IconRenderer, { iconName: "open_in_new" }),
1194
- " Link"
1195
- ]
1196
- }
1197
- ) : isModal ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "bg-accent-primary/20 hover:bg-accent-primary/30 px-4 py-2 cursor-pointer rounded-xl flex items-center gap-1.5 text-[10px] font-black uppercase tracking-widest opacity-50 group-hover:opacity-100 group-hover:text-accent-primary transition-all", children: [
1198
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(IconRenderer, { iconName: "arrow_forward" }),
1199
- " Abrir"
1200
- ] }) : null })
1201
- ] })
1202
- ]
1203
- }
1204
- ),
1205
- isModal && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1206
- Modal,
1207
- {
1208
- title: title || "Detalles",
1209
- isOpen: !!context.modals[modalId],
1210
- onClose: () => context.setModals((prev) => ({ ...prev, [modalId]: false })),
1211
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "prose prose-sm max-w-none", children: content })
1212
- }
1213
- )
1214
- ] });
1239
+ // vanilla/directives/admonition.ts
1240
+ var admonitionDirective = ({ directiveType, props, renderSlot }) => {
1241
+ const el = createAdmonition(directiveType, props.title, props.icon);
1242
+ if (props.class) el.classList.add(...props.class.split(/\s+/).filter(Boolean));
1243
+ if (props.style) el.setAttribute("style", props.style);
1244
+ const body = el.querySelector(".nr-admonition__body");
1245
+ if (body) {
1246
+ body.appendChild(renderSlot("default"));
1247
+ }
1248
+ return el;
1215
1249
  };
1216
- var CardDirective_default = CardDirective;
1250
+ var admonition_default = admonitionDirective;
1217
1251
 
1218
- // react/directives/DetailsDirective.tsx
1219
- var import_jsx_runtime5 = require("react/jsx-runtime");
1220
- var DetailsDirective = ({
1221
- props,
1222
- renderSlot
1223
- }) => {
1224
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1225
- Details,
1226
- {
1227
- title: props.title || "Details",
1228
- icon: props.icon,
1229
- defaultOpen: props.defaultOpen === "true",
1230
- className: props.class,
1231
- style: props.style ? parseCssString(props.style) : void 0,
1232
- children: renderSlot("default")
1233
- }
1252
+ // vanilla/directives/details.ts
1253
+ var detailsDirective = ({ props, renderSlot }) => {
1254
+ const el = createDetails(
1255
+ props.title || "Details",
1256
+ props.icon,
1257
+ props.defaultOpen === "true"
1234
1258
  );
1259
+ if (props.class) el.classList.add(...props.class.split(/\s+/).filter(Boolean));
1260
+ if (props.style) el.setAttribute("style", props.style);
1261
+ const body = el.querySelector(".nr-details__body");
1262
+ if (body) {
1263
+ body.appendChild(renderSlot("default"));
1264
+ }
1265
+ return el;
1235
1266
  };
1236
- var DetailsDirective_default = DetailsDirective;
1267
+ var details_default = detailsDirective;
1237
1268
 
1238
- // react/directives/ModalDirective.tsx
1239
- var import_react4 = require("react");
1240
- var import_jsx_runtime6 = require("react/jsx-runtime");
1241
- var ModalDirective = ({
1242
- props,
1243
- renderSlot,
1244
- context
1245
- }) => {
1246
- const stableId = (0, import_react4.useId)();
1247
- const modalId = `modal-${props.id || stableId}`;
1269
+ // vanilla/directives/modal.ts
1270
+ var modalDirective = ({ props, renderSlot }) => {
1248
1271
  const label = props.label || props.title || "Open";
1249
1272
  const modalTitle = props.title || "Modal";
1250
1273
  const customClass = props.class || "";
1251
- const hasSizeClass = /\btext-(xs|sm|base|lg|xl|[2-9]xl)\b/.test(customClass);
1252
- const sizeClass = hasSizeClass ? "" : "text-sm";
1253
- const hasDisplayClass = /\b(flex|inline-flex|block|inline-block|grid|inline-grid|hidden)\b/.test(customClass);
1254
- const displayClass = hasDisplayClass ? "" : "inline-flex";
1255
- const isInlineFlex = /\binline-flex\b/.test(customClass);
1256
- const marginClass = isInlineFlex ? "my-1 mx-1" : "my-4";
1257
- const btnBase = `${displayClass} items-center w-fit ${marginClass} ${sizeClass} px-4 py-2 rounded-xl font-bold no-underline gap-2 transition-all hover:scale-105 active:scale-95 border border-border bg-background-primary/5 hover:bg-background-primary/10 text-text-primary hover:text-text-primary`.replace(/\s+/g, " ");
1258
- const btnClass = `${btnBase} ${customClass}`.trim();
1259
- const positionMap = {
1260
- "#left": "text-left",
1261
- "#center": "text-center",
1262
- "#right": "text-right"
1263
- };
1264
- const wrapperClass = customClass.split(/\s+/).map((c) => positionMap[c] || c).join(" ");
1265
- const handleOpen = () => {
1266
- context.setModals((prev) => ({ ...prev, [modalId]: true }));
1267
- };
1268
- const handleClose = () => {
1269
- context.setModals((prev) => ({ ...prev, [modalId]: false }));
1270
- };
1271
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: `not-prose ${wrapperClass}`.trim(), children: [
1272
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { className: btnClass, onClick: handleOpen, children: [
1273
- props.icon && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(IconRenderer, { iconName: props.icon }),
1274
- label
1275
- ] }),
1276
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1277
- Modal,
1278
- {
1279
- title: modalTitle,
1280
- isOpen: !!context.modals[modalId],
1281
- onClose: handleClose,
1282
- children: renderSlot("default")
1283
- }
1284
- )
1285
- ] });
1274
+ const wrapper = document.createElement("div");
1275
+ wrapper.className = "nr-modal-trigger";
1276
+ const btn = document.createElement("button");
1277
+ btn.className = `nr-button nr-button--default`;
1278
+ if (customClass) btn.classList.add(...customClass.split(/\s+/).filter(Boolean));
1279
+ const icon = props.icon || "open_in_new";
1280
+ if (icon) btn.appendChild(createIcon(icon));
1281
+ btn.appendChild(document.createTextNode(label));
1282
+ const dialog = createModal(modalTitle);
1283
+ const body = dialog.querySelector(".nr-modal__body");
1284
+ if (body) {
1285
+ body.appendChild(renderSlot("default"));
1286
+ }
1287
+ btn.addEventListener("click", () => {
1288
+ if (!dialog.open) {
1289
+ document.body.appendChild(dialog);
1290
+ dialog.showModal();
1291
+ dialog.addEventListener("close", () => {
1292
+ dialog.remove();
1293
+ }, { once: true });
1294
+ }
1295
+ });
1296
+ wrapper.appendChild(btn);
1297
+ wrapper.appendChild(dialog);
1298
+ return wrapper;
1286
1299
  };
1287
- var ModalDirective_default = ModalDirective;
1300
+ var modal_default = modalDirective;
1288
1301
 
1289
- // react/directives/ButtonDirective.tsx
1290
- var import_react5 = __toESM(require("react"), 1);
1291
- var import_jsx_runtime7 = require("react/jsx-runtime");
1292
- var ButtonDirective = ({
1293
- props,
1294
- renderSlot
1295
- }) => {
1302
+ // vanilla/directives/button.ts
1303
+ var buttonDirective = ({ props, renderSlot }) => {
1296
1304
  const url = props.url || props.href || "#";
1297
1305
  const label = props.label;
1298
1306
  const icon = props.icon || "near_me";
1299
1307
  const target = props.target || "_blank";
1300
1308
  const customClass = props.class || "";
1301
- const hasSizeClass = /\btext-(xs|sm|base|lg|xl|[2-9]xl)\b/.test(customClass);
1302
- const sizeClass = hasSizeClass ? "" : "text-sm";
1303
- const hasDisplayClass = /\b(flex|inline-flex|block|inline-block|grid|inline-grid|hidden)\b/.test(customClass);
1304
- const displayClass = hasDisplayClass ? "" : "inline-flex";
1305
- const isInline = !customClass || !/\b(flex|block|grid)\b/.test(customClass) || /\binline-flex\b/.test(customClass);
1306
- const marginClass = isInline ? "my-1 mx-1" : "my-4";
1307
- const btnBase = `${displayClass} items-center w-fit ${marginClass} ${sizeClass} px-4 py-2 rounded-xl font-bold no-underline gap-2 transition-all hover:scale-105 active:scale-95 border border-border bg-background-primary/5 hover:bg-background-primary/10 text-text-primary hover:text-text-primary`.replace(/\s+/g, " ");
1308
- const btnClass = `${btnBase} ${customClass}`.trim();
1309
- const positionMap = {
1310
- "#left": "flex justify-start",
1311
- "#center": "flex justify-center",
1312
- "#right": "flex justify-end"
1313
- };
1314
- const wrapperClass = customClass.split(/\s+/).map((c) => positionMap[c] || c).join(" ");
1309
+ const wrapper = document.createElement("div");
1310
+ wrapper.className = "nr-button-wrap";
1315
1311
  if (label) {
1316
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: `not-prose ${wrapperClass}`.trim(), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1317
- "a",
1318
- {
1319
- href: url,
1320
- target,
1321
- rel: "noopener noreferrer",
1322
- className: btnClass,
1323
- children: [
1324
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(IconRenderer, { iconName: icon }),
1325
- label
1326
- ]
1327
- }
1328
- ) });
1312
+ const a = document.createElement("a");
1313
+ a.href = url;
1314
+ a.target = target;
1315
+ a.rel = "noopener noreferrer";
1316
+ a.className = "nr-button nr-button--default";
1317
+ if (customClass) a.classList.add(...customClass.split(/\s+/).filter(Boolean));
1318
+ a.appendChild(createIcon(icon));
1319
+ a.appendChild(document.createTextNode(label));
1320
+ wrapper.appendChild(a);
1321
+ return wrapper;
1329
1322
  }
1330
1323
  const slotContent = renderSlot("default");
1331
- const findLinks = (element) => {
1332
- if (!element) return [];
1333
- if (import_react5.default.isValidElement(element) && element.type === "a") {
1334
- return [element];
1335
- }
1336
- if (Array.isArray(element)) {
1337
- return element.flatMap(findLinks);
1338
- }
1339
- if (import_react5.default.isValidElement(element) && element.props.children) {
1340
- return findLinks(element.props.children);
1341
- }
1342
- return [];
1343
- };
1344
- const links = findLinks(slotContent);
1324
+ const links = slotContent.querySelectorAll("a");
1345
1325
  if (links.length > 0) {
1346
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: `not-prose ${wrapperClass}`.trim(), children: links.map(
1347
- (link, index) => import_react5.default.cloneElement(
1348
- link,
1349
- {
1350
- key: index,
1351
- className: `${link.props.className || ""} ${btnClass}`.trim(),
1352
- target,
1353
- rel: "noopener noreferrer"
1354
- },
1355
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1356
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(IconRenderer, { iconName: icon }),
1357
- link.props.children
1358
- ] })
1359
- )
1360
- ) });
1326
+ links.forEach((link) => {
1327
+ link.classList.add("nr-button", "nr-button--default");
1328
+ if (customClass) link.classList.add(...customClass.split(/\s+/).filter(Boolean));
1329
+ });
1330
+ wrapper.appendChild(slotContent);
1331
+ } else {
1332
+ const a = document.createElement("a");
1333
+ a.href = url;
1334
+ a.target = target;
1335
+ a.rel = "noopener noreferrer";
1336
+ a.className = "nr-button nr-button--default";
1337
+ if (customClass) a.classList.add(...customClass.split(/\s+/).filter(Boolean));
1338
+ a.appendChild(createIcon(icon));
1339
+ a.appendChild(slotContent);
1340
+ wrapper.appendChild(a);
1361
1341
  }
1362
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: `not-prose ${wrapperClass}`.trim(), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("a", { href: url, target, rel: "noopener noreferrer", className: btnClass, children: [
1363
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(IconRenderer, { iconName: icon }),
1364
- slotContent
1365
- ] }) });
1342
+ return wrapper;
1366
1343
  };
1367
- var ButtonDirective_default = ButtonDirective;
1344
+ var button_default = buttonDirective;
1368
1345
 
1369
- // react/directives/WrapperDirective.tsx
1370
- var import_jsx_runtime8 = require("react/jsx-runtime");
1371
- var WrapperDirective = ({
1346
+ // vanilla/directives/card.ts
1347
+ var cardDirective = ({
1348
+ directiveType,
1372
1349
  props,
1373
- renderSlot
1350
+ slots,
1351
+ renderSlot,
1352
+ options
1374
1353
  }) => {
1375
- const className = props.class || "";
1376
- const id = props.id || "";
1377
- const inlineStyle = props.style ? parseCssString(props.style) : {};
1378
- const wrapperProps = {};
1379
- if (className) wrapperProps.className = className;
1380
- if (id) wrapperProps.id = id;
1381
- if (Object.keys(inlineStyle).length > 0) wrapperProps.style = inlineStyle;
1354
+ const { title, image, icon, url, target } = props;
1355
+ const customClass = props.class || "";
1356
+ const hasDescription = !!slots.description;
1357
+ const { isSingleCard } = options || {};
1358
+ const isModal = directiveType === "card-m";
1359
+ const isLink = directiveType === "card-b";
1360
+ const inlineStyles = props.style ? parseCssString(props.style) : {};
1361
+ const card = document.createElement("div");
1362
+ card.className = `nr-card${isModal || isLink ? " nr-card--interactive" : ""} ${customClass}`.trim();
1363
+ for (const [key, value] of Object.entries(inlineStyles)) {
1364
+ card.style.setProperty(key, String(value));
1365
+ }
1366
+ if (image) {
1367
+ const imgWrap = document.createElement("div");
1368
+ imgWrap.className = `nr-card__image${isSingleCard ? " nr-card__image--tall" : ""}`;
1369
+ const img = document.createElement("img");
1370
+ img.src = image;
1371
+ img.alt = title || "";
1372
+ img.className = "nr-card__img";
1373
+ imgWrap.appendChild(img);
1374
+ const gradient = document.createElement("div");
1375
+ gradient.className = "nr-card__gradient";
1376
+ imgWrap.appendChild(gradient);
1377
+ card.appendChild(imgWrap);
1378
+ }
1379
+ const body = document.createElement("div");
1380
+ body.className = `nr-card__body${image ? " nr-card__body--overlap" : ""}`;
1381
+ if (icon || title) {
1382
+ const header = document.createElement("div");
1383
+ header.className = "nr-card__header";
1384
+ if (icon) {
1385
+ const iconWrap = document.createElement("div");
1386
+ iconWrap.className = "nr-card__icon-wrap";
1387
+ iconWrap.appendChild(createIcon(icon));
1388
+ header.appendChild(iconWrap);
1389
+ }
1390
+ if (title) {
1391
+ const h3 = document.createElement("h3");
1392
+ h3.className = "nr-card__title";
1393
+ h3.textContent = title;
1394
+ header.appendChild(h3);
1395
+ }
1396
+ body.appendChild(header);
1397
+ }
1398
+ if (hasDescription) {
1399
+ const desc = document.createElement("div");
1400
+ desc.className = "nr-card__description";
1401
+ desc.appendChild(renderSlot("description"));
1402
+ body.appendChild(desc);
1403
+ }
1404
+ if (directiveType === "card") {
1405
+ const contentSlot = renderSlot("content") || renderSlot("default");
1406
+ if (contentSlot.childNodes.length > 0) {
1407
+ const contentDiv = document.createElement("div");
1408
+ contentDiv.className = "nr-card__content";
1409
+ contentDiv.appendChild(contentSlot);
1410
+ body.appendChild(contentDiv);
1411
+ }
1412
+ }
1413
+ if (isModal || isLink) {
1414
+ const action = document.createElement("div");
1415
+ action.className = "nr-card__action";
1416
+ if (isLink && url) {
1417
+ const a = document.createElement("a");
1418
+ a.href = url;
1419
+ a.target = target || "_blank";
1420
+ a.rel = "noopener noreferrer";
1421
+ a.className = "nr-card__action-link";
1422
+ a.appendChild(createIcon("open_in_new"));
1423
+ a.appendChild(document.createTextNode(" Link"));
1424
+ action.appendChild(a);
1425
+ } else if (isModal) {
1426
+ const modalBtn = document.createElement("div");
1427
+ modalBtn.className = "nr-card__action-link";
1428
+ modalBtn.appendChild(createIcon("arrow_forward"));
1429
+ modalBtn.appendChild(document.createTextNode(" Abrir"));
1430
+ action.appendChild(modalBtn);
1431
+ }
1432
+ body.appendChild(action);
1433
+ }
1434
+ card.appendChild(body);
1435
+ if (isModal) {
1436
+ const dialog = createModal(title || "Detalles");
1437
+ const modalBody = dialog.querySelector(".nr-modal__body");
1438
+ if (modalBody) {
1439
+ const contentSlot = renderSlot("content") || renderSlot("default");
1440
+ modalBody.appendChild(contentSlot);
1441
+ }
1442
+ card.addEventListener("click", () => {
1443
+ if (!dialog.open) {
1444
+ document.body.appendChild(dialog);
1445
+ dialog.showModal();
1446
+ dialog.addEventListener("close", () => dialog.remove(), { once: true });
1447
+ }
1448
+ });
1449
+ const frag = document.createDocumentFragment();
1450
+ frag.appendChild(card);
1451
+ frag.appendChild(dialog);
1452
+ return frag;
1453
+ }
1454
+ if (isLink && url) {
1455
+ card.addEventListener("click", () => window.open(url, target || "_blank"));
1456
+ }
1457
+ return card;
1458
+ };
1459
+ var card_default = cardDirective;
1460
+
1461
+ // vanilla/directives/wrapper.ts
1462
+ var wrapperDirective = ({ props, renderSlot }) => {
1463
+ const el = document.createElement("div");
1464
+ el.className = "nr-wrapper";
1465
+ if (props.class) el.classList.add(...props.class.split(/\s+/).filter(Boolean));
1466
+ if (props.id) el.id = props.id;
1467
+ if (props.style) {
1468
+ const styles = parseCssString(props.style);
1469
+ for (const [key, value] of Object.entries(styles)) {
1470
+ el.style.setProperty(key, String(value));
1471
+ }
1472
+ }
1382
1473
  for (const [key, value] of Object.entries(props)) {
1383
1474
  if (key.startsWith("data-")) {
1384
- wrapperProps[key] = value;
1475
+ el.setAttribute(key, value);
1385
1476
  }
1386
1477
  }
1387
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ...wrapperProps, children: renderSlot("default") });
1478
+ el.appendChild(renderSlot("default"));
1479
+ return el;
1388
1480
  };
1389
- var WrapperDirective_default = WrapperDirective;
1481
+ var wrapper_default = wrapperDirective;
1390
1482
 
1391
- // react/directives/SlideDirective.tsx
1392
- var import_react6 = require("react");
1393
- var import_jsx_runtime9 = require("react/jsx-runtime");
1483
+ // vanilla/directives/slide.ts
1394
1484
  var slideCounter = 0;
1395
- var SlideDirective = ({
1485
+ var slideDirective = ({
1396
1486
  props,
1397
- context,
1398
- slots
1487
+ slots,
1488
+ renderInline: renderInline2,
1489
+ renderMarkdown
1399
1490
  }) => {
1400
1491
  const rawContent = slots.default || "";
1401
1492
  const lines = rawContent.split("\n").map((l) => l.trim()).filter(Boolean);
1402
- const elements = lines.map((line) => context.parseMarkdown(line));
1403
- const [current, setCurrent] = (0, import_react6.useState)(0);
1493
+ if (lines.length === 0) {
1494
+ return document.createDocumentFragment();
1495
+ }
1404
1496
  const interval = parseInt(props.interval || "3000", 10);
1405
1497
  const speed = parseInt(props.speed || "500", 10);
1406
- const elRefs = (0, import_react6.useRef)([]);
1407
- const [maxH, setMaxH] = (0, import_react6.useState)(0);
1408
- (0, import_react6.useLayoutEffect)(() => {
1409
- let h = 0;
1410
- elRefs.current.forEach((el) => {
1411
- if (el) h = Math.max(h, el.offsetHeight);
1412
- });
1413
- if (h > 0) setMaxH(h);
1414
- }, [elements]);
1415
- const cycle = (0, import_react6.useCallback)(() => {
1416
- if (elements.length <= 1) return;
1417
- setCurrent((prev) => (prev + 1) % elements.length);
1418
- }, [elements.length]);
1419
- (0, import_react6.useEffect)(() => {
1420
- if (elements.length <= 1) return;
1421
- const id = setInterval(cycle, interval);
1422
- return () => clearInterval(id);
1423
- }, [cycle, interval, elements.length]);
1424
- if (elements.length === 0) return null;
1425
1498
  const rawClass = props.class || "";
1426
1499
  const inlineStyle = props.style ? parseCssString(props.style) : {};
1427
- const textSizeMap = {
1428
- "text-xs": "0.75rem",
1429
- "text-sm": "0.875rem",
1430
- "text-base": "1rem",
1431
- "text-lg": "1.125rem",
1432
- "text-xl": "1.25rem",
1433
- "text-2xl": "1.5rem",
1434
- "text-3xl": "1.875rem",
1435
- "text-4xl": "2.25rem",
1436
- "text-5xl": "3rem",
1437
- "text-6xl": "3.75rem",
1438
- "text-7xl": "4.5rem",
1439
- "text-8xl": "6rem",
1440
- "text-9xl": "8rem"
1441
- };
1442
- const textSizeMatch = rawClass.match(/\btext-(xs|sm|base|lg|xl|[2-9]xl)\b/);
1443
- const forcedFontSize = textSizeMatch ? textSizeMap[textSizeMatch[0]] : null;
1444
1500
  const scopeClass = `sld-${++slideCounter}`;
1445
- const className = textSizeMatch ? rawClass.replace(textSizeMatch[0], "").replace(/\s+/g, " ").trim() : rawClass;
1446
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1447
- "div",
1448
- {
1449
- className: "not-prose",
1450
- style: { height: maxH || "auto", position: "relative", overflow: "hidden", ...inlineStyle },
1451
- children: [
1452
- forcedFontSize && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("style", { children: `.${scopeClass} * { font-size: ${forcedFontSize} !important; line-height: normal !important; }` }),
1453
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1454
- "div",
1455
- {
1456
- style: {
1457
- position: "absolute",
1458
- left: 0,
1459
- right: 0,
1460
- top: 0,
1461
- transition: `transform ${speed}ms cubic-bezier(0.16, 1, 0.3, 1)`,
1462
- transform: `translateY(${-current * maxH}px)`
1463
- },
1464
- children: elements.map((tokens, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1465
- "div",
1466
- {
1467
- ref: (el) => {
1468
- elRefs.current[i] = el;
1469
- },
1470
- style: maxH ? { height: maxH, display: "flex", alignItems: "center", overflow: "hidden" } : { display: "flex", alignItems: "center" },
1471
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `${scopeClass} ${className}`, style: { width: "100%" }, children: context.processAndRenderElements(tokens) })
1472
- },
1473
- i
1474
- ))
1475
- }
1476
- )
1477
- ]
1501
+ const container = document.createElement("div");
1502
+ container.className = "nr-slide";
1503
+ Object.assign(container.style, {
1504
+ position: "relative",
1505
+ overflow: "hidden",
1506
+ ...inlineStyle
1507
+ });
1508
+ const track = document.createElement("div");
1509
+ track.className = "nr-slide__track";
1510
+ track.style.transition = `transform ${speed}ms cubic-bezier(0.16, 1, 0.3, 1)`;
1511
+ const slideEls = [];
1512
+ for (const line of lines) {
1513
+ const slideEl = document.createElement("div");
1514
+ slideEl.className = `nr-slide__item ${scopeClass} ${rawClass}`.trim();
1515
+ slideEl.style.display = "flex";
1516
+ slideEl.style.alignItems = "center";
1517
+ if (renderMarkdown) {
1518
+ const tokens = renderMarkdown(line);
1519
+ slideEl.appendChild(tokens);
1520
+ } else if (renderInline2) {
1521
+ slideEl.appendChild(renderInline2(line));
1522
+ }
1523
+ track.appendChild(slideEl);
1524
+ slideEls.push(slideEl);
1525
+ }
1526
+ container.appendChild(track);
1527
+ let current = 0;
1528
+ let maxH = 0;
1529
+ const measureAndSetHeight = () => {
1530
+ maxH = 0;
1531
+ for (const el of slideEls) {
1532
+ maxH = Math.max(maxH, el.offsetHeight);
1533
+ }
1534
+ if (maxH > 0) {
1535
+ container.style.height = `${maxH}px`;
1536
+ for (const el of slideEls) {
1537
+ el.style.height = `${maxH}px`;
1538
+ }
1478
1539
  }
1479
- );
1540
+ };
1541
+ requestAnimationFrame(() => {
1542
+ measureAndSetHeight();
1543
+ if (document.fonts?.ready) {
1544
+ document.fonts.ready.then(measureAndSetHeight);
1545
+ }
1546
+ });
1547
+ if (lines.length > 1) {
1548
+ setInterval(() => {
1549
+ current = (current + 1) % lines.length;
1550
+ track.style.transform = `translateY(${-current * maxH}px)`;
1551
+ }, interval);
1552
+ }
1553
+ return container;
1480
1554
  };
1481
- var SlideDirective_default = SlideDirective;
1555
+ var slide_default = slideDirective;
1482
1556
 
1483
- // react/directives/index.ts
1557
+ // vanilla/directives/index.ts
1484
1558
  var directiveRegistry = {
1485
1559
  // Admonitions
1486
- note: AdmonitionDirective_default,
1487
- info: AdmonitionDirective_default,
1488
- warning: AdmonitionDirective_default,
1489
- danger: AdmonitionDirective_default,
1490
- greentext: AdmonitionDirective_default,
1560
+ note: admonition_default,
1561
+ info: admonition_default,
1562
+ warning: admonition_default,
1563
+ danger: admonition_default,
1564
+ greentext: admonition_default,
1491
1565
  // Cards
1492
- card: CardDirective_default,
1493
- "card-m": CardDirective_default,
1494
- "card-b": CardDirective_default,
1566
+ card: card_default,
1567
+ "card-m": card_default,
1568
+ "card-b": card_default,
1495
1569
  // Interactive
1496
- details: DetailsDirective_default,
1497
- modal: ModalDirective_default,
1498
- button: ButtonDirective_default,
1570
+ details: details_default,
1571
+ modal: modal_default,
1572
+ button: button_default,
1499
1573
  // Layout / generic wrappers
1500
- div: WrapperDirective_default,
1501
- style: WrapperDirective_default,
1502
- custom: WrapperDirective_default,
1503
- raw: WrapperDirective_default,
1574
+ div: wrapper_default,
1575
+ style: wrapper_default,
1576
+ custom: wrapper_default,
1577
+ raw: wrapper_default,
1504
1578
  // Animation
1505
- slide: SlideDirective_default
1579
+ slide: slide_default
1506
1580
  };
1507
1581
  var directives_default = directiveRegistry;
1508
1582
 
1509
- // react/DirectiveRenderer.tsx
1510
- var import_jsx_runtime10 = require("react/jsx-runtime");
1511
- var DirectiveRenderer = ({
1512
- element,
1513
- context,
1514
- index,
1515
- allElements
1516
- }) => {
1583
+ // vanilla/renderer.ts
1584
+ function renderTokens(tokens) {
1585
+ const article = document.createElement("article");
1586
+ article.className = "nr-prose";
1587
+ const ctx = {
1588
+ parseMarkdown,
1589
+ renderElements: (tks) => renderTokensInner(tks, ctx),
1590
+ renderInline,
1591
+ renderMarkdown: (md) => renderTokensInner(parseMarkdown(md), ctx)
1592
+ };
1593
+ article.appendChild(processElements(tokens, ctx, tokens));
1594
+ return article;
1595
+ }
1596
+ function renderMarkdownString(markdown2) {
1597
+ const tokens = parseMarkdown(markdown2);
1598
+ return renderTokens(tokens);
1599
+ }
1600
+ function renderHtmlString(html) {
1601
+ let processedContent = html;
1602
+ processedContent = processedContent.replace(
1603
+ /<style(?:\s+[^>]*)?>([\s\S]*?)<\/style>/gi,
1604
+ (_match, cssContent) => {
1605
+ const styleEl = document.createElement("style");
1606
+ styleEl.setAttribute("data-nr-global", "");
1607
+ styleEl.textContent = cssContent;
1608
+ document.head.appendChild(styleEl);
1609
+ return "";
1610
+ }
1611
+ );
1612
+ const wrapper = document.createElement("div");
1613
+ wrapper.className = "nr-raw-html";
1614
+ wrapper.innerHTML = processedContent;
1615
+ const scripts = wrapper.querySelectorAll("script");
1616
+ scripts.forEach((oldScript) => {
1617
+ const newScript = document.createElement("script");
1618
+ Array.from(oldScript.attributes).forEach(
1619
+ (attr) => newScript.setAttribute(attr.name, attr.value)
1620
+ );
1621
+ newScript.textContent = oldScript.textContent;
1622
+ oldScript.parentNode?.replaceChild(newScript, oldScript);
1623
+ });
1624
+ return wrapper;
1625
+ }
1626
+ function renderTokensInner(tokens, ctx) {
1627
+ const container = document.createElement("div");
1628
+ container.appendChild(processElements(tokens, ctx, tokens));
1629
+ return container;
1630
+ }
1631
+ function processElements(elements, ctx, allElements) {
1632
+ const fragment = document.createDocumentFragment();
1633
+ let i = 0;
1634
+ while (i < elements.length) {
1635
+ const el = elements[i];
1636
+ if (el.type === "directive" && ["card", "card-m", "card-b"].includes(el.directiveType)) {
1637
+ const cards = [];
1638
+ while (i < elements.length && elements[i].type === "directive" && ["card", "card-m", "card-b"].includes(elements[i].directiveType)) {
1639
+ cards.push(elements[i]);
1640
+ i++;
1641
+ }
1642
+ if (cards.length === 1 || cards[0].props?.batch === "off") {
1643
+ for (const card of cards) {
1644
+ const rendered = renderElement(card, ctx, allElements);
1645
+ if (rendered) fragment.appendChild(rendered);
1646
+ }
1647
+ } else {
1648
+ const grid = document.createElement("div");
1649
+ grid.className = "nr-card-grid";
1650
+ for (const card of cards) {
1651
+ const rendered = renderElement(card, ctx, allElements);
1652
+ if (rendered) grid.appendChild(rendered);
1653
+ }
1654
+ fragment.appendChild(grid);
1655
+ }
1656
+ } else {
1657
+ const rendered = renderElement(el, ctx, allElements);
1658
+ if (rendered) fragment.appendChild(rendered);
1659
+ i++;
1660
+ }
1661
+ }
1662
+ return fragment;
1663
+ }
1664
+ function renderElement(element, ctx, allElements) {
1665
+ switch (element.type) {
1666
+ case "header": {
1667
+ const tag = `h${element.level}`;
1668
+ let text = element.text;
1669
+ const alignCenter = text.match(/^->\s*(.+?)\s*<-\s*$/);
1670
+ const alignRight = text.match(/^->\s*(.+?)\s*->\s*$/);
1671
+ if (alignCenter) text = alignCenter[1];
1672
+ else if (alignRight) text = alignRight[1];
1673
+ const h = document.createElement(tag);
1674
+ h.id = element.id;
1675
+ let cls = `md-h${element.level}`;
1676
+ if (alignCenter) cls += " text-center";
1677
+ if (alignRight) cls += " text-right";
1678
+ if (element.classes) cls += ` ${element.classes}`;
1679
+ h.className = cls;
1680
+ h.appendChild(renderInline(text));
1681
+ return h;
1682
+ }
1683
+ case "paragraph": {
1684
+ const p = document.createElement("p");
1685
+ let cls = "md-p";
1686
+ if (element.classes) cls += ` ${element.classes}`;
1687
+ if (element.align) cls += ` text-${element.align}`;
1688
+ p.className = cls;
1689
+ if (element.id) p.id = element.id;
1690
+ const lines = element.content.split("\n");
1691
+ for (let li = 0; li < lines.length; li++) {
1692
+ const line = lines[li];
1693
+ const hardBreakMatch = line.match(/^(.*?)(\s{2,})$/);
1694
+ if (hardBreakMatch) {
1695
+ p.appendChild(renderInline(hardBreakMatch[1]));
1696
+ p.appendChild(document.createElement("br"));
1697
+ } else {
1698
+ p.appendChild(renderInline(line));
1699
+ if (li < lines.length - 1) {
1700
+ p.appendChild(document.createTextNode(" "));
1701
+ }
1702
+ }
1703
+ }
1704
+ return p;
1705
+ }
1706
+ case "codeblock":
1707
+ return createCodeBlock(element.content, element.language, element.title);
1708
+ case "directive":
1709
+ return renderDirective(element, ctx, allElements);
1710
+ case "html": {
1711
+ const el = element;
1712
+ return renderHtmlString(el.content);
1713
+ }
1714
+ case "html-block": {
1715
+ const htmlBlock = element;
1716
+ const rawProps = parseHtmlAttrs(htmlBlock.attrs);
1717
+ const el = document.createElement(htmlBlock.tag);
1718
+ for (const [key, value] of Object.entries(rawProps)) {
1719
+ if (key === "style" && typeof value === "object") {
1720
+ for (const [prop, val] of Object.entries(value)) {
1721
+ el.style.setProperty(prop, String(val));
1722
+ }
1723
+ } else if (value === true) {
1724
+ el.setAttribute(key, "");
1725
+ } else {
1726
+ el.setAttribute(key, String(value));
1727
+ }
1728
+ }
1729
+ const childFrag = processElements(htmlBlock.children, ctx, allElements);
1730
+ el.appendChild(childFrag);
1731
+ return el;
1732
+ }
1733
+ case "image": {
1734
+ const img = document.createElement("img");
1735
+ img.src = element.src;
1736
+ img.alt = element.alt;
1737
+ img.className = "nr-image";
1738
+ if (element.style) {
1739
+ for (const [key, value] of Object.entries(element.style)) {
1740
+ img.style.setProperty(key, String(value));
1741
+ }
1742
+ }
1743
+ return img;
1744
+ }
1745
+ case "table":
1746
+ return createTable(element.content, renderInline);
1747
+ case "list":
1748
+ return createList(element.content, renderInline);
1749
+ case "blockquote":
1750
+ return createBlockquote(element.content, element.classes, renderInline);
1751
+ case "hr": {
1752
+ const hr = document.createElement("hr");
1753
+ hr.className = "nr-hr";
1754
+ return hr;
1755
+ }
1756
+ case "toc": {
1757
+ const headers = allElements.filter((e) => e.type === "header");
1758
+ return createTOC(headers.map((h) => ({ level: h.level, text: h.text, id: h.id })), renderInline);
1759
+ }
1760
+ default:
1761
+ return null;
1762
+ }
1763
+ }
1764
+ function renderDirective(element, ctx, allElements) {
1517
1765
  const { directiveType, props, slots, scopeId } = element;
1518
- const Component = directives_default[directiveType];
1766
+ const renderer = directives_default[directiveType];
1519
1767
  const renderSlot = (name) => {
1768
+ const frag = document.createDocumentFragment();
1520
1769
  const slotContent = slots[name];
1521
- if (!slotContent) return null;
1522
- const parsed = context.parseMarkdown(slotContent);
1523
- return context.processAndRenderElements(parsed);
1770
+ if (!slotContent) return frag;
1771
+ const tokens = ctx.parseMarkdown(slotContent);
1772
+ frag.appendChild(ctx.renderElements(tokens));
1773
+ return frag;
1524
1774
  };
1525
1775
  const directiveProps = {
1526
1776
  directiveType,
1527
1777
  props,
1528
1778
  slots,
1529
1779
  renderSlot,
1530
- context,
1531
- index,
1532
- allElements
1780
+ context: ctx,
1781
+ index: 0,
1782
+ allElements,
1783
+ renderInline,
1784
+ renderMarkdown: ctx.renderMarkdown
1533
1785
  };
1534
- if (Component) {
1535
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Component, { ...directiveProps }, index);
1786
+ if (renderer) {
1787
+ return renderer(directiveProps);
1536
1788
  }
1537
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: `my-4 p-4 rounded-2xl border border-border bg-background-primary/5`, children: renderSlot("default") }, index);
1538
- };
1539
- var DirectiveRenderer_default = DirectiveRenderer;
1540
-
1541
- // react/RawHtmlRenderer.tsx
1542
- var import_react8 = require("react");
1543
-
1544
- // react/useTailwindCDN.ts
1545
- var import_react7 = require("react");
1546
- function scanTailwindCDN() {
1547
- const tw = window.tailwind;
1548
- if (tw?.scan) tw.scan();
1789
+ const fallback = document.createElement("div");
1790
+ fallback.className = "nr-unknown-directive";
1791
+ fallback.appendChild(renderSlot("default"));
1792
+ return fallback;
1549
1793
  }
1550
1794
 
1551
- // react/RawHtmlRenderer.tsx
1552
- var import_jsx_runtime11 = require("react/jsx-runtime");
1553
- var RawHtmlRenderer = ({
1554
- content,
1555
- globalStyles,
1556
- wrapperClassName
1557
- }) => {
1558
- const containerRef = (0, import_react8.useRef)(null);
1559
- (0, import_react8.useEffect)(() => {
1560
- if (!containerRef.current) return;
1561
- const scripts = containerRef.current.querySelectorAll("script");
1562
- scripts.forEach((oldScript) => {
1563
- const newScript = document.createElement("script");
1564
- Array.from(oldScript.attributes).forEach(
1565
- (attr) => newScript.setAttribute(attr.name, attr.value)
1566
- );
1567
- newScript.textContent = oldScript.textContent;
1568
- oldScript.parentNode?.replaceChild(newScript, oldScript);
1569
- });
1570
- scanTailwindCDN();
1571
- }, [content]);
1572
- (0, import_react8.useEffect)(() => {
1573
- if (!globalStyles) return;
1574
- const styleEl = document.createElement("style");
1575
- styleEl.setAttribute("data-global", "");
1576
- styleEl.textContent = globalStyles;
1577
- document.head.appendChild(styleEl);
1578
- return () => {
1579
- if (styleEl.parentNode) document.head.removeChild(styleEl);
1580
- };
1581
- }, [globalStyles]);
1582
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: wrapperClassName, ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { dangerouslySetInnerHTML: { __html: content } }) });
1583
- };
1584
- var RawHtmlRenderer_default = RawHtmlRenderer;
1585
-
1586
- // react/context.tsx
1587
- var import_react9 = require("react");
1588
- var RenderCtx = (0, import_react9.createContext)(null);
1589
- var RenderContextProvider = RenderCtx.Provider;
1590
-
1591
1795
  // react/CustomMarkdownRenderer.tsx
1592
- var import_jsx_runtime12 = require("react/jsx-runtime");
1593
- var CustomMarkdownRenderer = ({ content: initialContent }) => {
1594
- const [modals, setModals] = (0, import_react10.useState)({});
1595
- const baseId = (0, import_react10.useId)().replace(/:/g, "");
1596
- const articleClass = `scope-${baseId}`;
1597
- const contextRef = (0, import_react10.useRef)(null);
1598
- resetScopeCounter();
1599
- const allElements = (0, import_react10.useMemo)(() => parseMarkdown(initialContent), [initialContent]);
1600
- (0, import_react10.useEffect)(() => {
1796
+ var import_jsx_runtime = require("react/jsx-runtime");
1797
+ var CustomMarkdownRenderer = ({ content }) => {
1798
+ const containerRef = (0, import_react3.useRef)(null);
1799
+ (0, import_react3.useEffect)(() => {
1800
+ const container = containerRef.current;
1801
+ if (!container) return;
1802
+ container.replaceChildren();
1803
+ container.appendChild(renderMarkdownString(content));
1804
+ scanTailwindCDN();
1601
1805
  const handleHashChange = () => {
1602
1806
  const hash = window.location.hash;
1603
1807
  if (hash) {
1604
1808
  const parts = hash.split("#");
1605
- const id = parts[parts.length - 1];
1606
- scrollToId(id);
1809
+ scrollToId(parts[parts.length - 1]);
1607
1810
  }
1608
1811
  };
1609
1812
  handleHashChange();
1610
1813
  window.addEventListener("hashchange", handleHashChange);
1611
1814
  return () => window.removeEventListener("hashchange", handleHashChange);
1612
- }, [initialContent]);
1613
- const renderElement = (0, import_react10.useCallback)(
1614
- (element, index, _depth = 0) => {
1615
- switch (element.type) {
1616
- case "header": {
1617
- const HeaderTag = `h${element.level}`;
1618
- let text = element.text;
1619
- const alignCenter = text.match(/^->\s*(.+?)\s*<-\s*$/);
1620
- const alignRight = text.match(/^->\s*(.+?)\s*->\s*$/);
1621
- if (alignCenter) {
1622
- text = alignCenter[1];
1623
- } else if (alignRight) {
1624
- text = alignRight[1];
1625
- }
1626
- const userClasses = element.classes || "";
1627
- let headerClasses = `md-h${element.level}`;
1628
- if (alignCenter) headerClasses += " text-center";
1629
- if (alignRight) headerClasses += " text-right";
1630
- if (userClasses) headerClasses += ` ${userClasses}`;
1631
- return import_react10.default.createElement(
1632
- HeaderTag,
1633
- { key: index, id: element.id, className: headerClasses },
1634
- renderInline(text)
1635
- );
1636
- }
1637
- case "paragraph": {
1638
- const lines = element.content.split("\n");
1639
- const processedContent = lines.map((line, lineIndex) => {
1640
- const hardBreakMatch = line.match(/^(.*?)(\s{2,})$/);
1641
- if (hardBreakMatch) {
1642
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react10.default.Fragment, { children: [
1643
- renderInline(hardBreakMatch[1]),
1644
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("br", {})
1645
- ] }, lineIndex);
1646
- }
1647
- const isLastLine = lineIndex === lines.length - 1;
1648
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react10.default.Fragment, { children: [
1649
- renderInline(line),
1650
- !isLastLine && " "
1651
- ] }, lineIndex);
1652
- });
1653
- const pUserClasses = element.classes || "";
1654
- let pClasses = "md-p";
1655
- if (pUserClasses) pClasses += ` ${pUserClasses}`;
1656
- if (element.align) pClasses += ` text-${element.align}`;
1657
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { id: element.id, className: pClasses, children: processedContent }, index);
1658
- }
1659
- case "codeblock":
1660
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1661
- CodeBlock,
1662
- {
1663
- code: element.content,
1664
- language: element.language,
1665
- title: element.title
1666
- },
1667
- index
1668
- );
1669
- case "directive":
1670
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1671
- DirectiveRenderer_default,
1672
- {
1673
- element,
1674
- context: contextRef.current,
1675
- index,
1676
- allElements
1677
- },
1678
- index
1679
- );
1680
- case "html": {
1681
- let processedContent = element.content;
1682
- let globalStyles = "";
1683
- processedContent = processedContent.replace(
1684
- /<style(?:\s+[^>]*)?>([\s\S]*?)<\/style>/gi,
1685
- (_match, cssContent) => {
1686
- globalStyles += cssContent + "\n";
1687
- return "";
1688
- }
1689
- );
1690
- const wrapperClassName = "w-full my-4";
1691
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1692
- RawHtmlRenderer_default,
1693
- {
1694
- content: processedContent,
1695
- globalStyles: globalStyles || void 0,
1696
- wrapperClassName
1697
- },
1698
- index
1699
- );
1700
- }
1701
- case "html-block": {
1702
- const htmlBlock = element;
1703
- const rawProps = parseHtmlAttrs(htmlBlock.attrs);
1704
- const props = {};
1705
- for (const [key, value] of Object.entries(rawProps)) {
1706
- if (key === "class") props["className"] = value;
1707
- else if (key === "for") props["htmlFor"] = value;
1708
- else if (key === "tabindex") props["tabIndex"] = value;
1709
- else props[key] = value;
1710
- }
1711
- return import_react10.default.createElement(
1712
- htmlBlock.tag,
1713
- { key: index, ...props },
1714
- ...processAndRenderElements(htmlBlock.children, _depth + 1)
1715
- );
1716
- }
1717
- case "image":
1718
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1719
- "img",
1720
- {
1721
- alt: element.alt,
1722
- src: element.src,
1723
- style: element.style,
1724
- className: "max-w-full h-auto"
1725
- },
1726
- index
1727
- );
1728
- case "table":
1729
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { children: renderTable(element.content) }, index);
1730
- case "list":
1731
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { children: renderList(element.content) }, index);
1732
- case "blockquote":
1733
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("blockquote", { className: `border-l-4 border-accent-primary/30 pl-4 italic text-text-secondary my-4 text-sm sm:text-base${element.classes ? ` ${element.classes}` : ""}`, children: renderInline(element.content) }, index);
1734
- case "hr":
1735
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("hr", { className: "my-8 border-border" }, index);
1736
- case "toc":
1737
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { children: generateToc(allElements) }, index);
1738
- default:
1739
- return null;
1740
- }
1741
- },
1742
- [allElements]
1743
- );
1744
- const processAndRenderElements = (0, import_react10.useCallback)(
1745
- (elements, depth = 0) => {
1746
- const result = [];
1747
- let i = 0;
1748
- while (i < elements.length) {
1749
- const el = elements[i];
1750
- if (el.type === "directive" && ["card", "card-m", "card-b"].includes(el.directiveType)) {
1751
- const cards = [];
1752
- while (i < elements.length && elements[i].type === "directive" && ["card", "card-m", "card-b"].includes(elements[i].directiveType)) {
1753
- cards.push(elements[i]);
1754
- i++;
1755
- }
1756
- if (cards.length === 1 || cards[0].props?.batch === "off") {
1757
- for (let c = 0; c < cards.length; c++) {
1758
- result.push(renderElement(cards[c], result.length, depth));
1759
- }
1760
- } else {
1761
- const firstCardClass = cards[0].props?.["class"] || "";
1762
- const justifyClasses = firstCardClass.match(/\bjustify-\S+/g) || [];
1763
- const wrapperJustify = justifyClasses.length > 0 ? justifyClasses.join(" ") : "";
1764
- result.push(
1765
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: `not-prose flex flex-wrap gap-6 my-6 ${wrapperJustify}`, children: cards.map((card, ci) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react10.default.Fragment, { children: renderElement(card, ci, depth) }, ci)) }, `card-grid-${result.length}`)
1766
- );
1767
- }
1768
- } else {
1769
- result.push(renderElement(el, result.length, depth));
1770
- i++;
1771
- }
1772
- }
1773
- return result;
1774
- },
1775
- [renderElement]
1776
- );
1777
- const generateToc = (elements) => {
1778
- const headers = extractHeaders(elements);
1779
- if (headers.length === 0) return null;
1780
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("nav", { className: "not-prose my-6 p-4 rounded-2xl border border-border bg-background-primary/5", children: [
1781
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "text-base font-bold mb-3", children: "Table of Contents" }),
1782
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("ul", { className: "space-y-1 list-none p-0 m-0", children: headers.map((h, i) => {
1783
- if (h.type !== "header") return null;
1784
- const indentClass = h.level <= 2 ? "pl-0" : h.level === 3 ? "pl-4" : h.level === 4 ? "pl-8" : "pl-12";
1785
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("li", { className: `${indentClass} text-sm sm:text-base`, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1786
- "a",
1787
- {
1788
- href: `#${h.id}`,
1789
- className: "text-accent-primary hover:text-accent-primary/80 no-underline hover:underline transition-colors",
1790
- onClick: (e) => {
1791
- e.preventDefault();
1792
- scrollToId(h.id);
1793
- },
1794
- children: renderInline(h.text.replace(/->|<-/g, "").trim())
1795
- }
1796
- ) }, i);
1797
- }) })
1798
- ] });
1799
- };
1800
- const contextForDirectives = {
1801
- modals,
1802
- setModals,
1803
- articleClass,
1804
- allElements,
1805
- parseMarkdown,
1806
- renderElement,
1807
- renderInline,
1808
- processAndRenderElements
1809
- };
1810
- contextRef.current = contextForDirectives;
1811
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RenderContextProvider, { value: contextForDirectives, children: processAndRenderElements(allElements) });
1815
+ }, [content]);
1816
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: containerRef });
1812
1817
  };
1813
1818
  var CustomMarkdownRenderer_default = CustomMarkdownRenderer;
1814
1819
 
1815
1820
  // react/NReditor.tsx
1816
- var import_jsx_runtime13 = require("react/jsx-runtime");
1821
+ var import_jsx_runtime2 = require("react/jsx-runtime");
1817
1822
  var customSyntaxHighlighting = import_language2.HighlightStyle.define([
1818
1823
  { tag: import_highlight2.tags.heading, fontWeight: "bold", color: "var(--tc-heading, #e2e8f0)" },
1819
1824
  { tag: import_highlight2.tags.quote, color: "var(--tc-quote, #94a3b8)", fontStyle: "italic" },
@@ -2262,12 +2267,15 @@ var NReditor = ({
2262
2267
  onChange,
2263
2268
  className,
2264
2269
  debounceMs = 300,
2265
- tailwindCDN = false
2270
+ tailwindCDN = false,
2271
+ onGuide,
2272
+ onConfig
2266
2273
  }) => {
2267
- const editorRef = (0, import_react11.useRef)(null);
2268
- const [isAllFolded, setIsAllFolded] = (0, import_react11.useState)(false);
2269
- const [editorMode, setEditorMode] = (0, import_react11.useState)("editor");
2274
+ const editorRef = (0, import_react4.useRef)(null);
2275
+ const [isAllFolded, setIsAllFolded] = (0, import_react4.useState)(false);
2276
+ const [editorMode, setEditorMode] = (0, import_react4.useState)("split");
2270
2277
  const debouncedContent = useDebounce(value, debounceMs);
2278
+ useLazyTailwindCDN(tailwindCDN);
2271
2279
  const handleToggleFold = () => {
2272
2280
  if (!editorRef.current) return;
2273
2281
  if (isAllFolded) {
@@ -2278,7 +2286,7 @@ var NReditor = ({
2278
2286
  setIsAllFolded(true);
2279
2287
  }
2280
2288
  };
2281
- const extensions = import_react11.default.useMemo(
2289
+ const extensions = import_react4.default.useMemo(
2282
2290
  () => [
2283
2291
  customStreamParserV2,
2284
2292
  (0, import_view.lineNumbers)(),
@@ -2298,7 +2306,6 @@ var NReditor = ({
2298
2306
  customEditorTheme,
2299
2307
  (0, import_language2.syntaxHighlighting)(customSyntaxHighlighting),
2300
2308
  import_view.EditorView.lineWrapping,
2301
- (0, import_view.scrollPastEnd)(),
2302
2309
  import_view.keymap.of([
2303
2310
  { key: "Ctrl-Shift-[", run: import_language2.foldAll },
2304
2311
  { key: "Ctrl-Shift-]", run: import_language2.unfoldAll }
@@ -2315,43 +2322,73 @@ var NReditor = ({
2315
2322
  { key: "split", icon: "vertical_split", label: "Split" },
2316
2323
  { key: "preview", icon: "visibility", label: "Preview" }
2317
2324
  ];
2318
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: `relative flex-1 flex flex-col min-h-0 ${className || ""}`, children: [
2319
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center justify-between px-2 py-1.5 border-b border-border/30 bg-background-secondary-solid/50 rounded-t-2xl shrink-0", children: [
2320
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2321
- "button",
2322
- {
2323
- onClick: handleToggleFold,
2324
- className: "p-1 px-2 text-xs font-bold bg-background-secondary-solid border border-border rounded hover:bg-border text-accent-primary transition-colors",
2325
- title: isAllFolded ? "Expand all" : "Collapse all",
2326
- children: isAllFolded ? "\u2569" : "\u2566"
2327
- }
2328
- ),
2329
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex items-center gap-0.5 bg-black/10 dark:bg-white/5 rounded-lg p-0.5", children: modeButtons.map((btn) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2330
- "button",
2331
- {
2332
- onClick: () => setEditorMode(btn.key),
2333
- className: `flex items-center gap-1 px-2.5 py-1 text-xs rounded-md transition-colors ${editorMode === btn.key ? "bg-accent-primary/20 text-accent-primary font-semibold" : "text-text-secondary hover:text-text-primary hover:bg-white/5"}`,
2334
- title: btn.label,
2335
- children: [
2336
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "material-symbols-rounded text-sm", children: btn.icon }),
2337
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "hidden sm:inline", children: btn.label })
2338
- ]
2339
- },
2340
- btn.key
2341
- )) })
2325
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `nr-editor ${className || ""}`, children: [
2326
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "nr-editor-toolbar", children: [
2327
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "nr-editor-toolbar-left", children: [
2328
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2329
+ "button",
2330
+ {
2331
+ onClick: handleToggleFold,
2332
+ className: "nr-toolbar-btn nr-toolbar-btn-fold",
2333
+ title: isAllFolded ? "Expandir todo" : "Colapsar todo",
2334
+ "aria-label": isAllFolded ? "Expandir todo" : "Colapsar todo",
2335
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "material-icons-round", children: isAllFolded ? "unfold_more" : "unfold_less" })
2336
+ }
2337
+ ),
2338
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "nr-toolbar-divider" }),
2339
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "nr-toolbar-mode-group", children: modeButtons.map((btn) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2340
+ "button",
2341
+ {
2342
+ onClick: () => setEditorMode(btn.key),
2343
+ className: `nr-toolbar-btn nr-toolbar-btn-mode ${editorMode === btn.key ? "nr-toolbar-btn-mode--active" : ""} ${btn.key === "split" ? "nr-toolbar-btn-split" : ""}`,
2344
+ title: btn.label,
2345
+ children: [
2346
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "material-icons-round", children: btn.icon }),
2347
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "nr-toolbar-label", children: btn.label })
2348
+ ]
2349
+ },
2350
+ btn.key
2351
+ )) })
2352
+ ] }),
2353
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "nr-editor-toolbar-right", children: [
2354
+ onGuide && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2355
+ "button",
2356
+ {
2357
+ onClick: onGuide,
2358
+ className: "nr-toolbar-btn nr-toolbar-btn-sm nr-toolbar-btn-guide",
2359
+ title: "Gu\xEDa de sintaxis",
2360
+ children: [
2361
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "material-icons-round", children: "menu_book" }),
2362
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "nr-toolbar-label", children: "Gu\xEDa" })
2363
+ ]
2364
+ }
2365
+ ),
2366
+ onGuide && onConfig && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "nr-toolbar-divider" }),
2367
+ onConfig && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2368
+ "button",
2369
+ {
2370
+ onClick: onConfig,
2371
+ className: "nr-toolbar-btn nr-toolbar-btn-sm nr-toolbar-btn-config",
2372
+ title: "Configurar tema y metadata",
2373
+ children: [
2374
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "material-icons-round", children: "tune" }),
2375
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "nr-toolbar-label", children: "Configurar" })
2376
+ ]
2377
+ }
2378
+ )
2379
+ ] })
2342
2380
  ] }),
2343
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex-1 min-h-0 flex", children: [
2344
- (editorMode === "editor" || editorMode === "split") && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2381
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "nr-editor-body", children: [
2382
+ (editorMode === "editor" || editorMode === "split") && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2345
2383
  "div",
2346
2384
  {
2347
- className: `${editorMode === "split" ? "w-1/2 border-r border-border/30" : "w-full"} flex-1 flex flex-col min-h-0 min-w-0`,
2348
- children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2385
+ className: `nr-editor-pane ${editorMode === "split" ? "nr-editor-pane--half" : ""}`,
2386
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2349
2387
  import_react_codemirror.default,
2350
2388
  {
2351
2389
  value,
2352
2390
  onChange,
2353
- className: "flex-1 min-h-0 min-w-0",
2354
- height: "100%",
2391
+ height: "auto",
2355
2392
  onCreateEditor: (view) => {
2356
2393
  editorRef.current = view;
2357
2394
  },
@@ -2364,11 +2401,11 @@ var NReditor = ({
2364
2401
  )
2365
2402
  }
2366
2403
  ),
2367
- (editorMode === "preview" || editorMode === "split") && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2404
+ (editorMode === "preview" || editorMode === "split") && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2368
2405
  "div",
2369
2406
  {
2370
- className: `${editorMode === "split" ? "w-1/2" : "w-full"} flex-1 min-h-0 overflow-auto min-w-0`,
2371
- children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "nr-prose h-full shadow-xs overflow-auto p-4", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CustomMarkdownRenderer_default, { content: debouncedContent }) })
2407
+ className: `nr-editor-preview ${editorMode === "split" ? "nr-editor-preview--half" : ""}`,
2408
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "nr-editor-prose", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "nr-prose", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CustomMarkdownRenderer_default, { content: debouncedContent }) }) })
2372
2409
  }
2373
2410
  )
2374
2411
  ] })