import type { StateValue } from "./state.js"; import type { CustomVariableValue } from "./variables.js"; type EqualityOperator = "=" | "!="; type ArrayOperator = "in" | "not in"; export type ComparisonOperator = ">=" | ">" | "<=" | "<" | "="; export declare const RuleKey: { readonly SelectedPackageCondition: "selected_package_condition"; readonly IntroOfferCondition: "intro_offer_condition"; readonly PromoOfferCondition: "promo_offer_condition"; readonly VariableCondition: "variable_condition"; readonly StateCondition: "state_condition"; readonly WindowWidthCondition: "window_width_condition"; readonly WindowHeightCondition: "window_height_condition"; readonly WindowAspectRatioCondition: "window_aspect_ratio_condition"; readonly InputCondition: "input_condition"; readonly FunnelCondition: "funnel_condition"; }; interface IntroOfferCondition { type: "intro_offer"; } interface MultipleIntroOffersCondition { type: "multiple_intro_offers"; } interface SelectedCondition { type: "selected"; } interface HoverCondition { type: "hover"; } interface FocusCondition { type: "focus"; } interface ErrorCondition { type: "error"; } interface PromoOfferCondition { type: "promo_offer"; } interface SelectedPackageCondition { type: typeof RuleKey.SelectedPackageCondition; operator: ArrayOperator; packages: string[]; } interface IntroductoryOfferCondition { type: typeof RuleKey.IntroOfferCondition; operator: EqualityOperator; value: boolean; } interface PromotionalOfferCondition { type: typeof RuleKey.PromoOfferCondition; operator: EqualityOperator; value: boolean; } interface VariableCondition { type: typeof RuleKey.VariableCondition; operator: EqualityOperator; variable: string; value: CustomVariableValue | string | number | boolean; } interface StateCondition { type: typeof RuleKey.StateCondition; operator: EqualityOperator; name: string; value: StateValue; } /** * Matches the option ids currently selected for a choice input's `field_id`, * on this screen or an earlier funnel screen. `in` matches when any selected * id is in `value`; `all` when every id in `value` is selected. */ export interface InputCondition { type: typeof RuleKey.InputCondition; operator: "in" | "all"; field_id: string; value: string[]; } /** * A boolean JSON Logic expression over funnel state, e.g. * `{ "in": [{ "var": "country" }, ["US", "CA"]] }`. Only funnels send it; the * host evaluates `logic` through `FunnelConditionEvaluator`. */ export interface FunnelCondition { type: typeof RuleKey.FunnelCondition; logic: unknown; } /** * Evaluates a `funnel_condition`'s `logic` against the funnel's state when the * screen is entered. Without one, funnel conditions never match. */ export type FunnelConditionEvaluator = (logic: unknown) => boolean; /** * Compares the paywall's own box (CSS px, matching iOS points and Android dp) * or its aspect ratio (width รท height). Never matches before the paywall is * measured. */ export interface WindowSizeCondition { type: typeof RuleKey.WindowWidthCondition | typeof RuleKey.WindowHeightCondition | typeof RuleKey.WindowAspectRatioCondition; operator: ComparisonOperator; value: number; } export type OverrideCondition = IntroOfferCondition | MultipleIntroOffersCondition | SelectedCondition | HoverCondition | FocusCondition | ErrorCondition | PromoOfferCondition | IntroductoryOfferCondition | PromotionalOfferCondition | SelectedPackageCondition | VariableCondition | StateCondition | WindowSizeCondition | InputCondition | FunnelCondition; /** * The reserved properties of an override that should not be included in the override properties */ type ReservedProperty = "id" | "type" | "overrides" | "stack" | "components" | "items" | "pages" | "tabs" | "field_id" | "option_id" | "keyboard_type" | "capitalize" | "validation" | "validation_error_lid" | "validation_error_lids"; type OverrideProperties = Partial>; interface Override { conditions: OverrideCondition[]; properties: OverrideProperties; } export type Overrides = Override[]; export {};