buildscript {
  ext.kotlin_version = '1.9.24'
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

def safeExtGet(prop, fallback) {
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

android {
  namespace "com.fitnessgeolocation"
  // API 35 default — override via rootProject.ext in host app (API 36 ready)
  compileSdkVersion safeExtGet('compileSdkVersion', 35)

  defaultConfig {
    // Android 9 (API 28) minimum — aligns with scoped storage / modern FGS policy baselines
    minSdkVersion safeExtGet('minSdkVersion', 28)
    targetSdkVersion safeExtGet('targetSdkVersion', 35)
    // Provide BuildConfig.IS_NEW_ARCHITECTURE_ENABLED for conditional TurboModule wiring.
    def newArchEnabled = project.hasProperty("newArchEnabled") ? project.getProperty("newArchEnabled") : "false"
    buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", newArchEnabled.toString()
  }

  buildFeatures {
    buildConfig true
  }

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_17
    targetCompatibility JavaVersion.VERSION_17
  }

  kotlinOptions {
    jvmTarget = '17'
  }
}

dependencies {
  implementation "com.facebook.react:react-native:+"
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
  implementation "androidx.core:core-ktx:1.15.0"
  implementation "com.google.android.gms:play-services-location:21.3.0"
  implementation "androidx.work:work-runtime-ktx:2.10.0"
}
