Skip to content

Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️

54.4 KB
Raw Blame
/**
 * @todo - This file needs to be organized better. Split into multiple files.
 */
import {SupportedLocales} from "./locales.ts";
import type {DayOfWeek} from "@mantine/dates";

export type ConfigKeys = 
    | 'VITE_TURNSTILE_SITE_KEY'
    | 'VITE_API_URL_SERVER'
    | 'VITE_API_URL_CLIENT'
    | 'VITE_FRONTEND_URL'
    | 'VITE_APP_PRIMARY_COLOR'
    | 'VITE_APP_SECONDARY_COLOR'
    | 'VITE_APP_NAME'
    | 'VITE_APP_FAVICON'
    | 'VITE_APP_LOGO_DARK'
    | 'VITE_APP_LOGO_LIGHT'
    | 'VITE_CHATWOOT_BASE_URL'
    | 'VITE_CHATWOOT_WEBSITE_TOKEN'
    | 'VITE_HIDE_ABOUT_LINK'
    | 'VITE_TOS_URL'
    | 'VITE_PRIVACY_URL'
    | 'VITE_PLATFORM_SUPPORT_EMAIL'
    | 'VITE_STRIPE_PUBLISHABLE_KEY'
    | 'VITE_I_HAVE_PURCHASED_A_LICENCE'
    | 'VITE_DEFAULT_IMAGE_URL'
    | 'VITE_COOKIE_CONSENT_ENABLED'
    | 'VITE_COOKIE_CONSENT_TEXT'
    | 'VITE_COOKIE_CONSENT_DOMAIN'
    | 'VITE_GOOGLE_ADS_CONVERSION_ID'
    | 'VITE_GOOGLE_ADS_CONVERSION_LABELS';

export enum StripePlatform {
    Canada = 'ca',
    Ireland = 'ie',
}

export type IdParam = string | undefined | number;

export interface AcceptInvitationRequest {
    first_name: string;
    last_name: string;
    password: string;
    password_confirmation: string;
    marketing_opt_in?: boolean;
}

export interface RegisterAccountRequest extends AcceptInvitationRequest {
    email: string;
    locale: SupportedLocales;
    utm_source?: string | null;
    utm_medium?: string | null;
    utm_campaign?: string | null;
    utm_term?: string | null;
    utm_content?: string | null;
    referrer_url?: string | null;
    landing_page?: string | null;
    gclid?: string | null;
    fbclid?: string | null;
    utm_raw?: Record<string, string> | null;
    turnstile_token?: string;
}

export interface ResetPasswordRequest {
    password: string;
    password_confirmation: string;
}

export interface ColorTheme {
    name: string;
    homepage_background_color: string;
    homepage_content_background_color: string;
    homepage_primary_color: string;
    homepage_primary_text_color: string;
    homepage_secondary_color: string;
    homepage_secondary_text_color: string;
}

export type EventLayout = 'MARQUEE' | 'FLYER' | 'STORY' | 'INVITE';

export interface HomepageThemeSettings {
    accent: string;
    background: string;
    mode: 'light' | 'dark';
    background_type: 'COLOR' | 'MIRROR_COVER_IMAGE';
    font_family?: string;
    layout?: EventLayout;
}

export interface LoginResponse {
    token?: string | null;
    token_type: string;
    expires_in: number;
    user: User;
    accounts: Account[];
    two_factor_required?: boolean;
    two_factor_challenge_token?: string;
    two_factor_recovery_codes_remaining?: number;
}

export interface TwoFactorLoginRequest {
    challenge_token: string;
    code?: string;
    recovery_code?: string;
    account_id?: IdParam;
    remember_device?: boolean;
    sso_binding?: string;
}

export type SsoIntent = 'LOGIN' | 'SIGNUP' | 'INVITE' | 'LINK' | 'REAUTH' | 'TEST';

export type SsoProviderType = 'GOOGLE' | 'MICROSOFT' | 'OIDC';

export interface SsoProvider {
    key: string;
    name: string;
    type: SsoProviderType;
    logo_url: string | null;
}

export interface SsoProvidersResponse {
    providers: SsoProvider[];
    password_login_enabled: boolean;
    registration_enabled: boolean;
    enterprise_sso_enabled: boolean;
}

export interface SsoStartResponse {
    authorization_url: string;
    binding: string;
}

export type SsoExchangeStatus =
    | 'AUTHENTICATED'
    | 'TWO_FACTOR_REQUIRED'
    | 'CHOOSE_ACCOUNT'
    | 'SIGNUP_REQUIRED'
    | 'LINKED'
    | 'REAUTHENTICATED'
    | 'TESTED';

export interface SsoSignupDetails {
    ticket: string;
    email: string;
    email_verified: boolean;
    first_name: string | null;
    last_name: string | null;
}

export interface SsoExchangeResponse {
    status: SsoExchangeStatus;
    provider_name: string;
    return_path: string | null;
    token?: string;
    user?: User;
    accounts?: Account[];
    two_factor_challenge_token?: string;
    login_ticket?: string;
    signup?: SsoSignupDetails;
    reauth_proof?: string;
    test?: SsoTestResult;
}

export interface SsoTestResult {
    email: string | null;
    email_verified: boolean;
    email_domain_verified: boolean;
    first_name: string | null;
    last_name: string | null;
    groups: string[];
}

export type AccountSsoConnectionType = 'OKTA' | 'ENTRA' | 'GOOGLE_WORKSPACE' | 'OIDC';

export interface AccountSsoConnection {
    id: IdParam;
    provider_key: string;
    type: AccountSsoConnectionType;
    issuer: string;
    client_id: string;
    tenant_id: string | null;
    hosted_domain: string | null;
    status: 'ACTIVE' | 'INACTIVE';
    session_ttl_minutes: number;
    enforce_sso: boolean;
    jit_provisioning_enabled: boolean;
    jit_default_role: Exclude<UserRole, 'SUPERADMIN'>;
    last_tested_at: string | null;
    created_at: string;
}

export interface AccountSsoConnectionRequest {
    type: AccountSsoConnectionType;
    client_id: string;
    client_secret?: string | null;
    issuer?: string | null;
    tenant_id?: string | null;
    hosted_domain?: string | null;
    session_ttl_minutes: number;
    jit_provisioning_enabled: boolean;
    jit_default_role: Exclude<UserRole, 'SUPERADMIN'>;
}

export type AccountSsoDomainStatus = 'PENDING' | 'VERIFIED' | 'FAILING' | 'SUSPENDED';

export interface AccountSsoDomain {
    id: IdParam;
    domain: string;
    status: AccountSsoDomainStatus;
    txt_record_name: string;
    txt_record_value: string;
    verified_at: string | null;
    last_checked_at: string | null;
    failing_since: string | null;
}

export interface AccountSso {
    connection: AccountSsoConnection | null;
    domains: AccountSsoDomain[];
    redirect_uri: string;
    stats: {
        domain_count: number;
        verified_domain_count: number;
        sso_sign_ins_last_30_days: number;
    };
}

export interface SsoEnforcementMember {
    account_user_id: IdParam;
    user_id: IdParam;
    email: string;
    first_name: string | null;
    last_name: string | null;
    role: UserRole;
    is_account_owner: boolean;
    on_verified_domain: boolean;
    sso_enforced: boolean;
    sso_available: boolean;
}

export interface SsoEnforcementPreview {
    affected_count: number;
    outside_domain_count: number;
    members: SsoEnforcementMember[];
}

export interface SsoErrorResponse {
    message: string;
    error_code: string;
    context?: Record<string, string>;
}

export interface SsoSignupRequest {
    signup_ticket: string;
    binding: string;
    first_name: string;
    last_name?: string;
    timezone: string;
    currency_code: string;
    locale: SupportedLocales;
    marketing_opt_in: boolean;
    email_code?: string;
    invite_token?: string;
}

export interface IdentityConfirmation {
    password?: string;
    reauth_proof?: string;
}

export interface UserIdentity {
    id: IdParam;
    provider_key: string;
    email: string | null;
    last_used_at: string | null;
    created_at: string;
    organization_provider: SsoProvider | null;
}

export interface LinkableSsoConnection extends SsoProvider {
    account_name: string;
}

export interface SsoSignInMethods {
    identities: UserIdentity[];
    linkableConnections: LinkableSsoConnection[];
}

export interface Invitation {
    first_name: string;
    last_name: string | null;
    email: string;
    timezone: string | null;
    account_name: string;
    requires_sign_in: boolean;
    sso_required: boolean;
}

export interface TrustedDevice {
    id: IdParam;
    user_agent: string | null;
    ip_address: string | null;
    last_used_at: string | null;
    expires_at: string;
    created_at: string;
    is_current_device: boolean;
}

export type ApiKeyAccess = 'READ_ONLY' | 'READ_WRITE';

export interface ApiKey {
    id: IdParam;
    name: string;
    token_hint: string;
    access: ApiKeyAccess;
    last_used_at: string | null;
    expires_at: string | null;
    created_at: string;
    is_expired: boolean;
    is_own: boolean;
    owner: { id: IdParam; full_name: string; email: string } | null;
}

export interface CreatedApiKey extends ApiKey {
    key: string;
}

export interface ApiKeysMeta {
    expiry_options_in_days: number[];
    max_active_keys: number;
}

export interface ApiKeysResponse {
    data: ApiKey[];
    meta: ApiKeysMeta;
}

export interface CreateApiKeyRequest extends IdentityConfirmation {
    name: string;
    access: ApiKeyAccess;
    expires_in_days: number | null;
}

export interface TwoFactorStatus {
    enabled: boolean;
    confirmed_at: string | null;
    recovery_codes_remaining: number;
    recovery_codes_total: number;
    trusted_devices: TrustedDevice[];
    required_by_accounts: string[];
    required_by_sso_accounts: string[];
}

export interface TwoFactorSetup {
    secret: string;
    otpauth_uri: string;
}

export interface TwoFactorRecoveryCodes {
    recovery_codes: string[];
}

export interface DisableTwoFactorRequest {
    password?: string;
    reauth_proof?: string;
    code?: string;
    recovery_code?: string;
}

export interface User {
    id?: IdParam;
    account_id?: IdParam;
    first_name: string;
    last_name: string;
    full_name: string;
    email: string;
    timezone?: string;
    password?: string;
    is_email_verified?: boolean;
    has_pending_email_change?: boolean;
    has_password?: boolean;
    is_impersonating?: boolean;
    impersonator_id?: IdParam;
    two_factor_enabled?: boolean;
    two_factor_setup_required?: boolean;
    password_reset_allowed?: boolean;
    enforce_email_confirmation_during_registration?: boolean;
    pending_email?: string;
    last_login_at?: string;
    status?: 'ACTIVE' | 'INACTIVE' | 'INVITED';
    role?: UserRole;
    is_account_owner?: boolean;
    notify_new_orders?: boolean;
    access?: UserAccess;
    sso_sign_in?: 'SSO' | 'EXEMPT' | 'PASSWORD' | null;
    locale?: SupportedLocales;
    marketing_opted_in_at?: string | null;
    feature_flags?: Record<string, boolean>;
    licence?: LicenceSummary;
}

export type UserRole = 'ADMIN' | 'ORGANIZER' | 'VIEWER' | 'SUPERADMIN';

export type AccessScope = 'ACCOUNT' | 'RESTRICTED';

export type Permission =
    | 'EDIT'
    | 'VIEW_FINANCIALS'
    | 'ISSUE_REFUNDS'
    | 'MANAGE_PAYMENTS'
    | 'DELETE_EVENTS'
    | 'MANAGE_TEAM'
    | 'MANAGE_ACCOUNT';

export type AdjustablePermission = 'VIEW_FINANCIALS' | 'ISSUE_REFUNDS';

export interface UserAccess {
    scope: AccessScope;
    organizer_ids: number[];
    event_ids: number[];
    permissions: Permission[];
}

export interface TeamMemberAccess {
    user_id: number;
    first_name: string;
    last_name: string | null;
    email: string;
    role: UserRole;
    status: 'ACTIVE' | 'INACTIVE' | 'INVITED';
    access_via: 'ACCOUNT' | 'ORGANIZER' | 'EVENT';
}

export interface TeamAccessRequest {
    access_scope: AccessScope;
    organizer_ids: number[];
    event_ids: number[];
    permissions: Partial<Record<AdjustablePermission, boolean>>;
}

export type LicenceStatus = 'ACTIVE' | 'GRACE' | 'LAPSED' | 'NONE' | 'DEV';

export interface LicenceSummary {
    status: LicenceStatus;
    expires_at: string | null;
    grace_ends_at: string | null;
    invalid_reason: string | null;
    features: LicensedFeature[];
    unlocked_features: LicensedFeature[];
    features_in_use: LicensedFeature[];
}

export type LicensedFeature = 'seating' | 'box_office' | 'enterprise_sso' | 'white_label';

export interface Account {
    id?: IdParam;
    name: string;
    email: string;
    timezone?: string;
    currency_code?: string;
    password?: string;
    is_account_email_confirmed?: boolean;
    is_saas_mode_enabled?: boolean;
    requires_manual_verification?: boolean;
    require_two_factor_authentication?: boolean;
    deletion_request?: AccountDeletionRequest | null;
}

export type AccountSubscriptionStatus =
    'INCOMPLETE'
    | 'INCOMPLETE_EXPIRED'
    | 'TRIALING'
    | 'ACTIVE'
    | 'PAST_DUE'
    | 'CANCELED'
    | 'UNPAID'
    | 'PAUSED';

export type SubscriptionBillingInterval = 'month' | 'year';

export interface SubscriptionPrice {
    interval: SubscriptionBillingInterval;
    unit_amount: number;
    currency: string;
}

export interface AccountSubscription {
    available: boolean;
    active: boolean;
    status: AccountSubscriptionStatus | null;
    current_period_end: string | null;
    cancel_at_period_end: boolean;
    prices: SubscriptionPrice[];
}

export interface AccountDeletionRequest {
    id: IdParam;
    status: 'REQUESTED' | 'CANCELLED' | 'COMPLETED';
    initiated_by: 'ACCOUNT_OWNER' | 'ADMIN';
    expected_outcome: 'HARD_DELETE' | 'ANONYMIZE';
    scheduled_deletion_at: string;
    cancelled_at: string | null;
    requested_at: string;
}

export interface AccountDeletionStatus {
    deletion_request: AccountDeletionRequest | null;
    can_request_deletion: boolean;
    cannot_delete_reason: string | null;
    expected_outcome: 'HARD_DELETE' | 'ANONYMIZE';
    blocking_events: { id: number; title: string }[];
}

export interface AccountConfiguration {
    id: IdParam;
    name: string;
    application_fees: {
        percentage: number;
        fixed: number;
        currency: string;
    },
    is_system_default: boolean;
    default_for_currency: string | null;
}

export interface OrganizerStripeConnectDetails {
    organizer: Organizer;
    stripe_account_id: string;
    is_connect_setup_complete: boolean;
    connect_url: string | null;
}

export interface OrganizerStripeConnectAccount {
    stripe_account_id: string;
    connect_url: string | null;
    is_setup_complete: boolean;
    platform: string | null;
    account_type: string | null;
    is_primary: boolean;
    country?: string | null;
    business_type?: string | null;
    charges_enabled: boolean;
    payouts_enabled: boolean;
    capabilities: Record<string, string>;
    requirements: {
        currently_due: string[];
        eventually_due: string[];
        past_due: string[];
        pending_verification: string[];
    };
}

export interface ReusableStripeConnection {
    organizer_id: IdParam;
    organizer_name: string;
    stripe_account_id: string;
    platform: string | null;
    country?: string | null;
    business_type?: string | null;
}

export interface OrganizerStripeConnectAccountsResponse {
    organizer: {
        id: IdParam;
        name: string;
        stripe_platform: string | null;
    };
    stripe_connect_accounts: OrganizerStripeConnectAccount[];
    reusable_connections: ReusableStripeConnection[];
    primary_stripe_account_id: string | null;
    has_completed_setup: boolean;
}

export interface LoginData {
    email: string;
    password: string;
    account_id?: IdParam;
}

export interface Image {
    id: IdParam;
    file_name: string;
    url: string;
    size: number;
    mime_type: string;
    type: ImageType;
    width?: number | null;
    height?: number | null;
    avg_colour?: string | null;
    lqip_base64?: string | null;
}

export type ImageType = 'EVENT_COVER' | 'EDITOR_IMAGE' | 'ORGANIZER_LOGO' | 'ORGANIZER_COVER' | 'ORGANIZER_IMAGE' | 'TICKET_LOGO' | 'PROFILE_IMAGE' | 'EVENT_GALLERY' | 'EVENT_SPONSOR_LOGO' | 'ORGANIZER_GALLERY' | 'ORGANIZER_SPONSOR_LOGO';

export type HomepageSectionType =
    'TICKETS'
    | 'ABOUT'
    | 'LINEUP'
    | 'SCHEDULE'
    | 'LOCATION'
    | 'ORGANIZER'
    | 'MORE_EVENTS'
    | 'EVENTS'
    | 'CONTACT'
    | 'PAST_EVENTS'
    | 'TEXT'
    | 'GALLERY'
    | 'FAQ'
    | 'VIDEO'
    | 'SPONSORS';

export interface HomepageSectionFaq {
    question: string;
    answer?: string | null;
}

export interface HomepageSectionSponsor {
    image_id: number;
    name?: string | null;
    url?: string | null;
}

export interface HomepageSection {
    id: string;
    type: HomepageSectionType;
    enabled: boolean;
    heading?: string | null;
    body?: string | null;
    faqs?: HomepageSectionFaq[];
    video_url?: string | null;
    image_ids?: number[];
    sponsors?: HomepageSectionSponsor[];
}

export type PaymentProvider = 'STRIPE' | 'OFFLINE';

export type AttendeeDetailsCollectionMethod = 'PER_TICKET' | 'PER_ORDER';

export interface EventSettings {
    event_id?: IdParam;
    id?: IdParam;
    continue_button_text: string;
    get_tickets_button_text?: string;
    email_footer_message: string;
    pre_checkout_message: string;
    product_page_message: string;
    post_checkout_message: string;
    support_email?: string;
    notify_organizer_of_new_orders: boolean;
    order_timeout_in_minutes?: number;
    homepage_background_color: string;
    homepage_primary_color: string;
    homepage_primary_text_color: string;
    homepage_secondary_color: string;
    homepage_secondary_text_color: string;
    homepage_body_background_color: string;
    homepage_background_type: 'COLOR' | 'MIRROR_COVER_IMAGE';
    maps_url?: string;
    seo_title?: string;
    seo_description?: string;
    seo_keywords?: string;
    allow_search_engine_indexing?: boolean;
    price_display_mode?: 'INCLUSIVE' | 'EXCLUSIVE';
    attendee_details_collection_method?: AttendeeDetailsCollectionMethod;

    // Payment settings
    offline_payment_instructions: string;
    payment_providers: PaymentProvider[];
    allow_orders_awaiting_offline_payment_to_check_in: boolean;
    offline_payment_reporting_enabled: boolean;
    offline_payment_order_reference_enabled: boolean;
    payment_links_enabled: boolean;
    payment_link_expiry_hours: number;

    // Invoice settings
    enable_invoicing: boolean;
    invoice_label?: string;
    invoice_prefix?: string;
    invoice_start_number?: number;
    require_billing_address: boolean;
    organization_name?: string;
    organization_address?: string;
    invoice_tax_details?: string;
    invoice_notes?: string;
    invoice_payment_terms_days?: number;
    // Ticket design settings
    ticket_design_settings?: {
        accent_color?: string;
        logo_image_id?: IdParam;
        footer_text?: string;
        layout_type?: 'default' | 'modern';
        date_display_mode?: 'START_DATE_TIME' | 'DATE_RANGE' | 'HIDDEN';
        enabled?: boolean;
    };

    // Marketing settings
    show_marketing_opt_in?: boolean;

    // Attendee detail copy control
    allow_copy_details_to_all_attendees?: boolean;

    // Platform fee settings
    pass_platform_fee_to_buyer?: boolean;

    // Self-service settings
    allow_attendee_self_edit?: boolean;

    // Simplified homepage theme settings (new 2-color + mode system)
    homepage_theme_settings?: HomepageThemeSettings;
    homepage_sections?: HomepageSection[] | null;

    // Waitlist settings
    waitlist_auto_process?: boolean;
    waitlist_offer_timeout_minutes?: number | null;

    show_available_occurrence_capacity?: boolean;
    hide_sold_out_occurrences?: boolean;
}

export interface VenueAddress {
    venue_name?: string;
    address_line_1?: string;
    address_line_2?: string;
    city?: string;
    state_or_region?: string;
    zip_or_postal_code?: string;
    country?: string;
}

export interface Location {
    id?: IdParam;
    short_id?: string;
    organizer_id?: IdParam;
    name?: string | null;
    structured_address?: VenueAddress | null;
    latitude?: number | null;
    longitude?: number | null;
    provider?: string | null;
    provider_place_id?: string | null;
    created_at?: string;
    updated_at?: string;
}

export interface GeoSuggestion {
    provider_place_id: string;
    primary_text: string;
    secondary_text?: string | null;
}

export interface GeoPlace {
    provider: string;
    provider_place_id: string;
    address: VenueAddress;
    latitude?: number | null;
    longitude?: number | null;
    display_name?: string | null;
}

export interface EventLocation {
    id: number;
    type: LocationType;
    location_id?: number | null;
    location?: Location;
    online_event_connection_details?: string | null;
}

export type UpsertEventLocationPayload = {
    type: LocationType;
    location_id?: number | null;
    online_event_connection_details?: string | null;
};

export interface EventBase {
    title: string;
    description?: string;
    category?: string;
    start_date: string;
    end_date?: string;
}

export interface EventDuplicatePayload extends EventBase {
    duplicate_products: boolean;
    duplicate_questions: boolean;
    duplicate_settings: boolean;
    duplicate_promo_codes: boolean;
    duplicate_capacity_assignments: boolean;
    duplicate_check_in_lists: boolean;
    duplicate_event_cover_image: boolean;
    duplicate_ticket_logo: boolean;
    duplicate_webhooks: boolean;
    duplicate_affiliates: boolean;
    duplicate_lineup: boolean;
    duplicate_occurrences?: boolean;
    duplicate_email_templates?: boolean;
}

export enum EventStatus {
    DRAFT = 'DRAFT',
    LIVE = 'LIVE',
    PAUSED = 'PAUSED',
    ARCHIVED = 'ARCHIVED',
    PENDING_MANUAL_REVIEW = 'PENDING_MANUAL_REVIEW'
}

export enum OrganizerStatus {
    DRAFT = 'DRAFT',
    LIVE = 'LIVE',
    ARCHIVED = 'ARCHIVED'
}

export enum EventLifecycleStatus {
    ONGOING = 'ONGOING',
    UPCOMING = 'UPCOMING',
    ENDED = 'ENDED'
}

export enum EventType {
    SINGLE = 'SINGLE',
    RECURRING = 'RECURRING',
}

export enum LocationType {
    InPerson = 'IN_PERSON',
    Online = 'ONLINE',
}

export enum EventOccurrenceStatus {
    ACTIVE = 'ACTIVE',
    CANCELLED = 'CANCELLED',
    SOLD_OUT = 'SOLD_OUT',
}

export interface RecurrenceRuleRange {
    type: 'until' | 'count';
    until?: string;
    count?: number;
    start?: string;
}

export interface RecurrenceRuleAdditionalDate {
    date: string;
    time: string;
}

export interface RecurrenceTimeSlot {
    time: string;
    label?: string;
    duration_minutes?: number;
}

export interface RecurrenceRule {
    frequency: 'daily' | 'weekly' | 'monthly' | 'yearly';
    interval: number;
    days_of_week?: string[];
    times_of_day?: (string | RecurrenceTimeSlot)[];
    duration_minutes?: number;
    range: RecurrenceRuleRange;
    default_capacity?: number | null;
    excluded_dates?: string[];
    excluded_occurrences?: string[];
    additional_dates?: RecurrenceRuleAdditionalDate[];
    monthly_pattern?: 'by_day_of_month' | 'by_day_of_week';
    days_of_month?: number[];
    day_of_week?: string;
    week_position?: number;
    month?: number;
}

export interface EventOccurrenceStatistics {
    total_gross_sales?: number;
    total_tax?: number;
    total_fee?: number;
    orders_created?: number;
    total_refunded?: number;
    attendees_registered?: number;
    products_sold?: number;
}

export interface EventOccurrence {
    id?: IdParam;
    event_id?: IdParam;
    short_id?: string;
    start_date: string;
    end_date?: string;
    status?: EventOccurrenceStatus;
    capacity?: number | null;
    used_capacity?: number;
    available_capacity?: number | null;
    label?: string;
    show_available_capacity?: boolean | null;
    is_overridden?: boolean;
    is_past?: boolean;
    is_future?: boolean;
    is_active?: boolean;
    event_location?: EventLocation;
    statistics?: EventOccurrenceStatistics;
    booking_limits?: OccurrenceBookingLimits;
    created_at?: string;
    updated_at?: string;
}

export interface OccurrenceAllocation {
    product_price_id: IdParam | null;
    product_title: string;
    price_label: string | null;
    quantity: number | null;
    applies_to: ProductQuantityAppliesTo;
}

export interface OccurrenceBookingLimits {
    capacity: number | null;
    allocation_total: number | null;
    sellable: number | null;
    allocations: OccurrenceAllocation[];
}

export interface OccurrenceProductAvailability {
    product_id: IdParam;
    product_price_id: IdParam;
    quantity_sold: number;
    quantity_available: number | null;
}

export interface ProductPriceOccurrenceOverride {
    id?: IdParam;
    event_occurrence_id?: IdParam;
    product_price_id?: IdParam;
    price: number | null;
    quantity_available?: number | null;
    created_at?: string;
    updated_at?: string;
}

export interface ProductOccurrenceVisibility {
    id: IdParam;
    event_occurrence_id: IdParam;
    product_id: IdParam;
}

export interface UpsertEventOccurrenceRequest {
    start_date: string;
    end_date?: string;
    capacity?: number | null;
    label?: string;
    status?: string;
    show_available_capacity?: boolean | null;
    event_location?: UpsertEventLocationPayload | null;
    clear_event_location?: boolean;
}

export interface GenerateOccurrencesRequest {
    recurrence_rule: RecurrenceRule;
}

export interface OccurrenceGenerationStatus {
    status: 'IN_PROGRESS' | 'FINISHED' | 'FAILED' | 'NOT_FOUND';
    job_uuid?: string;
    message?: string;
}

export interface BulkUpdateOccurrencesRequest {
    action: 'update' | 'cancel' | 'delete';
    start_time_shift?: number;
    end_time_shift?: number;
    capacity?: number | null;
    clear_capacity?: boolean;
    future_only?: boolean;
    skip_overridden?: boolean;
    refund_orders?: boolean;
    occurrence_ids?: number[];
    apply_to_all?: boolean;
    label?: string;
    clear_label?: boolean;
    duration_minutes?: number;
    event_location?: UpsertEventLocationPayload | null;
    clear_event_location?: boolean;
}

export interface UpsertPriceOverrideRequest {
    product_price_id: IdParam;
    price?: number | null;
    quantity_available?: number | null;
}

export interface Event extends EventBase {
    id?: IdParam;
    slug: string;
    status?: EventStatus;
    type?: EventType;
    recurrence_rule?: RecurrenceRule;
    description_preview?: string;
    lifecycle_status?: EventLifecycleStatus;
    settings?: EventSettings;
    products?: Product[];
    product_categories?: ProductCategory[];
    images?: Image[];
    organizer?: Organizer;
    currency: string;
    timezone: string;
    organizer_id?: IdParam;
    event_location?: EventLocation;
    statistics?: EventStatistics;
    occurrences?: EventOccurrence[];
    next_occurrence_start_date?: string | null;
    upcoming_occurrences_sold_out?: boolean;
    products_sold_out?: boolean;
    has_seat_map?: boolean;
    last_occurrence_date?: string | null;
    occurrences_month?: string | null;
}

export interface EventStatistics {
    unique_views: number;
    total_views: number;
    sales_total_gross: number;
    total_tax: number;
    sales_total_before_additions: number;
    total_fee: number;
    products_sold: number;
    attendees_registered: number;
    total_refunded: number;
}

export interface EventDailyStats {
    date: string;
    total_fees: number;
    total_tax: number;
    total_sales_gross: number;
    products_sold: number;
    attendees_registered: number;
    total_refunded: number;
    orders_created: number;
}

export interface CheckInStats {
    total_checked_in_attendees: number;
    total_attendees: number;
}

export interface EventCounts {
    total_orders: number;
    total_attendees_registered: number;
}

export interface EventStats {
    daily_stats: EventDailyStats[];
    start_date: string;
    end_date: string;
    check_in_stats: CheckInStats;
    total_products_sold: number;
    total_attendees_registered: number;
    total_product_sold_percentage_change: number;
    total_orders: number;
    total_orders_percentage_change: number;
    total_gross_sales: number;
    total_gross_sales_percentage_change: number;
    total_tax: number;
    total_fees: number;
    total_views: number;
    total_refunded: number;
}

export interface OrganizerDailyStats {
    date: string;
    attendees_registered: number;
    products_sold: number;
    total_sales_gross: number;
    orders_created: number;
    total_refunded: number;
}

export interface OrganizerStats {
    total_products_sold: number;
    total_attendees_registered: number;
    total_orders: number;
    total_gross_sales: number;
    total_tax: number;
    total_fees: number;
    total_views: number;
    total_refunded: number;
    daily_stats: OrganizerDailyStats[];
    start_date: string;
    end_date: string;
    all_organizers_currencies: string[];
}

export interface Organizer {
    id?: IdParam;
    name: string;
    email: string;
    description?: string;
    website?: string;
    timezone?: string;
    currency?: string;
    slug?: string;
    phone?: string;
    images?: Image[];
    events?: Event[];
    settings?: OrganizerSettings;
    location_id?: IdParam | null;
    location?: Location | null;
    status?: OrganizerStatus;
    branding_removed?: boolean;
    stripe_connect_setup_complete?: boolean;
    stripe_account_id?: string | null;
    configuration?: AccountConfiguration;
}

export interface OrganizerSettings {
    id: IdParam;
    organizer_id: IdParam;
    default_attendee_details_collection_method?: AttendeeDetailsCollectionMethod;
    default_show_marketing_opt_in?: boolean;
    default_pass_platform_fee_to_buyer?: boolean;
    default_allow_attendee_self_edit?: boolean;
    homepage_visibility: 'PUBLIC' | 'PRIVATE' | 'PASSWORD_PROTECTED';
    homepage_theme_settings: HomepageThemeSettings;
    homepage_sections?: HomepageSection[] | null;
    website_url?: string;
    social_media_handles?: {
        facebook?: string;
        instagram?: string;
        twitter?: string;
        linkedin?: string;
        youtube?: string;
        tiktok?: string;
        bluesky?: string;
        snapchat?: string;
        twitch?: string;
        discord?: string;
        github?: string;
        reddit?: string;
        pinterest?: string;
        whatsapp?: string;
        telegram?: string;
        wechat?: string;
        weibo?: string;
    },
    seo_keywords?: string;
    seo_description?: string;
    seo_title?: string;
    allow_search_engine_indexing?: boolean;
    tracking_pixels?: TrackingPixelConfig[];
    tracking_consent_acknowledged?: boolean;
    first_day_of_week?: DayOfWeek;
}

export interface TrackingPixelConfig {
    provider: string;
    pixel_id: string;
    enabled: boolean;
}

export interface SortDirectionLabel {
    asc: string;
    desc: string;
}

export interface PaginationData {
    total: number;
    per_page: number;
    current_page: number;
    links: string[];
    last_page: number;
    from: number;
    to: number;
    path: number;
    allowed_sorts: Record<string, SortDirectionLabel>;
    default_sort: string;
    default_sort_direction: string;
}

export interface GenericDataResponse<T> {
    data: T;
    errors?: Record<string, string>;
}

export interface GenericPaginatedResponse<T> {
    data: T[];
    meta: PaginationData;
}

export enum ProductPriceType {
    Paid = 'PAID',
    Donation = 'DONATION',
    Free = 'FREE',
    Tiered = 'TIERED',
}

export enum ProductType {
    Ticket = 'TICKET',
    General = 'GENERAL',
}

export enum ProductQuantityAppliesTo {
    Occurrence = 'OCCURRENCE',
    Event = 'EVENT',
}

export enum ProductStatus {
    Active = 'ACTIVE',
    Inactive = 'INACTIVE',
}

export interface ProductPrice {
    id?: number;
    label?: string;
    price: number;
    sale_start_date?: string | Date;
    sale_end_date?: string | Date;
    price_including_taxes_and_fees?: number;
    price_before_discount?: number;
    price_before_discount_including_taxes_and_fees?: number | null;
    is_discounted?: boolean;
    tax_total?: number;
    fee_total?: number;
    is_available?: boolean;
    is_before_sale_start_date?: boolean;
    is_after_sale_end_date?: boolean;
    is_sold_out?: boolean;
    is_locked_behind_earlier_tier?: boolean;
    initial_quantity_available?: number;
    quantity_sold?: number;
    quantity_applies_to?: ProductQuantityAppliesTo;
    is_hidden?: boolean;
    quantity_remaining?: number;
    band_prices?: Record<string, number>;
}

export interface Product {
    id?: number;
    order?: number;
    title: string;
    event_id?: IdParam;
    // todo - rename to price_type
    type: ProductPriceType;
    product_type: ProductType;
    description?: string;
    price?: number;
    prices?: ProductPrice[];
    price_before_discount?: number;
    is_discounted?: boolean;
    initial_quantity_available?: number | undefined;
    quantity_sold?: number;
    sale_start_date?: string | Date;
    sale_end_date?: string | Date;
    max_per_order?: number;
    min_per_order?: number;
    hide_before_sale_start_date?: boolean;
    hide_after_sale_end_date?: boolean;
    hide_when_sold_out?: boolean;
    sequential_tier_release_enabled?: boolean;
    start_collapsed?: boolean;
    show_quantity_remaining?: boolean;
    quantity_available?: number;
    status?: ProductStatus;
    is_sold_out?: boolean;
    is_available?: boolean;
    is_hidden_without_promo_code?: boolean;
    is_before_sale_start_date?: boolean;
    is_after_sale_end_date?: boolean;
    taxes?: TaxAndFee[];
    tax_total?: number;
    service_fee_total?: number;
    price_including_taxes_and_fees?: number;
    tax_and_fee_ids?: IdParam[];
    taxes_and_fees?: TaxAndFee[];
    is_hidden?: boolean;
    product_category_id?: IdParam;
    is_highlighted?: boolean;
    highlight_message?: string;
    waitlist_enabled?: boolean | null;
    has_waiting_entries?: boolean;
    waitlist_entry_count?: number;
    addon_product_ids?: IdParam[];
    is_addon_only?: boolean;
    addons?: Array<{ id: number; title: string }>;
}

export interface ProductCategory {
    id?: number;
    name: string;
    description?: string;
    products?: Product[];
    event_id?: number;
    is_hidden?: boolean;
    no_products_message?: string;
}

export interface Attendee {
    id?: number;
    seat_uid?: string | null;
    seat_label?: string | null;
    product_id: number;
    product?: Product;
    product_price_id: number;
    order_id: number;
    status: 'ACTIVE' | 'CANCELLED' | 'AWAITING_PAYMENT';
    first_name: string;
    last_name: string;
    email: string | null;
    notes?: string;
    order?: Order;
    public_id: string;
    short_id: string;
    checked_in_at?: string;
    checked_out_by?: number;
    checked_in_by?: number;
    question_answers?: QuestionAnswer[];
    locale?: SupportedLocales;
    event_occurrence_id?: number;
    event_occurrence?: EventOccurrence;
    check_in?: AttendeeCheckIn;
    is_checked_in?: boolean;
    check_ins?: AttendeeCheckIn[];
}

export type PublicCheckIn = Pick<AttendeeCheckIn, 'id' | 'short_id' | 'order_id' | 'attendee_id' | 'check_in_list_id' | 'product_id' | 'event_id'>;

export interface AttendeeCheckIn {
    id: IdParam;
    attendee_id: IdParam;
    check_in_list_id: IdParam;
    product_id: IdParam;
    event_id: IdParam;
    event_occurrence_id?: number;
    short_id: IdParam;
    order_id: IdParam;
    created_at: string;
    check_in_list?: CheckInList;
}

export interface Address {
    address_line_1: string;
    address_line_2: string;
    city: string;
    state_or_region: string;
    country: string;
    zip_or_postal_code: string;
}

interface TaxOrFee {
    name: string;
    value: number;
}

interface TaxesAndFeesRollup {
    fees: TaxOrFee[];
    taxes: TaxOrFee[];
}

export interface OrderSeat {
    seat_uid: string;
    seat_label: string;
    order_item_id: number;
}

export enum ProductPurchaseStatus {
    Sold = 'SOLD',
    AwaitingPayment = 'AWAITING_PAYMENT',
    Cancelled = 'CANCELLED',
}

export interface ProductPurchase {
    order_id: number;
    order_public_id: string;
    order_status: 'COMPLETED' | 'CANCELLED' | 'AWAITING_OFFLINE_PAYMENT';
    refund_status: 'REFUND_PENDING' | 'REFUND_FAILED' | 'REFUNDED' | 'PARTIALLY_REFUNDED' | null;
    order_created_at: string;
    currency: string;
    first_name: string | null;
    last_name: string | null;
    email: string | null;
    product_title: string;
    product_price_id: number | null;
    price_label: string | null;
    event_occurrence_id: number | null;
    occurrence_start_date: string | null;
    sold_quantity: number;
    awaiting_payment_quantity: number;
    cancelled_quantity: number;
    line_total: number | null;
    status: ProductPurchaseStatus;
}

export interface ProductPurchaseSummary {
    sold_quantity: number;
    awaiting_payment_quantity: number;
    cancelled_quantity: number;
    buyer_count: number;
    gross_sales: number;
    refunded_order_count: number;
}

export interface ProductPurchaseExportFilters {
    product_id?: IdParam;
    event_occurrence_id?: IdParam;
    statuses?: ProductPurchaseStatus[];
    refund_statuses?: string[];
    query?: string;
}

export interface Order {
    id: IdParam;
    seats?: OrderSeat[];
    short_id: string;
    event_id: IdParam;
    first_name: string;
    last_name: string;
    company_name: string;
    address: Address;
    payment_provider: PaymentProvider;
    notes?: string;
    email: string | null;
    reserved_until: string;
    total_before_additions: number;
    total_tax: number;
    total_fee: number;
    total_gross: number;
    total_gross_after_refund: number;
    total_refunded: number;
    is_expired: boolean;
    order_items?: OrderItem[];
    attendees?: Attendee[];
    created_at: string;
    currency: string;
    status: 'RESERVED' | 'CANCELLED' | 'COMPLETED' | 'AWAITING_OFFLINE_PAYMENT' | 'ABANDONED';
    refund_status?: 'REFUND_PENDING' | 'REFUND_FAILED' | 'REFUNDED' | 'PARTIALLY_REFUNDED';
    payment_status?: 'NO_PAYMENT_REQUIRED' | 'AWAITING_PAYMENT' | 'PAYMENT_FAILED' | 'PAYMENT_RECEIVED' | 'AWAITING_OFFLINE_PAYMENT';
    public_id: string;
    is_payment_required: boolean;
    is_manually_created: boolean;
    box_office_id?: number | null;
    box_office_operator_name?: string | null;
    box_office_tender?: BoxOfficeTenderType | null;
    box_office_amount_tendered?: number | null;
    box_office_change_due?: number | null;
    box_office_reference?: string | null;
    box_office_card_error?: { code?: string | null; message?: string | null } | null;
    is_free_order: boolean;
    promo_code?: string;
    promo_code_id?: number;
    taxes_and_fees_rollup?: TaxesAndFeesRollup;
    question_answers?: QuestionAnswer[];
    event?: Event;
    latest_invoice?: Invoice;
    session_identifier?: string;
    payment_link_created_at?: string | null;
    payment_link_url?: string;
    is_payment_link_payer?: boolean;
    offline_payment_reported_at?: string | null;
    offline_payment_note?: string | null;
}

export interface Invoice {
    download_url: string;
    invoice_number: string;
    id: IdParam,
    order_id: IdParam,
    status: 'PAID' | 'UNPAID' | 'VOID',
}

export interface OrderItem {
    id: number;
    product_id: number;
    product_price_id: number;
    item_name: string;
    total_before_additions: number;
    total_before_discount?: number;
    price_before_discount?: number;
    price: number;
    quantity: number;
    total_gross?: number;
    event_occurrence_id?: number;
    event_occurrence?: EventOccurrence;
}

export interface StripePaymentIntent {
    status: string;
    paymentIntentId: string;
    amount: number;
}

export interface Question {
    id?: number;
    title: string;
    description?: string;
    required: boolean;
    type: string;
    options: string[];
    event_id?: number;
    products?: Product[];
    product_ids?: number[];
    belongs_to: string;
    is_hidden: boolean;
}

export interface CapacityAssignment {
    id?: number;
    event_id: number;
    name: string;
    used_capacity: number;
    status: 'ACTIVE' | 'INACTIVE';
    capacity: number | undefined;
    products: {
        id: number;
        title: string;
    }[];
}

export type CapacityAssignmentRequest = Omit<CapacityAssignment, 'id' | 'event_id' | 'used_capacity' | 'products'> & {
    product_ids: IdParam[];
};

export interface CheckInList {
    id?: number;
    short_id: string;
    name: string;
    description?: string | null;
    expires_at?: string;
    activates_at?: string;
    total_attendees: number;
    checked_in_attendees: number;
    is_expired: boolean;
    is_active: boolean;
    event_id: number;
    event_occurrence_id?: number | null;
    event?: Event;
    event_occurrence?: EventOccurrence;
    is_system_default?: boolean;
    event_occurrences?: EventOccurrence[];
    products: {
        id: number;
        title: string;
    }[];
    public_show_attendee_notes?: boolean;
    public_show_question_answers?: boolean;
    public_show_order_details?: boolean;
}

export enum BoxOfficeTenderType {
    CASH = 'CASH',
    CARD = 'CARD',
    COMP = 'COMP',
    OTHER = 'OTHER',
    FREE = 'FREE',
}

export interface BoxOffice {
    id?: number;
    short_id: string;
    name: string;
    description?: string | null;
    event_id: number;
    event_occurrence_id?: number | null;
    event_occurrence?: EventOccurrence;
    check_in_list_id?: number | null;
    check_in_list?: {
        id: number;
        short_id: string;
        name: string;
    };
    has_pin: boolean;
    allow_price_override: boolean;
    allow_discounts: boolean;
    collect_order_questions: boolean;
    is_system_default: boolean;
    activates_at?: string | null;
    expires_at?: string | null;
    sales_count: number;
    gross_sales: number;
    currency?: string;
    is_expired?: boolean;
    is_active?: boolean;
    products?: {
        id: number;
        title: string;
    }[];
}

export type BoxOfficeRequest = {
    name: string;
    description?: string | null;
    product_ids: IdParam[];
    event_occurrence_id?: number | null;
    check_in_list_id?: IdParam | null;
    allow_price_override: boolean;
    allow_discounts: boolean;
    collect_order_questions: boolean;
    activates_at?: string;
    expires_at?: string;
};

export type BoxOfficeWithPin = BoxOffice & { pin: string };

export interface BoxOfficeStatsTotals {
    orders: number;
    gross: number;
    refunded: number;
}

export interface BoxOfficeStats extends BoxOfficeStatsTotals {
    currency: string;
    by_tender: (BoxOfficeStatsTotals & { tender: BoxOfficeTenderType })[];
    by_operator: (BoxOfficeStatsTotals & { operator_name: string })[];
    by_day: (BoxOfficeStatsTotals & { day: string })[];
}

export interface BoxOfficeStatsRange {
    from: string | null;
    to: string | null;
}

export interface TerminalReader {
    id: number;
    label: string;
    device_type?: string | null;
    status: 'online' | 'offline' | 'unknown' | 'unavailable';
    is_available: boolean;
}

export interface TerminalReadersResponse {
    readers: TerminalReader[];
    stripe_configured: boolean;
    stripe_connected: boolean;
}

export interface BoxOfficePublic {
    short_id: string;
    name: string;
    description?: string | null;
    has_pin: boolean;
    is_expired: boolean;
    is_active: boolean;
    activates_at?: string | null;
    allow_price_override: boolean;
    allow_discounts: boolean;
    collect_order_questions: boolean;
    card_payments_enabled: boolean;
    can_skip_pin: boolean;
    readers: TerminalReader[];
    occurrences: EventOccurrence[];
    event: {
        id: number;
        title: string;
        timezone: string;
        currency: string;
        type: EventType;
        status: string;
        price_display_mode?: string | null;
    };
}

export interface BoxOfficeSession {
    token: string;
    expires_at: string;
    operator_name: string;
    event_occurrence?: EventOccurrence;
    reader?: { id: number; label: string };
    check_in_list_short_id: string | null;
    check_in_available: boolean;
    check_in_unavailable_reason: string | null;
}

export interface BoxOfficeProductPrice {
    id: number;
    label?: string | null;
    price: number;
    price_including_taxes_and_fees: number;
    tax_total?: number | null;
    fee_total?: number | null;
    is_available: boolean;
    quantity_remaining: number | null;
    off_sale_reason: 'BEFORE_SALE_START' | 'AFTER_SALE_END' | null;
    band_prices?: Record<string, number>;
}

export interface BoxOfficeProduct {
    id: number;
    title: string;
    type: string;
    product_type: ProductType;
    description?: string | null;
    max_per_order?: number | null;
    product_category_id?: number | null;
    is_hidden: boolean;
    is_hidden_without_promo_code: boolean;
    is_addon_only: boolean;
    prices: BoxOfficeProductPrice[];
    taxes?: TaxAndFee[];
}

export interface BoxOfficeCatalogue {
    products: BoxOfficeProduct[];
    questions: Question[];
}

export interface BoxOfficeOrderItemRequest {
    product_id: number;
    product_price_id: number;
    quantity: number;
    override_price?: number;
    seat_uids?: string[];
}

export interface BoxOfficeOrderRequest {
    idempotency_key: string;
    items: BoxOfficeOrderItemRequest[];
    discount?: { type: 'FIXED' | 'PERCENTAGE'; value: number } | null;
    buyer?: { first_name?: string; last_name?: string; email?: string };
    questions?: { question_id: number; response: any }[];
    attendees?: { product_id: number; product_price_id: number; questions: { question_id: number; response: any }[] }[];
}

export interface BoxOfficeTenderRequest {
    tender: 'CASH' | 'COMP' | 'OTHER';
    amount_tendered?: number;
    reference?: string;
}

export interface AttendeeDetailPublicCheckIn {
    id: number;
    short_id: string;
    check_in_list_id: number;
    attendee_id: number;
    checked_in_at: string;
    order_id: number;
}

export interface AttendeeDetailPublicOrder {
    id: number;
    public_id: string;
    status: string;
    total_gross: number;
    currency: string;
    first_name: string | null;
    last_name: string | null;
    email: string | null;
    created_at: string;
}

export interface AttendeeDetailPublicQuestionAnswer {
    question_id: number;
    title: string;
    answer: string | string[] | null;
    belongs_to: string;
}

export interface AttendeeDetailPublic {
    id: number;
    public_id: string;
    first_name: string;
    last_name: string;
    email: string | null;
    status: 'ACTIVE' | 'CANCELLED' | 'AWAITING_PAYMENT';
    product_id: number;
    product_title: string | null;
    seat_label?: string | null;
    event_occurrence: EventOccurrence | null;
    check_ins: AttendeeDetailPublicCheckIn[];
    visibility: {
        notes: boolean;
        question_answers: boolean;
        order_details: boolean;
    };
    notes?: string | null;
    question_answers?: AttendeeDetailPublicQuestionAnswer[];
    order?: AttendeeDetailPublicOrder;
}

export type CheckInListRequest =
    Omit<CheckInList, 'event_id' | 'short_id' | 'id' | 'products' | 'total_attendees' | 'checked_in_attendees' | 'is_expired' | 'is_active' | 'event_occurrence' | 'public_show_attendee_notes' | 'public_show_question_answers' | 'public_show_order_details'>
    & {
    product_ids: IdParam[];
    public_show_attendee_notes?: boolean;
    public_show_question_answers?: boolean;
    public_show_order_details?: boolean;
};

export interface CheckInListProductStat {
    product_id: number;
    product_title: string;
    total_attendees: number;
    checked_in_attendees: number;
}

export interface CheckInListRecentCheckIn {
    attendee_public_id: string;
    first_name: string;
    last_name: string;
    product_title: string | null;
    checked_in_at: string;
}

export interface CheckInListStats {
    total_attendees: number;
    checked_in_attendees: number;
    per_product: CheckInListProductStat[];
    recent_check_ins: CheckInListRecentCheckIn[];
}

export interface QuestionRequestData {
    title: string;
    description?: string;
    required: boolean;
    is_hidden: boolean;
    type: string;
    options: string[];
    product_ids?: string[];
    belongs_to: string;
}

export interface Message {
    id?: IdParam;
    subject: string;
    message: string;
    message_preview: string;
    type: MessageType;
    is_test: boolean;
    order_id?: number;
    attendee_ids?: IdParam[];
    product_ids?: IdParam[];
    created_at?: string;
    updated_at?: string;
    sent_at?: string;
    scheduled_at?: string | null;
    sent_by_user?: User;
    status?: 'SENT' | 'PROCESSING' | 'FAILED' | 'SCHEDULED' | 'CANCELLED' | 'PENDING_REVIEW';
}

export interface OutgoingMessage {
    id?: IdParam;
    message_id: number;
    recipient: string;
    status: 'SENT' | 'FAILED';
    subject: string;
    delivered_at: string | null;
    bounced_at: string | null;
    complained_at: string | null;
    created_at?: string;
}

export enum QuestionType {
    ADDRESS = 'ADDRESS',
    SINGLE_LINE_TEXT = 'SINGLE_LINE_TEXT',
    MULTI_LINE_TEXT = 'MULTI_LINE_TEXT',
    CHECKBOX = 'CHECKBOX',
    RADIO = 'RADIO',
    DROPDOWN = 'DROPDOWN',
    DATE = 'DATE',
}

export enum QuestionBelongsToType {
    PRODUCT = 'PRODUCT',
    ORDER = 'ORDER',
}

export enum QueryFilterOperator {
    Equals = 'eq',
    NotEquals = 'ne',
    GreaterThan = 'gt',
    GreaterThanOrEquals = 'gte',
    LessThan = 'lt',
    LessThanOrEquals = 'lte',
    Like = 'like',
    ILike = 'ilike',
    NotLike = 'not_like',
    In = 'in',
}

export type QueryFilterValue = string | number | boolean;

export type QueryFilterCondition = {
    operator: QueryFilterOperator;
    value: QueryFilterValue;
};

export type QueryFilterFields = {
    [key: string]: QueryFilterCondition | QueryFilterCondition[] | undefined;
}

export interface QueryFilters {
    pageNumber?: number;
    perPage?: number;
    query?: string;
    sortBy?: string;
    sortDirection?: string;
    filterFields?: QueryFilterFields;
    additionalParams?: Record<string, any>;
}

export interface GenericModalProps {
    onClose: () => void;
    isOpen?: boolean;
}

export interface MessageOrderRequest {
    subject: string;
    message: string;
    sendCopy: boolean;
}

export enum MessageType {
    IndividualAttendees = 'INDIVIDUAL_ATTENDEES',
    OrderOwner = 'ORDER_OWNER',
    TicketHolders = 'TICKET_HOLDERS',
    AllAttendees = 'ALL_ATTENDEES',
    OrderOwnersWithProduct = 'ORDER_OWNERS_WITH_PRODUCT',
}

export interface PromoCode {
    id?: number;
    code: string;
    discount?: number;
    applicable_product_ids?: number[] | string[];
    expiry_date?: string;
    event_id?: number;
    discount_type?: PromoCodeDiscountType | null;
    discount_applies_to?: PromoCodeDiscountAppliesTo;
    attendee_usage_count?: number;
    order_usage_count?: number;
    max_allowed_usages?: number | undefined;
}

export enum PromoCodeDiscountType {
    Percentage = 'PERCENTAGE',
    Fixed = 'FIXED',
    None = 'NONE',
}

export enum PromoCodeDiscountAppliesTo {
    Order = 'ORDER',
    EachProduct = 'EACH_PRODUCT',
}

export interface PromoCodeValidationResponse {
    valid: boolean;
    discount?: number;
    discount_type?: PromoCodeDiscountType;
    discount_applies_to?: PromoCodeDiscountAppliesTo;
    applies_to_all_products?: boolean;
}

export enum TaxAndFeeType {
    Tax = 'TAX',
    Fee = 'FEE',
}

export enum TaxAndFeeCalculationType {
    Percentage = 'PERCENTAGE',
    Fixed = 'FIXED'
}

export interface TaxAndFee {
    id?: number;
    name: string;
    rate: number | undefined;
    type: TaxAndFeeType;
    calculation_type: TaxAndFeeCalculationType;
    is_default: boolean;
    is_active: boolean;
    description?: string;
    account_id?: IdParam;
}

export interface InviteUserRequest extends TeamAccessRequest {
    email: string;
    first_name: string;
    last_name: string;
    role: UserRole;
}

export interface SortableItem {
    id: IdParam;
    order: number;
}

export interface QuestionAnswer {
    product_id?: number;
    product_title?: string;
    question_id: number;
    title: string;
    answer: string[] | string;
    text_answer: string;
    order_id: number;
    belongs_to: string;
    question_type: string;
    attendee_id?: number;
    attendee_public_id?: IdParam;
    first_name?: string;
    last_name?: string;
    question_answer_id?: IdParam;
    question_description?: string;
    question_required?: boolean;
    question_options?: string[];
}

export enum ReportTypes {
    ProductSales = 'product_sales',
    DailySales = 'daily_sales_report',
    PromoCodes = 'promo_codes_report',
    OccurrenceSummary = 'occurrence_summary',
    SeatingSales = 'seating_sales',
}

export enum OrganizerReportTypes {
    RevenueSummary = 'revenue_summary',
    EventsPerformance = 'events_performance',
    TaxSummary = 'tax_summary',
    CheckInSummary = 'check_in_summary',
    PlatformFees = 'platform_fees',
}

export interface Webhook {
    id: IdParam;
    event_id: IdParam;
    url: string;
    secret: string;
    status: 'ENABLED' | 'PAUSED';
    event?: Event;
    event_types?: string[];
    last_response_code?: number;
    last_response_body?: string;
    last_triggered_at?: string | Date;
    logs?: WebhookLog[];
}

export interface WebhookLog {
    id: IdParam;
    webhook_id: IdParam;
    payload?: string;
    response_code?: number;
    response_body?: string;
    event_type: string;
    created_at: string;
}

// Email Template Types
export type EmailTemplateType = 'order_confirmation' | 'attendee_ticket' | 'occurrence_cancellation';
export type EmailTemplateEngine = 'liquid' | 'blade';

export interface EmailTemplate {
    id: number;
    account_id: number;
    organizer_id?: number;
    event_id?: number;
    template_type: EmailTemplateType;
    subject: string;
    body: string;
    cta?: {
        label: string;
        url_token: string;
    };
    engine: EmailTemplateEngine;
    is_active: boolean;
    created_at: string;
    updated_at: string;
}

export interface EmailTemplateToken {
    token: string;
    description: string;
    example: string;
}

export interface CreateEmailTemplateRequest {
    template_type: EmailTemplateType;
    subject: string;
    body: string;
    cta?: {
        label: string;
        url_token: string;
    };
}

export interface UpdateEmailTemplateRequest {
    subject: string;
    body: string;
    cta?: {
        label: string;
        url_token: string;
    };
    is_active?: boolean;
}

export interface PreviewEmailTemplateRequest {
    template_type: EmailTemplateType;
    subject: string;
    body: string;
    cta?: {
        label: string;
        url_token: string;
    };
}

export interface EmailTemplatePreview {
    subject: string;
    body: string;
    context: Record<string, any>;
}

export interface DefaultEmailTemplate {
    subject: string;
    body: string;
    cta?: {
        label: string;
        url_token: string;
    };
}

export enum WaitlistEntryStatus {
    Waiting = 'WAITING',
    Offered = 'OFFERED',
    Purchased = 'PURCHASED',
    Cancelled = 'CANCELLED',
    OfferExpired = 'OFFER_EXPIRED',
}

export interface WaitlistEntry {
    id?: number;
    event_id?: number;
    product_price_id?: number;
    event_occurrence_id?: number | null;
    event_occurrence?: EventOccurrence | null;
    product?: Product;
    product_price?: ProductPrice;
    email?: string;
    first_name?: string;
    last_name?: string;
    status?: WaitlistEntryStatus;
    position?: number;
    offered_at?: string;
    offer_expires_at?: string;
    purchased_at?: string;
    cancelled_at?: string;
    order_id?: number;
    order_short_id?: string;
    order_public_id?: string;
    cancel_token?: string;
    created_at?: string;
    updated_at?: string;
}

export interface JoinWaitlistRequest {
    product_price_id: number;
    event_occurrence_id?: number;
    email: string;
    first_name: string;
    last_name?: string;
    locale?: string;
    promo_code?: string;
}

export interface WaitlistProductStats {
    product_price_id: number;
    product_title: string;
    waiting: number;
    offered: number;
    available: number | null;
}

export interface WaitlistStats {
    total: number;
    waiting: number;
    offered: number;
    purchased: number;
    cancelled: number;
    expired: number;
    products: WaitlistProductStats[];
}