"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __esm = (fn, res) => function __init() {
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/RichEditor/components/MathNode.tsx
function MathNodeView({ node, editor, getPos }) {
  const latex = node.attrs.latex;
  const renderedHtml = (0, import_react2.useMemo)(() => {
    try {
      return import_katex.default.renderToString(latex, {
        throwOnError: false,
        displayMode: false
      });
    } catch {
      return `<span class="text-error-600">${latex}</span>`;
    }
  }, [latex]);
  const handleClick = () => {
    const pos = getPos();
    if (typeof pos !== "number") return;
    editor.chain().focus().deleteRange({ from: pos, to: pos + node.nodeSize }).insertContent(`$${latex}$`).run();
    const newPos = pos + latex.length + 1;
    editor.commands.setTextSelection(newPos);
  };
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    import_react.NodeViewWrapper,
    {
      as: "span",
      className: "inline-math cursor-pointer hover:bg-primary-50 rounded px-0.5 transition-colors",
      onClick: handleClick,
      title: "Clique para editar",
      children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
        "span",
        {
          dangerouslySetInnerHTML: { __html: renderedHtml },
          className: "inline"
        }
      )
    }
  );
}
var import_core, import_react, import_katex, import_react2, import_jsx_runtime, MathNode;
var init_MathNode = __esm({
  "src/components/RichEditor/components/MathNode.tsx"() {
    "use strict";
    import_core = require("@tiptap/core");
    import_react = require("@tiptap/react");
    import_katex = __toESM(require("katex"));
    import_react2 = require("react");
    import_jsx_runtime = require("react/jsx-runtime");
    MathNode = import_core.Node.create({
      name: "mathInline",
      group: "inline",
      inline: true,
      atom: true,
      selectable: true,
      addAttributes() {
        return {
          latex: {
            default: ""
          }
        };
      },
      parseHTML() {
        return [
          {
            tag: 'span[data-type="math-inline"]',
            getAttrs: (dom) => {
              return { latex: dom.dataset.latex };
            }
          }
        ];
      },
      renderHTML({ node, HTMLAttributes: HTMLAttributes2 }) {
        return [
          "span",
          (0, import_core.mergeAttributes)(HTMLAttributes2, {
            "data-type": "math-inline",
            "data-latex": node.attrs.latex
          })
        ];
      },
      addNodeView() {
        return (0, import_react.ReactNodeViewRenderer)(MathNodeView);
      },
      // Disable default input rules
      addInputRules() {
        return [];
      },
      addKeyboardShortcuts() {
        return {
          // When space is pressed after closing $, convert to math node
          Space: ({ editor }) => {
            const { state } = editor;
            const { selection } = state;
            const { $from } = selection;
            const textBefore = $from.parent.textBetween(
              Math.max(0, $from.parentOffset - 200),
              $from.parentOffset,
              "\n"
            );
            const regex = /\$([^$]+)\$$/;
            const match = regex.exec(textBefore);
            if (match?.[1]?.trim()) {
              const latex = match[1];
              const matchStart = $from.pos - match[0].length;
              editor.chain().deleteRange({ from: matchStart, to: $from.pos }).insertContent([
                { type: "mathInline", attrs: { latex } },
                { type: "text", text: " " }
              ]).run();
              return true;
            }
            return false;
          },
          // When backspace is pressed on a math node, convert it back to text for editing
          Backspace: ({ editor }) => {
            const { selection } = editor.state;
            const { $from } = selection;
            const nodeBefore = $from.nodeBefore;
            if (nodeBefore?.type.name === "mathInline") {
              const pos = $from.pos - nodeBefore.nodeSize;
              const latex = nodeBefore.attrs.latex;
              editor.chain().deleteRange({ from: pos, to: $from.pos }).insertContent(`$${latex}`).run();
              return true;
            }
            return false;
          }
        };
      }
    });
  }
});

// src/components/RichEditor/components/utils.ts
function processLatexInHtml(html) {
  if (!html) return html;
  const latexPattern = /\$([^$]+?)\$/g;
  return html.replaceAll(latexPattern, (_match, latex) => {
    const escapedLatex = latex.replaceAll('"', "&quot;");
    return `<span data-type="math-inline" data-latex="${escapedLatex}"></span>`;
  });
}
function unprocessLatexInHtml(html) {
  if (!html) return html;
  const mathSpanPattern = /<span[^>]*data-type="math-inline"[^>]*data-latex="([^"]*)"[^>]*><\/span>/g;
  return html.replaceAll(mathSpanPattern, (_match, latex) => {
    const unescapedLatex = latex.replaceAll("&quot;", '"');
    return `$${unescapedLatex}$`;
  });
}
var init_utils = __esm({
  "src/components/RichEditor/components/utils.ts"() {
    "use strict";
  }
});

// src/utils/utils.ts
function cn(...inputs) {
  return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
}
var import_clsx, import_tailwind_merge;
var init_utils2 = __esm({
  "src/utils/utils.ts"() {
    "use strict";
    import_clsx = require("clsx");
    import_tailwind_merge = require("tailwind-merge");
  }
});

// src/components/Button/Button.tsx
var import_react3, import_jsx_runtime2, VARIANT_ACTION_CLASSES, SIZE_CLASSES, Button, Button_default;
var init_Button = __esm({
  "src/components/Button/Button.tsx"() {
    "use strict";
    import_react3 = require("react");
    init_utils2();
    import_jsx_runtime2 = require("react/jsx-runtime");
    VARIANT_ACTION_CLASSES = {
      solid: {
        primary: "bg-primary-950 text-text border border-primary-950 hover:bg-primary-800 hover:border-primary-800 focus-visible:outline-none focus-visible:bg-primary-950 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:bg-primary-700 active:border-primary-700 disabled:bg-primary-500 disabled:border-primary-500 disabled:opacity-40 disabled:cursor-not-allowed",
        secondary: "bg-text-950 text-text border border-text-800 hover:bg-text-800 hover:border-text-950 focus-visible:outline-none focus-visible:bg-text-900 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:bg-text-700 active:border-text-700 disabled:bg-text-500 disabled:border-text-500 disabled:opacity-40 disabled:cursor-not-allowed",
        positive: "bg-success-500 text-text border border-success-500 hover:bg-success-600 hover:border-success-600 focus-visible:outline-none focus-visible:bg-success-500 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:bg-success-700 active:border-success-700 disabled:bg-success-500 disabled:border-success-500 disabled:opacity-40 disabled:cursor-not-allowed",
        negative: "bg-error-500 text-text border border-error-500 hover:bg-error-600 hover:border-error-600 focus-visible:outline-none focus-visible:bg-error-500 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:bg-error-700 active:border-error-700 disabled:bg-error-500 disabled:border-error-500 disabled:opacity-40 disabled:cursor-not-allowed"
      },
      outline: {
        primary: "bg-transparent text-primary-950 border border-primary-950 hover:bg-background-50 hover:text-primary-400 hover:border-primary-400 focus-visible:border-0 focus-visible:outline-none focus-visible:text-primary-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-primary-700 active:border-primary-700 disabled:opacity-40 disabled:cursor-not-allowed",
        secondary: "bg-transparent text-text-950 border border-text-800 hover:bg-background-50 hover:text-text-700 hover:border-text-700 focus-visible:border-0 focus-visible:outline-none focus-visible:text-text-900 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-text-700 active:border-text-700 disabled:opacity-40 disabled:cursor-not-allowed",
        positive: "bg-transparent text-success-500 border border-success-300 hover:bg-background-50 hover:text-success-400 hover:border-success-400 focus-visible:border-0 focus-visible:outline-none focus-visible:text-success-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-success-700 active:border-success-700 disabled:opacity-40 disabled:cursor-not-allowed",
        negative: "bg-transparent text-error-500 border border-error-300 hover:bg-background-50 hover:text-error-400 hover:border-error-400 focus-visible:border-0 focus-visible:outline-none focus-visible:text-error-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-error-700 active:border-error-700 disabled:opacity-40 disabled:cursor-not-allowed"
      },
      link: {
        primary: "bg-transparent text-primary-950 hover:text-primary-400 focus-visible:outline-none focus-visible:text-primary-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-primary-700 disabled:opacity-40 disabled:cursor-not-allowed",
        secondary: "bg-transparent text-text-950 hover:text-text-800 focus-visible:outline-none focus-visible:text-text-900 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-text-700 disabled:opacity-40 disabled:cursor-not-allowed",
        positive: "bg-transparent text-success-500 hover:text-success-400 focus-visible:outline-none focus-visible:text-success-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-success-700 disabled:opacity-40 disabled:cursor-not-allowed",
        negative: "bg-transparent text-error-500 hover:text-error-400 focus-visible:outline-none focus-visible:text-error-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-error-700 disabled:opacity-40 disabled:cursor-not-allowed"
      }
    };
    SIZE_CLASSES = {
      "extra-small": "text-xs px-3.5 py-2",
      small: "text-sm px-4 py-2.5",
      medium: "text-md px-5 py-2.5",
      large: "text-lg px-6 py-3",
      "extra-large": "text-lg px-7 py-3.5"
    };
    Button = (0, import_react3.forwardRef)(
      ({
        children,
        iconLeft,
        iconRight,
        size = "medium",
        variant = "solid",
        action = "primary",
        className = "",
        disabled,
        type = "button",
        ...props
      }, ref) => {
        if (variant === "raw") {
          return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
            "button",
            {
              ref,
              className,
              disabled,
              type,
              ...props,
              children: [
                iconLeft && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "mr-2 flex items-center", children: iconLeft }),
                children,
                iconRight && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "ml-2 flex items-center", children: iconRight })
              ]
            }
          );
        }
        const sizeClasses = SIZE_CLASSES[size];
        const variantClasses = VARIANT_ACTION_CLASSES[variant][action];
        const baseClasses = "inline-flex items-center justify-center rounded-full cursor-pointer font-medium";
        return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
          "button",
          {
            ref,
            className: cn(baseClasses, variantClasses, sizeClasses, className),
            disabled,
            type,
            ...props,
            children: [
              iconLeft && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "mr-2 flex items-center", children: iconLeft }),
              children,
              iconRight && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "ml-2 flex items-center", children: iconRight })
            ]
          }
        );
      }
    );
    Button.displayName = "Button";
    Button_default = Button;
  }
});

// src/components/Input/Input.tsx
var import_phosphor_react, import_react4, import_jsx_runtime3, SIZE_CLASSES2, STATE_CLASSES, VARIANT_CLASSES, getActualState, getIconSize, getPasswordToggleConfig, getCombinedClasses, Input, Input_default;
var init_Input = __esm({
  "src/components/Input/Input.tsx"() {
    "use strict";
    import_phosphor_react = require("phosphor-react");
    import_react4 = require("react");
    import_jsx_runtime3 = require("react/jsx-runtime");
    SIZE_CLASSES2 = {
      small: "text-sm",
      medium: "text-md",
      large: "text-lg",
      "extra-large": "text-xl"
    };
    STATE_CLASSES = {
      default: "border-border-300 placeholder:text-text-600 hover:border-border-400",
      error: "border-2 border-indicator-error placeholder:text-text-600",
      disabled: "border-border-300 placeholder:text-text-600 cursor-not-allowed opacity-40",
      "read-only": "border-transparent !text-text-600 cursor-default focus:outline-none bg-transparent"
    };
    VARIANT_CLASSES = {
      outlined: "border rounded-lg",
      underlined: "border-0 border-b rounded-none bg-transparent focus:outline-none focus:border-primary-950 focus:border-b-2",
      rounded: "border rounded-full"
    };
    getActualState = (disabled, readOnly, errorMessage, state) => {
      if (disabled) return "disabled";
      if (readOnly) return "read-only";
      if (errorMessage) return "error";
      return state || "default";
    };
    getIconSize = (size) => {
      const iconSizeClasses = {
        small: "w-4 h-4",
        medium: "w-5 h-5",
        large: "w-6 h-6",
        "extra-large": "w-7 h-7"
      };
      return iconSizeClasses[size] || iconSizeClasses.medium;
    };
    getPasswordToggleConfig = (type, disabled, readOnly, showPassword, iconRight) => {
      const isPasswordType = type === "password";
      const shouldShowPasswordToggle = isPasswordType && !disabled && !readOnly;
      let actualIconRight = iconRight;
      let ariaLabel;
      if (shouldShowPasswordToggle) {
        actualIconRight = showPassword ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_phosphor_react.EyeSlash, {}) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_phosphor_react.Eye, {});
        ariaLabel = showPassword ? "Ocultar senha" : "Mostrar senha";
      }
      return { shouldShowPasswordToggle, actualIconRight, ariaLabel };
    };
    getCombinedClasses = (actualState, variant) => {
      const stateClasses = STATE_CLASSES[actualState];
      const variantClasses = VARIANT_CLASSES[variant];
      if (actualState === "error" && variant === "underlined") {
        return "border-0 border-b-2 border-indicator-error rounded-none bg-transparent focus:outline-none focus:border-primary-950 placeholder:text-text-600";
      }
      if (actualState === "read-only" && variant === "underlined") {
        return "border-0 border-b-0 rounded-none bg-transparent focus:outline-none !text-text-900 cursor-default";
      }
      return `${stateClasses} ${variantClasses}`;
    };
    Input = (0, import_react4.forwardRef)(
      ({
        label,
        helperText,
        errorMessage,
        size = "medium",
        variant = "outlined",
        state = "default",
        iconLeft,
        iconRight,
        className = "",
        containerClassName = "",
        disabled,
        readOnly,
        required,
        id,
        type = "text",
        ...props
      }, ref) => {
        const [showPassword, setShowPassword] = (0, import_react4.useState)(false);
        const isPasswordType = type === "password";
        const actualType = isPasswordType && showPassword ? "text" : type;
        const actualState = getActualState(disabled, readOnly, errorMessage, state);
        const sizeClasses = SIZE_CLASSES2[size];
        const combinedClasses = (0, import_react4.useMemo)(
          () => getCombinedClasses(actualState, variant),
          [actualState, variant]
        );
        const iconSize = getIconSize(size);
        const baseClasses = `bg-background w-full py-2 ${actualState === "read-only" ? "px-0" : "px-3"} font-normal text-text-900 focus:outline-primary-950`;
        const generatedId = (0, import_react4.useId)();
        const inputId = id ?? `input-${generatedId}`;
        const togglePasswordVisibility = () => setShowPassword(!showPassword);
        const { shouldShowPasswordToggle, actualIconRight, ariaLabel } = getPasswordToggleConfig(
          type,
          disabled,
          readOnly,
          showPassword,
          iconRight
        );
        return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: `${containerClassName}`, children: [
          label && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
            "label",
            {
              htmlFor: inputId,
              className: `block font-bold text-text-900 mb-1.5 ${sizeClasses}`,
              children: [
                label,
                " ",
                required && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-indicator-error", children: "*" })
              ]
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "relative", children: [
            iconLeft && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "absolute left-3 top-1/2 transform -translate-y-1/2 pointer-events-none", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
              "span",
              {
                className: `${iconSize} text-text-400 flex items-center justify-center`,
                children: iconLeft
              }
            ) }),
            /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
              "input",
              {
                ref,
                id: inputId,
                type: actualType,
                className: `${baseClasses} ${sizeClasses} ${combinedClasses} ${iconLeft ? "pl-10" : ""} ${actualIconRight ? "pr-10" : ""} ${className}`,
                disabled,
                readOnly,
                required,
                "aria-invalid": actualState === "error" ? "true" : void 0,
                ...props
              }
            ),
            actualIconRight && (shouldShowPasswordToggle ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
              "button",
              {
                type: "button",
                className: "absolute right-3 top-1/2 transform -translate-y-1/2 cursor-pointer border-0 bg-transparent p-0",
                onClick: togglePasswordVisibility,
                "aria-label": ariaLabel,
                children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
                  "span",
                  {
                    className: `${iconSize} text-text-400 flex items-center justify-center hover:text-text-600 transition-colors`,
                    children: actualIconRight
                  }
                )
              }
            ) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "absolute right-3 top-1/2 transform -translate-y-1/2 pointer-events-none", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
              "span",
              {
                className: `${iconSize} text-text-400 flex items-center justify-center`,
                children: actualIconRight
              }
            ) }))
          ] }),
          /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mt-1.5 gap-1.5", children: [
            helperText && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "text-sm text-text-500", children: helperText }),
            errorMessage && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: "flex gap-1 items-center text-sm text-indicator-error", children: [
              /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_phosphor_react.WarningCircle, { size: 16 }),
              " ",
              errorMessage
            ] })
          ] })
        ] });
      }
    );
    Input_default = Input;
  }
});

// src/components/Menu/Menu.tsx
var import_zustand, import_react5, import_phosphor_react2, import_jsx_runtime4, createMenuStore, useMenuStore, VARIANT_CLASSES2, BASE_CLASSES_BY_VARIANT, Menu, MenuContent, MenuItem, injectStore, Menu_default;
var init_Menu = __esm({
  "src/components/Menu/Menu.tsx"() {
    "use strict";
    import_zustand = require("zustand");
    import_react5 = require("react");
    import_phosphor_react2 = require("phosphor-react");
    init_utils2();
    import_jsx_runtime4 = require("react/jsx-runtime");
    createMenuStore = (onValueChange) => (0, import_zustand.create)((set) => ({
      value: "",
      setValue: (value) => {
        set({ value });
        onValueChange?.(value);
      },
      syncValue: (value) => set((state) => state.value === value ? state : { value }),
      onValueChange
    }));
    useMenuStore = (externalStore) => {
      if (!externalStore) throw new Error("MenuItem must be inside Menu");
      return externalStore;
    };
    VARIANT_CLASSES2 = {
      menu: "bg-background shadow-soft-shadow-1 px-6",
      menu2: "",
      "menu-overflow": "",
      "menu-overflow-col": "bg-background shadow-soft-shadow-1",
      breadcrumb: "bg-transparent shadow-none !px-0"
    };
    BASE_CLASSES_BY_VARIANT = {
      menu: "w-full py-2 flex flex-row items-center justify-center",
      menu2: "w-full py-2 flex flex-row items-center justify-center",
      "menu-overflow": "w-fit py-2 flex flex-row items-center justify-center",
      "menu-overflow-col": "w-full py-2 flex flex-row items-center justify-start",
      breadcrumb: "w-full py-2 flex flex-row items-center justify-center"
    };
    Menu = (0, import_react5.forwardRef)(
      ({
        className,
        children,
        defaultValue,
        value: propValue,
        variant = "menu",
        onValueChange,
        ...props
      }, ref) => {
        const storeRef = (0, import_react5.useRef)(null);
        storeRef.current ??= createMenuStore(onValueChange);
        const store = storeRef.current;
        const { syncValue } = (0, import_zustand.useStore)(store, (s) => s);
        (0, import_react5.useEffect)(() => {
          syncValue(propValue ?? defaultValue);
        }, [defaultValue, propValue, syncValue]);
        const baseClasses = BASE_CLASSES_BY_VARIANT[variant];
        const variantClasses = VARIANT_CLASSES2[variant];
        return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
          "div",
          {
            ref,
            className: `
          ${baseClasses}
          ${variantClasses}
          ${className ?? ""}
        `,
            ...props,
            children: injectStore(children, store)
          }
        );
      }
    );
    Menu.displayName = "Menu";
    MenuContent = (0, import_react5.forwardRef)(
      ({ className, children, variant = "menu", ...props }, ref) => {
        const baseClasses = "w-full flex flex-row items-center gap-2";
        const isOverflowVariant = variant === "menu2" || variant === "menu-overflow" || variant === "menu-overflow-col";
        const variantClasses = isOverflowVariant ? "overflow-x-auto scroll-smooth" : "";
        return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
          "ul",
          {
            ref,
            className: `
          ${baseClasses}
          ${variantClasses}
          ${variant == "breadcrumb" ? "flex-wrap" : ""}
          ${className ?? ""}
        `,
            style: isOverflowVariant ? { scrollbarWidth: "none", msOverflowStyle: "none" } : void 0,
            ...props,
            children
          }
        );
      }
    );
    MenuContent.displayName = "MenuContent";
    MenuItem = (0, import_react5.forwardRef)(
      ({
        className,
        children,
        value,
        disabled = false,
        store: externalStore,
        variant = "menu",
        separator = false,
        ...props
      }, ref) => {
        const store = useMenuStore(externalStore);
        const { value: selectedValue, setValue } = (0, import_zustand.useStore)(store, (s) => s);
        const handleClick = (e) => {
          if (!disabled) {
            setValue(value);
          }
          props.onClick?.(e);
        };
        const commonProps = {
          role: "menuitem",
          "aria-disabled": disabled,
          ref,
          onClick: handleClick,
          onKeyDown: (e) => {
            if (["Enter", " "].includes(e.key)) handleClick(e);
          },
          tabIndex: disabled ? -1 : 0,
          onMouseDown: (e) => {
            e.preventDefault();
          },
          ...props
        };
        const variants = {
          menu: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
            "li",
            {
              "data-variant": "menu",
              className: `
            w-full flex flex-col items-center justify-center gap-0.5 py-1 px-2 rounded-sm font-medium text-xs
            [&>svg]:size-6 cursor-pointer hover:bg-primary-600 hover:text-text
            focus:outline-none focus:border-indicator-info focus:border-2
            ${selectedValue === value ? "bg-primary-50 text-primary-950" : "text-text-950"}
            ${className ?? ""}
          `,
              ...commonProps,
              children
            }
          ),
          menu2: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
            "li",
            {
              "data-variant": "menu2",
              className: `
            w-full flex flex-col items-center px-2 pt-4 gap-3 cursor-pointer focus:rounded-sm justify-center hover:bg-background-100 rounded-lg
            focus:outline-none focus:border-indicator-info focus:border-2
            ${selectedValue === value ? "" : "pb-4"}
          `,
              ...commonProps,
              children: [
                /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
                  "span",
                  {
                    className: cn(
                      "flex flex-row items-center gap-2 px-4 text-text-950 text-xs font-bold",
                      className
                    ),
                    children
                  }
                ),
                selectedValue === value && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "h-1 w-full bg-primary-950 rounded-lg" })
              ]
            }
          ),
          "menu-overflow": /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
            "li",
            {
              "data-variant": "menu-overflow",
              className: `
            w-fit flex flex-col items-center px-2 pt-4 gap-3 cursor-pointer focus:rounded-sm justify-center hover:bg-background-100 rounded-lg
            focus:outline-none focus:border-indicator-info focus:border-2
            ${selectedValue === value ? "" : "pb-4"}
          `,
              ...commonProps,
              children: [
                /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
                  "span",
                  {
                    className: cn(
                      "flex flex-row items-center gap-2 px-4 text-text-950 text-xs font-bold",
                      className
                    ),
                    children
                  }
                ),
                selectedValue === value && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "h-1 w-full bg-primary-950 rounded-lg" })
              ]
            }
          ),
          "menu-overflow-col": /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
            "li",
            {
              "data-variant": "menu-overflow-col",
              className: cn(
                "flex-1 min-w-fit flex flex-col items-center justify-center gap-0.5 py-1 px-2 rounded-sm font-medium text-xs whitespace-nowrap [&>svg]:size-6 cursor-pointer hover:bg-primary-600 hover:text-text focus:outline-none focus:border-indicator-info focus:border-2",
                selectedValue === value ? "bg-primary-50 text-primary-950" : "text-text-950",
                className
              ),
              ...commonProps,
              children
            }
          ),
          breadcrumb: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
            "li",
            {
              "data-variant": "breadcrumb",
              className: `
            flex flex-row gap-2 items-center w-fit p-2 rounded-lg hover:text-primary-600 cursor-pointer font-bold text-xs
            focus:outline-none focus:border-indicator-info focus:border-2
            ${selectedValue === value ? "text-text-950" : "text-text-600"}
            ${className ?? ""}
          `,
              ...commonProps,
              children: [
                /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
                  "span",
                  {
                    className: cn(
                      "border-b border-text-600 hover:border-primary-600 text-inherit text-xs",
                      selectedValue === value ? "border-b-0 font-bold" : "border-b-text-600"
                    ),
                    children
                  }
                ),
                separator && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
                  import_phosphor_react2.CaretRight,
                  {
                    size: 16,
                    className: "text-text-600",
                    "data-testid": "separator"
                  }
                )
              ]
            }
          )
        };
        return variants[variant] ?? variants["menu"];
      }
    );
    MenuItem.displayName = "MenuItem";
    injectStore = (children, store) => import_react5.Children.map(children, (child) => {
      if (!(0, import_react5.isValidElement)(child)) return child;
      const typedChild = child;
      const shouldInject = typedChild.type === MenuItem;
      return (0, import_react5.cloneElement)(typedChild, {
        ...shouldInject ? { store } : {},
        ...typedChild.props.children ? { children: injectStore(typedChild.props.children, store) } : {}
      });
    });
    Menu_default = Menu;
  }
});

// src/components/Modal/utils/videoUtils.ts
var isYouTubeUrl, isValidYouTubeHost, extractYoutuBeId, extractYouTubeId, getYouTubeVideoId, getYouTubeEmbedUrl;
var init_videoUtils = __esm({
  "src/components/Modal/utils/videoUtils.ts"() {
    "use strict";
    isYouTubeUrl = (url) => {
      const youtubeRegex = /^(https?:\/\/)?((www|m|music)\.)?(youtube\.com|youtu\.be|youtube-nocookie\.com)\/.+/i;
      return youtubeRegex.test(url);
    };
    isValidYouTubeHost = (host) => {
      if (host === "youtu.be") return "youtu.be";
      const isValidYouTubeCom = host === "youtube.com" || host.endsWith(".youtube.com") && /^(www|m|music)\.youtube\.com$/.test(host);
      if (isValidYouTubeCom) return "youtube";
      const isValidNoCookie = host === "youtube-nocookie.com" || host.endsWith(".youtube-nocookie.com") && /^(www|m|music)\.youtube-nocookie\.com$/.test(host);
      if (isValidNoCookie) return "nocookie";
      return null;
    };
    extractYoutuBeId = (pathname) => {
      const firstSeg = pathname.split("/").filter(Boolean)[0];
      return firstSeg || null;
    };
    extractYouTubeId = (pathname, searchParams) => {
      const parts = pathname.split("/").filter(Boolean);
      const [first, second] = parts;
      if (first === "embed" && second) return second;
      if (first === "shorts" && second) return second;
      if (first === "live" && second) return second;
      const v = searchParams.get("v");
      if (v) return v;
      return null;
    };
    getYouTubeVideoId = (url) => {
      try {
        const u = new URL(url);
        const hostType = isValidYouTubeHost(u.hostname.toLowerCase());
        if (!hostType) return null;
        if (hostType === "youtu.be") {
          return extractYoutuBeId(u.pathname);
        }
        return extractYouTubeId(u.pathname, u.searchParams);
      } catch {
        return null;
      }
    };
    getYouTubeEmbedUrl = (videoId) => {
      return `https://www.youtube-nocookie.com/embed/${videoId}?autoplay=0&rel=0&modestbranding=1`;
    };
  }
});

// src/components/Modal/Modal.tsx
var import_react6, import_phosphor_react3, import_jsx_runtime5, SIZE_CLASSES3, Modal, Modal_default;
var init_Modal = __esm({
  "src/components/Modal/Modal.tsx"() {
    "use strict";
    import_react6 = require("react");
    import_phosphor_react3 = require("phosphor-react");
    init_utils2();
    init_Button();
    init_videoUtils();
    import_jsx_runtime5 = require("react/jsx-runtime");
    SIZE_CLASSES3 = {
      xs: "max-w-[360px]",
      sm: "max-w-[420px]",
      md: "max-w-[510px]",
      lg: "max-w-[640px]",
      xl: "max-w-[970px]"
    };
    Modal = ({
      isOpen,
      onClose,
      title,
      children,
      size = "md",
      className = "",
      closeOnEscape = true,
      footer,
      hideCloseButton = false,
      variant = "default",
      description,
      image,
      imageAlt,
      actionLink,
      actionLabel,
      contentClassName = ""
    }) => {
      const titleId = (0, import_react6.useId)();
      (0, import_react6.useEffect)(() => {
        if (!isOpen || !closeOnEscape) return;
        const handleEscape = (event) => {
          if (event.key === "Escape") {
            onClose();
          }
        };
        document.addEventListener("keydown", handleEscape);
        return () => document.removeEventListener("keydown", handleEscape);
      }, [isOpen, closeOnEscape, onClose]);
      (0, import_react6.useEffect)(() => {
        if (!isOpen) return;
        const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
        const originalOverflow = document.body.style.overflow;
        const originalPaddingRight = document.body.style.paddingRight;
        document.body.style.overflow = "hidden";
        if (scrollbarWidth > 0) {
          document.body.style.paddingRight = `${scrollbarWidth}px`;
          const overlay = document.createElement("div");
          overlay.id = "modal-scrollbar-overlay";
          overlay.style.cssText = `
        position: fixed;
        top: 0;
        right: 0;
        width: ${scrollbarWidth}px;
        height: 100vh;
        background-color: rgb(0 0 0 / 0.6);
        z-index: 40;
        pointer-events: none;
      `;
          document.body.appendChild(overlay);
        }
        return () => {
          document.body.style.overflow = originalOverflow;
          document.body.style.paddingRight = originalPaddingRight;
          const overlay = document.getElementById("modal-scrollbar-overlay");
          if (overlay) {
            overlay.remove();
          }
        };
      }, [isOpen]);
      if (!isOpen) return null;
      const sizeClasses = SIZE_CLASSES3[size];
      const baseClasses = "bg-secondary-50 rounded-3xl shadow-hard-shadow-2 border border-border-100 w-full mx-4 max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";
      const dialogResetClasses = "p-0 m-0 border-none outline-none static";
      const modalClasses = cn(
        baseClasses,
        sizeClasses,
        dialogResetClasses,
        className
      );
      const normalizeUrl = (href) => /^https?:\/\//i.test(href) ? href : `https://${href}`;
      const handleActionClick = () => {
        if (actionLink) {
          window.open(normalizeUrl(actionLink), "_blank", "noopener,noreferrer");
        }
      };
      if (variant === "activity") {
        return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-xs border-none p-0 m-0 w-full cursor-default", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
          "dialog",
          {
            className: modalClasses,
            "aria-labelledby": titleId,
            "aria-modal": "true",
            open: true,
            children: [
              /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex justify-end p-6 pb-0", children: !hideCloseButton && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
                "button",
                {
                  onClick: onClose,
                  className: "p-1 text-text-500 hover:text-text-700 hover:bg-background-50 rounded-md transition-colors focus:outline-none focus:ring-2 focus:ring-indicator-info focus:ring-offset-2",
                  "aria-label": "Fechar modal",
                  children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_phosphor_react3.X, { size: 18 })
                }
              ) }),
              /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col items-center px-6 pb-6 gap-5 flex-1 min-h-0 overflow-y-auto", children: [
                image && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
                  "img",
                  {
                    src: image,
                    alt: imageAlt ?? "",
                    className: "w-[122px] h-[122px] object-contain"
                  }
                ) }),
                /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
                  "h2",
                  {
                    id: titleId,
                    className: "text-lg font-semibold text-text-950 text-center",
                    children: title
                  }
                ),
                description && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-sm font-normal text-text-400 text-center max-w-md leading-[21px]", children: description }),
                actionLink && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "w-full", children: [
                  (() => {
                    const normalized = normalizeUrl(actionLink);
                    const isYT = isYouTubeUrl(normalized);
                    if (!isYT) return null;
                    const id = getYouTubeVideoId(normalized);
                    if (!id) {
                      return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
                        Button_default,
                        {
                          variant: "solid",
                          action: "primary",
                          size: "large",
                          className: "w-full",
                          onClick: handleActionClick,
                          children: actionLabel || "Iniciar Atividade"
                        }
                      );
                    }
                    return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
                      "iframe",
                      {
                        src: getYouTubeEmbedUrl(id),
                        className: "w-full aspect-video rounded-lg",
                        allowFullScreen: true,
                        allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
                        title: "V\xEDdeo YouTube"
                      }
                    );
                  })(),
                  !isYouTubeUrl(normalizeUrl(actionLink)) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
                    Button_default,
                    {
                      variant: "solid",
                      action: "primary",
                      size: "large",
                      className: "w-full",
                      onClick: handleActionClick,
                      children: actionLabel || "Iniciar Atividade"
                    }
                  )
                ] })
              ] })
            ]
          }
        ) });
      }
      return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-xs border-none p-0 m-0 w-full cursor-default", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
        "dialog",
        {
          className: modalClasses,
          "aria-labelledby": titleId,
          "aria-modal": "true",
          open: true,
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-between px-6 py-6", children: [
              /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h2", { id: titleId, className: "text-lg font-semibold text-text-950", children: title }),
              !hideCloseButton && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
                "button",
                {
                  onClick: onClose,
                  className: "p-1 text-text-500 hover:text-text-700 hover:bg-background-50 rounded-md transition-colors focus:outline-none focus:ring-2 focus:ring-indicator-info focus:ring-offset-2",
                  "aria-label": "Fechar modal",
                  children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_phosphor_react3.X, { size: 18 })
                }
              )
            ] }),
            children && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
              "div",
              {
                className: cn(
                  "px-6 pb-6 flex-1 min-h-0 overflow-y-auto",
                  contentClassName
                ),
                children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
                  "div",
                  {
                    className: cn(
                      "text-text-500 font-normal text-sm leading-6",
                      contentClassName?.includes("flex") && "flex flex-col flex-1 min-h-0"
                    ),
                    children
                  }
                )
              }
            ),
            footer && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex justify-end gap-3 px-6 pb-6", children: footer })
          ]
        }
      ) });
    };
    Modal_default = Modal;
  }
});

// src/components/Text/Text.tsx
var import_jsx_runtime6, Text, Text_default;
var init_Text = __esm({
  "src/components/Text/Text.tsx"() {
    "use strict";
    init_utils2();
    import_jsx_runtime6 = require("react/jsx-runtime");
    Text = ({
      children,
      size = "md",
      weight = "normal",
      color = "text-text-950",
      as,
      className = "",
      ...props
    }) => {
      let sizeClasses;
      let weightClasses;
      const sizeClassMap = {
        "2xs": "text-2xs",
        xs: "text-xs",
        sm: "text-sm",
        md: "text-md",
        lg: "text-lg",
        xl: "text-xl",
        "2xl": "text-2xl",
        "3xl": "text-3xl",
        "4xl": "text-4xl",
        "5xl": "text-5xl",
        "6xl": "text-6xl"
      };
      sizeClasses = sizeClassMap[size] ?? sizeClassMap.md;
      const weightClassMap = {
        hairline: "font-hairline",
        light: "font-light",
        normal: "font-normal",
        medium: "font-medium",
        semibold: "font-semibold",
        bold: "font-bold",
        extrabold: "font-extrabold",
        black: "font-black"
      };
      weightClasses = weightClassMap[weight] ?? weightClassMap.normal;
      const baseClasses = "font-primary";
      const Component2 = as ?? "p";
      return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
        Component2,
        {
          className: cn(baseClasses, sizeClasses, weightClasses, color, className),
          ...props,
          children
        }
      );
    };
    Text_default = Text;
  }
});

// src/components/TextArea/TextArea.tsx
var import_react7, import_phosphor_react4, import_jsx_runtime7, SIZE_CLASSES4, BASE_TEXTAREA_CLASSES, STATE_CLASSES2, TextArea, TextArea_default;
var init_TextArea = __esm({
  "src/components/TextArea/TextArea.tsx"() {
    "use strict";
    import_react7 = require("react");
    import_phosphor_react4 = require("phosphor-react");
    init_Text();
    init_utils2();
    import_jsx_runtime7 = require("react/jsx-runtime");
    SIZE_CLASSES4 = {
      small: {
        textarea: "h-24 text-sm",
        // 96px height, 14px font
        textSize: "sm"
      },
      medium: {
        textarea: "h-24 text-base",
        // 96px height, 16px font
        textSize: "md"
      },
      large: {
        textarea: "h-24 text-lg",
        // 96px height, 18px font
        textSize: "lg"
      },
      extraLarge: {
        textarea: "h-24 text-xl",
        // 96px height, 20px font
        textSize: "xl"
      }
    };
    BASE_TEXTAREA_CLASSES = "w-full box-border p-3 bg-background border border-solid rounded-[4px] resize-none focus:outline-none font-roboto font-normal leading-[150%] placeholder:text-text-600 transition-all duration-200";
    STATE_CLASSES2 = {
      default: {
        base: "border-border-300 bg-background text-text-600",
        hover: "hover:border-border-400",
        focus: "focus:border-border-500"
      },
      hovered: {
        base: "border-border-400 bg-background text-text-600",
        hover: "",
        focus: "focus:border-border-500"
      },
      focused: {
        base: "border-2 border-primary-950 bg-background text-text-900",
        hover: "",
        focus: ""
      },
      invalid: {
        base: "border-2 border-red-700 bg-white text-gray-800",
        hover: "hover:border-red-700",
        focus: "focus:border-red-700"
      },
      disabled: {
        base: "border-border-300 bg-background text-text-600 cursor-not-allowed opacity-40",
        hover: "",
        focus: ""
      }
    };
    TextArea = (0, import_react7.forwardRef)(
      ({
        label,
        size = "medium",
        state = "default",
        errorMessage,
        helperMessage,
        className = "",
        labelClassName = "",
        disabled,
        id,
        onChange,
        placeholder,
        required,
        showCharacterCount = false,
        maxLength,
        value,
        autoResize = false,
        minHeight = 96,
        ...props
      }, ref) => {
        const generatedId = (0, import_react7.useId)();
        const inputId = id ?? `textarea-${generatedId}`;
        const internalRef = (0, import_react7.useRef)(null);
        (0, import_react7.useImperativeHandle)(ref, () => internalRef.current);
        const [isFocused, setIsFocused] = (0, import_react7.useState)(false);
        const currentLength = typeof value === "string" ? value.length : 0;
        const isNearLimit = maxLength && currentLength >= maxLength * 0.8;
        (0, import_react7.useEffect)(() => {
          if (autoResize && internalRef.current) {
            const textarea = internalRef.current;
            textarea.style.height = "auto";
            textarea.style.height = `${Math.max(textarea.scrollHeight, minHeight)}px`;
          }
        }, [autoResize, minHeight, value]);
        const handleChange = (event) => {
          onChange?.(event);
        };
        const handleFocus = (event) => {
          setIsFocused(true);
          props.onFocus?.(event);
        };
        const handleBlur = (event) => {
          setIsFocused(false);
          props.onBlur?.(event);
        };
        let currentState = disabled ? "disabled" : state;
        if (isFocused && currentState !== "invalid" && currentState !== "disabled") {
          currentState = "focused";
        }
        const sizeClasses = SIZE_CLASSES4[size];
        const stateClasses = STATE_CLASSES2[currentState];
        const heightClasses = autoResize ? "h-auto overflow-hidden" : sizeClasses.textarea;
        const fontSizeClass = sizeClasses.textarea.split(" ").find((c) => c.startsWith("text-")) ?? "text-base";
        const textareaClasses = cn(
          BASE_TEXTAREA_CLASSES,
          autoResize ? fontSizeClass : sizeClasses.textarea,
          heightClasses,
          stateClasses.base,
          stateClasses.hover,
          stateClasses.focus,
          className
        );
        return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: `flex flex-col`, children: [
          label && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
            Text_default,
            {
              as: "label",
              htmlFor: inputId,
              size: sizeClasses.textSize,
              weight: "medium",
              color: "text-text-950",
              className: cn("mb-1.5", labelClassName),
              children: [
                label,
                " ",
                required && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-indicator-error", children: "*" })
              ]
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
            "textarea",
            {
              ref: internalRef,
              id: inputId,
              disabled,
              onChange: handleChange,
              onFocus: handleFocus,
              onBlur: handleBlur,
              className: textareaClasses,
              placeholder,
              required,
              maxLength,
              value,
              ...props
            }
          ),
          errorMessage && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("p", { className: "flex gap-1 items-center text-sm text-indicator-error mt-1.5", children: [
            /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_phosphor_react4.WarningCircle, { size: 16 }),
            " ",
            errorMessage
          ] }),
          !errorMessage && showCharacterCount && maxLength && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
            Text_default,
            {
              size: "sm",
              weight: "normal",
              className: `mt-1.5 ${isNearLimit ? "text-indicator-warning" : "text-text-500"}`,
              children: [
                currentLength,
                "/",
                maxLength,
                " caracteres"
              ]
            }
          ),
          !errorMessage && helperMessage && !(showCharacterCount && maxLength) && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text_default, { size: "sm", weight: "normal", className: "mt-1.5 text-text-500", children: helperMessage })
        ] });
      }
    );
    TextArea.displayName = "TextArea";
    TextArea_default = TextArea;
  }
});

// src/hooks/useMobile.ts
var import_react8, MOBILE_WIDTH, TABLET_WIDTH, SMALL_MOBILE_WIDTH, EXTRA_SMALL_MOBILE_WIDTH, ULTRA_SMALL_MOBILE_WIDTH, TINY_MOBILE_WIDTH, DEFAULT_WIDTH, getWindowWidth, getDeviceType, useMobile;
var init_useMobile = __esm({
  "src/hooks/useMobile.ts"() {
    "use strict";
    import_react8 = require("react");
    MOBILE_WIDTH = 500;
    TABLET_WIDTH = 931;
    SMALL_MOBILE_WIDTH = 425;
    EXTRA_SMALL_MOBILE_WIDTH = 375;
    ULTRA_SMALL_MOBILE_WIDTH = 375;
    TINY_MOBILE_WIDTH = 320;
    DEFAULT_WIDTH = 1200;
    getWindowWidth = () => {
      if (typeof window === "undefined") {
        return DEFAULT_WIDTH;
      }
      return window.innerWidth;
    };
    getDeviceType = () => {
      const width = getWindowWidth();
      return width < TABLET_WIDTH ? "responsive" : "desktop";
    };
    useMobile = () => {
      const [isMobile, setIsMobile] = (0, import_react8.useState)(false);
      const [isTablet, setIsTablet] = (0, import_react8.useState)(false);
      const [isSmallMobile, setIsSmallMobile] = (0, import_react8.useState)(false);
      const [isExtraSmallMobile, setIsExtraSmallMobile] = (0, import_react8.useState)(false);
      const [isUltraSmallMobile, setIsUltraSmallMobile] = (0, import_react8.useState)(false);
      const [isTinyMobile, setIsTinyMobile] = (0, import_react8.useState)(false);
      (0, import_react8.useEffect)(() => {
        const checkScreenSize = () => {
          const width = getWindowWidth();
          setIsMobile(width < MOBILE_WIDTH);
          setIsTablet(width < TABLET_WIDTH);
          setIsSmallMobile(width < SMALL_MOBILE_WIDTH);
          setIsExtraSmallMobile(width < EXTRA_SMALL_MOBILE_WIDTH);
          setIsUltraSmallMobile(width < ULTRA_SMALL_MOBILE_WIDTH);
          setIsTinyMobile(width < TINY_MOBILE_WIDTH);
        };
        checkScreenSize();
        window.addEventListener("resize", checkScreenSize);
        return () => window.removeEventListener("resize", checkScreenSize);
      }, []);
      const getFormContainerClasses = () => {
        if (isMobile) {
          return "w-full px-4";
        }
        if (isTablet) {
          return "w-full px-6";
        }
        return "w-full max-w-[992px] mx-auto px-0";
      };
      const getMobileHeaderClasses = () => {
        return "flex flex-col items-start gap-4 mb-6";
      };
      const getDesktopHeaderClasses = () => {
        return "flex flex-row justify-between items-center gap-6 mb-8";
      };
      const getHeaderClasses = () => {
        return isMobile ? getMobileHeaderClasses() : getDesktopHeaderClasses();
      };
      const getVideoContainerClasses = () => {
        if (isTinyMobile) return "aspect-square";
        if (isExtraSmallMobile) return "aspect-[4/3]";
        if (isSmallMobile) return "aspect-[16/12]";
        return "aspect-video";
      };
      return {
        isMobile,
        isTablet,
        isSmallMobile,
        isExtraSmallMobile,
        isUltraSmallMobile,
        isTinyMobile,
        getFormContainerClasses,
        getHeaderClasses,
        getMobileHeaderClasses,
        getDesktopHeaderClasses,
        getVideoContainerClasses,
        getDeviceType
      };
    };
  }
});

// src/components/RichEditor/components/FormulaDialog.tsx
function FormulaDialog({
  open,
  onClose,
  onInsert,
  onGenerateWithAI
}) {
  const { isTablet } = useMobile();
  const [category, setCategory] = (0, import_react9.useState)("matematica");
  const [latex, setLatex] = (0, import_react9.useState)("");
  const [preview, setPreview] = (0, import_react9.useState)("");
  const [error, setError] = (0, import_react9.useState)("");
  const [aiDescription, setAiDescription] = (0, import_react9.useState)("");
  const [isGeneratingAI, setIsGeneratingAI] = (0, import_react9.useState)(false);
  const [aiError, setAiError] = (0, import_react9.useState)("");
  (0, import_react9.useEffect)(() => {
    if (!latex.trim()) {
      setPreview("");
      setError("");
      return;
    }
    try {
      const rendered = import_katex2.default.renderToString(latex, {
        throwOnError: true,
        displayMode: false
      });
      setPreview(rendered);
      setError("");
    } catch {
      setError("F\xF3rmula inv\xE1lida");
      setPreview("");
    }
  }, [latex]);
  const handleInsert = () => {
    if (!latex.trim() || error) return;
    onInsert(latex);
    resetState();
  };
  const handleClose = () => {
    resetState();
    onClose();
  };
  const resetState = () => {
    setLatex("");
    setError("");
    setPreview("");
    setAiDescription("");
    setAiError("");
    setCategory("matematica");
  };
  const handleGenerateWithAI = async () => {
    if (!onGenerateWithAI || !aiDescription.trim()) return;
    setIsGeneratingAI(true);
    setAiError("");
    try {
      const generatedLatex = await onGenerateWithAI(aiDescription.trim());
      setLatex(generatedLatex);
    } catch (err) {
      setAiError(
        err instanceof Error ? err.message : "Erro ao gerar f\xF3rmula com IA"
      );
    } finally {
      setIsGeneratingAI(false);
    }
  };
  const selectFormula = (formula) => {
    setLatex(formula.latex);
  };
  const renderPreview = () => {
    if (error) {
      return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-sm text-error-600", children: error });
    }
    if (preview) {
      return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
        "span",
        {
          dangerouslySetInnerHTML: { __html: preview },
          className: "text-lg"
        }
      );
    }
    return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-sm text-text-300 text-center", children: "Selecione uma f\xF3rmula ou s\xEDmbolo, insira o c\xF3digo LaTeX, ou crie sua f\xF3rmula com a IA e ela aparecer\xE1 aqui." });
  };
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
    Modal_default,
    {
      isOpen: open,
      onClose: handleClose,
      title: "Inserir f\xF3rmula",
      size: "xl",
      className: isTablet ? "max-w-[90vw] max-h-[90vh] overflow-y-auto" : "",
      footer: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
        /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
          Button_default,
          {
            variant: "outline",
            size: isTablet ? "extra-small" : "medium",
            onClick: handleClose,
            children: "Cancelar"
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
          Button_default,
          {
            variant: "solid",
            action: "primary",
            size: isTablet ? "extra-small" : "medium",
            onClick: handleInsert,
            disabled: !latex.trim() || !!error,
            children: "Inserir f\xF3rmula"
          }
        )
      ] }),
      children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: isTablet ? "flex flex-col gap-6" : "flex gap-6", children: [
        /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex-1", children: [
          /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text_default, { size: "sm", weight: "bold", className: "text-text-900 mb-4", children: "F\xF3rmulas e s\xEDmbolos mais usados" }),
          /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
            Menu_default,
            {
              defaultValue: "matematica",
              value: category,
              onValueChange: (value) => setCategory(value),
              variant: "menu2",
              className: "mb-4",
              children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(MenuContent, { variant: "menu2", children: Object.entries(categoryLabels).map(([key, label]) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(MenuItem, { value: key, variant: "menu2", children: label }, key)) })
            }
          ),
          /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
            "div",
            {
              className: `grid ${isTablet ? "grid-cols-1" : "grid-cols-2 max-h-[300px] overflow-y-auto pr-2"} gap-3`,
              children: formulas[category].map((formula) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
                Button_default,
                {
                  type: "button",
                  onClick: () => selectFormula(formula),
                  className: `bg-transparent flex flex-col items-start p-3 text-left border rounded-lg hover:border-primary-400 hover:bg-primary-50 transition-colors ${latex === formula.latex ? "border-primary-500" : "border-border-200"}`,
                  children: [
                    /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text_default, { weight: "medium", className: "text-sm text-text-900 mb-1", children: formula.label }),
                    /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text_default, { size: "xs", className: "text-text-500 font-mono", children: formula.preview })
                  ]
                },
                formula.label
              ))
            }
          )
        ] }),
        /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex-1", children: [
          /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text_default, { size: "sm", weight: "bold", className: "text-text-900 mb-4", children: "Crie sua f\xF3rmula" }),
          /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "mb-4", children: [
            /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text_default, { weight: "medium", className: "text-xs text-text-600 mb-2", children: "F\xF3rmula gerada" }),
            /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "min-h-[80px] border border-border-200 rounded-lg px-4 py-3 bg-background-50 flex items-center justify-center", children: renderPreview() })
          ] }),
          /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "mb-4", children: [
            /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text_default, { weight: "medium", className: "text-xs text-text-600 mb-2 block", children: "Digite o c\xF3digo LaTeX" }),
            /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
              Input_default,
              {
                type: "text",
                value: latex,
                onChange: (e) => setLatex(e.target.value),
                placeholder: String.raw`Ex: \sqrt{x^2 + y^2} ou \frac{a}{b}`
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Text_default, { className: "text-xs text-text-400 mt-1", children: [
              "Use sintaxe LaTeX:",
              " ",
              String.raw`\sqrt{}, \frac{}{}, ^{}, _{}, \pi, \alpha`,
              ", etc."
            ] })
          ] }),
          /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center gap-3 my-4", children: [
            /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex-1 h-px bg-border-200" }),
            /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "text-xs text-text-400", children: "Ou" }),
            /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex-1 h-px bg-border-200" })
          ] }),
          /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "mb-4", children: [
            /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center gap-1 mb-2", children: [
              /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_phosphor_react5.Sparkle, { size: 14, className: "text-primary-600" }),
              /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text_default, { className: "text-xs font-medium text-text-600", children: "Descreva o que deseja criar com IA" })
            ] }),
            /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
              TextArea_default,
              {
                value: aiDescription,
                onChange: (e) => setAiDescription(e.target.value),
                placeholder: "Ex: \xE1rea do c\xEDrculo, bhaskara, velocidade m\xE9dia...",
                rows: 2,
                disabled: isGeneratingAI
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text_default, { size: "xs", className: "text-text-400 mt-1", children: onGenerateWithAI ? "Descreva em linguagem natural e a IA gerar\xE1 o LaTeX correspondente." : "Funcionalidade de IA n\xE3o dispon\xEDvel." }),
            aiError && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text_default, { size: "xs", className: "text-error-600 mt-1", children: aiError }),
            /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
              Button_default,
              {
                variant: "outline",
                size: "small",
                disabled: !onGenerateWithAI || !aiDescription.trim() || isGeneratingAI,
                onClick: handleGenerateWithAI,
                className: "mt-2 ml-auto flex items-center gap-1",
                children: [
                  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_phosphor_react5.Sparkle, { size: 14 }),
                  isGeneratingAI ? "Gerando..." : "Gerar f\xF3rmula"
                ]
              }
            )
          ] })
        ] })
      ] })
    }
  );
}
var import_react9, import_phosphor_react5, import_katex2, import_katex_min, import_jsx_runtime8, formulas, categoryLabels;
var init_FormulaDialog = __esm({
  "src/components/RichEditor/components/FormulaDialog.tsx"() {
    "use strict";
    import_react9 = require("react");
    init_Button();
    init_Input();
    init_Menu();
    init_Modal();
    init_Text();
    init_TextArea();
    import_phosphor_react5 = require("phosphor-react");
    init_useMobile();
    import_katex2 = __toESM(require("katex"));
    import_katex_min = require("katex/dist/katex.min.css");
    import_jsx_runtime8 = require("react/jsx-runtime");
    formulas = {
      matematica: [
        {
          label: "Teorema de Pit\xE1goras",
          latex: "a^2 + b^2 = c^2",
          preview: "a\xB2 + b\xB2 = c\xB2"
        },
        {
          label: "Equa\xE7\xE3o de 2\xBA grau",
          latex: String.raw`x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}`,
          preview: "x = (-b \xB1 \u221A(b\xB2 - 4ac)) / 2a"
        },
        {
          label: "\xC1rea do c\xEDrculo",
          latex: String.raw`A = \pi r^2`,
          preview: "A = \u03C0r\xB2"
        },
        {
          label: "\xC1rea do tri\xE2ngulo",
          latex: String.raw`A = \frac{b \cdot h}{2}`,
          preview: "A = (b \xB7 h) / 2"
        },
        {
          label: "Volume do cilindro",
          latex: String.raw`V = \pi r^2 h`,
          preview: "V = \u03C0r\xB2h"
        },
        {
          label: "Volume da esfera",
          latex: String.raw`V = \frac{4}{3} \pi r^3`,
          preview: "V = (4/3)\u03C0r\xB3"
        }
      ],
      fisica: [
        {
          label: "Velocidade m\xE9dia",
          latex: String.raw`v = \frac{\Delta s}{\Delta t}`,
          preview: "v = \u0394s / \u0394t"
        },
        {
          label: "Acelera\xE7\xE3o",
          latex: String.raw`a = \frac{\Delta v}{\Delta t}`,
          preview: "a = \u0394v / \u0394t"
        },
        {
          label: "For\xE7a (2\xAA Lei de Newton)",
          latex: String.raw`F = m \cdot a`,
          preview: "F = m \xB7 a"
        },
        {
          label: "Energia cin\xE9tica",
          latex: String.raw`E_c = \frac{1}{2} m v^2`,
          preview: "Ec = \xBDmv\xB2"
        },
        {
          label: "Energia potencial",
          latex: String.raw`E_p = m \cdot g \cdot h`,
          preview: "Ep = m \xB7 g \xB7 h"
        },
        {
          label: "Lei da Gravita\xE7\xE3o",
          latex: String.raw`F = G \frac{m_1 m_2}{r^2}`,
          preview: "F = G(m\u2081m\u2082)/r\xB2"
        }
      ],
      quimica: [
        {
          label: "Concentra\xE7\xE3o molar",
          latex: String.raw`C = \frac{n}{V}`,
          preview: "C = n / V"
        },
        {
          label: "Densidade",
          latex: String.raw`\rho = \frac{m}{V}`,
          preview: "\u03C1 = m / V"
        },
        {
          label: "pH",
          latex: String.raw`pH = -\log[H^+]`,
          preview: "pH = -log[H\u207A]"
        },
        { label: "Lei dos gases ideais", latex: "PV = nRT", preview: "PV = nRT" },
        {
          label: "Equa\xE7\xE3o de Arrhenius",
          latex: String.raw`k = A e^{-\frac{E_a}{RT}}`,
          preview: "k = Ae^(-Ea/RT)"
        },
        {
          label: "N\xFAmero de mols",
          latex: String.raw`n = \frac{m}{M}`,
          preview: "n = m / M"
        }
      ],
      simbolos: [
        { label: "Alfa", latex: String.raw`\alpha`, preview: "\u03B1" },
        { label: "Beta", latex: String.raw`\beta`, preview: "\u03B2" },
        { label: "Gama", latex: String.raw`\gamma`, preview: "\u03B3" },
        { label: "Delta", latex: String.raw`\Delta`, preview: "\u0394" },
        { label: "Pi", latex: String.raw`\pi`, preview: "\u03C0" },
        { label: "Sigma", latex: String.raw`\sigma`, preview: "\u03C3" },
        { label: "Omega", latex: String.raw`\omega`, preview: "\u03C9" },
        { label: "Infinito", latex: String.raw`\infty`, preview: "\u221E" },
        { label: "Somat\xF3rio", latex: String.raw`\sum`, preview: "\u03A3" },
        { label: "Integral", latex: String.raw`\int`, preview: "\u222B" },
        { label: "Raiz quadrada", latex: String.raw`\sqrt{}`, preview: "\u221A" },
        { label: "Fra\xE7\xE3o", latex: String.raw`\frac{}{}`, preview: "a/b" }
      ]
    };
    categoryLabels = {
      matematica: "Matem\xE1tica",
      fisica: "F\xEDsica",
      quimica: "Qu\xEDmica",
      simbolos: "S\xEDmbolos"
    };
  }
});

// src/components/RichEditor/RichEditorCore.tsx
var RichEditorCore_exports = {};
__export(RichEditorCore_exports, {
  RichEditor: () => RichEditor
});
function RichEditor({
  content,
  onChange,
  placeholder = "Digite aqui...",
  onGenerateLatexWithAI
}) {
  const [formulaOpen, setFormulaOpen] = (0, import_react11.useState)(false);
  const isExternalUpdateRef = (0, import_react11.useRef)(false);
  const lastContentRef = (0, import_react11.useRef)(content);
  const editor = (0, import_react10.useEditor)({
    extensions: [
      import_starter_kit.default,
      import_extension_underline.default,
      import_extension_text_style.TextStyle,
      import_extension_color.Color,
      import_extension_highlight.default.configure({ multicolor: true }),
      import_extension_subscript.default,
      import_extension_superscript.default,
      import_extension_text_align.default.configure({ types: ["heading", "paragraph"] }),
      import_extension_link.default.configure({ openOnClick: false }),
      import_extension_placeholder.default.configure({ placeholder }),
      MathNode
    ],
    content: processLatexInHtml(content || ""),
    onUpdate: ({ editor: editor2 }) => {
      if (isExternalUpdateRef.current) {
        isExternalUpdateRef.current = false;
        return;
      }
      const html = editor2.getHTML();
      lastContentRef.current = html;
      onChange?.({
        json: editor2.getJSON(),
        html
      });
    },
    editorProps: {
      attributes: {
        class: "min-h-[120px] outline-none prose prose-sm max-w-none px-4 py-3 focus:outline-none"
      }
    }
  });
  (0, import_react11.useEffect)(() => {
    if (editor && content !== void 0 && content !== lastContentRef.current) {
      const processedContent = processLatexInHtml(content || "");
      editor.commands.setContent(processedContent, { emitUpdate: false });
      lastContentRef.current = content;
    }
  }, [content, editor]);
  const insertFormula = (latex) => {
    if (!latex || !editor) return;
    editor.chain().focus().insertContent({
      type: "mathInline",
      attrs: { latex }
    }).run();
    setFormulaOpen(false);
  };
  const setLink = () => {
    const url = globalThis.window.prompt("URL do link:");
    if (url === null || !editor) return;
    if (url === "") {
      editor.chain().focus().extendMarkRange("link").unsetLink().run();
      return;
    }
    editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
  };
  if (!editor) return null;
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "border border-border-200 rounded-xl overflow-hidden bg-background-0", children: [
    /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-0.5 border-b border-border-200 bg-background-50 px-2 py-1.5 flex-wrap", children: [
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
        ToolbarBtn,
        {
          onClick: () => editor.chain().focus().toggleHeading({ level: 1 }).run(),
          active: editor.isActive("heading", { level: 1 }),
          title: "T\xEDtulo 1",
          children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_phosphor_react6.TextHOne, { size: 16, weight: "bold" })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
        ToolbarBtn,
        {
          onClick: () => editor.chain().focus().toggleHeading({ level: 2 }).run(),
          active: editor.isActive("heading", { level: 2 }),
          title: "T\xEDtulo 2",
          children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_phosphor_react6.TextHTwo, { size: 16, weight: "bold" })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
        ToolbarBtn,
        {
          onClick: () => editor.chain().focus().toggleHeading({ level: 3 }).run(),
          active: editor.isActive("heading", { level: 3 }),
          title: "T\xEDtulo 3",
          children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_phosphor_react6.TextHThree, { size: 16, weight: "bold" })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Divider, {}),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
        ToolbarBtn,
        {
          onClick: () => editor.chain().focus().toggleBold().run(),
          active: editor.isActive("bold"),
          title: "Negrito (Ctrl+B)",
          children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_phosphor_react6.TextBolder, { size: 16, weight: "bold" })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
        ToolbarBtn,
        {
          onClick: () => editor.chain().focus().toggleItalic().run(),
          active: editor.isActive("italic"),
          title: "It\xE1lico (Ctrl+I)",
          children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_phosphor_react6.TextItalic, { size: 16 })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
        ToolbarBtn,
        {
          onClick: () => editor.chain().focus().toggleUnderline().run(),
          active: editor.isActive("underline"),
          title: "Sublinhado (Ctrl+U)",
          children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_phosphor_react6.TextUnderline, { size: 16 })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
        ToolbarBtn,
        {
          onClick: () => editor.chain().focus().toggleStrike().run(),
          active: editor.isActive("strike"),
          title: "Tachado",
          children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_phosphor_react6.TextStrikethrough, { size: 16 })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
        ToolbarBtn,
        {
          onClick: () => editor.chain().focus().toggleSubscript().run(),
          active: editor.isActive("subscript"),
          title: "Subscrito",
          children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-xs font-medium", children: [
            "X",
            /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("sub", { className: "text-[8px]", children: "2" })
          ] })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
        ToolbarBtn,
        {
          onClick: () => editor.chain().focus().toggleSuperscript().run(),
          active: editor.isActive("superscript"),
          title: "Sobrescrito",
          children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-xs font-medium", children: [
            "X",
            /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("sup", { className: "text-[8px]", children: "2" })
          ] })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
        ToolbarBtn,
        {
          onClick: () => editor.chain().focus().toggleCode().run(),
          active: editor.isActive("code"),
          title: "C\xF3digo inline",
          children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_phosphor_react6.Code, { size: 16 })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Divider, {}),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
        ToolbarBtn,
        {
          onClick: () => editor.chain().focus().setTextAlign("left").run(),
          active: editor.isActive({ textAlign: "left" }),
          title: "Alinhar \xE0 esquerda",
          children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_phosphor_react6.TextAlignLeft, { size: 16 })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
        ToolbarBtn,
        {
          onClick: () => editor.chain().focus().setTextAlign("center").run(),
          active: editor.isActive({ textAlign: "center" }),
          title: "Centralizar",
          children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_phosphor_react6.TextAlignCenter, { size: 16 })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
        ToolbarBtn,
        {
          onClick: () => editor.chain().focus().setTextAlign("right").run(),
          active: editor.isActive({ textAlign: "right" }),
          title: "Alinhar \xE0 direita",
          children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_phosphor_react6.TextAlignRight, { size: 16 })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
        ToolbarBtn,
        {
          onClick: () => editor.chain().focus().setTextAlign("justify").run(),
          active: editor.isActive({ textAlign: "justify" }),
          title: "Justificar",
          children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_phosphor_react6.TextAlignJustify, { size: 16 })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Divider, {}),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
        ToolbarBtn,
        {
          onClick: () => editor.chain().focus().toggleBulletList().run(),
          active: editor.isActive("bulletList"),
          title: "Lista com marcadores",
          children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_phosphor_react6.ListBullets, { size: 16 })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
        ToolbarBtn,
        {
          onClick: () => editor.chain().focus().toggleOrderedList().run(),
          active: editor.isActive("orderedList"),
          title: "Lista numerada",
          children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_phosphor_react6.ListNumbers, { size: 16 })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
        ToolbarBtn,
        {
          onClick: () => editor.chain().focus().toggleBlockquote().run(),
          active: editor.isActive("blockquote"),
          title: "Cita\xE7\xE3o",
          children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_phosphor_react6.Quotes, { size: 16 })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
        ToolbarBtn,
        {
          onClick: () => editor.chain().focus().setHorizontalRule().run(),
          active: false,
          title: "Linha horizontal",
          children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_phosphor_react6.Minus, { size: 16 })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Divider, {}),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
        ToolbarBtn,
        {
          onClick: setLink,
          active: editor.isActive("link"),
          title: "Inserir link",
          children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_phosphor_react6.Link, { size: 16 })
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
        Button_default,
        {
          type: "button",
          onClick: () => setFormulaOpen(true),
          title: "Inserir f\xF3rmula LaTeX",
          size: "extra-small",
          variant: "link",
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_phosphor_react6.MathOperations, { size: 16 }),
            "LaTeX"
          ]
        }
      )
    ] }),
    /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react10.EditorContent, { editor }),
    /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "border-t border-border-200 px-4 py-2 bg-background-50", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Text_default, { size: "xs", color: "text-text-400", children: [
      "Dica: use",
      " ",
      /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("code", { className: "bg-background-200 px-1 rounded", children: "$f\xF3rmula$" }),
      " para inserir LaTeX inline diretamente."
    ] }) }),
    /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
      FormulaDialog,
      {
        open: formulaOpen,
        onClose: () => setFormulaOpen(false),
        onInsert: insertFormula,
        onGenerateWithAI: onGenerateLatexWithAI
      }
    )
  ] });
}
var import_react10, import_starter_kit, import_extension_underline, import_extension_text_align, import_extension_color, import_extension_text_style, import_extension_highlight, import_extension_subscript, import_extension_superscript, import_extension_link, import_extension_placeholder, import_katex_min2, import_phosphor_react6, import_react11, import_jsx_runtime9, ToolbarBtn, Divider;
var init_RichEditorCore = __esm({
  "src/components/RichEditor/RichEditorCore.tsx"() {
    "use strict";
    import_react10 = require("@tiptap/react");
    import_starter_kit = __toESM(require("@tiptap/starter-kit"));
    import_extension_underline = __toESM(require("@tiptap/extension-underline"));
    import_extension_text_align = __toESM(require("@tiptap/extension-text-align"));
    import_extension_color = require("@tiptap/extension-color");
    import_extension_text_style = require("@tiptap/extension-text-style");
    import_extension_highlight = __toESM(require("@tiptap/extension-highlight"));
    import_extension_subscript = __toESM(require("@tiptap/extension-subscript"));
    import_extension_superscript = __toESM(require("@tiptap/extension-superscript"));
    import_extension_link = __toESM(require("@tiptap/extension-link"));
    import_extension_placeholder = __toESM(require("@tiptap/extension-placeholder"));
    init_MathNode();
    init_utils();
    import_katex_min2 = require("katex/dist/katex.min.css");
    import_phosphor_react6 = require("phosphor-react");
    import_react11 = require("react");
    init_FormulaDialog();
    init_Button();
    init_Text();
    import_jsx_runtime9 = require("react/jsx-runtime");
    ToolbarBtn = ({ onClick, active, title, children }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
      Button_default,
      {
        type: "button",
        onClick,
        title,
        size: "small",
        className: `bg-transparent border-transparent h-7 w-7 p-0 flex items-center justify-center rounded hover:bg-background-100 ${active ? "bg-background-200 text-primary-700" : "text-text-700"}`,
        children
      }
    );
    Divider = () => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "w-px h-5 bg-border-200 mx-0.5" });
  }
});

// src/components/RichEditor/index.ts
var RichEditor_exports = {};
__export(RichEditor_exports, {
  FormulaDialog: () => FormulaDialog,
  RichEditor: () => RichEditor2,
  processLatexInHtml: () => processLatexInHtml,
  unprocessLatexInHtml: () => unprocessLatexInHtml
});
module.exports = __toCommonJS(RichEditor_exports);

// src/components/RichEditor/RichEditor.tsx
var import_react12 = require("react");
var import_jsx_runtime10 = require("react/jsx-runtime");
var RichEditorCore = (0, import_react12.lazy)(
  () => Promise.resolve().then(() => (init_RichEditorCore(), RichEditorCore_exports)).then((module2) => ({
    default: module2.RichEditor
  }))
);
var RichEditorErrorBoundary = class extends import_react12.Component {
  constructor(props) {
    super(props);
    this.state = { hasError: false, error: null };
  }
  static getDerivedStateFromError(error) {
    return { hasError: true, error };
  }
  render() {
    if (this.state.hasError && this.state.error) {
      return this.props.fallback(this.state.error);
    }
    return this.props.children;
  }
};
var TIPTAP_DEPENDENCIES = [
  "@tiptap/react",
  "@tiptap/core",
  "@tiptap/starter-kit",
  "@tiptap/extension-underline",
  "@tiptap/extension-text-align",
  "@tiptap/extension-color",
  "@tiptap/extension-text-style",
  "@tiptap/extension-highlight",
  "@tiptap/extension-subscript",
  "@tiptap/extension-superscript",
  "@tiptap/extension-link",
  "@tiptap/extension-placeholder"
];
function MissingDependenciesError({ error }) {
  const isTiptapError = error.message.includes("@tiptap") || error.message.includes("Cannot find module '@tiptap");
  const installCommand = `yarn add ${TIPTAP_DEPENDENCIES.join(" ")}`;
  const npmCommand = `npm install ${TIPTAP_DEPENDENCIES.join(" ")}`;
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "border border-red-200 rounded-xl overflow-hidden bg-red-50 p-6", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-start gap-3", children: [
    /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "shrink-0 w-10 h-10 bg-red-100 rounded-full flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
      "svg",
      {
        className: "w-5 h-5 text-red-600",
        fill: "none",
        viewBox: "0 0 24 24",
        stroke: "currentColor",
        children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
          "path",
          {
            strokeLinecap: "round",
            strokeLinejoin: "round",
            strokeWidth: 2,
            d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
          }
        )
      }
    ) }),
    /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex-1", children: [
      /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h3", { className: "text-lg font-semibold text-red-800 mb-2", children: isTiptapError ? "Depend\xEAncias do TipTap n\xE3o encontradas" : "Erro ao carregar o RichEditor" }),
      /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "text-red-700 text-sm mb-4", children: isTiptapError ? "O componente RichEditor requer as depend\xEAncias do TipTap para funcionar. Instale-as executando um dos comandos abaixo:" : error.message }),
      isTiptapError && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "space-y-3", children: [
        /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { children: [
          /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "text-xs text-red-600 font-medium mb-1", children: "Usando Yarn:" }),
          /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("code", { className: "block bg-red-100 text-red-800 px-3 py-2 rounded text-xs font-mono overflow-x-auto", children: installCommand })
        ] }),
        /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { children: [
          /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "text-xs text-red-600 font-medium mb-1", children: "Usando NPM:" }),
          /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("code", { className: "block bg-red-100 text-red-800 px-3 py-2 rounded text-xs font-mono overflow-x-auto", children: npmCommand })
        ] })
      ] })
    ] })
  ] }) });
}
function LoadingFallback() {
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "border border-border-200 rounded-xl overflow-hidden bg-background-0 animate-pulse", children: [
    /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "h-10 bg-background-100 border-b border-border-200" }),
    /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "h-32 bg-background-50" }),
    /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "h-8 bg-background-100 border-t border-border-200" })
  ] });
}
function RichEditor2(props) {
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RichEditorErrorBoundary, { fallback: MissingDependenciesErrorFallback, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react12.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(LoadingFallback, {}), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RichEditorCore, { ...props }) }) });
}
function MissingDependenciesErrorFallback(error) {
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(MissingDependenciesError, { error });
}

// src/components/RichEditor/index.ts
init_FormulaDialog();
init_utils();
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  FormulaDialog,
  RichEditor,
  processLatexInHtml,
  unprocessLatexInHtml
});
//# sourceMappingURL=index.js.map