// Copyright 2023, the Chromium project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Autogenerated from Pigeon (v25.3.2), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#if __has_include("include/firebase_core/messages.g.h")
#import "include/firebase_core/messages.g.h"
#else
#import "include/messages.g.h"
#endif

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif

#if !__has_feature(objc_arc)
#error File requires ARC to be enabled.
#endif

static NSArray<id> *wrapResult(id result, FlutterError *error) {
  if (error) {
    return @[
      error.code ?: [NSNull null], error.message ?: [NSNull null], error.details ?: [NSNull null]
    ];
  }
  return @[ result ?: [NSNull null] ];
}

static id GetNullableObjectAtIndex(NSArray<id> *array, NSInteger key) {
  id result = array[key];
  return (result == [NSNull null]) ? nil : result;
}

@interface CoreFirebaseOptions ()
+ (CoreFirebaseOptions *)fromList:(NSArray<id> *)list;
+ (nullable CoreFirebaseOptions *)nullableFromList:(NSArray<id> *)list;
- (NSArray<id> *)toList;
@end

@interface CoreInitializeResponse ()
+ (CoreInitializeResponse *)fromList:(NSArray<id> *)list;
+ (nullable CoreInitializeResponse *)nullableFromList:(NSArray<id> *)list;
- (NSArray<id> *)toList;
@end

@implementation CoreFirebaseOptions
+ (instancetype)makeWithApiKey:(NSString *)apiKey
                         appId:(NSString *)appId
             messagingSenderId:(NSString *)messagingSenderId
                     projectId:(NSString *)projectId
                    authDomain:(nullable NSString *)authDomain
                   databaseURL:(nullable NSString *)databaseURL
                 storageBucket:(nullable NSString *)storageBucket
                 measurementId:(nullable NSString *)measurementId
                    trackingId:(nullable NSString *)trackingId
             deepLinkURLScheme:(nullable NSString *)deepLinkURLScheme
               androidClientId:(nullable NSString *)androidClientId
                   iosClientId:(nullable NSString *)iosClientId
                   iosBundleId:(nullable NSString *)iosBundleId
                    appGroupId:(nullable NSString *)appGroupId {
  CoreFirebaseOptions *pigeonResult = [[CoreFirebaseOptions alloc] init];
  pigeonResult.apiKey = apiKey;
  pigeonResult.appId = appId;
  pigeonResult.messagingSenderId = messagingSenderId;
  pigeonResult.projectId = projectId;
  pigeonResult.authDomain = authDomain;
  pigeonResult.databaseURL = databaseURL;
  pigeonResult.storageBucket = storageBucket;
  pigeonResult.measurementId = measurementId;
  pigeonResult.trackingId = trackingId;
  pigeonResult.deepLinkURLScheme = deepLinkURLScheme;
  pigeonResult.androidClientId = androidClientId;
  pigeonResult.iosClientId = iosClientId;
  pigeonResult.iosBundleId = iosBundleId;
  pigeonResult.appGroupId = appGroupId;
  return pigeonResult;
}
+ (CoreFirebaseOptions *)fromList:(NSArray<id> *)list {
  CoreFirebaseOptions *pigeonResult = [[CoreFirebaseOptions alloc] init];
  pigeonResult.apiKey = GetNullableObjectAtIndex(list, 0);
  pigeonResult.appId = GetNullableObjectAtIndex(list, 1);
  pigeonResult.messagingSenderId = GetNullableObjectAtIndex(list, 2);
  pigeonResult.projectId = GetNullableObjectAtIndex(list, 3);
  pigeonResult.authDomain = GetNullableObjectAtIndex(list, 4);
  pigeonResult.databaseURL = GetNullableObjectAtIndex(list, 5);
  pigeonResult.storageBucket = GetNullableObjectAtIndex(list, 6);
  pigeonResult.measurementId = GetNullableObjectAtIndex(list, 7);
  pigeonResult.trackingId = GetNullableObjectAtIndex(list, 8);
  pigeonResult.deepLinkURLScheme = GetNullableObjectAtIndex(list, 9);
  pigeonResult.androidClientId = GetNullableObjectAtIndex(list, 10);
  pigeonResult.iosClientId = GetNullableObjectAtIndex(list, 11);
  pigeonResult.iosBundleId = GetNullableObjectAtIndex(list, 12);
  pigeonResult.appGroupId = GetNullableObjectAtIndex(list, 13);
  return pigeonResult;
}
+ (nullable CoreFirebaseOptions *)nullableFromList:(NSArray<id> *)list {
  return (list) ? [CoreFirebaseOptions fromList:list] : nil;
}
- (NSArray<id> *)toList {
  return @[
    self.apiKey ?: [NSNull null],
    self.appId ?: [NSNull null],
    self.messagingSenderId ?: [NSNull null],
    self.projectId ?: [NSNull null],
    self.authDomain ?: [NSNull null],
    self.databaseURL ?: [NSNull null],
    self.storageBucket ?: [NSNull null],
    self.measurementId ?: [NSNull null],
    self.trackingId ?: [NSNull null],
    self.deepLinkURLScheme ?: [NSNull null],
    self.androidClientId ?: [NSNull null],
    self.iosClientId ?: [NSNull null],
    self.iosBundleId ?: [NSNull null],
    self.appGroupId ?: [NSNull null],
  ];
}
@end

@implementation CoreInitializeResponse
+ (instancetype)makeWithName:(NSString *)name
                             options:(CoreFirebaseOptions *)options
    isAutomaticDataCollectionEnabled:(nullable NSNumber *)isAutomaticDataCollectionEnabled
                     pluginConstants:(NSDictionary<NSString *, id> *)pluginConstants {
  CoreInitializeResponse *pigeonResult = [[CoreInitializeResponse alloc] init];
  pigeonResult.name = name;
  pigeonResult.options = options;
  pigeonResult.isAutomaticDataCollectionEnabled = isAutomaticDataCollectionEnabled;
  pigeonResult.pluginConstants = pluginConstants;
  return pigeonResult;
}
+ (CoreInitializeResponse *)fromList:(NSArray<id> *)list {
  CoreInitializeResponse *pigeonResult = [[CoreInitializeResponse alloc] init];
  pigeonResult.name = GetNullableObjectAtIndex(list, 0);
  pigeonResult.options = GetNullableObjectAtIndex(list, 1);
  pigeonResult.isAutomaticDataCollectionEnabled = GetNullableObjectAtIndex(list, 2);
  pigeonResult.pluginConstants = GetNullableObjectAtIndex(list, 3);
  return pigeonResult;
}
+ (nullable CoreInitializeResponse *)nullableFromList:(NSArray<id> *)list {
  return (list) ? [CoreInitializeResponse fromList:list] : nil;
}
- (NSArray<id> *)toList {
  return @[
    self.name ?: [NSNull null],
    self.options ?: [NSNull null],
    self.isAutomaticDataCollectionEnabled ?: [NSNull null],
    self.pluginConstants ?: [NSNull null],
  ];
}
@end

@interface nullMessagesPigeonCodecReader : FlutterStandardReader
@end
@implementation nullMessagesPigeonCodecReader
- (nullable id)readValueOfType:(UInt8)type {
  switch (type) {
    case 129:
      return [CoreFirebaseOptions fromList:[self readValue]];
    case 130:
      return [CoreInitializeResponse fromList:[self readValue]];
    default:
      return [super readValueOfType:type];
  }
}
@end

@interface nullMessagesPigeonCodecWriter : FlutterStandardWriter
@end
@implementation nullMessagesPigeonCodecWriter
- (void)writeValue:(id)value {
  if ([value isKindOfClass:[CoreFirebaseOptions class]]) {
    [self writeByte:129];
    [self writeValue:[value toList]];
  } else if ([value isKindOfClass:[CoreInitializeResponse class]]) {
    [self writeByte:130];
    [self writeValue:[value toList]];
  } else {
    [super writeValue:value];
  }
}
@end

@interface nullMessagesPigeonCodecReaderWriter : FlutterStandardReaderWriter
@end
@implementation nullMessagesPigeonCodecReaderWriter
- (FlutterStandardWriter *)writerWithData:(NSMutableData *)data {
  return [[nullMessagesPigeonCodecWriter alloc] initWithData:data];
}
- (FlutterStandardReader *)readerWithData:(NSData *)data {
  return [[nullMessagesPigeonCodecReader alloc] initWithData:data];
}
@end

NSObject<FlutterMessageCodec> *nullGetMessagesCodec(void) {
  static FlutterStandardMessageCodec *sSharedObject = nil;
  static dispatch_once_t sPred = 0;
  dispatch_once(&sPred, ^{
    nullMessagesPigeonCodecReaderWriter *readerWriter =
        [[nullMessagesPigeonCodecReaderWriter alloc] init];
    sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter];
  });
  return sSharedObject;
}
void SetUpFirebaseCoreHostApi(id<FlutterBinaryMessenger> binaryMessenger,
                              NSObject<FirebaseCoreHostApi> *api) {
  SetUpFirebaseCoreHostApiWithSuffix(binaryMessenger, api, @"");
}

void SetUpFirebaseCoreHostApiWithSuffix(id<FlutterBinaryMessenger> binaryMessenger,
                                        NSObject<FirebaseCoreHostApi> *api,
                                        NSString *messageChannelSuffix) {
  messageChannelSuffix = messageChannelSuffix.length > 0
                             ? [NSString stringWithFormat:@".%@", messageChannelSuffix]
                             : @"";
  {
    FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
           initWithName:[NSString stringWithFormat:@"%@%@",
                                                   @"dev.flutter.pigeon.firebase_core_platform_"
                                                   @"interface.FirebaseCoreHostApi.initializeApp",
                                                   messageChannelSuffix]
        binaryMessenger:binaryMessenger
                  codec:nullGetMessagesCodec()];
    if (api) {
      NSCAssert(
          [api respondsToSelector:@selector(initializeAppAppName:initializeAppRequest:completion:)],
          @"FirebaseCoreHostApi api (%@) doesn't respond to "
          @"@selector(initializeAppAppName:initializeAppRequest:completion:)",
          api);
      [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
        NSArray<id> *args = message;
        NSString *arg_appName = GetNullableObjectAtIndex(args, 0);
        CoreFirebaseOptions *arg_initializeAppRequest = GetNullableObjectAtIndex(args, 1);
        [api initializeAppAppName:arg_appName
             initializeAppRequest:arg_initializeAppRequest
                       completion:^(CoreInitializeResponse *_Nullable output,
                                    FlutterError *_Nullable error) {
                         callback(wrapResult(output, error));
                       }];
      }];
    } else {
      [channel setMessageHandler:nil];
    }
  }
  {
    FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
           initWithName:[NSString stringWithFormat:@"%@%@",
                                                   @"dev.flutter.pigeon.firebase_core_platform_"
                                                   @"interface.FirebaseCoreHostApi.initializeCore",
                                                   messageChannelSuffix]
        binaryMessenger:binaryMessenger
                  codec:nullGetMessagesCodec()];
    if (api) {
      NSCAssert([api respondsToSelector:@selector(initializeCoreWithCompletion:)],
                @"FirebaseCoreHostApi api (%@) doesn't respond to "
                @"@selector(initializeCoreWithCompletion:)",
                api);
      [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
        [api initializeCoreWithCompletion:^(NSArray<CoreInitializeResponse *> *_Nullable output,
                                            FlutterError *_Nullable error) {
          callback(wrapResult(output, error));
        }];
      }];
    } else {
      [channel setMessageHandler:nil];
    }
  }
  {
    FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
           initWithName:[NSString
                            stringWithFormat:@"%@%@",
                                             @"dev.flutter.pigeon.firebase_core_platform_interface."
                                             @"FirebaseCoreHostApi.optionsFromResource",
                                             messageChannelSuffix]
        binaryMessenger:binaryMessenger
                  codec:nullGetMessagesCodec()];
    if (api) {
      NSCAssert([api respondsToSelector:@selector(optionsFromResourceWithCompletion:)],
                @"FirebaseCoreHostApi api (%@) doesn't respond to "
                @"@selector(optionsFromResourceWithCompletion:)",
                api);
      [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
        [api optionsFromResourceWithCompletion:^(CoreFirebaseOptions *_Nullable output,
                                                 FlutterError *_Nullable error) {
          callback(wrapResult(output, error));
        }];
      }];
    } else {
      [channel setMessageHandler:nil];
    }
  }
}
void SetUpFirebaseAppHostApi(id<FlutterBinaryMessenger> binaryMessenger,
                             NSObject<FirebaseAppHostApi> *api) {
  SetUpFirebaseAppHostApiWithSuffix(binaryMessenger, api, @"");
}

void SetUpFirebaseAppHostApiWithSuffix(id<FlutterBinaryMessenger> binaryMessenger,
                                       NSObject<FirebaseAppHostApi> *api,
                                       NSString *messageChannelSuffix) {
  messageChannelSuffix = messageChannelSuffix.length > 0
                             ? [NSString stringWithFormat:@".%@", messageChannelSuffix]
                             : @"";
  {
    FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
           initWithName:
               [NSString stringWithFormat:@"%@%@",
                                          @"dev.flutter.pigeon.firebase_core_platform_interface."
                                          @"FirebaseAppHostApi.setAutomaticDataCollectionEnabled",
                                          messageChannelSuffix]
        binaryMessenger:binaryMessenger
                  codec:nullGetMessagesCodec()];
    if (api) {
      NSCAssert(
          [api
              respondsToSelector:@selector(
                                     setAutomaticDataCollectionEnabledAppName:enabled:completion:)],
          @"FirebaseAppHostApi api (%@) doesn't respond to "
          @"@selector(setAutomaticDataCollectionEnabledAppName:enabled:completion:)",
          api);
      [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
        NSArray<id> *args = message;
        NSString *arg_appName = GetNullableObjectAtIndex(args, 0);
        BOOL arg_enabled = [GetNullableObjectAtIndex(args, 1) boolValue];
        [api setAutomaticDataCollectionEnabledAppName:arg_appName
                                              enabled:arg_enabled
                                           completion:^(FlutterError *_Nullable error) {
                                             callback(wrapResult(nil, error));
                                           }];
      }];
    } else {
      [channel setMessageHandler:nil];
    }
  }
  {
    FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
           initWithName:[NSString stringWithFormat:
                                      @"%@%@",
                                      @"dev.flutter.pigeon.firebase_core_platform_interface."
                                      @"FirebaseAppHostApi.setAutomaticResourceManagementEnabled",
                                      messageChannelSuffix]
        binaryMessenger:binaryMessenger
                  codec:nullGetMessagesCodec()];
    if (api) {
      NSCAssert([api respondsToSelector:@selector(setAutomaticResourceManagementEnabledAppName:
                                                  enabled:completion:)],
                @"FirebaseAppHostApi api (%@) doesn't respond to "
                @"@selector(setAutomaticResourceManagementEnabledAppName:enabled:completion:)",
                api);
      [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
        NSArray<id> *args = message;
        NSString *arg_appName = GetNullableObjectAtIndex(args, 0);
        BOOL arg_enabled = [GetNullableObjectAtIndex(args, 1) boolValue];
        [api setAutomaticResourceManagementEnabledAppName:arg_appName
                                                  enabled:arg_enabled
                                               completion:^(FlutterError *_Nullable error) {
                                                 callback(wrapResult(nil, error));
                                               }];
      }];
    } else {
      [channel setMessageHandler:nil];
    }
  }
  {
    FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
           initWithName:[NSString stringWithFormat:@"%@%@",
                                                   @"dev.flutter.pigeon.firebase_core_platform_"
                                                   @"interface.FirebaseAppHostApi.delete",
                                                   messageChannelSuffix]
        binaryMessenger:binaryMessenger
                  codec:nullGetMessagesCodec()];
    if (api) {
      NSCAssert(
          [api respondsToSelector:@selector(deleteAppName:completion:)],
          @"FirebaseAppHostApi api (%@) doesn't respond to @selector(deleteAppName:completion:)",
          api);
      [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
        NSArray<id> *args = message;
        NSString *arg_appName = GetNullableObjectAtIndex(args, 0);
        [api deleteAppName:arg_appName
                completion:^(FlutterError *_Nullable error) {
                  callback(wrapResult(nil, error));
                }];
      }];
    } else {
      [channel setMessageHandler:nil];
    }
  }
}
