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


def isNewArchitectureEnabled() {
    return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}

if (isNewArchitectureEnabled()) {
  apply plugin: "com.facebook.react"
}

def reactNativeArchitectures() {
  def value = rootProject.getProperties().get("reactNativeArchitectures")
  return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

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

def supportsNamespace() {
  def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
  def major = parsed[0].toInteger()
  def minor = parsed[1].toInteger()

  // Namespace support was added in 7.3.0
  return (major >= 7 && minor >= 3) || major >= 8
}

android {
  ndkVersion="27.1.122297006"
  if (supportsNamespace()) {
    namespace="com.seonreactnativemobilewrapper"
  }

  compileSdkVersion 35
  defaultConfig {
    minSdkVersion 19
    targetSdkVersion 35
    buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
    versionCode 1
    versionName '1.0'
  }

  sourceSets {
    main {
      if (isNewArchitectureEnabled()) {
        java.srcDirs += ['src/newarch']
      } else {
        java.srcDirs += ['src/oldarch']
      }
    }
  }

  buildTypes {
    release {
      minifyEnabled false
    }
  }

  buildFeatures {
    buildConfig true
  }

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
  kotlinOptions {
    freeCompilerArgs = ['-Xjvm-default=all']
  }
}

repositories {
  mavenCentral()
  google()
}

dependencies {
  // 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-native:+'
  implementation 'org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version'
  implementation 'io.seon.androidsdk:androidsdk:6.8.2'
}
