import {
	Archive,
	ArrowDownToLine,
	ArrowUpFromLine,
	BadgeCheck,
	ChartPie,
	Database,
	FileSearch,
	FileText,
	Frame,
	GalleryVerticalEnd,
	Hash,
	LayoutDashboard,
	Package,
	Settings2,
	Shield,
	Ship,
	Truck,
	Users,
} from '@lucide/svelte';
import * as m from "$lib/paraglide/messages.js";
import { Title } from '../ui/alert';

export interface NavItem {
	title: string;
	url: string;
}

export interface NavMainItem {
	title: string;
	url: string;
	icon: any;
	isActive?: boolean;
	items?: NavItem[];
}

export interface Project {
	name: string;
	url: string;
	icon: any;
}

export interface Team {
	name: string;
	logo: any;
	plan: string;
}

export interface User {
	name: string;
	email: string;
	avatar: string;
}

export interface SidebarData {
	user: User;
	teams: Team[];
	navMain: NavMainItem[];
	projects: Project[];
}

// Función que retorna los datos del sidebar con traducciones
export function getSidebarData(): SidebarData {
	return {
		user: {
			name: "", // Se llena dinámicamente desde Keycloak
			email: "", // Se llena dinámicamente desde Keycloak
			avatar: "", // Se llena dinámicamente desde Keycloak
		},
		teams: [
			{
				name: "Anexo76",
				logo: GalleryVerticalEnd,
				plan: "Enterprise",
			},
		],
		navMain: [
			{
				title: "Dashboard",
				url: "/dashboard",
				icon: LayoutDashboard,
				items: [],
			},
			{
				title: m["sidebar.audit_logs"](),
				url: "/dashboard/audit_logs",
				icon: Shield,
				items: [],
			},

			{
				title: m["sidebar.reference_data.title"](),
				url: "/dashboard",
				icon: Database,
				items: [
					{
						title: m["sidebar.reference_data.codes_pedimento_regimen"](),
						url: "/dashboard/reference_data/code_pedimento_regimens",
					},
					{
						title: m["sidebar.reference_data.containers"](),
						url: "/dashboard/reference_data/containers",
					},
					{
						title: m["sidebar.reference_data.countries"](),
						url: "/dashboard/reference_data/countries",
					},
					{
						title: m["sidebar.reference_data.currency_types"](),
						url: "/dashboard/reference_data/currency_types",
					},
					{
						title: m["sidebar.reference_data.customs_sections"](),
						url: "/dashboard/reference_data/customs_sections",
					},
					{
						title: m["sidebar.reference_data.customs_warehouses"](),
						url: "/dashboard/reference_data/customs_warehouses",
					},
					{
						title: m["sidebar.reference_data.incoterms"](),
						url: "/dashboard/reference_data/incoterms",
					},
					{
						title: m["sidebar.reference_data.invoice_types"](),
						url: "/dashboard/reference_data/invoice_types",
					},
					{
						title: m["sidebar.reference_data.material_types"](),
						url: "/dashboard/reference_data/material_types",
					},
					{
						title: m["sidebar.reference_data.payment_methods"](),
						url: "/dashboard/reference_data/payment_methods",
					},
					{
						title: m["sidebar.reference_data.pedimento_codes"](),
						url: "/dashboard/reference_data/pedimento_codes",
					},
					{
						title: m["sidebar.reference_data.pedimento_regimes"](),
						url: "/dashboard/reference_data/pedimento_regimens",
					},
					{
						title: m["sidebar.reference_data.sectors"](),
						url: "/dashboard/reference_data/sectors",
					},
					{
						title: m["sidebar.reference_data.states"](),
						url: "/dashboard/reference_data/states",
					},
					{
						title: m["sidebar.reference_data.transportation_modes"](),
						url: "/dashboard/reference_data/transport_modes",
					},
					{
						title: m["sidebar.reference_data.transportation_types"](),
						url: "/dashboard/reference_data/transport_types",
					},
					{
						title: m["sidebar.reference_data.valuation_methods"](),
						url: "/dashboard/reference_data/valuation_methods",
					},
				],
				isActive: false,
			},
			{
				title: m["sidebar.general_catalogs.title"](),
				url: "#",
				icon: Package,
				items: [
					{
						title: m["sidebar.general_catalogs.company_information"](),
						url: "/dashboard/general_catalogs/company_information",
					},
					{
						title: m["sidebar.general_catalogs.packages"](),
						url: "/dashboard/general_catalogs/packages",
					},
					{
						title: m["sidebar.general_catalogs.concepts"](),
						url: "/dashboard/general_catalogs/concepts",
					},
					{
						title: "Conceptos de Agente Aduanal",
						url: "/dashboard/general_catalogs/customs_broker_concepts",
					},
					{
						title: m["sidebar.general_catalogs.classification"](),
						url: "/dashboard/general_catalogs/classification_concepts",
					},
					{
						title: m["sidebar.general_catalogs.identifiers"](),
						url: "/dashboard/general_catalogs/identifiers",
					},
					// -------------------------------------
					{
						title: m["sidebar.general_catalogs.incoterms"](),
						url: "/dashboard/reference_data/incoterms",
					},
					{
						title: m["sidebar.general_catalogs.inpc"](),
						url: "/dashboard/general_catalogs/inpc",
					},
					{
						title: m["sidebar.general_catalogs.fixed_legends"](),
						url: "/dashboard/general_catalogs/legends",
					},
					{
						title: m["sidebar.general_catalogs.seals"](),
						url: "/dashboard/general_catalogs/seal",
					},
					{
						title: m["sidebar.general_catalogs.valuation_methods"](),
						url: "/dashboard/reference_data/valuation_methods",
					},
					{
						title: m["sidebar.general_catalogs.countries"](),
						url: "/dashboard/reference_data/countries",
					},
					{
						title: m["sidebar.general_catalogs.ports"](),
						url: "/dashboard/general_catalogs/ports",
					},
					{
						title: m["sidebar.general_catalogs.unit_measures"](),
						url: "/dashboard/general_catalogs/units_of_measure/general",
					},
					{
						title: m["sidebar.general_catalogs.um_customs_mex"](),
						url: "/dashboard/general_catalogs/units_of_measure/customs",
					},
					{
						title: m["sidebar.general_catalogs.um_customs_ame"](),
						url: "/dashboard/general_catalogs/units_of_measure/american",
					},
					{
						title: m["sidebar.general_catalogs.um_ace"](),
						url: "/dashboard/general_catalogs/units_of_measure/ace",
					},
					{
						title: m["sidebar.general_catalogs.um_oma"](),
						url: "/dashboard/general_catalogs/units_of_measure/oma",
					},
					{
						title: m["sidebar.general_catalogs.conversions"](),
						url: "/dashboard/general_catalogs/unit_conversions",
					},
					{
						title: m["sidebar.general_catalogs.equivalences"](),
						url: "/dashboard/general_catalogs/equivalencies",
					},
					{
						title: m["sidebar.general_catalogs.exchange_rates"](),
						url: "/dashboard/general_catalogs/exchange-rate",
					},
					{
						title: m["sidebar.general_catalogs.currency_types"](),
						url: "/dashboard/reference_data/currency_types",
					},
					{
						title: m["sidebar.general_catalogs.multi_currency"](),
						url: "/dashboard/general_catalogs/multi_currency_types",
					},
					{
						title: m["sidebar.general_catalogs.invoice_types"](),
						url: "/dashboard/reference_data/invoice_types",
					},
					{
						title: m["sidebar.general_catalogs.electronic_signatures"](),
						url: "/dashboard/general_catalogs/signatures",
					},
					{
						title: m["sidebar.general_catalogs.billing_errors"](),
						url: "/dashboard/general_catalogs/error_catalogs",
					},
					{
						title: m["sidebar.general_catalogs.customs_warehouses"](),
						url: "/dashboard/reference_data/customs_warehouses",
					},
					{
						title: m["sidebar.general_catalogs.doda"](),
						url: "/dashboard/general_catalogs/doda",
					},
					{
						title: m["sidebar.general_catalogs.prevalidators"](),
						url: "/dashboard/general_catalogs/prevalidators",
					},
					{
						title: m["sidebar.general_catalogs.electronic_notices"](),
						url: "/dashboard/general_catalogs/electronic_notices",
					},
					{
						title: m["sidebar.general_catalogs.crossing_notice"](),
						url: "#",
					},
				],
			},
			{
				title: m["sidebar.fractions.title"](),
				url: "#",
				icon: Hash,
				items: [
					{
						title: m["sidebar.fractions.sitar"](),
						url: "/dashboard/general_catalogs/tariff-fractions/sitar",
					},
					{
						title: m["sidebar.fractions.sitar_seventh_amendment"](),
						url: "/dashboard/general_catalogs/tariff-fractions/seventh-amendment",
					},
					{
						title: m["sidebar.fractions.sitar_us"](),
						url: "/dashboard/general_catalogs/tariff-fractions/us",
					},
					{
						title: m["sidebar.fractions.american"](),
						url: "/dashboard/general_catalogs/tariff-fractions/american",
					},
					{
						title: m["sidebar.fractions.canadian"](),
						url: "/dashboard/general_catalogs/tariff-fractions/canadian",
					},
					{
						title: m["sidebar.fractions.historical"](),
						url: "/dashboard/general_catalogs/tariff-fractions/historical",
					},
					{
						title: m["sidebar.fractions.sectors"](),
						url: "/dashboard/general_catalogs/sectors",
					},
				],
			},
			{
				title: "Transportes",
				url: "#",
				icon: Truck,
				items: [
					{
						title: "Transportistas",
						url: "/dashboard/general_catalogs/transporters",
					},
					{
						title: "Conductores",
						url: "/dashboard/general_catalogs/drivers",
					},
					{
						title: "Trailers",
						url: "/dashboard/general_catalogs/trailers",
					},
					{
						title: "Vehículos",
						url: "/dashboard/general_catalogs/vehicles",
					},
				],
			},
			{
				title: m["sidebar.goods.title"](),
				url: "#",
				icon: Archive,
				items: [
					{
						title: m["sidebar.goods.classes"](),
						url: "/dashboard/goods/fixed-asset-classes",
					},
					{
						title: m["sidebar.goods.parts"](),
						url: "/dashboard/goods/parts",
					},
					{
						title: m["sidebar.goods.fda_codes"](),
						url: "/dashboard/goods/fda-codes",
					}
				],
			},
			{
				title: m["sidebar.pedimentos.title"](),
				url: "#",
				icon: FileText,
				items: [
					{
						title: m["sidebar.pedimentos.pedimento_management"](),
						url: "/dashboard/pedimentos",
					},
					{
						title: m["sidebar.pedimentos.pedimento_codes"](),
						url: "/dashboard/reference_data/pedimento_codes",
					},
					{
						title: m["sidebar.pedimentos.customs_regimes"](),
						url: "/dashboard/reference_data/pedimento_regimens",
					},
					{
						title: m["sidebar.pedimentos.payment_methods"](),
						url: "/dashboard/reference_data/payment_methods",
					},
					{
						title: m["sidebar.pedimentos.customs_sections"](),
						url: "/dashboard/reference_data/customs_sections",
					},
					{
						title: m["sidebar.pedimentos.anexo_22_app_31"](),
						url: "#",
					},
				],
			},
			{
				title: m["sidebar.import_invoices.title"](),
				url: "#",
				icon: ArrowDownToLine,
				items: [
					{
						title: m["sidebar.import_invoices.temporary"](),
						url: "/dashboard/invoices?operation_type=imp&invoice_type=TEM"
					},
					{
						title: m["sidebar.import_invoices.definitive"](),
						url: "/dashboard/invoices?operation_type=imp&invoice_type=DEF",
					},
					{
						title: m["sidebar.import_invoices.mexican_purchases"](),
						url: "/dashboard/invoices?operation_type=imp&invoice_type=MEX",
					},
					{
						title: m["sidebar.import_invoices.regime_change"](),
						url: "/dashboard/invoices?operation_type=imp&invoice_type=CR",
					},
					{
						title: m["sidebar.import_invoices.repair"](),
						url: "/dashboard/invoices?operation_type=imp&invoice_type=REP",
					}
				],
			},
			{
				title: m["sidebar.export_invoices.title"](),
				url: "#",
				icon: ArrowUpFromLine,
				items: [
					{
						title: m["sidebar.export_invoices.exportation"](),
						url: "/dashboard/invoices?operation_type=exp",
					},
					{
						title: m["sidebar.export_invoices.repair"](),
						url: "/dashboard/invoices?operation_type=exp&invoice_type=REPAR",
					},
				],
			},
			{
				title: m["sidebar.export.title"](),
				url: "#",
				icon: Ship,
				items: [
					{
						title: m["sidebar.export.catalog"](),
						url: "/dashboard/export/catalog",
					},
					{
						title: m["sidebar.export.repair"](),
						url: "/dashboard/export/repair",
					},
					{
						title: m["sidebar.export.manifest"](),
						url: "/dashboard/export/manifest",
					},
					{
						title: m["sidebar.export.proforma"](),
						url: "/dashboard/export/proforma",
					},
					{
						title: m["sidebar.export.reports"](),
						url: "/dashboard/export/reports",
					},
					{
						title: m["sidebar.export.used_materials"](),
						url: "/dashboard/export/used-materials",
					},
					{
						title: m["sidebar.export.destruction"](),
						url: "/dashboard/export/destruction",
					},
					{
						title: m["sidebar.export.special_processes"](),
						url: "/dashboard/export/special-processes",
					},
				],
			},

			{
				title: m["sidebar.clients_and_providers"](),
				url: "/dashboard/clients_and_providers",
				icon: Users,
				items: [],
			},
			{
				title: m["sidebar.customs_brokers"](),
				url: "/dashboard/customs_brokers",
				icon: BadgeCheck,
				items: [],
			},
			{
				title: "Reportes",
				url: "#",
				icon: FileSearch,
				items: [
					{
						title: "Facturas Impo/Expo",
						url: "/dashboard/reports/invoices",
					},
				],
			},
			{
				title: m["sidebar.reference_data.configuracion"](),
				url: "#",
				icon: Settings2,
				items: [
					{
						title: m["sidebar.reference_data.usuarios"](),
						url: "",
					},
				],
			},
		],
		projects: [
			{
				name: m["sidebar.reference_data.usuarios"](),
				url: "/dashboard/users",
				icon: Users,
			},
			{
				name: m["sidebar.reference_data.licencia"](),
				url: "#",
				icon: BadgeCheck,
			},
			{
				name: m["sidebar.reference_data.configuracion"](),
				url: "#",
				icon: Settings2,
			},
			{
				name: m["sidebar.reference_data.ayuda"](),
				url: "/dashboard/help-center",
				icon: Frame,
			},
		],
	};
}

// Exportar también como constante para compatibilidad (deprecado)
export const sidebarData: SidebarData = getSidebarData();