UNPKG

analytica-frontend-lib

Version:

Repositório público dos componentes utilizados nas plataformas da Analytica Ensino

853 lines (836 loc) 31.1 kB
import { DEFAULT_COMPARATOR_LABELS, DEFAULT_COMPARATOR_TABS } from "./chunk-ZDQTP6K3.mjs"; import { SearchSelect_default } from "./chunk-HZDLDWBN.mjs"; import { SkeletonCard } from "./chunk-NKVUUWCA.mjs"; import { Badge_default } from "./chunk-OEW3ST4F.mjs"; import { Modal_default } from "./chunk-TNLGS7SB.mjs"; import { Button_default } from "./chunk-LAYB7IKW.mjs"; import { Text_default } from "./chunk-IMCIR6TJ.mjs"; // src/components/ComparatorChart/ComparatorView.tsx import { useState as useState2, useMemo, useCallback, useEffect, useRef } from "react"; import { CaretLeftIcon } from "@phosphor-icons/react/dist/csr/CaretLeft"; // src/components/ComparatorChart/ComparatorEmptyState.tsx import { PlusIcon } from "@phosphor-icons/react/dist/csr/Plus"; import { jsx, jsxs } from "react/jsx-runtime"; function ComparatorEmptyState({ onSelectClick, canCompareSchools, canCompareSchoolYears, isLoading = false, labels: customLabels }) { const labels = { ...DEFAULT_COMPARATOR_LABELS, ...customLabels }; const hasAnyOption = canCompareSchools || canCompareSchoolYears; const getButtonText = () => { if (canCompareSchools && canCompareSchoolYears) { return labels.selectComparison; } if (canCompareSchools) { return labels.selectSchools; } return labels.selectSchoolYears; }; const getDescriptionText = () => { if (canCompareSchools && canCompareSchoolYears) { return labels.emptyStateDescriptionBoth; } if (canCompareSchools) { return labels.emptyStateDescriptionSchools; } if (canCompareSchoolYears) { return labels.emptyStateDescriptionSchoolYears; } return labels.noAccessMessage; }; const buttonText = getButtonText(); const descriptionText = getDescriptionText(); return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center h-full gap-6", children: [ /* @__PURE__ */ jsx("div", { className: "w-24 h-24 rounded-full bg-primary-100 flex items-center justify-center", children: /* @__PURE__ */ jsx( "svg", { className: "w-12 h-12 text-primary-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx( "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" } ) } ) }), /* @__PURE__ */ jsxs("div", { className: "text-center", children: [ /* @__PURE__ */ jsx(Text_default, { size: "lg", weight: "semibold", className: "text-text-950 mb-2", children: labels.title }), /* @__PURE__ */ jsx(Text_default, { size: "sm", className: "text-text-500", children: descriptionText }) ] }), hasAnyOption && /* @__PURE__ */ jsxs( Button_default, { variant: "outline", action: "primary", size: "medium", onClick: onSelectClick, disabled: isLoading, children: [ /* @__PURE__ */ jsx(PlusIcon, { size: 18 }), buttonText ] } ) ] }); } // src/components/ComparatorChart/ComparatorLoadingState.tsx import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime"; function ComparatorLoadingState() { return /* @__PURE__ */ jsxs2( "div", { className: "flex flex-col gap-6", "data-testid": "comparator-loading-skeleton", children: [ /* @__PURE__ */ jsx2(SkeletonCard, { className: "h-12 w-full" }), /* @__PURE__ */ jsx2(SkeletonCard, { className: "h-64 w-full" }), /* @__PURE__ */ jsx2(SkeletonCard, { className: "h-64 w-full" }) ] } ); } // src/components/ComparatorChart/ComparatorSelectTypeStep.tsx import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime"; function ComparatorSelectTypeStep({ onSelectType, canCompareSchools, canCompareSchoolYears, labels: customLabels }) { const labels = { ...DEFAULT_COMPARATOR_LABELS, ...customLabels }; if (!canCompareSchools && !canCompareSchoolYears) { return /* @__PURE__ */ jsx3("div", { className: "flex flex-col gap-4", children: /* @__PURE__ */ jsx3(Text_default, { size: "sm", className: "text-text-600", children: labels.noAccessMessage }) }); } return /* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-4", children: [ /* @__PURE__ */ jsx3(Text_default, { size: "sm", className: "text-text-600", children: labels.selectComparisonType }), /* @__PURE__ */ jsxs3("div", { className: "flex gap-4", children: [ canCompareSchools && /* @__PURE__ */ jsxs3( Button_default, { variant: "raw", onClick: () => onSelectType("school"), className: "flex-1 p-4 border border-border-200 rounded-xl hover:border-primary-500 hover:bg-primary-50 transition-colors text-left", children: [ /* @__PURE__ */ jsx3(Text_default, { size: "md", weight: "semibold", className: "text-text-950", children: labels.schools }), /* @__PURE__ */ jsx3(Text_default, { size: "sm", className: "text-text-500", children: labels.compareSchoolsDescription }) ] } ), canCompareSchoolYears && /* @__PURE__ */ jsxs3( Button_default, { variant: "raw", onClick: () => onSelectType("schoolYear"), className: "flex-1 p-4 border border-border-200 rounded-xl hover:border-primary-500 hover:bg-primary-50 transition-colors text-left", children: [ /* @__PURE__ */ jsx3(Text_default, { size: "md", weight: "semibold", className: "text-text-950", children: labels.schoolYears }), /* @__PURE__ */ jsx3(Text_default, { size: "sm", className: "text-text-500", children: labels.compareSchoolYearsDescription }) ] } ) ] }) ] }); } // src/components/ComparatorChart/ComparatorSelectItemsStep.tsx import { XIcon } from "@phosphor-icons/react/dist/csr/X"; import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime"; function ComparatorSelectItemsStep({ options, selectedItems, onSelectItem, onRemoveItem, comparisonType, labels: customLabels }) { const labels = { ...DEFAULT_COMPARATOR_LABELS, ...customLabels }; const isMaxReached = selectedItems.length >= 5; const placeholder = comparisonType === "school" ? labels.schools : labels.schoolYears; const itemTypeName = comparisonType === "school" ? labels.schools.toLowerCase() : labels.schoolYears.toLowerCase(); const singularItemTypeName = comparisonType === "school" ? labels.school : labels.schoolYear; return /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-4", children: [ /* @__PURE__ */ jsx4(Text_default, { size: "sm", className: "text-text-600", children: labels.selectItemInstruction.replace("{item}", singularItemTypeName) }), /* @__PURE__ */ jsx4( SearchSelect_default, { options, placeholder, searchPlaceholder: `${labels.search} ${placeholder.toLowerCase()}...`, onValueChange: onSelectItem, disabled: isMaxReached, emptyText: "Nenhum resultado encontrado", size: "medium", variant: "outlined" } ), selectedItems.length > 0 && /* @__PURE__ */ jsx4("div", { className: "flex flex-wrap gap-2 p-3 bg-secondary-50 rounded-xl border border-border-100", children: selectedItems.map((item) => /* @__PURE__ */ jsxs4( Badge_default, { variant: "outlined", action: "info", size: "medium", className: "flex items-center gap-1 pr-1", children: [ /* @__PURE__ */ jsx4( "span", { className: "w-2 h-2 rounded-full mr-1", style: { backgroundColor: item.color } } ), /* @__PURE__ */ jsx4("span", { className: "truncate max-w-[200px]", children: item.name }), /* @__PURE__ */ jsx4( Button_default, { variant: "raw", onClick: () => onRemoveItem(item.id), className: "ml-1 p-0.5 rounded-full hover:bg-secondary-200 transition-colors", "aria-label": `Remover ${item.name}`, children: /* @__PURE__ */ jsx4(XIcon, { size: 14 }) } ) ] }, item.id )) }), isMaxReached && /* @__PURE__ */ jsx4(Text_default, { size: "xs", className: "text-warning-600", children: labels.maxLimitWarning }), /* @__PURE__ */ jsxs4(Text_default, { size: "xs", className: "text-text-500", children: [ selectedItems.length, " de 5 ", itemTypeName, " ", labels.ofSelected ] }) ] }); } // src/components/ComparatorChart/Legend.tsx import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime"; function Legend({ items }) { return /* @__PURE__ */ jsx5("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ jsx5("div", { className: "flex flex-wrap gap-4 items-center", children: items.map((item) => /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2", children: [ /* @__PURE__ */ jsx5( "div", { className: "w-3 h-3 rounded-full", style: { backgroundColor: item.color } } ), /* @__PURE__ */ jsx5(Text_default, { size: "sm", className: "text-text-700", children: item.name }) ] }, item.id)) }) }); } // src/components/ComparatorChart/PercentageScale.tsx import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime"; function PercentageScale() { return /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-4 mb-2 border-b border-border-100 pb-2", children: [ /* @__PURE__ */ jsx6("div", { className: "w-64 shrink-0" }), /* @__PURE__ */ jsxs6("div", { className: "flex-1 flex justify-between px-1", children: [ /* @__PURE__ */ jsx6(Text_default, { size: "xs", className: "text-text-400", children: "0%" }), /* @__PURE__ */ jsx6(Text_default, { size: "xs", className: "text-text-400", children: "25%" }), /* @__PURE__ */ jsx6(Text_default, { size: "xs", className: "text-text-400", children: "50%" }), /* @__PURE__ */ jsx6(Text_default, { size: "xs", className: "text-text-400", children: "75%" }), /* @__PURE__ */ jsx6(Text_default, { size: "xs", className: "text-text-400", children: "100%" }) ] }) ] }); } // src/components/ComparatorChart/ChartArea.tsx import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime"; function ChartArea({ children }) { return /* @__PURE__ */ jsxs7("div", { className: "relative", children: [ /* @__PURE__ */ jsxs7("div", { className: "absolute inset-0 flex items-stretch pointer-events-none gap-4", children: [ /* @__PURE__ */ jsx7("div", { className: "w-64 shrink-0" }), /* @__PURE__ */ jsxs7("div", { className: "flex-1 flex", children: [ /* @__PURE__ */ jsx7("div", { className: "w-1/4 border-r border-dashed border-border-200" }), /* @__PURE__ */ jsx7("div", { className: "w-1/4 border-r border-dashed border-border-200" }), /* @__PURE__ */ jsx7("div", { className: "w-1/4 border-r border-dashed border-border-200" }), /* @__PURE__ */ jsx7("div", { className: "w-1/4" }) ] }) ] }), /* @__PURE__ */ jsx7("div", { className: "relative space-y-6", children }) ] }); } // src/components/ComparatorChart/BarChartRow.tsx import { useState } from "react"; import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime"; function BarChartRow({ label, values, items }) { const [hoveredItem, setHoveredItem] = useState(null); return /* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-4", children: [ /* @__PURE__ */ jsx8(Text_default, { size: "sm", className: "text-text-700 w-64 shrink-0", children: label }), /* @__PURE__ */ jsx8("div", { className: "flex-1 space-y-1.5", children: items.map((item) => { const value = values.find((v) => v.itemId === item.id); const percentage = value?.percentage ?? 0; const clampedPercentage = Math.max(0, Math.min(percentage, 100)); const isHovered = hoveredItem === item.id; return /* @__PURE__ */ jsxs8( "div", { className: "relative group", onMouseEnter: () => setHoveredItem(item.id), onMouseLeave: () => setHoveredItem(null), children: [ /* @__PURE__ */ jsx8("div", { className: "flex-1 h-5 bg-secondary-100 rounded-full overflow-hidden relative", children: /* @__PURE__ */ jsx8( "div", { className: `h-full rounded-full transition-all duration-500 ${isHovered ? "opacity-90" : ""}`, style: { width: `${clampedPercentage}%`, backgroundColor: item.color, minWidth: clampedPercentage > 0 ? "8px" : "0px" } } ) }), isHovered && /* @__PURE__ */ jsxs8( "div", { className: "absolute z-10 px-2 py-1 bg-text-900 rounded shadow-lg whitespace-nowrap", style: { left: `${Math.min(Math.max(percentage, 5), 95)}%`, top: "-28px", transform: "translateX(-50%)" }, children: [ /* @__PURE__ */ jsxs8(Text_default, { size: "xs", weight: "medium", className: "text-white", children: [ item.name, ": ", percentage.toFixed(1), "%" ] }), /* @__PURE__ */ jsx8( "div", { className: "absolute w-2 h-2 bg-text-900 rotate-45", style: { left: "50%", bottom: "-4px", transform: "translateX(-50%)" } } ) ] } ) ] }, item.id ); }) }) ] }); } // src/components/ComparatorChart/KnowledgeAreasContent.tsx import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime"; function KnowledgeAreasContent({ data, items, title = "Profici\xEAncia m\xE9dia das escolas por \xE1rea do Enem" }) { return /* @__PURE__ */ jsxs9("div", { className: "bg-secondary-50 rounded-2xl p-6", children: [ /* @__PURE__ */ jsxs9("div", { className: "mb-6", children: [ /* @__PURE__ */ jsx9(Text_default, { size: "md", weight: "semibold", className: "text-text-950 mb-4", children: title }), /* @__PURE__ */ jsx9(Legend, { items }) ] }), /* @__PURE__ */ jsx9(PercentageScale, {}), /* @__PURE__ */ jsx9(ChartArea, { children: data.map((area) => /* @__PURE__ */ jsx9( BarChartRow, { label: area.area, values: area.values, items }, area.area )) }) ] }); } // src/components/ComparatorChart/CurricularComponentsContent.tsx import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime"; function CurricularComponentsContent({ data, items, title = "Profici\xEAncia m\xE9dia por componente curricular" }) { return /* @__PURE__ */ jsxs10("div", { className: "bg-secondary-50 rounded-2xl p-6", children: [ /* @__PURE__ */ jsxs10("div", { className: "mb-6", children: [ /* @__PURE__ */ jsx10(Text_default, { size: "md", weight: "semibold", className: "text-text-950 mb-4", children: title }), /* @__PURE__ */ jsx10(Legend, { items }) ] }), /* @__PURE__ */ jsx10(PercentageScale, {}), /* @__PURE__ */ jsx10(ChartArea, { children: data.map((component) => /* @__PURE__ */ jsx10( BarChartRow, { label: component.component, values: component.values, items }, component.component )) }) ] }); } // src/components/ComparatorChart/CompetenciesContent.tsx import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime"; function CompetenciesContent({ data, items, title = "Profici\xEAncia m\xE9dia por compet\xEAncia" }) { return /* @__PURE__ */ jsxs11("div", { className: "bg-secondary-50 rounded-2xl p-6", children: [ /* @__PURE__ */ jsxs11("div", { className: "mb-6", children: [ /* @__PURE__ */ jsx11(Text_default, { size: "md", weight: "semibold", className: "text-text-950 mb-4", children: title }), /* @__PURE__ */ jsx11(Legend, { items }) ] }), /* @__PURE__ */ jsx11(PercentageScale, {}), /* @__PURE__ */ jsx11(ChartArea, { children: data.map((competency) => /* @__PURE__ */ jsx11( BarChartRow, { label: competency.competency, values: competency.values, items }, competency.competency )) }) ] }); } // src/components/ComparatorChart/NationalAverageCard.tsx import { jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime"; var DETAIL_LABELS = [ { key: "languages", label: "LINGUAGENS, C\xD3DIGOS E SUAS TECNOLOGIAS" }, { key: "humanities", label: "CI\xCANCIAS HUMANAS E SUAS TECNOLOGIAS" }, { key: "essay", label: "REDA\xC7\xC3O" }, { key: "naturalSciences", label: "CI\xCANCIAS DA NATUREZA E SUAS TECNOLOGIAS" }, { key: "mathematics", label: "MATEM\xC1TICA E SUAS TECNOLOGIAS" } ]; function NationalAverageCard({ data, color, labels: customLabels }) { const labels = { ...DEFAULT_COMPARATOR_LABELS, ...customLabels }; return /* @__PURE__ */ jsxs12("div", { className: "bg-secondary-50 rounded-2xl p-6", children: [ /* @__PURE__ */ jsx12(Text_default, { size: "md", weight: "semibold", className: "text-text-950 mb-4", children: data.itemName }), /* @__PURE__ */ jsxs12("div", { className: "grid grid-cols-3 gap-4 mb-6", children: [ /* @__PURE__ */ jsxs12( "div", { className: "bg-background rounded-xl p-4 text-center border-l-4", style: { borderColor: color }, children: [ /* @__PURE__ */ jsx12(Text_default, { size: "2xl", weight: "bold", className: "text-primary-700", children: data.simulatedProficiency.toFixed(1) }), /* @__PURE__ */ jsx12(Text_default, { size: "xs", className: "text-text-500 uppercase", children: labels.simulatedProficiency }) ] } ), /* @__PURE__ */ jsxs12("div", { className: "bg-warning-50 rounded-xl p-4 text-center", children: [ /* @__PURE__ */ jsx12(Text_default, { size: "2xl", weight: "bold", className: "text-warning-700", children: data.publicAverage }), /* @__PURE__ */ jsx12(Text_default, { size: "xs", className: "text-text-500 uppercase", children: labels.publicSchoolAverage }) ] }), /* @__PURE__ */ jsxs12("div", { className: "bg-success-50 rounded-xl p-4 text-center", children: [ /* @__PURE__ */ jsx12(Text_default, { size: "2xl", weight: "bold", className: "text-success-700", children: data.privateAverage }), /* @__PURE__ */ jsx12(Text_default, { size: "xs", className: "text-text-500 uppercase", children: labels.privateSchoolAverage }) ] }) ] }), /* @__PURE__ */ jsx12("div", { className: "grid grid-cols-5 gap-4 mb-4", children: DETAIL_LABELS.map(({ key, label }) => /* @__PURE__ */ jsxs12("div", { className: "bg-background rounded-xl p-3 text-center", children: [ /* @__PURE__ */ jsx12( Text_default, { size: "xs", className: "text-text-500 uppercase mb-1 line-clamp-2", children: label } ), /* @__PURE__ */ jsx12(Text_default, { size: "lg", weight: "bold", className: "text-primary-700", children: data.details[key] }) ] }, key)) }), /* @__PURE__ */ jsx12( Badge_default, { variant: "solid", action: data.status === "above" ? "success" : "warning", size: "medium", className: "w-full justify-center py-3", children: data.status === "above" ? labels.aboveAverage : labels.belowAverage } ) ] }); } // src/components/ComparatorChart/NationalAveragesContent.tsx import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime"; function NationalAveragesContent({ data, items, title, labels: customLabels }) { const labels = { ...DEFAULT_COMPARATOR_LABELS, ...customLabels }; return /* @__PURE__ */ jsxs13("div", { className: "space-y-6", children: [ /* @__PURE__ */ jsx13(Text_default, { size: "md", weight: "semibold", className: "text-text-950", children: title || labels.nationalAveragesTitle }), data.map((item) => { const selectedItem = items.find((i) => i.id === item.itemId); return /* @__PURE__ */ jsx13( NationalAverageCard, { data: item, color: selectedItem?.color, labels }, item.itemId ); }) ] }); } // src/components/ComparatorChart/ComparatorTabContent.tsx import { jsx as jsx14 } from "react/jsx-runtime"; function ComparatorTabContent({ activeTab, data, selectedItems, labels }) { switch (activeTab) { case "knowledge-areas" /* KNOWLEDGE_AREAS */: return /* @__PURE__ */ jsx14( KnowledgeAreasContent, { data: data.knowledgeAreas, items: selectedItems, title: labels?.knowledgeAreasTitle } ); case "curricular-components" /* CURRICULAR_COMPONENTS */: return /* @__PURE__ */ jsx14( CurricularComponentsContent, { data: data.curricularComponents, items: selectedItems, title: labels?.curricularComponentsTitle } ); case "competencies" /* COMPETENCIES */: return /* @__PURE__ */ jsx14( CompetenciesContent, { data: data.competencies, items: selectedItems, title: labels?.competenciesTitle } ); case "national-averages" /* NATIONAL_AVERAGES */: return /* @__PURE__ */ jsx14( NationalAveragesContent, { data: data.nationalAverages, items: selectedItems, title: labels?.nationalAveragesTitle, labels } ); default: return null; } } // src/components/ComparatorChart/ComparatorView.tsx import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime"; function ComparatorView({ schools, schoolYears, useComparatorStore, useComparator, onBack, activeTab: externalActiveTab, onTabChange, tabs = DEFAULT_COMPARATOR_TABS, labels: customLabels, isUserLoading = false, onFetchUserData }) { const labels = useMemo( () => ({ ...DEFAULT_COMPARATOR_LABELS, ...customLabels }), [customLabels] ); const { comparisonType, selectedItems, setComparisonType, addItem, removeItem, clearSelection } = useComparatorStore(); const { data, loading, fetchData } = useComparator(); const [isModalOpen, setIsModalOpen] = useState2(false); const [modalStep, setModalStep] = useState2(1); const [internalActiveTab, setInternalActiveTab] = useState2( "knowledge-areas" /* KNOWLEDGE_AREAS */ ); const hasInitializedRef = useRef(false); const activeTab = externalActiveTab ?? internalActiveTab; const canCompareSchools = schools.length > 1; const canCompareSchoolYears = schoolYears.length > 1; const hasAnyComparisonOption = canCompareSchools || canCompareSchoolYears; useEffect(() => { onFetchUserData?.(true); }, [onFetchUserData]); useEffect(() => { if (hasInitializedRef.current) return; if (selectedItems.length > 0 && comparisonType) { hasInitializedRef.current = true; fetchData( selectedItems.map((i) => i.id), comparisonType, activeTab ); } }, [selectedItems, comparisonType, activeTab, fetchData]); const options = useMemo(() => { if (comparisonType === "school") return schools; if (comparisonType === "schoolYear") return schoolYears; return []; }, [comparisonType, schools, schoolYears]); const availableOptions = useMemo(() => { return options.filter( (opt) => !selectedItems.some((item) => item.id === opt.value) ); }, [options, selectedItems]); const handleTabChange = useCallback( (tab) => { if (onTabChange) { onTabChange(tab); } else { setInternalActiveTab(tab); } if (selectedItems.length > 0 && comparisonType) { fetchData( selectedItems.map((i) => i.id), comparisonType, tab ); } }, [selectedItems, comparisonType, onTabChange, fetchData] ); const handleOpenModal = useCallback(() => { if (comparisonType) { setModalStep(2); setIsModalOpen(true); return; } if (canCompareSchools && !canCompareSchoolYears) { setComparisonType("school"); setModalStep(2); } else if (canCompareSchoolYears && !canCompareSchools) { setComparisonType("schoolYear"); setModalStep(2); } else { setModalStep(1); } setIsModalOpen(true); }, [ comparisonType, canCompareSchools, canCompareSchoolYears, setComparisonType ]); const handleSelectType = useCallback( (type) => { clearSelection(); setComparisonType(type); setModalStep(2); }, [clearSelection, setComparisonType] ); const handleSelectItem = useCallback( (value) => { if (selectedItems.length >= 5) return; const option = options.find((opt) => opt.value === value); if (!option) return; addItem({ id: option.value, name: option.label, color: "" }); }, [options, selectedItems.length, addItem] ); const handleRemoveItem = useCallback( (itemId) => { removeItem(itemId); }, [removeItem] ); const handleConfirmSelection = useCallback(() => { setIsModalOpen(false); if (selectedItems.length > 0 && comparisonType) { fetchData( selectedItems.map((i) => i.id), comparisonType, activeTab ); } }, [selectedItems, comparisonType, activeTab, fetchData]); const handleCloseModal = useCallback(() => { setIsModalOpen(false); }, []); const handleChangeType = useCallback(() => { setModalStep(1); clearSelection(); }, [clearSelection]); const buttonText = useMemo(() => { if (selectedItems.length > 0) { return comparisonType === "school" ? labels.selectSchools : labels.selectSchoolYears; } if (canCompareSchools && canCompareSchoolYears) { return labels.selectComparison; } return canCompareSchools ? labels.selectSchools : labels.selectSchoolYears; }, [ selectedItems.length, comparisonType, canCompareSchools, canCompareSchoolYears, labels ]); const renderMainContent = () => { if (selectedItems.length === 0) { return /* @__PURE__ */ jsx15( ComparatorEmptyState, { onSelectClick: handleOpenModal, canCompareSchools, canCompareSchoolYears, isLoading: isUserLoading, labels } ); } if (loading) { return /* @__PURE__ */ jsx15(ComparatorLoadingState, {}); } return /* @__PURE__ */ jsx15( ComparatorTabContent, { activeTab, data, selectedItems, labels } ); }; return /* @__PURE__ */ jsxs14("div", { className: "h-screen bg-background flex flex-col", children: [ /* @__PURE__ */ jsxs14("header", { className: "flex items-center justify-between px-6 py-4 border-b border-border-100 bg-secondary-50", children: [ onBack ? /* @__PURE__ */ jsxs14( Button_default, { variant: "raw", onClick: onBack, className: "flex items-center gap-2 text-text-950 hover:text-text-700 transition-colors", children: [ /* @__PURE__ */ jsx15(CaretLeftIcon, { size: 20, weight: "bold" }), /* @__PURE__ */ jsx15(Text_default, { size: "lg", weight: "semibold", children: labels.title }) ] } ) : /* @__PURE__ */ jsx15("div", { className: "flex items-center gap-2 text-text-950", children: /* @__PURE__ */ jsx15(Text_default, { size: "lg", weight: "semibold", children: labels.title }) }), /* @__PURE__ */ jsx15( Button_default, { variant: "solid", action: "primary", size: "medium", onClick: handleOpenModal, disabled: !hasAnyComparisonOption || isUserLoading, children: buttonText } ) ] }), /* @__PURE__ */ jsx15("div", { className: "flex gap-2 px-6 py-4 border-b border-border-100 bg-secondary-50", children: tabs.map((tab) => /* @__PURE__ */ jsx15( Button_default, { variant: "raw", onClick: () => handleTabChange(tab.value), className: `px-4 py-2 text-sm font-medium transition-colors ${activeTab === tab.value ? "text-primary-700 border-b-2 border-primary-600" : "text-text-500 hover:text-text-700"}`, children: tab.label }, tab.value )) }), /* @__PURE__ */ jsx15("main", { className: "flex-1 overflow-auto p-6", children: renderMainContent() }), /* @__PURE__ */ jsx15( Modal_default, { isOpen: isModalOpen, onClose: handleCloseModal, title: labels.filters, size: "md", footer: modalStep === 2 ? /* @__PURE__ */ jsxs14("div", { className: "flex justify-end gap-3 w-full", children: [ /* @__PURE__ */ jsx15(Button_default, { variant: "outline", onClick: handleChangeType, children: labels.back }), /* @__PURE__ */ jsxs14( Button_default, { variant: "solid", action: "primary", onClick: handleConfirmSelection, disabled: selectedItems.length === 0, children: [ labels.confirm, " (", selectedItems.length, "/5)" ] } ) ] }) : void 0, children: modalStep === 1 ? /* @__PURE__ */ jsx15( ComparatorSelectTypeStep, { onSelectType: handleSelectType, canCompareSchools, canCompareSchoolYears, labels } ) : /* @__PURE__ */ jsx15( ComparatorSelectItemsStep, { options: availableOptions, selectedItems, onSelectItem: handleSelectItem, onRemoveItem: handleRemoveItem, comparisonType, labels } ) } ) ] }); } export { Legend, PercentageScale, ChartArea, BarChartRow, KnowledgeAreasContent, CurricularComponentsContent, CompetenciesContent, NationalAverageCard, NationalAveragesContent, ComparatorEmptyState, ComparatorLoadingState, ComparatorSelectTypeStep, ComparatorSelectItemsStep, ComparatorTabContent, ComparatorView }; //# sourceMappingURL=chunk-F3AUWGLG.mjs.map