interface ReportDetails {
    cta_click: {
        slot: "primary" | "secondary";
    };
    calendar_step: {
        provider: "calendly";
        step: "profile_viewed" | "event_type_viewed" | "time_selected";
    };
    calendar_booking: {
        provider: "calendly" | "savvycal";
    };
}
type ReportArgs = {
    [K in keyof ReportDetails]: [name: K, details: ReportDetails[K]];
}[keyof ReportDetails];

type Consent = "granted" | "denied";

declare const videoFields: {
    readonly id: {
        readonly kind: "text";
        readonly nullable: false;
    };
    readonly shortId: {
        readonly kind: "text";
        readonly nullable: false;
    };
    readonly title: {
        readonly kind: "text";
        readonly nullable: true;
    };
    readonly videoUrl: {
        readonly kind: "https";
        readonly nullable: false;
    };
    readonly posterImageUrl: {
        readonly kind: "https";
        readonly nullable: true;
    };
    readonly createdAt: {
        readonly kind: "instant";
        readonly nullable: false;
    };
    readonly renderedAt: {
        readonly kind: "instant";
        readonly nullable: true;
    };
};
declare const pageFields: {
    readonly locale: {
        readonly kind: "language";
        readonly nullable: false;
    };
};
declare const commonFields: {
    readonly firstName: {
        readonly standard: "FIRST_NAME";
        readonly conventional: "first_name";
    };
    readonly lastName: {
        readonly standard: "LAST_NAME";
        readonly conventional: "last_name";
    };
    readonly email: {
        readonly standard: "EMAIL";
        readonly conventional: "email";
    };
    readonly companyName: {
        readonly standard: "COMPANY_NAME";
        readonly conventional: "company_name";
    };
    readonly website: {
        readonly standard: "WEBSITE";
        readonly conventional: "website";
    };
    readonly linkedinUrl: {
        readonly standard: "LINKEDIN_PROFILE";
        readonly conventional: "linkedin";
    };
};
type Values<T extends Record<string, {
    nullable: boolean;
}>> = {
    readonly [K in keyof T]: T[K]["nullable"] extends true ? string | null : string;
};
interface PublicContext {
    readonly video: Values<typeof videoFields>;
    readonly page: Values<typeof pageFields>;
    readonly commonData: Readonly<Record<keyof typeof commonFields, string | null>>;
    readonly leadData: Readonly<Record<string, string | null | undefined>>;
}

type BindingRoot = Element | Document | DocumentFragment;

interface PageError {
    scope: "player" | "sdk";
    code: string;
    message: string;
}
interface Position {
    currentTime: number;
}
interface PlaybackEvents {
    "player:play": Position & {
        reason: "start" | "resume" | "replay";
    };
    "player:pause": Position;
    "player:ended": Position;
    "player:timeupdate": Position & {
        duration: number;
    };
    error: PageError;
}

interface PlayerControls {
    mount(target: string | HTMLElement): void;
    unmount(): void;
    play(): Promise<void>;
    pause(): void;
    seek(seconds: number): void;
}

type Off = () => void;
type Cue = {
    at: number;
    currentTime: number;
};
type OnCue = (cue: Cue) => void;
type OnPlayerReady = (player: {
    duration: number;
}) => void;
type StreamSubscription = {
    [K in keyof PlaybackEvents]: [name: K, callback: (payload: PlaybackEvents[K]) => void];
}[keyof PlaybackEvents];
type Subscription = StreamSubscription | [name: "ready", callback: () => void] | [name: "player:ready", callback: OnPlayerReady] | [name: "player:cue", options: {
    at: number;
}, callback: OnCue];
type SubscriptionName = Subscription[0];
/** Only this read-only face is handed to page authors. */
interface PageSubscriptions {
    on<K extends keyof PlaybackEvents>(name: K, callback: (payload: PlaybackEvents[K]) => void): Off;
    on(name: "ready", callback: () => void): Off;
    on(name: "player:ready", callback: OnPlayerReady): Off;
    on(name: "player:cue", options: {
        at: number;
    }, callback: OnCue): Off;
}
interface PageSdk extends PageSubscriptions {
    setAnalyticsConsent(state: Consent): void;
    track(...args: ReportArgs): void;
    getContext(): PublicContext | null;
    bind(root: BindingRoot): void;
    getState(): Readonly<{
        ready: boolean;
        playerReady: boolean;
        currentTime: number | null;
        duration: number | null;
        lastError: Readonly<PageError> | null;
    }>;
    readonly player: PlayerControls;
}

declare global {
    /** Installed synchronously by the classic SDK script. */
    const pitchlane: PageSdk;
    interface Window {
        pitchlane?: PageSdk;
    }
}

export type { PageSdk, PlayerControls, PublicContext, ReportDetails, SubscriptionName };
