import { A as StateMachine, C as StateValue, D as PromiseActorLogic, a as ActorRefFromLogic, b as RequiredActorOptions, c as AnyEventObject, g as IsNotNever, h as InputFrom, i as ActorRefFrom, k as MachineSnapshot, m as GetConcreteByKey, o as AnyActorLogic, p as EventObject, r as ActorRef, s as AnyActorRef, u as ConditionalRequired, v as MetaObject, w as Values, x as RequiredLogicInput, y as NonReducibleUnknown } from "./spawn-D9jgw9pW.js"; import "./StateMachine-EDpYWy0i.js"; import { t as Manager } from "./Manager-CQQ99QOI.js"; import "./Actor-iTq7YY48.js"; //#region ../infra/src/capabilities/IGeolocationCapability.d.ts type GeolocationCoords = { latitude: number; longitude: number; }; type IGeolocationCapability = { getCurrentPosition(): Promise; }; //#endregion //#region src/modules/geolocation/types.d.ts /** * Configuration options for the Geolocation module. * * @example * ```typescript * const config: GeolocationConfig = { * allowUserToSkipGeolocation: true, * }; * ``` */ type GeolocationConfig = { /** * Whether the user is allowed to skip geolocation capture. * When true, a skip button is shown on the permission-denied screen. * Backend field name from flow/workflow configuration. * @default false */ allowUserToSkipGeolocation?: boolean; /** * Maximum number of backend submit attempts before the error screen stops * offering "Try again" and falls back to skip/quit. * @default 3 */ maxAttempts?: number; }; type AddGeolocationParams = { latitude: number; longitude: number; }; //#endregion //#region src/modules/geolocation/geolocationStateMachine.d.ts type GeolocationDeviceType = 'ios' | 'android' | 'desktop'; type GeolocationContext = { config: GeolocationConfig; geolocation: IGeolocationCapability; coords: AddGeolocationParams | undefined; location: string | null | undefined; deviceType: GeolocationDeviceType; attemptsRemaining: number; }; type GeolocationInput = { config: GeolocationConfig; geolocation: IGeolocationCapability; }; declare const geolocationMachine: StateMachine> | ActorRefFromLogic> | undefined; }, Values<{ requestPosition: { src: "requestPosition"; logic: PromiseActorLogic; id: string | undefined; }; submitPosition: { src: "submitPosition"; logic: PromiseActorLogic<{ location: string | null; }, AddGeolocationParams, EventObject>; id: string | undefined; }; }>, Values<{ setCoords: { type: "setCoords"; params: NonReducibleUnknown; }; setLocation: { type: "setLocation"; params: NonReducibleUnknown; }; setDeviceType: { type: "setDeviceType"; params: NonReducibleUnknown; }; decrementAttemptsRemaining: { type: "decrementAttemptsRemaining"; params: NonReducibleUnknown; }; }>, Values<{ canSkip: { type: "canSkip"; params: unknown; }; hasAttemptsRemaining: { type: "hasAttemptsRemaining"; params: unknown; }; isNetworkError: { type: "isNetworkError"; params: unknown; }; isPermissionDenied: { type: "isPermissionDenied"; params: unknown; }; }>, never, "error" | "idle" | "closed" | "finished" | "requestingLocation" | "submitting" | "permissionDenied" | "locationAcquired" | "noNetwork", string, GeolocationInput, NonReducibleUnknown, EventObject, MetaObject, { readonly id: "geolocation"; readonly initial: "idle"; readonly context: ({ input }: { spawn: { (logic: TSrc, ...[options]: ({ src: "requestPosition"; logic: PromiseActorLogic; id: string | undefined; } extends (infer T) ? T extends { src: "requestPosition"; logic: PromiseActorLogic; id: string | undefined; } ? T extends { src: TSrc; } ? ConditionalRequired<[options?: ({ id?: T["id"] | undefined; systemId?: string; input?: InputFrom | undefined; syncSnapshot?: boolean; } & { [K in RequiredActorOptions]: unknown; }) | undefined], IsNotNever>> : never : never : never) | ({ src: "submitPosition"; logic: PromiseActorLogic<{ location: string | null; }, AddGeolocationParams, EventObject>; id: string | undefined; } extends (infer T_1) ? T_1 extends { src: "submitPosition"; logic: PromiseActorLogic<{ location: string | null; }, AddGeolocationParams, EventObject>; id: string | undefined; } ? T_1 extends { src: TSrc; } ? ConditionalRequired<[options?: ({ id?: T_1["id"] | undefined; systemId?: string; input?: InputFrom | undefined; syncSnapshot?: boolean; } & { [K_1 in RequiredActorOptions]: unknown; }) | undefined], IsNotNever>> : never : never : never)): ActorRefFromLogic; id: string | undefined; }; submitPosition: { src: "submitPosition"; logic: PromiseActorLogic<{ location: string | null; }, AddGeolocationParams, EventObject>; id: string | undefined; }; }>, "src", TSrc>["logic"]>; (src: TLogic, ...[options]: ConditionalRequired<[options?: ({ id?: never; systemId?: string; input?: InputFrom | undefined; syncSnapshot?: boolean; } & { [K in RequiredLogicInput]: unknown; }) | undefined], IsNotNever>>): ActorRefFromLogic; }; input: GeolocationInput; self: ActorRef, StateValue, string, unknown, any, any>, { type: "REQUEST"; } | { type: "CONTINUE"; } | { type: "SKIP"; } | { type: "RETRY"; } | { type: "QUIT"; }, AnyEventObject>; }) => { config: GeolocationConfig; geolocation: IGeolocationCapability; coords: undefined; location: undefined; deviceType: GeolocationDeviceType; attemptsRemaining: number; }; readonly states: { readonly idle: { readonly on: { readonly REQUEST: { readonly target: "requestingLocation"; }; }; }; readonly requestingLocation: { readonly invoke: { readonly id: "requestPosition"; readonly src: "requestPosition"; readonly input: ({ context }: { context: GeolocationContext; event: { type: "REQUEST"; } | { type: "CONTINUE"; } | { type: "SKIP"; } | { type: "RETRY"; } | { type: "QUIT"; }; self: ActorRef, StateValue, string, unknown, any, any>, { type: "REQUEST"; } | { type: "CONTINUE"; } | { type: "SKIP"; } | { type: "RETRY"; } | { type: "QUIT"; }, AnyEventObject>; }) => { geolocation: IGeolocationCapability; }; readonly onDone: { readonly target: "submitting"; readonly actions: "setCoords"; }; readonly onError: readonly [{ readonly target: "permissionDenied"; readonly guard: "isPermissionDenied"; readonly actions: "setDeviceType"; }, { readonly target: "error"; readonly actions: "decrementAttemptsRemaining"; }]; }; }; readonly submitting: { readonly invoke: { readonly id: "submitPosition"; readonly src: "submitPosition"; readonly input: ({ context }: { context: GeolocationContext; event: { type: "REQUEST"; } | { type: "CONTINUE"; } | { type: "SKIP"; } | { type: "RETRY"; } | { type: "QUIT"; }; self: ActorRef, StateValue, string, unknown, any, any>, { type: "REQUEST"; } | { type: "CONTINUE"; } | { type: "SKIP"; } | { type: "RETRY"; } | { type: "QUIT"; }, AnyEventObject>; }) => { latitude: number; longitude: number; }; readonly onDone: { readonly target: "locationAcquired"; readonly actions: "setLocation"; }; readonly onError: readonly [{ readonly target: "noNetwork"; readonly guard: "isNetworkError"; }, { readonly target: "error"; readonly actions: "decrementAttemptsRemaining"; }]; }; }; readonly noNetwork: {}; readonly error: { readonly on: { readonly RETRY: { readonly target: "idle"; readonly guard: "hasAttemptsRemaining"; }; readonly SKIP: { readonly target: "finished"; readonly guard: "canSkip"; }; readonly QUIT: { readonly target: "closed"; }; }; }; readonly locationAcquired: { readonly on: { readonly CONTINUE: { readonly target: "finished"; }; }; }; readonly permissionDenied: { readonly on: { readonly SKIP: { readonly target: "finished"; readonly guard: "canSkip"; }; }; }; readonly closed: { readonly type: "final"; }; readonly finished: { readonly type: "final"; }; }; }>; type GeolocationMachine = typeof geolocationMachine; //#endregion //#region src/modules/geolocation/geolocationActor.d.ts type CreateGeolocationActorOptions = { config: GeolocationConfig; geolocation?: IGeolocationCapability; }; type GeolocationActor = ActorRefFrom; //#endregion //#region src/modules/geolocation/geolocationManager.d.ts /** Geolocation manager is in initial state, waiting for `request()` to be called */ type GeolocationIdleState = { status: 'idle'; }; /** Browser geolocation permission prompt is active */ type GeolocationRequestingState = { status: 'requestingLocation'; }; /** Coordinates are being submitted to the backend */ type GeolocationSubmittingState = { status: 'submitting'; }; /** * Location successfully acquired — call `continue()` to proceed * @property location - Location name returned from backend, or null */ type GeolocationAcquiredState = { status: 'locationAcquired'; location: string | null; }; type GeolocationErrorState = { status: 'error'; attemptsRemaining: number; canSkip: boolean; }; /** * A backend request failed due to lost connectivity (device offline/network * error) = the user refreshes once the connection returns. */ type GeolocationNoNetworkState = { status: 'noNetwork'; }; /** * User denied geolocation permission — shows device-specific instructions * @property deviceType - Used by UI to render the correct instruction panel * @property canSkip - Whether the skip button should be shown */ type GeolocationPermissionDeniedState = { status: 'permissionDenied'; deviceType: GeolocationDeviceType; canSkip: boolean; }; /** Geolocation flow completed successfully */ type GeolocationFinishedState = { status: 'finished'; }; type GeolocationClosedState = { status: 'closed'; }; /** * Union of all possible geolocation manager states. * * @example * ```typescript * const state = geolocationManager.getState(); * if (state.status === 'locationAcquired') { * console.log(state.location); * } * if (state.status === 'permissionDenied') { * console.log(state.deviceType); // 'ios' | 'android' | 'desktop' * } * ``` */ type GeolocationState = GeolocationIdleState | GeolocationRequestingState | GeolocationSubmittingState | GeolocationAcquiredState | GeolocationErrorState | GeolocationNoNetworkState | GeolocationPermissionDeniedState | GeolocationFinishedState | GeolocationClosedState; /** * Creates a geolocation manager for headless or UI-driven usage. * * @example Headless usage * ```typescript * const manager = createGeolocationManager({ config: { allowUserToSkipGeolocation: true } }); * manager.subscribe((state) => console.log(state.status)); * manager.request(); * ``` */ declare function createGeolocationManager(options: CreateGeolocationActorOptions): Manager & { /** * Initiates the browser geolocation permission request. * Transitions from 'idle' to 'requestingLocation'. */ request(): void; /** * Confirms the acquired location and completes the module. * Should be called when state is 'locationAcquired'. */ continue(): void; /** * Skips geolocation when the user has denied permission. * Only works when `config.allowUserToSkipGeolocation` is true. */ skip(): void; retry(): void; quit(): void; }; /** * Creates a geolocation manager from a pre-built actor. * Use this when overriding the machine via `.provide()` for custom backends * or for story-isolation testing. */ declare function createGeolocationManagerFromActor(actor: GeolocationActor): Manager & { /** * Initiates the browser geolocation permission request. * Transitions from 'idle' to 'requestingLocation'. */ request(): void; /** * Confirms the acquired location and completes the module. * Should be called when state is 'locationAcquired'. */ continue(): void; /** * Skips geolocation when the user has denied permission. * Only works when `config.allowUserToSkipGeolocation` is true. */ skip(): void; retry(): void; quit(): void; }; type GeolocationManager = ReturnType; //#endregion export { GeolocationActor as a, createGeolocationManagerFromActor as i, GeolocationState as n, geolocationMachine as o, createGeolocationManager as r, GeolocationConfig as s, GeolocationManager as t };