import type { ExpoConfig, ConfigContext } from 'expo/config';

export default ({ config }: ConfigContext): ExpoConfig => ({
  ...config,
  name: 'Baltique OS Staff',
  slug: 'baltique-os-staff',
  owner: process.env.EXPO_OWNER,
  scheme: 'baltiqueos',
  platforms: ['ios', 'android'],
  version: '1.0.0',
  orientation: 'portrait',
  userInterfaceStyle: 'automatic',
  icon: './assets/icon.png',
  assetBundlePatterns: ['**/*'],
  ios: {
    supportsTablet: true,
    bundleIdentifier: 'pl.baltique.staff',
    buildNumber: '1',
    requireFullScreen: false,
    usesAppleSignIn: false,
    infoPlist: {
      NSCameraUsageDescription: 'Baltique OS używa kamery do bezpiecznego skanowania dokumentów pacjenta i załączników klinicznych.',
      NSFaceIDUsageDescription: 'Baltique OS używa Face ID do ochrony dostępu personelu do aplikacji.',
      NSPhotoLibraryUsageDescription: 'Baltique OS umożliwia wybranie dokumentu lub zdjęcia wyłącznie na polecenie użytkownika.',
      UIBackgroundModes: ['remote-notification'],
      ITSAppUsesNonExemptEncryption: false
    },
    privacyManifests: {
      NSPrivacyAccessedAPITypes: [
        { NSPrivacyAccessedAPIType: 'NSPrivacyAccessedAPICategoryUserDefaults', NSPrivacyAccessedAPITypeReasons: ['CA92.1'] },
        { NSPrivacyAccessedAPIType: 'NSPrivacyAccessedAPICategoryFileTimestamp', NSPrivacyAccessedAPITypeReasons: ['C617.1'] }
      ],
      NSPrivacyCollectedDataTypes: [
        { NSPrivacyCollectedDataType: 'NSPrivacyCollectedDataTypeUserID', NSPrivacyCollectedDataTypeLinked: true, NSPrivacyCollectedDataTypeTracking: false, NSPrivacyCollectedDataTypePurposes: ['NSPrivacyCollectedDataTypePurposeAppFunctionality'] },
        { NSPrivacyCollectedDataType: 'NSPrivacyCollectedDataTypeDeviceID', NSPrivacyCollectedDataTypeLinked: true, NSPrivacyCollectedDataTypeTracking: false, NSPrivacyCollectedDataTypePurposes: ['NSPrivacyCollectedDataTypePurposeAppFunctionality', 'NSPrivacyCollectedDataTypePurposeAppAnalytics'] }
      ],
      NSPrivacyTracking: false
    }
  },
  android: {
    package: 'pl.baltique.staff',
    versionCode: 1,
    adaptiveIcon: {
      foregroundImage: './assets/adaptive-foreground.png',
      backgroundColor: '#07111F'
    },
    permissions: ['CAMERA', 'USE_BIOMETRIC', 'POST_NOTIFICATIONS'],
    blockedPermissions: ['READ_MEDIA_IMAGES', 'READ_MEDIA_VIDEO', 'READ_EXTERNAL_STORAGE', 'WRITE_EXTERNAL_STORAGE']
  },
  plugins: [
    ['expo-splash-screen', { image: './assets/splash.png', imageWidth: 250, resizeMode: 'contain', backgroundColor: '#07111F' }],
    'expo-secure-store',
    'expo-local-authentication',
    ['expo-camera', { cameraPermission: 'Baltique OS używa kamery do skanowania dokumentów pacjenta.' }],
    ['expo-notifications', { icon: './assets/notification-icon.png', color: '#D7B56D', defaultChannel: 'baltique-critical' }],
    ['expo-build-properties', {
      android: { compileSdkVersion: 35, targetSdkVersion: 35, minSdkVersion: 26, kotlinVersion: '2.1.20' },
      ios: { deploymentTarget: '16.4', useFrameworks: 'static' }
    }]
  ],
  extra: {
    apiBaseUrl: process.env.EXPO_PUBLIC_API_BASE_URL ?? 'https://baltique.pl/api/mobile/v1',
    eas: { projectId: process.env.EXPO_PUBLIC_EAS_PROJECT_ID ?? 'REPLACE_WITH_EAS_PROJECT_ID' }
  },
  updates: { enabled: false },
  runtimeVersion: '1.0.0'
});
