package output

import "context"

// NotificationServicePort defines the interface for sending notifications to parties
// This is used for parties operating in OFFLINE mode (with notification channels configured)
//
// Parties without notification channels operate in REAL-TIME mode:
//   - Session events are pushed via Message Router
//   - Parties must be connected to receive events immediately
//
// Parties with notification channels operate in OFFLINE mode:
//   - Session invitations are sent via email/SMS/push notifications
//   - Parties have 24 hours to complete their participation
//   - Parties poll for pending sessions when they come online
//
// TODO: Implement notification service adapters (email, SMS, push)
type NotificationServicePort interface {
	// SendSessionInvitation sends a session invitation notification to a party
	// This is called when a party with notification channels is selected for a session
	SendSessionInvitation(ctx context.Context, input SessionInvitationInput) error

	// SendSessionReminder sends a reminder for a pending session
	// Called periodically for sessions approaching expiration
	SendSessionReminder(ctx context.Context, input SessionReminderInput) error

	// SendSessionExpiredNotification notifies a party that a session has expired
	SendSessionExpiredNotification(ctx context.Context, input SessionExpiredInput) error
}

// SessionInvitationInput contains data for sending a session invitation
type SessionInvitationInput struct {
	// Party identification
	PartyID string

	// Notification channels (at least one should be set)
	Email     string
	Phone     string
	PushToken string

	// Session details
	SessionID   string
	SessionType string // "keygen" or "sign"
	JoinToken   string
	ExpiresAt   int64 // Unix timestamp milliseconds

	// Optional context
	InitiatorID  string // Who initiated the session
	MessageToSign string // For sign sessions, human-readable description
}

// SessionReminderInput contains data for sending a session reminder
type SessionReminderInput struct {
	PartyID   string
	Email     string
	Phone     string
	PushToken string

	SessionID   string
	SessionType string
	JoinToken   string
	ExpiresAt   int64

	// Reminder specific
	TimeRemaining string // e.g., "2 hours", "30 minutes"
	ReminderCount int    // How many reminders have been sent
}

// SessionExpiredInput contains data for sending session expiration notification
type SessionExpiredInput struct {
	PartyID   string
	Email     string
	Phone     string
	PushToken string

	SessionID   string
	SessionType string
	ExpiredAt   int64
}

// NotificationResult represents the result of a notification attempt
type NotificationResult struct {
	Success bool
	Channel string // Which channel was used: "email", "sms", "push"
	Error   string // Error message if failed
}
