buildscript {
  ext.getExtOrDefault = {name ->
    return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['StorytellerSdkGam_' + name]
  }

  repositories {
    google()
    mavenCentral()
  }

  dependencies {
    classpath "com.android.tools.build:gradle:8.7.2"
    // noinspection DifferentKotlinGradleVersion
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
    classpath "org.jetbrains.kotlin:compose-compiler-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
  }
}


apply plugin: "com.android.library"
apply plugin: "kotlin-android"
apply plugin: "org.jetbrains.kotlin.plugin.compose"

apply plugin: "com.facebook.react"

def getExtOrIntegerDefault(name) {
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["StorytellerSdkGam_" + name]).toInteger()
}

android {
  namespace "com.storytellersdkgam"

  compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

  defaultConfig {
    minSdkVersion getExtOrIntegerDefault("minSdkVersion")
    targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
  }

  buildFeatures {
    buildConfig true
    compose = true
  }

  buildTypes {
    release {
      minifyEnabled false
    }
  }

  lintOptions {
    disable "GradleCompatible"
  }

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }

  sourceSets {
    main {
      java.srcDirs += [
        "generated/java",
        "generated/jni"
      ]
    }
  }
}

repositories {
  mavenCentral()
  google()
}

def kotlin_version = getExtOrDefault('kotlinVersion')

dependencies {
  testImplementation 'androidx.test.ext:junit-ktx:1.2.1'
  testImplementation 'junit:junit:4.13.2'
  testImplementation 'io.mockk:mockk:1.13.5'
  testImplementation "org.robolectric:robolectric:4.10"

  implementation 'com.google.ads.mediation:facebook:6.18.0.0'

  def coroutines_version = "1.7.3"

  // For < 0.71, this will be from the local maven repo
  // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
  //noinspection GradleDynamicVersion
  implementation "com.facebook.react:react-android:+"
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
  testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"

  /**
   * Compose (BoM)
   **/
  implementation(platform("androidx.compose:compose-bom:2026.06.01"))
  implementation("androidx.compose.material3:material3")
  implementation("androidx.compose.material:material")
  implementation("androidx.compose.animation:animation-core")
  implementation("androidx.compose.ui:ui-tooling-preview")
  debugImplementation("androidx.compose.ui:ui-tooling")

  /**
   * Compose Other
   */
  implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.8.7")
  implementation("androidx.lifecycle:lifecycle-runtime-compose:2.8.7")
  implementation("androidx.activity:activity-compose:1.9.3")
  implementation("org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.5")

  /**
   * Fragment
   */
  implementation("androidx.fragment:fragment-ktx:1.8.5")
  implementation("androidx.fragment:fragment-compose:1.8.5")

  implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1"

  implementation(group: "com.getstoryteller", name: "sdk", version: getExtOrDefault("sdkVersion"))
  api(group: "com.getstoryteller", name: "ads", version: getExtOrDefault("sdkVersion"))
}
