package httpapi

import "sync"

type screenshotRecord struct {
	Data     []byte
	MimeType string
}

type ScreenshotStore struct {
	mu      sync.RWMutex
	records map[string]screenshotRecord
}

func NewScreenshotStore() *ScreenshotStore {
	return &ScreenshotStore{records: make(map[string]screenshotRecord)}
}

func (s *ScreenshotStore) Save(screenID string, data []byte, mimeType string) {
	s.mu.Lock()
	defer s.mu.Unlock()
	s.records[screenID] = screenshotRecord{Data: data, MimeType: mimeType}
}

func (s *ScreenshotStore) Get(screenID string) ([]byte, string, bool) {
	s.mu.RLock()
	defer s.mu.RUnlock()
	rec, ok := s.records[screenID]
	if !ok {
		return nil, "", false
	}
	return rec.Data, rec.MimeType, true
}
