import { PanzoomObject } from "@panzoom/panzoom";

export interface SeatAvailability {
    available: string[];
    unavailable: string[];
}

export interface Trim {
    coord: string[];
    enabled: string[];
    id: string[];
    image_path: string[];
    metadata: string[];
    text: string[];
    type: string[];
    target_seat_map_id: string[];
}

export interface State {
    priceOverallEur: string;
    priceOverall: string;
    cartChanged: boolean;
    selectedSeatsArr: string[][];
    selectedSeatsObj: StateJSCSelectedSeats;
    layoutRows: layoutRows;
    isValidSeatSelection: boolean;    
    seatmap: any;
    seatmapXML: any;
    panzoom: PanzoomObject | undefined;
    inVenueXML: VenueXML | undefined;
    inputsWithValue: InputsWithValue | undefined;
}

interface layoutRows {
    [key: string]: string[]
}

export interface StateJSCSelectedSeats {
    [key: string]: JSCSelectedSeat;
}

export interface Inputs {
    [key: string]: string;
}

export interface InputsWithValue {
    param1: number[];
    param2: string;
    param3: string;
    trxstate: string;
    etpgcode: string;
    is_ticket_exchange_request: string;
    prevtrxstate: string;
    user_context: string;
    target_trxstate: string;
    orgid: string;
    p_orgid: string;
    pid: string;
    supplier_code: string;
    inventory_filtering_action: string;
    inventory_month: string;
    inventory_year: string;
    upsell_selected: string;
    listing_type: string;
    invalid_seats: string;
    package_pids: string;
    mlbamsp: string;
    pay_pal_token: string;
    APPTE: string;
    schedule: string;
    secure_trxn_enabled: string;
    isCapEnabled: string;
    supplierCode: string;
    venueLocation: string;
    event: string;
    holdcode: string;
    posturl: string;
    posturlRaw: string;
    posturlRawDecoded: string;
    seatmapUrl: string;
    importantNote?: string;
    importantNoteEncoded?: string;
    venueImageSrc: string;
    venueImageHeight: number;
    venueImageWidth: number;
    ticketPurchaseUrl: string;
    smap: string | undefined;
}

export interface Config {
    debug: boolean;
    branch: "staging" | "master";
    version: string;
    childHasVenueXML: boolean;
    maxSelectedSeats: number;
    state: State;
    resources: Resources;
}

export interface Resources {
    "staging": ResourcesURL;
    "master": ResourcesURL;
}

export interface ResourcesURL {
    seatmap: string;
    JSC: string;
    CSSChild: string;    
    CSSJSC: string;
    CSSParent: string;
    CSSjQueryUI: string;
    CSSjBox: string;
}

export interface Message {
    message: any | VenueXML,
    event: string,
    date: number,
    from: string,
    callback?: CallableFunction,
}

// export interface EventInfo = Event & EventExtend;
export interface EventInfo extends Event, EventExtend {}

export interface EventExtend {
    venue_config_capacity: string[];
    venue_config_code: string[];
    venue_config_desc: string[];
    venue_config_id: string[];
    venue_config_nav_image: string[];
    venue_config_nav_image_height: string[];
    venue_config_nav_image_width: string[];
    start: string[];
    weekday: string[];
    seats_available: number;
}

// venueXML

export interface VenueXML {
    offer: Offer[];
    event: Event[];
    venue: Venue[];
    master_config: MasterConfig[];
    venue_config: VenueConfig[];
    pricescale_config: PricescaleConfig[];
    price_structure: PriceStructure[];
    seatmap_config: SeatmapConfig3[];
}
export interface Offer {
    id: string[];
    timestamp: string[];
}

export interface Event {
    id: string[];
    code: string[];
    desc: string[];
    public_desc: string[];
    year: string[];
    month: string[];
    day: string[];
    hour: string[];
    minute: string[];
    event_run_code: string[];
    event_run_desc: string[];
    event_run_public_desc: string[];
    timestamp: string[];
}

export type Pricescale2Properties = "code" | "color" | "desc" | "id" | "pricescale_group_id" | "text_color";

export interface Pricescale2 {
    code: string[];
    color: string[];
    desc: string[];
    id: string[];
    pricescale_group_id: string[];
    text_color: string[];
}

export interface Pricescale {
    pricescale: Pricescale2[];
}

export interface BuyerType2 {
    buyer_type_group_id: string[];
    code: string[];
    desc: string[];
    display_indicator: string[];
    id: string[];
}

export interface BuyerType {
    buyer_type: BuyerType2[];
}

export interface Venue {
    code: string[];
    desc: string[];
    id: string[];
    name: string[];
    timestamp: string[];
    pricescales: Pricescale[];
    extended_defs: string[];
    buyer_types: BuyerType[];
}

export interface Section {
    code: string[];
    desc: string[];
    type: string[];
    hover_coords: string[];
    id: string[];
}

export interface SectionConfig {
    section: Section[];
}

export interface Pricescale3 {
    id: string[];
    available: string[];
}

export interface Section2 {
    available: string[];
    capacity: string[];
    id: string[];
    max_contiguous: string[];
    pricescale: Pricescale3[];
}

export interface SectionInventory {
    as_of_date: string[];
    event_id: string[];
    holdcode_id: string[];
    section: Section2[];
}

export interface MasterConfig {
    capacity: string[];
    code: string[];
    desc: string[];
    id: string[];
    metadata: string[];
    nav_image: string[];
    nav_image_height: string[];
    nav_image_width: string[];
    orientation: string[];
    stage_desc: string[];
    timestamp: string[];
    section_config: SectionConfig[];
    section_inventory: SectionInventory[];
}

export interface SeatMapConfig {
    hidden_seat_map_ids: string[];
    id: string[];
}

export interface SectionConfig2 {
    hidden_section_ids: string[];
}

export interface VenueConfig {
    capacity: string[];
    code: string[];
    desc: string[];
    id: string[];
    nav_image: string[];
    nav_image_height: string[];
    nav_image_width: string[];
    timestamp: string[];
    seat_map_config: SeatMapConfig[];
    section_config: SectionConfig2[];
}

export interface Pricescale4 {
    id: string[];
}

export interface PricescaleConfig {
    code: string[];
    desc: string[];
    id: string[];
    nav_image: string[];
    nav_image_height: string[];
    nav_image_width: string[];
    timestamp: string[];
    pricescale: Pricescale4[];
}

export interface BuyerType3 {
    currency: string[];
    display_order: string[];
    id: string[];
    price: string[];
    all_in_price: string[];
}

export interface Pricescale5 {
    currency: string[];
    display_order: string[];
    id: string[];
    ref_price: string[];
    all_in_ref_price: string[];
    buyer_type: BuyerType3[];
}

export interface PriceStructure {
    code: string[];
    desc: string[];
    event_id: string[];
    id: string[];
    sales_type: string[];
    timestamp: string[];
    pricescale: Pricescale5[];
}

export interface Seatmap {
    code: string[];
    desc: string[];
    hotspot_coords: string[];
    id: string[];
}

export interface SeatmapConfig3 {
    code: string[];
    desc: string[];
    id: string[];
    timestamp: string[];
    seatmap: Seatmap[];
}

// layout
export interface LayoutRow2 {
    seats: string[];
    y_cell_coord: string[];
}

export interface LayoutRow {
    row: LayoutRow2[];
}

export interface SeatmapLayout {
    cell_coord: string[];
    code: string[];
    desc: string[];
    height: string[];
    id: string[];
    type: string[];
    width: string[];
    rows: LayoutRow[];
}

// pricescale
export interface SeatmapPricescale {
    currency: string[];
    display_order: string[];
    id: string[];
    mask: string[];
    ref_price: string[];
}

// seats object
export interface SeatsObj {
    currency: string[];
    display_order: string[];
    id: string[];
    mask: string[];
    ref_price: string[];
}

export interface JSCSeats2 {
    classes: string;
    seatsObj: SeatsObj;
}

export interface JSCSeats {
    [key: string]: JSCSeats2;
}

// legend object
export interface JSCLegend {
    node: JQuery<HTMLElement>;
    items: string[][];
}

// availability object
export interface JSCAvailability {
    available_selectable_mask: string[];
    unavailable_unselectable_mask: string[];
}

// JSC seatObj settings
export interface Data {
    classes: string;
    seatsObj: SeatsObj;
}

export interface Node {
    [key: number]: JQuery<Node>;
    length: number;
}

export interface JSCSelectedSeat {
    status: string;
    style: string;
    data: Data;
    id: string;
    label: string;
    row: number;
    column: number;
    character: string;
    $node: Node;
}

export interface VenueImage {
    venueImageSrc: string;
    venueImageHeight: number;
    venueImageWidth: number;
}

export interface ImportantNote {
    importantNote: string;
    importantNoteEncoded: string;
}

export interface TrimPos {
    x: number;
    y: number;
    xJSC: number;
    yJSC: number;
}

export type TypeBuyerType = (string | undefined)[][] | undefined;
export type TypeBuyerTypeArr = (string | undefined)[];
export type TypeWaitForElementSwitch = "selector" | "seatmap";
export type TypeInjectScript = HTMLLinkElement | HTMLScriptElement | HTMLStyleElement;
export type TypeConfigBranch = "staging" | "master";
export type TypeConfigResourcesProperty = keyof ResourcesURL;