"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/hooks/useA11yKeyboardShortcut.ts
var useA11yKeyboardShortcut_exports = {};
__export(useA11yKeyboardShortcut_exports, {
  useA11yKeyboardShortcut: () => useA11yKeyboardShortcut
});
module.exports = __toCommonJS(useA11yKeyboardShortcut_exports);
var import_react = require("react");

// src/store/accessibilityStore.ts
var import_zustand = require("zustand");
var import_middleware = require("zustand/middleware");
var DEFAULT_ACCESSIBILITY_PREFERENCES = {
  contrastMode: "normal",
  saturationMode: "normal",
  fontSize: 0,
  letterSpacing: 0,
  lineSpacing: 0,
  highlightLinks: false,
  pauseAnimations: false,
  bigCursor: false,
  dyslexiaFont: false,
  readingAid: "none",
  keyboardShortcut: true,
  colorBlindMode: "none" /* None */,
  ttsMode: "off",
  ttsRate: 1,
  ttsVoiceId: null,
  librasEnabled: false
};
var useAccessibilityStore = (0, import_zustand.create)()(
  (0, import_middleware.devtools)(
    (0, import_middleware.persist)(
      (set) => ({
        ...DEFAULT_ACCESSIBILITY_PREFERENCES,
        isPanelOpen: false,
        ttsStatus: "idle",
        setContrastMode: (contrastMode) => set({ contrastMode }),
        setSaturationMode: (saturationMode) => set({ saturationMode }),
        setFontSize: (fontSize) => set({ fontSize }),
        setLetterSpacing: (letterSpacing) => set({ letterSpacing }),
        setLineSpacing: (lineSpacing) => set({ lineSpacing }),
        setHighlightLinks: (highlightLinks) => set({ highlightLinks }),
        setPauseAnimations: (pauseAnimations) => set({ pauseAnimations }),
        setBigCursor: (bigCursor) => set({ bigCursor }),
        setDyslexiaFont: (dyslexiaFont) => set({ dyslexiaFont }),
        setReadingAid: (readingAid) => set({ readingAid }),
        setKeyboardShortcut: (keyboardShortcut) => set({ keyboardShortcut }),
        setColorBlindMode: (colorBlindMode) => set({ colorBlindMode }),
        setTTSMode: (ttsMode) => set({ ttsMode }),
        setTTSRate: (ttsRate) => set({ ttsRate }),
        setTTSVoiceId: (ttsVoiceId) => set({ ttsVoiceId }),
        setTTSStatus: (ttsStatus) => set({ ttsStatus }),
        setLibrasEnabled: (librasEnabled) => set({ librasEnabled }),
        resetPreferences: () => set({ ...DEFAULT_ACCESSIBILITY_PREFERENCES }),
        openPanel: () => set({ isPanelOpen: true }),
        closePanel: () => set({ isPanelOpen: false }),
        togglePanel: () => set((state) => ({ isPanelOpen: !state.isPanelOpen }))
      }),
      {
        name: "accessibility-store",
        // version 1: removeu `librasEnabled` da persistência (era custoso
        // recarregar VLibras a cada refresh). A migração limpa esse valor
        // de localStorages antigos para evitar auto-load surpresa.
        version: 1,
        // eslint-disable-next-line @typescript-eslint/no-explicit-any -- migrate works with arbitrary persisted shapes from older versions
        migrate: (persistedState) => {
          if (persistedState && typeof persistedState === "object" && "librasEnabled" in persistedState) {
            delete persistedState.librasEnabled;
          }
          return persistedState;
        },
        partialize: (state) => ({
          contrastMode: state.contrastMode,
          saturationMode: state.saturationMode,
          fontSize: state.fontSize,
          letterSpacing: state.letterSpacing,
          lineSpacing: state.lineSpacing,
          highlightLinks: state.highlightLinks,
          pauseAnimations: state.pauseAnimations,
          bigCursor: state.bigCursor,
          dyslexiaFont: state.dyslexiaFont,
          readingAid: state.readingAid,
          keyboardShortcut: state.keyboardShortcut,
          colorBlindMode: state.colorBlindMode,
          ttsRate: state.ttsRate,
          ttsVoiceId: state.ttsVoiceId
          // ttsMode e librasEnabled NÃO são persistidos:
          // - ttsMode: o leitor sempre começa desligado ao recarregar
          //   a página para evitar comportamento confuso
          // - librasEnabled: o VLibras é pesado (~MBs de assets); auto-
          //   carregar a cada refresh seria custoso e surpreendente. O
          //   usuário ativa explicitamente quando precisa.
        })
      }
    ),
    { name: "accessibility-store" }
  )
);

// src/hooks/useA11yKeyboardShortcut.ts
var useA11yKeyboardShortcut = () => {
  const enabled = useAccessibilityStore((s) => s.keyboardShortcut);
  const togglePanel = useAccessibilityStore((s) => s.togglePanel);
  (0, import_react.useEffect)(() => {
    if (!enabled) return;
    const handler = (event) => {
      if (!event.altKey || event.key.toLowerCase() !== "a") return;
      if (event.repeat) return;
      const target = event.target;
      if (target) {
        const tag = target.tagName;
        if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT" || target.isContentEditable) {
          return;
        }
      }
      event.preventDefault();
      togglePanel();
    };
    globalThis.addEventListener("keydown", handler);
    return () => globalThis.removeEventListener("keydown", handler);
  }, [enabled, togglePanel]);
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  useA11yKeyboardShortcut
});
//# sourceMappingURL=index.js.map