/**
 * Profiles domain — the nurse *seller* profile and the customer *payer* profile. Shapes
 * mirror the b3 contract (`dev/contracts/domains/identity-profiles.md` → `NurseProfileDto`,
 * `CustomerProfileDto`) exactly. The bank account is a separate domain (`services/nurse`).
 *
 * Client-augmented fields (not on the wire yet — filed in requests/for-backend.md):
 *  - nurse `avatarUrl` — no avatar/object-storage route in b3 (REQ-006).
 *  - customer `firstName`/`lastName`/`preferredLanguage` — the wire `CustomerProfileDto`
 *    carries only the emergency contact; name lives on `/me` with no update endpoint (REQ-007).
 * The mock persists these; the real client sends only the wire fields.
 */

/** `NurseProfileDto` — `isVerified` + the three aggregates are server-owned and read-only. */
export interface NurseProfileDto {
  id: number;
  bio: string;
  yearsOfExperience: number;
  educationLevel: string;
  educationField: string;
  /** Raw JSON array string of specialization codes (the builder is deferred to f4). */
  specializationsJson: string;
  isVerified: boolean;
  isAcceptingBookings: boolean;
  averageRating: number;
  totalReviews: number;
  totalCompletedBookings: number;
}

export interface NurseProfile extends NurseProfileDto {
  avatarUrl: string | null;
}

/** `nurse_profiles/upsert` body — never carries `isVerified` or the aggregates. */
export interface UpsertNurseProfileInput {
  bio: string;
  yearsOfExperience: number;
  educationLevel: string;
  educationField: string;
  specializationsJson: string;
  avatarUrl?: string | null;
}

/** `CustomerProfileDto` — emergency contact returned in full to the owning customer. */
export interface CustomerProfileDto {
  id: number;
  defaultEmergencyContactName: string;
  defaultEmergencyContactPhone: string;
}

export interface CustomerProfile extends CustomerProfileDto {
  firstName: string | null;
  lastName: string | null;
  preferredLanguage: string | null;
}

/** `customer_profiles/upsert` body (emergency contact) + client-augmented name/language. */
export interface UpsertCustomerProfileInput {
  defaultEmergencyContactName: string;
  defaultEmergencyContactPhone: string;
  firstName?: string | null;
  lastName?: string | null;
  preferredLanguage?: string | null;
}

export interface AvatarUploadResult {
  url: string;
}

/** The domain's API seam. `get*` resolve to `null` when the caller has no profile yet (404). */
export interface ProfilesApi {
  getCustomerProfile(): Promise<CustomerProfile | null>;
  upsertCustomerProfile(input: UpsertCustomerProfileInput): Promise<CustomerProfile>;
  getNurseProfile(): Promise<NurseProfile | null>;
  upsertNurseProfile(input: UpsertNurseProfileInput): Promise<NurseProfile>;
  uploadAvatar(file: File): Promise<AvatarUploadResult>;
}
