package response

import (
	shareddto "wucher/internal/transport/http/dto/shared"
)

type TakeoverResponseAttributes struct {
	ID                 string                               `json:"id,omitempty"`
	FlightID           string                               `json:"flight_id,omitempty"`
	ReserveAcID        string                               `json:"reserve_ac_id,omitempty"`
	FlightInspectionID string                               `json:"flight_inspection_id,omitempty"`
	ShiftStart         string                               `json:"shift_start,omitempty"`
	ShiftEnd           string                               `json:"shift_end,omitempty"`
	BaseID             string                               `json:"base_id,omitempty"`
	Base               *DutyRosterBaseInfo                  `json:"base,omitempty"`
	DutyDate           string                               `json:"duty_date,omitempty"`
	HelicopterID       string                               `json:"helicopter_id,omitempty"`
	Helicopter         *TakeoverHelicopter                  `json:"helicopter,omitempty"`
	Notes              *string                              `json:"notes,omitempty"`
	CreatedBy          string                               `json:"created_by,omitempty" example:"018f3a5c-7a6f-7c2a-8d4a-4b5b1f6c8e9d"`
	UpdatedBy          string                               `json:"updated_by,omitempty" example:"018f3a5c-7a6f-7c2a-8d4a-4b5b1f6c8e9d"`
	CreatedAt          string                               `json:"created_at,omitempty" example:"2026-03-12T03:04:05Z"`
	UpdatedAt          string                               `json:"updated_at,omitempty" example:"2026-03-12T03:04:05Z"`
	RosterDetail       TakeoverDutyRosterDetailsResponse    `json:"roster_detail"`
	Inspection         shareddto.ReserveAcInspectionSummary `json:"inspection"`
	Files              []TakeoverFileResource               `json:"files,omitempty"`
}

// TakeoverHelicopter is the selected helicopter shown on a takeover, enriched
// with its last daily inspection and its maintenance schedule (the "next due"
// per inspection type) from the helicopter's latest fleet status.
type TakeoverHelicopter struct {
	ID                   string                                    `json:"id" example:"018f3a5c-7a6f-7c2a-8d4a-4b5b1f6c8e9d"`
	Designation          string                                    `json:"designation" example:"OE-XHZ"`
	Identifier           string                                    `json:"identifier" example:"1234"`
	Type                 string                                    `json:"type" example:"EC-135"`
	LastDailyInspection  *shareddto.HelicopterLastDailyInspection  `json:"last_daily_inspection"`
	MaintenanceSchedules []shareddto.MaintenanceScheduleAttributes `json:"maintenance_schedules"`
}

type TakeoverDutyRosterAttributes struct {
	Bases      DutyRosterBaseInfo                `json:"bases"`
	FlightID   string                            `json:"flight_id,omitempty" example:"018f3a5c-7a6f-7c2a-8d4a-4b5b1f6c8e9d"`
	Helicopter DutyRosterHelicopterSummary       `json:"helicopter"`
	DutyDate   string                            `json:"duty_date,omitempty" example:"2026-03-16"`
	Detail     TakeoverDutyRosterDetailsResponse `json:"roster_detail"`
	CreatedBy  string                            `json:"created_by,omitempty" example:"018f3a5c-7a6f-7c2a-8d4a-4b5b1f6c8e9d"`
	CreatedAt  string                            `json:"created_at,omitempty" example:"2026-03-12T03:04:05Z"`
	UpdatedAt  string                            `json:"updated_at,omitempty" example:"2026-03-12T03:04:05Z"`
}

type TakeoverDutyRosterResource struct {
	Type       string                       `json:"type" example:"duty_roster"`
	ID         string                       `json:"id,omitempty" example:"018f3a5c-7a6f-7c2a-8d4a-4b5b1f6c8e9d"`
	Attributes TakeoverDutyRosterAttributes `json:"attributes"`
}

type TakeoverDutyRosterCrew struct {
	ID          string `json:"id,omitempty" example:"018f3a5c-7a6f-7c2a-8d4a-4b5b1f6c8e9d"`
	Name        string `json:"name,omitempty" example:"Hunter Wolfgang"`
	Role        string `json:"role,omitempty" example:"doctor"`
	MobilePhone string `json:"mobile_phone,omitempty" example:"+43-1234"`
	Email       string `json:"email,omitempty" example:"doctor@example.com"`
}

type TakeoverDutyRosterPilotCrew struct {
	ID               string `json:"id,omitempty" example:"018f3a5c-7a6f-7c2a-8d4a-4b5b1f6c8e9d"`
	Name             string `json:"name,omitempty" example:"Hunter Wolfgang"`
	Role             string `json:"role,omitempty" example:"pilot"`
	MobilePhone      string `json:"mobile_phone,omitempty" example:"+43-1234"`
	Email            string `json:"email,omitempty" example:"pilot@example.com"`
	CrewType         string `json:"crew_type,omitempty" example:"main"`
	FlightInstructor *bool  `json:"flight_instructor,omitempty"`
	LineChecker      *bool  `json:"line_checker,omitempty"`
	Supervisor       *bool  `json:"supervisor,omitempty"`
	Examiner         *bool  `json:"examiner,omitempty"`
	CoPilot          *bool  `json:"co_pilot,omitempty"`
}

type TakeoverDutyRosterDetailsResponse struct {
	Pilot       []TakeoverDutyRosterPilotCrew `json:"pilot"`
	Doctor      []TakeoverDutyRosterCrew      `json:"doctor"`
	Rescuer     []TakeoverDutyRosterCrew      `json:"rescuer"`
	Helper      []TakeoverDutyRosterCrew      `json:"helper"`
	OtherPerson []TakeoverDutyRosterCrew      `json:"other_person"`
}

type TakeoverResource struct {
	Type       string                     `json:"type" example:"takeover"`
	Attributes TakeoverResponseAttributes `json:"attributes"`
}

type TakeoverFileAttributes struct {
	FileAttachmentID string `json:"file_attachment_id" example:"019d7000-aaaa-7bbb-8ccc-222222222222"`
	FileName         string `json:"file_name,omitempty" example:"takeover-report.pdf"`
	DownloadURL      string `json:"download_url,omitempty" example:"https://s3.localhost.localstack.cloud:4566/wucher-file-dev/files/2026/04/05/takeover-report.pdf?X-Amz-Signature=..."`
}

type TakeoverFileResource struct {
	Type       string                 `json:"type" example:"takeover_file"`
	ID         string                 `json:"id,omitempty" example:"019d7000-aaaa-7bbb-8ccc-111111111111"`
	Attributes TakeoverFileAttributes `json:"attributes"`
}

type TakeoverResponse struct {
	Data TakeoverResource `json:"data"`
}

type TakeoverListResponse struct {
	Data []TakeoverResource `json:"data"`
	Meta map[string]any     `json:"meta,omitempty"`
}
