// Data-import DOMAIN — Sample-Path Verification state machine (§6). Pure.
// Idle -> Verifying -> (Verified preview | VerifyFailed). V1 (bucket-relative input) is checked
// synchronously in the reducer; V2 (does it resolve? bad-path vs permission/CORS) is the async
// gateway result fed back via VERIFY_OK / VERIFY_FAIL.

import type { ImportError } from '../types';

export type SamplePathState = 'Idle' | 'Verifying' | 'Verified' | 'VerifyFailed';

/** A successful resolution preview (V2) — an asset URL and/or a human note. */
export interface SamplePathPreview {
  assetUrl?: string;
  note?: string;
}

export interface SamplePathContext {
  path: string;
  preview: SamplePathPreview | null;
  error: ImportError | null;
}

export type SamplePathEvent =
  | { type: 'PASTE_PATH'; path: string }
  | { type: 'VERIFY_OK'; preview: SamplePathPreview }
  | { type: 'VERIFY_FAIL'; error: ImportError }
  | { type: 'RESET' };

export interface SamplePathMachine {
  state: SamplePathState;
  context: SamplePathContext;
}

export const initialSamplePathContext: SamplePathContext = { path: '', preview: null, error: null };
export const initialSamplePathMachine: SamplePathMachine = { state: 'Idle', context: initialSamplePathContext };
