///
/// HybridVideoPlayerEventEmitterSpec_cxx.swift
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2025 Marc Rousavy @ Margelo
///

import Foundation
import NitroModules

/**
 * A class implementation that bridges HybridVideoPlayerEventEmitterSpec over to C++.
 * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
 *
 * Also, some Swift types need to be bridged with special handling:
 * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
 * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
 * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
 */
open class HybridVideoPlayerEventEmitterSpec_cxx {
  /**
   * The Swift <> C++ bridge's namespace (`margelo::nitro::video::bridge::swift`)
   * from `ReactNativeVideo-Swift-Cxx-Bridge.hpp`.
   * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
   */
  public typealias bridge = margelo.nitro.video.bridge.swift

  /**
   * Holds an instance of the `HybridVideoPlayerEventEmitterSpec` Swift protocol.
   */
  private var __implementation: any HybridVideoPlayerEventEmitterSpec

  /**
   * Holds a weak pointer to the C++ class that wraps the Swift class.
   */
  private var __cxxPart: bridge.std__weak_ptr_HybridVideoPlayerEventEmitterSpec_

  /**
   * Create a new `HybridVideoPlayerEventEmitterSpec_cxx` that wraps the given `HybridVideoPlayerEventEmitterSpec`.
   * All properties and methods bridge to C++ types.
   */
  public init(_ implementation: any HybridVideoPlayerEventEmitterSpec) {
    self.__implementation = implementation
    self.__cxxPart = .init()
    /* no base class */
  }

  /**
   * Get the actual `HybridVideoPlayerEventEmitterSpec` instance this class wraps.
   */
  @inline(__always)
  public func getHybridVideoPlayerEventEmitterSpec() -> any HybridVideoPlayerEventEmitterSpec {
    return __implementation
  }

  /**
   * Casts this instance to a retained unsafe raw pointer.
   * This acquires one additional strong reference on the object!
   */
  public func toUnsafe() -> UnsafeMutableRawPointer {
    return Unmanaged.passRetained(self).toOpaque()
  }

  /**
   * Casts an unsafe pointer to a `HybridVideoPlayerEventEmitterSpec_cxx`.
   * The pointer has to be a retained opaque `Unmanaged<HybridVideoPlayerEventEmitterSpec_cxx>`.
   * This removes one strong reference from the object!
   */
  public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridVideoPlayerEventEmitterSpec_cxx {
    return Unmanaged<HybridVideoPlayerEventEmitterSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
  }

  /**
   * Gets (or creates) the C++ part of this Hybrid Object.
   * The C++ part is a `std::shared_ptr<HybridVideoPlayerEventEmitterSpec>`.
   */
  public func getCxxPart() -> bridge.std__shared_ptr_HybridVideoPlayerEventEmitterSpec_ {
    let cachedCxxPart = self.__cxxPart.lock()
    if cachedCxxPart.__convertToBool() {
      return cachedCxxPart
    } else {
      let newCxxPart = bridge.create_std__shared_ptr_HybridVideoPlayerEventEmitterSpec_(self.toUnsafe())
      __cxxPart = bridge.weakify_std__shared_ptr_HybridVideoPlayerEventEmitterSpec_(newCxxPart)
      return newCxxPart
    }
  }

  

  /**
   * Get the memory size of the Swift class (plus size of any other allocations)
   * so the JS VM can properly track it and garbage-collect the JS object if needed.
   */
  @inline(__always)
  public var memorySize: Int {
    return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
  }

  /**
   * Call dispose() on the Swift class.
   * This _may_ be called manually from JS.
   */
  @inline(__always)
  public func dispose() {
    self.__implementation.dispose()
  }

  // Properties
  public final var onAudioBecomingNoisy: bridge.Func_void {
    @inline(__always)
    get {
      return { () -> bridge.Func_void in
        let __closureWrapper = Func_void(self.__implementation.onAudioBecomingNoisy)
        return bridge.create_Func_void(__closureWrapper.toUnsafe())
      }()
    }
    @inline(__always)
    set {
      self.__implementation.onAudioBecomingNoisy = { () -> () -> Void in
        let __wrappedFunction = bridge.wrap_Func_void(newValue)
        return { () -> Void in
          __wrappedFunction.call()
        }
      }()
    }
  }
  
  public final var onAudioFocusChange: bridge.Func_void_bool {
    @inline(__always)
    get {
      return { () -> bridge.Func_void_bool in
        let __closureWrapper = Func_void_bool(self.__implementation.onAudioFocusChange)
        return bridge.create_Func_void_bool(__closureWrapper.toUnsafe())
      }()
    }
    @inline(__always)
    set {
      self.__implementation.onAudioFocusChange = { () -> (Bool) -> Void in
        let __wrappedFunction = bridge.wrap_Func_void_bool(newValue)
        return { (__hasAudioFocus: Bool) -> Void in
          __wrappedFunction.call(__hasAudioFocus)
        }
      }()
    }
  }
  
  public final var onBandwidthUpdate: bridge.Func_void_BandwidthData {
    @inline(__always)
    get {
      return { () -> bridge.Func_void_BandwidthData in
        let __closureWrapper = Func_void_BandwidthData(self.__implementation.onBandwidthUpdate)
        return bridge.create_Func_void_BandwidthData(__closureWrapper.toUnsafe())
      }()
    }
    @inline(__always)
    set {
      self.__implementation.onBandwidthUpdate = { () -> (BandwidthData) -> Void in
        let __wrappedFunction = bridge.wrap_Func_void_BandwidthData(newValue)
        return { (__data: BandwidthData) -> Void in
          __wrappedFunction.call(__data)
        }
      }()
    }
  }
  
  public final var onBuffer: bridge.Func_void_bool {
    @inline(__always)
    get {
      return { () -> bridge.Func_void_bool in
        let __closureWrapper = Func_void_bool(self.__implementation.onBuffer)
        return bridge.create_Func_void_bool(__closureWrapper.toUnsafe())
      }()
    }
    @inline(__always)
    set {
      self.__implementation.onBuffer = { () -> (Bool) -> Void in
        let __wrappedFunction = bridge.wrap_Func_void_bool(newValue)
        return { (__buffering: Bool) -> Void in
          __wrappedFunction.call(__buffering)
        }
      }()
    }
  }
  
  public final var onControlsVisibleChange: bridge.Func_void_bool {
    @inline(__always)
    get {
      return { () -> bridge.Func_void_bool in
        let __closureWrapper = Func_void_bool(self.__implementation.onControlsVisibleChange)
        return bridge.create_Func_void_bool(__closureWrapper.toUnsafe())
      }()
    }
    @inline(__always)
    set {
      self.__implementation.onControlsVisibleChange = { () -> (Bool) -> Void in
        let __wrappedFunction = bridge.wrap_Func_void_bool(newValue)
        return { (__visible: Bool) -> Void in
          __wrappedFunction.call(__visible)
        }
      }()
    }
  }
  
  public final var onEnd: bridge.Func_void {
    @inline(__always)
    get {
      return { () -> bridge.Func_void in
        let __closureWrapper = Func_void(self.__implementation.onEnd)
        return bridge.create_Func_void(__closureWrapper.toUnsafe())
      }()
    }
    @inline(__always)
    set {
      self.__implementation.onEnd = { () -> () -> Void in
        let __wrappedFunction = bridge.wrap_Func_void(newValue)
        return { () -> Void in
          __wrappedFunction.call()
        }
      }()
    }
  }
  
  public final var onExternalPlaybackChange: bridge.Func_void_bool {
    @inline(__always)
    get {
      return { () -> bridge.Func_void_bool in
        let __closureWrapper = Func_void_bool(self.__implementation.onExternalPlaybackChange)
        return bridge.create_Func_void_bool(__closureWrapper.toUnsafe())
      }()
    }
    @inline(__always)
    set {
      self.__implementation.onExternalPlaybackChange = { () -> (Bool) -> Void in
        let __wrappedFunction = bridge.wrap_Func_void_bool(newValue)
        return { (__externalPlaybackActive: Bool) -> Void in
          __wrappedFunction.call(__externalPlaybackActive)
        }
      }()
    }
  }
  
  public final var onLoad: bridge.Func_void_onLoadData {
    @inline(__always)
    get {
      return { () -> bridge.Func_void_onLoadData in
        let __closureWrapper = Func_void_onLoadData(self.__implementation.onLoad)
        return bridge.create_Func_void_onLoadData(__closureWrapper.toUnsafe())
      }()
    }
    @inline(__always)
    set {
      self.__implementation.onLoad = { () -> (onLoadData) -> Void in
        let __wrappedFunction = bridge.wrap_Func_void_onLoadData(newValue)
        return { (__data: onLoadData) -> Void in
          __wrappedFunction.call(__data)
        }
      }()
    }
  }
  
  public final var onLoadStart: bridge.Func_void_onLoadStartData {
    @inline(__always)
    get {
      return { () -> bridge.Func_void_onLoadStartData in
        let __closureWrapper = Func_void_onLoadStartData(self.__implementation.onLoadStart)
        return bridge.create_Func_void_onLoadStartData(__closureWrapper.toUnsafe())
      }()
    }
    @inline(__always)
    set {
      self.__implementation.onLoadStart = { () -> (onLoadStartData) -> Void in
        let __wrappedFunction = bridge.wrap_Func_void_onLoadStartData(newValue)
        return { (__data: onLoadStartData) -> Void in
          __wrappedFunction.call(__data)
        }
      }()
    }
  }
  
  public final var onPlaybackStateChange: bridge.Func_void_onPlaybackStateChangeData {
    @inline(__always)
    get {
      return { () -> bridge.Func_void_onPlaybackStateChangeData in
        let __closureWrapper = Func_void_onPlaybackStateChangeData(self.__implementation.onPlaybackStateChange)
        return bridge.create_Func_void_onPlaybackStateChangeData(__closureWrapper.toUnsafe())
      }()
    }
    @inline(__always)
    set {
      self.__implementation.onPlaybackStateChange = { () -> (onPlaybackStateChangeData) -> Void in
        let __wrappedFunction = bridge.wrap_Func_void_onPlaybackStateChangeData(newValue)
        return { (__data: onPlaybackStateChangeData) -> Void in
          __wrappedFunction.call(__data)
        }
      }()
    }
  }
  
  public final var onPlaybackRateChange: bridge.Func_void_double {
    @inline(__always)
    get {
      return { () -> bridge.Func_void_double in
        let __closureWrapper = Func_void_double(self.__implementation.onPlaybackRateChange)
        return bridge.create_Func_void_double(__closureWrapper.toUnsafe())
      }()
    }
    @inline(__always)
    set {
      self.__implementation.onPlaybackRateChange = { () -> (Double) -> Void in
        let __wrappedFunction = bridge.wrap_Func_void_double(newValue)
        return { (__rate: Double) -> Void in
          __wrappedFunction.call(__rate)
        }
      }()
    }
  }
  
  public final var onProgress: bridge.Func_void_onProgressData {
    @inline(__always)
    get {
      return { () -> bridge.Func_void_onProgressData in
        let __closureWrapper = Func_void_onProgressData(self.__implementation.onProgress)
        return bridge.create_Func_void_onProgressData(__closureWrapper.toUnsafe())
      }()
    }
    @inline(__always)
    set {
      self.__implementation.onProgress = { () -> (onProgressData) -> Void in
        let __wrappedFunction = bridge.wrap_Func_void_onProgressData(newValue)
        return { (__data: onProgressData) -> Void in
          __wrappedFunction.call(__data)
        }
      }()
    }
  }
  
  public final var onReadyToDisplay: bridge.Func_void {
    @inline(__always)
    get {
      return { () -> bridge.Func_void in
        let __closureWrapper = Func_void(self.__implementation.onReadyToDisplay)
        return bridge.create_Func_void(__closureWrapper.toUnsafe())
      }()
    }
    @inline(__always)
    set {
      self.__implementation.onReadyToDisplay = { () -> () -> Void in
        let __wrappedFunction = bridge.wrap_Func_void(newValue)
        return { () -> Void in
          __wrappedFunction.call()
        }
      }()
    }
  }
  
  public final var onSeek: bridge.Func_void_double {
    @inline(__always)
    get {
      return { () -> bridge.Func_void_double in
        let __closureWrapper = Func_void_double(self.__implementation.onSeek)
        return bridge.create_Func_void_double(__closureWrapper.toUnsafe())
      }()
    }
    @inline(__always)
    set {
      self.__implementation.onSeek = { () -> (Double) -> Void in
        let __wrappedFunction = bridge.wrap_Func_void_double(newValue)
        return { (__seekTime: Double) -> Void in
          __wrappedFunction.call(__seekTime)
        }
      }()
    }
  }
  
  public final var onTimedMetadata: bridge.Func_void_TimedMetadata {
    @inline(__always)
    get {
      return { () -> bridge.Func_void_TimedMetadata in
        let __closureWrapper = Func_void_TimedMetadata(self.__implementation.onTimedMetadata)
        return bridge.create_Func_void_TimedMetadata(__closureWrapper.toUnsafe())
      }()
    }
    @inline(__always)
    set {
      self.__implementation.onTimedMetadata = { () -> (TimedMetadata) -> Void in
        let __wrappedFunction = bridge.wrap_Func_void_TimedMetadata(newValue)
        return { (__metadata: TimedMetadata) -> Void in
          __wrappedFunction.call(__metadata)
        }
      }()
    }
  }
  
  public final var onTextTrackDataChanged: bridge.Func_void_std__vector_std__string_ {
    @inline(__always)
    get {
      return { () -> bridge.Func_void_std__vector_std__string_ in
        let __closureWrapper = Func_void_std__vector_std__string_(self.__implementation.onTextTrackDataChanged)
        return bridge.create_Func_void_std__vector_std__string_(__closureWrapper.toUnsafe())
      }()
    }
    @inline(__always)
    set {
      self.__implementation.onTextTrackDataChanged = { () -> ([String]) -> Void in
        let __wrappedFunction = bridge.wrap_Func_void_std__vector_std__string_(newValue)
        return { (__texts: [String]) -> Void in
          __wrappedFunction.call({ () -> bridge.std__vector_std__string_ in
            var __vector = bridge.create_std__vector_std__string_(__texts.count)
            for __item in __texts {
              __vector.push_back(std.string(__item))
            }
            return __vector
          }())
        }
      }()
    }
  }
  
  public final var onTrackChange: bridge.Func_void_std__optional_TextTrack_ {
    @inline(__always)
    get {
      return { () -> bridge.Func_void_std__optional_TextTrack_ in
        let __closureWrapper = Func_void_std__optional_TextTrack_(self.__implementation.onTrackChange)
        return bridge.create_Func_void_std__optional_TextTrack_(__closureWrapper.toUnsafe())
      }()
    }
    @inline(__always)
    set {
      self.__implementation.onTrackChange = { () -> (TextTrack?) -> Void in
        let __wrappedFunction = bridge.wrap_Func_void_std__optional_TextTrack_(newValue)
        return { (__track: TextTrack?) -> Void in
          __wrappedFunction.call({ () -> bridge.std__optional_TextTrack_ in
            if let __unwrappedValue = __track {
              return bridge.create_std__optional_TextTrack_(__unwrappedValue)
            } else {
              return .init()
            }
          }())
        }
      }()
    }
  }
  
  public final var onVolumeChange: bridge.Func_void_onVolumeChangeData {
    @inline(__always)
    get {
      return { () -> bridge.Func_void_onVolumeChangeData in
        let __closureWrapper = Func_void_onVolumeChangeData(self.__implementation.onVolumeChange)
        return bridge.create_Func_void_onVolumeChangeData(__closureWrapper.toUnsafe())
      }()
    }
    @inline(__always)
    set {
      self.__implementation.onVolumeChange = { () -> (onVolumeChangeData) -> Void in
        let __wrappedFunction = bridge.wrap_Func_void_onVolumeChangeData(newValue)
        return { (__data: onVolumeChangeData) -> Void in
          __wrappedFunction.call(__data)
        }
      }()
    }
  }
  
  public final var onStatusChange: bridge.Func_void_VideoPlayerStatus {
    @inline(__always)
    get {
      return { () -> bridge.Func_void_VideoPlayerStatus in
        let __closureWrapper = Func_void_VideoPlayerStatus(self.__implementation.onStatusChange)
        return bridge.create_Func_void_VideoPlayerStatus(__closureWrapper.toUnsafe())
      }()
    }
    @inline(__always)
    set {
      self.__implementation.onStatusChange = { () -> (VideoPlayerStatus) -> Void in
        let __wrappedFunction = bridge.wrap_Func_void_VideoPlayerStatus(newValue)
        return { (__status: VideoPlayerStatus) -> Void in
          __wrappedFunction.call(__status.rawValue)
        }
      }()
    }
  }

  // Methods
  
}
