/*
 * Copyright © Harsh Shandilya.
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 */
package dev.msfjarvis.claw.android.injection

import android.util.Log
import dev.zacsweers.metro.AppScope
import dev.zacsweers.metro.BindingContainer
import dev.zacsweers.metro.ContributesTo
import dev.zacsweers.metro.Provides
import me.saket.unfurl.UnfurlLogger
import me.saket.unfurl.Unfurler
import okhttp3.OkHttpClient

@BindingContainer
@ContributesTo(AppScope::class)
object MetadataExtractorModule {
  @Provides
  fun provideUnfurlLogger(): UnfurlLogger {
    return object : UnfurlLogger {
      override fun log(message: String) {
        Log.d("Unfurler", message)
      }

      override fun log(e: Throwable, message: String) {
        Log.e("Unfurler", message, e)
      }
    }
  }

  @Provides
  fun provideUnfurler(okHttpClient: OkHttpClient, logger: UnfurlLogger): Unfurler {
    return Unfurler(httpClient = okHttpClient, logger = logger)
  }
}
