// ignore_for_file: non_constant_identifier_names, avoid_init_to_null

import 'package:json_annotation/json_annotation.dart';
import 'package:oto/oto/data/base_data.dart';

part 'util_data.g.dart';

//Print
@JsonSerializable()
class DataPrint extends DataParam {
  DataPrint();

  late String message;

  factory DataPrint.fromJson(Map<String, dynamic> json) =>
      _$DataPrintFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataPrintToJson(this);
}

//SetValue
@JsonSerializable()
class DataSetValue extends DataParam {
  DataSetValue();

  @JsonKey(name: 'values-int')
  late Map<String, dynamic>? values_int;
  @JsonKey(name: 'values-float')
  late Map<String, dynamic>? values_float;
  @JsonKey(name: 'values-string')
  late Map<String, dynamic>? values_string;
  @JsonKey(name: 'values-bool')
  late Map<String, dynamic>? values_bool;
  @JsonKey(name: 'values-object')
  late Map<String, dynamic>? values_object;

  factory DataSetValue.fromJson(Map<String, dynamic> json) =>
      _$DataSetValueFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataSetValueToJson(this);
}

//Shell
@JsonSerializable()
class DataShell extends DataParam {
  DataShell();

  late List<String> commands;
  late String? setMessage;

  factory DataShell.fromJson(Map<String, dynamic> json) =>
      _$DataShellFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataShellToJson(this);
}

@JsonSerializable()
class DataShellFile extends DataParam {
  DataShellFile();

  late String path;

  factory DataShellFile.fromJson(Map<String, dynamic> json) =>
      _$DataShellFileFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataShellFileToJson(this);
}

//String Sub
@JsonSerializable()
class DataStringSub extends DataParam {
  DataStringSub();

  late int? startIndex;
  late int? lastIndex;
  late String text;
  late String setValue;

  factory DataStringSub.fromJson(Map<String, dynamic> json) =>
      _$DataStringSubFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataStringSubToJson(this);
}

//String Replace
@JsonSerializable()
class DataStringReplace extends DataParam {
  DataStringReplace();

  late String text;
  late String setValue;
  late List<DataStringReplacePair> pair;

  factory DataStringReplace.fromJson(Map<String, dynamic> json) =>
      _$DataStringReplaceFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataStringReplaceToJson(this);
}

//String Replace with Pattern
@JsonSerializable()
class DataStringReplacePattern extends DataParam {
  DataStringReplacePattern();

  int? startAt = 0;
  late String startPattern; // start delimiter pattern
  late String endPattern; // end delimiter pattern
  late String text; // original text to process
  late String value; // replacement value
  late String setValue; // property key to store the result

  factory DataStringReplacePattern.fromJson(Map<String, dynamic> json) =>
      _$DataStringReplacePatternFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataStringReplacePatternToJson(this);
}

//String Find Index
@JsonSerializable()
class DataStringIndex extends DataParam {
  DataStringIndex();

  int? startAt = 0;
  late String text;
  late String value;
  late String setValue;

  factory DataStringIndex.fromJson(Map<String, dynamic> json) =>
      _$DataStringIndexFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataStringIndexToJson(this);
}

//URL Info
@JsonSerializable()
class DataURLInfo extends DataParam {
  DataURLInfo();

  late String url;
  late String? setScheme; // https
  late String? setHost; // example.com
  late String? setPort; // 8080
  late String? setPath; // /path/to/resource
  late String? setQuery; // query=123
  late String? setFragment; // #section

  factory DataURLInfo.fromJson(Map<String, dynamic> json) =>
      _$DataURLInfoFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataURLInfoToJson(this);
}

//String Replace Pair
@JsonSerializable()
class DataStringReplacePair extends DataParam {
  DataStringReplacePair();

  late String? from;
  late String? fromRegExp;
  late String to;

  factory DataStringReplacePair.fromJson(Map<String, dynamic> json) =>
      _$DataStringReplacePairFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataStringReplacePairToJson(this);
}

//JsonReader
@JsonSerializable()
class DataJsonReader extends DataParam {
  DataJsonReader();

  late dynamic json;
  late List<DataPair> pair;

  factory DataJsonReader.fromJson(Map<String, dynamic> json) =>
      _$DataJsonReaderFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataJsonReaderToJson(this);
}

//JsonReaderFile
@JsonSerializable()
class DataJsonReaderFile extends DataParam {
  DataJsonReaderFile();

  late String path;
  late List<DataPair> pair;

  factory DataJsonReaderFile.fromJson(Map<String, dynamic> json) =>
      _$DataJsonReaderFileFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataJsonReaderFileToJson(this);
}

//JsonWriterFile
@JsonSerializable()
class DataJsonWriterFile extends DataParam {
  DataJsonWriterFile();

  late String path;
  late List<DataJsonPair> pair;

  factory DataJsonWriterFile.fromJson(Map<String, dynamic> json) =>
      _$DataJsonWriterFileFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataJsonWriterFileToJson(this);
}

@JsonSerializable()
class DataPair {
  late String from;
  late String setValue;

  DataPair();

  factory DataPair.fromJson(Map<String, dynamic> json) =>
      _$DataPairFromJson(json);
  Map<String, dynamic> toJson() => _$DataPairToJson(this);
}

@JsonSerializable()
class DataJsonPair {
  late String from;
  late String value;

  DataJsonPair();

  factory DataJsonPair.fromJson(Map<String, dynamic> json) =>
      _$DataJsonPairFromJson(json);
  Map<String, dynamic> toJson() => _$DataJsonPairToJson(this);
}

@JsonSerializable()
class DataExecuteApp {
  late String executable;
  late String desktopServicePath;

  DataExecuteApp();

  factory DataExecuteApp.fromJson(Map<String, dynamic> json) =>
      _$DataExecuteAppFromJson(json);
  Map<String, dynamic> toJson() => _$DataExecuteAppToJson(this);
}

//Process Using Port
@JsonSerializable()
class DataProcessPortUse extends DataParam {
  DataProcessPortUse();

  late String port;
  late String setPid;

  factory DataProcessPortUse.fromJson(Map<String, dynamic> json) =>
      _$DataProcessPortUseFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataProcessPortUseToJson(this);
}

//Process Run
@JsonSerializable()
class DataProcessRun extends DataParam {
  DataProcessRun();

  late String executable;
  late String? param;

  factory DataProcessRun.fromJson(Map<String, dynamic> json) =>
      _$DataProcessRunFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataProcessRunToJson(this);
}

//Process Kill
@JsonSerializable()
class DataProcessKill extends DataParam {
  DataProcessKill();

  late String pid;

  factory DataProcessKill.fromJson(Map<String, dynamic> json) =>
      _$DataProcessKillFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataProcessKillToJson(this);
}

//Smb Authorize
@JsonSerializable()
class DataSMBAuthorize extends DataParam {
  DataSMBAuthorize();

  late String domain;
  late String id;
  late String password;

  factory DataSMBAuthorize.fromJson(Map<String, dynamic> json) =>
      _$DataSMBAuthorizeFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataSMBAuthorizeToJson(this);
}

//Delay
@JsonSerializable()
class DataDelay extends DataParam {
  DataDelay();

  late int? millisecond;
  late int? second;
  late int? minute;
  late int? hour;

  factory DataDelay.fromJson(Map<String, dynamic> json) =>
      _$DataDelayFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataDelayToJson(this);
}
