export {};

declare global {
    // Types for props
    interface Category {
        id: number;
        name: string;
        parent_id?: number | null;
        children?: Category[];
    }

    interface Brand {
        id: number;
        name: string;
    }

    interface Unit {
        id: number;
        name: string;
    }

    interface Discount {
        id: number;
        name: string;
    }

    interface Tax {
        id: number;
        name: string;
        rate: number;
        type?: string;
    }

    interface PageProps {
        categories?: Category[];
        brands?: Brand[];
        units?: Unit[];
        discounts?: Discount[];
        taxes?: Tax[];
        product_branches?: {
            id: number;
            title: string;
            description?: string;
            is_default: boolean;
            status: number;
        }[];
        product_channels?: {
            id: number;
            name: string;
            description?: string;
            is_default: boolean;
            status: number;
        }[];
        variant_types?: {
            id: number;
            title: string;
            description?: string;
            options: {
                id: number;
                name: string;
                sort_order: number;
            }[];
        }[];
    }

    // Section Card Component
    interface SectionCardProps {
        title: string;
        icon: React.ReactNode;
        children: React.ReactNode;
    }
    interface SectionCardWithSwitchProps {
        title: string;
        icon: React.ReactNode;
        children: React.ReactNode;
        checked: boolean;
        onCheckedChange: (checked: boolean) => void;
    }
    type Branch = {
        id: number;
        title: string;
        description?: string;
        is_default: boolean;
        status: number;
    };

    type VariantType = {
        id: number;
        title: string;
        description?: string;
        options: {
            id: number;
            name: string;
            sort_order: number;
        }[];
    };

    interface PricingManagerProps {
        branchesConfig?: Branch[];
        channelsConfig?: ProductChannel[];
        variantTypes?: VariantType[];
        taxes?: Array<{ id: number; name: string; rate: number; type?: string }>;
        onChange?: (pricingData: any) => void;
        initialProduct?: any;
        setChannelPrices?: (prices: any) => void;
        setVariantsChannelPrices?: (prices: any) => void;
    }

    type ProductChannel = {
        id: number;
        name: string;
        description?: string;
        is_default: boolean;
        status: number;
    };
    type ProductOption = {
        id: number;
        name: string;
        values: string[];
        isPredefined?: boolean;
    };

    type Variant = {
        id: number;
        title: string;
        sku: string;
    };
    interface RetailOnlyPricingSectionProps {
        hasVariants: boolean;
        variants: Variant[];
        options: ProductOption[];
        simpleRetailPrice: string;
        onSimpleRetailChange: (value: string) => void;
        simpleCostPrice: string;
        onSimpleCostChange: (value: string) => void;
        variantRetailPrices: Record<number, string>;
        onVariantRetailChange: (variantId: number, value: string) => void;
        variantWholesalePrices: Record<number, string>;
        onVariantWholesaleChange: (variantId: number, value: string) => void;
        variantCostPrices: Record<number, string>;
        onVariantCostChange: (variantId: number, value: string) => void;
        channelsConfig?: Array<{
            id: number;
            name: string;
            description?: string;
            is_default: boolean;
            status: number;
        }>;
        setChannelPrices?: (prices: any) => void;
        setVariantsChannelPrices?: (prices: any) => void;
    }

    // ─── Grouped view sub-component ──────────────────────────────────────────────

    interface GroupedRetailViewProps {
        options: ProductOption[];
        variants: Variant[];
        variantRetailPrices: Record<number, string>;
        onVariantRetailChange: (variantId: number, value: string) => void;
        variantWholesalePrices: Record<number, string>;
        onVariantWholesaleChange: (variantId: number, value: string) => void;
        variantCostPrices: Record<number, string>;
        onVariantCostChange: (variantId: number, value: string) => void;
        copiedRetail: string | null;
        onCopy: (value: string, source: string) => void;
        onPaste: (variantId: number) => void;
        onVariantDetailsClick: (variant: Variant) => void;
        register: any;
        groupByOptionId?: number;
    }
}
