// src/errors.ts
var PayydSDKError = class extends Error {
  constructor(message) {
    super(message);
    this.name = new.target.name;
  }
};
var SigningConfigurationError = class extends PayydSDKError {
};
var OperationNotFoundError = class extends PayydSDKError {
};
var GraphQLRequestError = class extends PayydSDKError {
  statusCode;
  responseBody;
  endpoint;
  operationName;
  requestId;
  constructor(message, options = {}) {
    super(message);
    this.statusCode = options.statusCode ?? null;
    this.responseBody = options.responseBody ?? null;
    this.endpoint = options.endpoint ?? null;
    this.operationName = options.operationName ?? null;
    this.requestId = options.requestId ?? null;
  }
};
var GraphQLError = class extends PayydSDKError {
  errors;
  data;
  statusCode;
  endpoint;
  operationName;
  requestId;
  constructor(message, options) {
    super(message);
    this.errors = options.errors;
    this.data = options.data ?? null;
    this.statusCode = options.statusCode ?? null;
    this.endpoint = options.endpoint ?? null;
    this.operationName = options.operationName ?? null;
    this.requestId = options.requestId ?? null;
  }
};

// src/generated/payinCountryRules.json
var payinCountryRules_default = {
  __GLOBAL__: [
    {
      fieldName: "BankAccountNumber",
      entityType: null,
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: "^[a-zA-Z0-9]+$",
      transactionType: "Receive"
    },
    {
      fieldName: "BankAccountType",
      entityType: null,
      paymentMethodSource: null,
      isRequired: false,
      regexPattern: null,
      transactionType: "Receive"
    },
    {
      fieldName: "BankName",
      entityType: null,
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: null,
      transactionType: "Receive"
    },
    {
      fieldName: "BusinessName",
      entityType: "Business",
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: null,
      transactionType: "Receive"
    },
    {
      fieldName: "BusinessName",
      entityType: "Business",
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "EmailAddress",
      entityType: null,
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$",
      transactionType: "Send"
    },
    {
      fieldName: "FirstName",
      entityType: "Personal",
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: null,
      transactionType: "Receive"
    },
    {
      fieldName: "FirstName",
      entityType: "Personal",
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "LastName",
      entityType: "Personal",
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: null,
      transactionType: "Receive"
    },
    {
      fieldName: "LastName",
      entityType: "Personal",
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "PhoneNumber",
      entityType: null,
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  AND: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  ARG: [
    {
      fieldName: "BankAccountNumber",
      entityType: null,
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: "^[0-9]{22}$",
      transactionType: "Send"
    },
    {
      fieldName: "EmailAddress",
      entityType: null,
      paymentMethodSource: "M018",
      isRequired: false,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "IdentificationNumber",
      entityType: null,
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: "^[0-9]{11}$",
      transactionType: "Send"
    },
    {
      fieldName: "PhoneNumber",
      entityType: null,
      paymentMethodSource: "M018",
      isRequired: false,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  AUS: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: null,
      transactionType: "Receive"
    },
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressState",
      entityType: null,
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: null,
      transactionType: "Receive"
    },
    {
      fieldName: "AddressState",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: null,
      transactionType: "Receive"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressUnitNumber",
      entityType: null,
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: null,
      transactionType: "Receive"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: null,
      transactionType: "Receive"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "BankAccountNumber",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: "^\\d{6,12}$",
      transactionType: "Send"
    },
    {
      fieldName: "BankBranchCode",
      entityType: null,
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: "^[0-9]{6}$",
      transactionType: "Receive"
    },
    {
      fieldName: "BankBranchCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: "^[0-9]{6}$",
      transactionType: "Send"
    },
    {
      fieldName: "DOB",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "DOB",
      entityType: "Personal",
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: null,
      transactionType: "Receive"
    },
    {
      fieldName: "DOB",
      entityType: "Personal",
      paymentMethodSource: "I027",
      isRequired: false,
      regexPattern: null,
      transactionType: "Receive"
    },
    {
      fieldName: "Gender",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "PhoneCountryCode",
      entityType: null,
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: null,
      transactionType: "Receive"
    },
    {
      fieldName: "PhoneCountryCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "PhoneNumber",
      entityType: null,
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: null,
      transactionType: "Receive"
    },
    {
      fieldName: "PhoneNumber",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: "^\\d{9}$",
      transactionType: "Send"
    }
  ],
  AUT: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  BEL: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  BGR: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  BRA: [
    {
      fieldName: "BusinessName",
      entityType: "Business",
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: "[a-zA-Z0-9\\\\s\\\\-]+",
      transactionType: "Send"
    },
    {
      fieldName: "FirstName",
      entityType: "Personal",
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: "[a-zA-Z0-9\\\\s\\\\-]+",
      transactionType: "Send"
    },
    {
      fieldName: "IdentificationNumber",
      entityType: "Business",
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: "^\\d{14}$",
      transactionType: "Send"
    },
    {
      fieldName: "IdentificationNumber",
      entityType: "Personal",
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: "^\\d{11}$",
      transactionType: "Send"
    },
    {
      fieldName: "LastName",
      entityType: "Personal",
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: "[a-zA-Z0-9\\\\s\\\\-]+",
      transactionType: "Send"
    },
    {
      fieldName: "PhoneNumber",
      entityType: null,
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: "^\\\\+?[1-9]\\\\d{1,14}$",
      transactionType: "Send"
    }
  ],
  CHE: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  CHL: [
    {
      fieldName: "BusinessName",
      entityType: "Business",
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: "[a-zA-Z\xE1\xE9\xED\xF3\xFA\xC1\xC9\xCD\xD3\xDA\xF1\xD1\xFC\xDC'\xB4`\\\\-0-9 ]+",
      transactionType: "Send"
    },
    {
      fieldName: "FirstName",
      entityType: "Personal",
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "IdentificationNumber",
      entityType: null,
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: "^(?:\\d{1,2}\\.\\d{3}\\.\\d{3}-[\\dKk]|\\d{7,8}-[\\dKk]|\\d{8,9}[\\dKk])$",
      transactionType: "Send"
    },
    {
      fieldName: "LastName",
      entityType: "Personal",
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  COL: [
    {
      fieldName: "IdentificationIdentificationTypeName",
      entityType: null,
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "IdentificationNumber",
      entityType: null,
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: "^[0-9]+$",
      transactionType: "Send"
    },
    {
      fieldName: "PhoneNumber",
      entityType: null,
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  CYP: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  CZE: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  DEU: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  DNK: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  ESP: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  EST: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  FIN: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  FRA: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  GRC: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  HRV: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  HUN: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  IDN: [
    {
      fieldName: "PhoneCountryCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "PhoneNumber",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  IND: [
    {
      fieldName: "BankBranchCode",
      entityType: null,
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: null,
      transactionType: "Receive"
    },
    {
      fieldName: "BankBranchCode",
      entityType: null,
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: "^[A-Z]{4}0[A-Z0-9]{6}$",
      transactionType: "Receive"
    }
  ],
  IRL: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  ISL: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  ITA: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  KOR: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "A270",
      isRequired: true,
      regexPattern: null,
      transactionType: "Receive"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "A270",
      isRequired: true,
      regexPattern: null,
      transactionType: "Receive"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "A270",
      isRequired: true,
      regexPattern: null,
      transactionType: "Receive"
    },
    {
      fieldName: "BankAccountNumber",
      entityType: null,
      paymentMethodSource: "A269",
      isRequired: true,
      regexPattern: "^\\d+$",
      transactionType: "Send"
    },
    {
      fieldName: "BankName",
      entityType: null,
      paymentMethodSource: "A269",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "DOB",
      entityType: "Personal",
      paymentMethodSource: "A269",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "PhoneCountryCode",
      entityType: null,
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "PhoneCountryCode",
      entityType: null,
      paymentMethodSource: "A270",
      isRequired: true,
      regexPattern: null,
      transactionType: "Receive"
    },
    {
      fieldName: "PhoneNumber",
      entityType: null,
      paymentMethodSource: "A270",
      isRequired: true,
      regexPattern: null,
      transactionType: "Receive"
    }
  ],
  LIE: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  LTU: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  LUX: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  LVA: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  MCO: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  MLT: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  MTQ: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  NLD: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  NZL: [
    {
      fieldName: "BankBranchCode",
      entityType: null,
      paymentMethodSource: null,
      isRequired: true,
      regexPattern: "^[0-9]{4}$",
      transactionType: "Receive"
    }
  ],
  PER: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: "[a-zA-Z0-9 ]+",
      transactionType: "Send"
    },
    {
      fieldName: "AddressState",
      entityType: null,
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: "[a-zA-Z0-9 ]+",
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: "^[a-zA-Z0-9 ]{1,32}$",
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: "[a-zA-Z0-9 ]+",
      transactionType: "Send"
    },
    {
      fieldName: "IdentificationIdentificationTypeName",
      entityType: null,
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "IdentificationNumber",
      entityType: null,
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: "[0-9.-]+",
      transactionType: "Send"
    },
    {
      fieldName: "PhoneNumber",
      entityType: null,
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: "^\\+?[1-9][0-9]{0,14}$",
      transactionType: "Send"
    }
  ],
  POL: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  PRT: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  ROU: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  SMR: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  SVK: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  SVN: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  SWE: [
    {
      fieldName: "AddressCity",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressStreetAddress",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "AddressZipCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  URY: [
    {
      fieldName: "IdentificationIdentificationTypeName",
      entityType: null,
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "IdentificationNumber",
      entityType: null,
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: "[a-zA-Z0-9]{1,20}",
      transactionType: "Send"
    },
    {
      fieldName: "PhoneNumber",
      entityType: null,
      paymentMethodSource: "M018",
      isRequired: true,
      regexPattern: "[0-9.-]+",
      transactionType: "Send"
    }
  ],
  USA: [
    {
      fieldName: "PhoneCountryCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "PhoneNumber",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ],
  VNM: [
    {
      fieldName: "PhoneCountryCode",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    },
    {
      fieldName: "PhoneNumber",
      entityType: null,
      paymentMethodSource: "T185",
      isRequired: true,
      regexPattern: null,
      transactionType: "Send"
    }
  ]
};

// src/payinCountryRules.ts
var PAYIN_COUNTRY_RULES = payinCountryRules_default;

// src/modelHelpers.ts
var DEFAULT_EMAIL_REGEX = "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$";
var DEFAULT_MOBILE_REGEX = "^\\+?[1-9]\\d{1,14}$";
var DEFAULT_COUNTRY_TEXT_REGEX = "^[A-Za-z ]+$";
function requiredText(fieldName, value) {
  if (value == null) {
    throw new Error(`${fieldName} is required.`);
  }
  const normalized = value.trim();
  if (normalized === "") {
    throw new Error(`${fieldName} is required.`);
  }
  return normalized;
}
function setOptionalText(target, key, value) {
  if (value == null) {
    return;
  }
  const normalized = value.trim();
  if (normalized !== "") {
    target[key] = normalized;
  }
}
function normalizeCountryCode(value) {
  if (value == null) {
    return "";
  }
  return value.trim().toUpperCase();
}
function sanitizeRegex(pattern) {
  if (pattern.startsWith("^+")) {
    return `^\\+${pattern.slice(2)}`;
  }
  return pattern;
}
function matchesRuleRegex(pattern, value) {
  try {
    const regex = new RegExp(sanitizeRegex(pattern));
    return regex.test(value);
  } catch {
    return true;
  }
}
function isPlainObject(value) {
  return typeof value === "object" && value !== null && !Array.isArray(value);
}
function deepClone(value) {
  return structuredClone(value);
}
function stripNullValues(value) {
  if (Array.isArray(value)) {
    return value.filter((item) => item !== null && item !== void 0).map((item) => stripNullValues(item));
  }
  if (isPlainObject(value)) {
    const cleaned = {};
    for (const [key, inner] of Object.entries(value)) {
      if (inner === null || inner === void 0) {
        continue;
      }
      cleaned[key] = stripNullValues(inner);
    }
    return cleaned;
  }
  return value;
}
function canonicalizeNumber(value) {
  if (typeof value === "boolean" || typeof value === "bigint") {
    return value;
  }
  if (typeof value === "number") {
    if (Number.isInteger(value)) {
      return value;
    }
    return value;
  }
  if (typeof value === "string") {
    const stripped = value.trim();
    if (stripped === "") {
      return value;
    }
    if (/^-?\d+$/.test(stripped)) {
      return Number.parseInt(stripped, 10);
    }
    if (!Number.isNaN(Number(stripped))) {
      const parsed = Number(stripped);
      if (Number.isInteger(parsed)) {
        return parsed;
      }
      return parsed;
    }
  }
  return value;
}
function normalizeAmountFields(value, parentKey) {
  if (Array.isArray(value)) {
    return value.map((item) => normalizeAmountFields(item, parentKey));
  }
  if (isPlainObject(value)) {
    const output = {};
    for (const [key, inner] of Object.entries(value)) {
      output[key] = normalizeAmountFields(inner, key);
    }
    return output;
  }
  if (parentKey && parentKey.toLowerCase().includes("amount")) {
    return canonicalizeNumber(value);
  }
  return value;
}
function extractBearerToken(headers) {
  const authHeader = headers.Authorization;
  if (!authHeader) {
    return null;
  }
  const [scheme, token] = authHeader.split(" ", 2);
  if (!scheme || !token || scheme.toLowerCase() !== "bearer" || token.trim() === "") {
    return null;
  }
  return token.trim();
}
function resolvePattern(rule) {
  if (rule.regexPattern && rule.regexPattern.trim() !== "") {
    return rule.regexPattern;
  }
  if (rule.fieldName === "EmailAddress") {
    return DEFAULT_EMAIL_REGEX;
  }
  if (rule.fieldName === "PhoneNumber") {
    return DEFAULT_MOBILE_REGEX;
  }
  return null;
}
function getRequiredSenderFieldsForCountry(countryIsoCode3, entityType, paymentMethodSource) {
  const country = normalizeCountryCode(countryIsoCode3);
  const entity = normalizeCountryCode(entityType);
  const source = normalizeCountryCode(paymentMethodSource);
  const rules = [
    ...PAYIN_COUNTRY_RULES.__GLOBAL__ ?? [],
    ...PAYIN_COUNTRY_RULES[country] ?? []
  ];
  const requiredFields = {};
  for (const rule of rules) {
    const transactionType = normalizeCountryCode(rule.transactionType);
    if (transactionType !== "" && transactionType !== "SEND") {
      continue;
    }
    const ruleEntity = normalizeCountryCode(rule.entityType);
    if (ruleEntity !== "" && ruleEntity !== entity) {
      continue;
    }
    const ruleSource = normalizeCountryCode(rule.paymentMethodSource);
    if (ruleSource !== "" && ruleSource !== source) {
      continue;
    }
    if (rule.isRequired) {
      requiredFields[rule.fieldName] = true;
    }
  }
  return requiredFields;
}
function countriesWithSendRules() {
  const countries = [];
  for (const [country, rules] of Object.entries(PAYIN_COUNTRY_RULES)) {
    if (country === "__GLOBAL__") {
      continue;
    }
    for (const rule of rules) {
      const transactionType = normalizeCountryCode(rule.transactionType);
      if (transactionType === "" || transactionType === "SEND") {
        countries.push(country.toUpperCase());
        break;
      }
    }
  }
  return [...new Set(countries)].sort();
}
function validatePayinCountryRules(payInput) {
  const sender = payInput.sender;
  const address = sender.address;
  const country = normalizeCountryCode(address?.countryIsoCode3);
  if (country === "") {
    return;
  }
  const rules = [
    ...PAYIN_COUNTRY_RULES.__GLOBAL__ ?? [],
    ...PAYIN_COUNTRY_RULES[country] ?? []
  ];
  if (rules.length === 0) {
    return;
  }
  const identification = sender.identification;
  const bankDetails = sender.bankDetails;
  const paymentMethodSource = normalizeCountryCode(payInput.paymentMethod.paymentMethodSource);
  const entityType = normalizeCountryCode(sender.entityType);
  const transactionType = "SEND";
  const fieldValues = {
    AddressZipCode: address?.zipCode,
    AddressCity: address?.city,
    AddressStreetAddress: address?.streetAddress,
    AddressState: address?.state,
    BankBranchCode: bankDetails?.bankBranchCode,
    BankAccountNumber: bankDetails?.accountNumber,
    BankName: bankDetails?.bankName,
    BusinessName: sender.businessName,
    DOB: sender.dob,
    EmailAddress: sender.emailAddress,
    FirstName: sender.firstName,
    Gender: sender.gender,
    IdentificationExpirationDate: identification?.expirationDate,
    IdentificationIdentificationTypeName: identification?.identificationTypeName,
    IdentificationNumber: identification?.number,
    LastName: sender.lastName,
    PhoneCountryCode: sender.phoneCountryCode,
    PhoneNumber: sender.phoneNumber
  };
  for (const rule of rules) {
    const ruleTransactionType = normalizeCountryCode(rule.transactionType);
    if (ruleTransactionType !== "" && ruleTransactionType !== transactionType) {
      continue;
    }
    const ruleEntityType = normalizeCountryCode(rule.entityType);
    if (ruleEntityType !== "" && ruleEntityType !== entityType) {
      continue;
    }
    const ruleSource = normalizeCountryCode(rule.paymentMethodSource);
    if (ruleSource !== "" && ruleSource !== paymentMethodSource) {
      continue;
    }
    const rawValue = fieldValues[rule.fieldName];
    const value = typeof rawValue === "string" ? rawValue.trim() : "";
    const pattern = resolvePattern(rule);
    if (rule.isRequired && value === "") {
      throw new Error(
        `Country rule validation failed for ${country}: '${rule.fieldName}' is required.`
      );
    }
    if (value !== "" && pattern && !matchesRuleRegex(pattern, value)) {
      throw new Error(
        `Country rule validation failed for ${country}: '${rule.fieldName}' format is invalid.`
      );
    }
  }
}

// src/models.ts
var AccountGetBalancesFilter = class {
  currencyCode;
  constructor(options = {}) {
    this.currencyCode = options.currencyCode ?? null;
  }
  toVariables() {
    if (this.currencyCode == null) {
      return null;
    }
    const normalized = this.currencyCode.trim();
    if (normalized === "") {
      throw new Error("currency_code cannot be empty.");
    }
    return {
      where: {
        or: [
          {
            currencyCode: {
              eq: normalized
            }
          }
        ]
      }
    };
  }
};
var PayinCreateTransactionInput = class {
  countryIsoCode2;
  amount;
  currencyCode;
  reference;
  callbackUrl;
  paymentRedirectUrl;
  constructor(options) {
    this.countryIsoCode2 = options.countryIsoCode2;
    this.amount = options.amount;
    this.currencyCode = options.currencyCode;
    this.reference = options.reference;
    this.callbackUrl = options.callbackUrl;
    this.paymentRedirectUrl = options.paymentRedirectUrl ?? null;
  }
  toVariables() {
    return {
      input: {
        countryIsoCode2: requiredText("country_iso_code2", this.countryIsoCode2),
        amount: this.amount,
        currencyCode: requiredText("currency_code", this.currencyCode),
        reference: requiredText("reference", this.reference),
        callbackUrl: requiredText("callback_url", this.callbackUrl),
        paymentRedirectUrl: this.paymentRedirectUrl === null ? null : requiredText("payment_redirect_url", this.paymentRedirectUrl)
      }
    };
  }
};
var PayinCancelTransactionInput = class {
  internalRef;
  reason;
  constructor(options) {
    this.internalRef = options.internalRef;
    this.reason = options.reason;
  }
  toVariables() {
    return {
      input: {
        internalRef: requiredText("internal_ref", this.internalRef),
        reason: requiredText("reason", this.reason)
      }
    };
  }
};
var PayinGetTransactionsQuery = class {
  skip;
  take;
  where;
  order;
  constructor(options = {}) {
    this.skip = options.skip ?? null;
    this.take = options.take ?? 50;
    this.where = options.where ?? null;
    this.order = options.order ?? null;
  }
  toVariables() {
    if (this.take <= 0) {
      throw new Error("take must be greater than zero.");
    }
    return {
      skip: this.skip,
      take: this.take,
      where: this.where,
      order: this.order ?? [{ createdOn: "DESC" }]
    };
  }
};
var PayinCountryQuery = class {
  countryIsoCode3;
  constructor(options) {
    this.countryIsoCode3 = options.countryIsoCode3;
  }
  toVariables() {
    return {
      countryIsoCode3: requiredText("country_iso_code3", this.countryIsoCode3)
    };
  }
};
var PayinGetBanksQuery = class {
  countryIsoCode3;
  language;
  skip;
  take;
  order;
  constructor(options) {
    this.countryIsoCode3 = options.countryIsoCode3;
    this.language = options.language ?? "EN";
    this.skip = options.skip ?? null;
    this.take = options.take ?? 300;
    this.order = options.order ?? null;
  }
  toVariables() {
    if (this.skip !== null && this.skip < 0) {
      throw new Error("skip cannot be negative.");
    }
    if (this.take <= 0) {
      throw new Error("take must be greater than zero.");
    }
    return {
      skip: this.skip,
      take: this.take,
      countryIsoCode3: requiredText("country_iso_code3", this.countryIsoCode3),
      language: requiredText("language", this.language),
      order: this.order ?? [{ name: "ASC" }]
    };
  }
};
var PayinPaymentMethodInput = class {
  paymentMethodSource;
  type;
  constructor(options) {
    this.paymentMethodSource = options.paymentMethodSource;
    this.type = options.type;
  }
  toDict() {
    return {
      paymentMethodSource: requiredText("payment_method_source", this.paymentMethodSource),
      type: requiredText("type", this.type)
    };
  }
};
var PayinSenderAddressInput = class {
  countryIsoCode3;
  streetAddress;
  city;
  state;
  zipCode;
  constructor(options) {
    this.countryIsoCode3 = options.countryIsoCode3;
    this.streetAddress = options.streetAddress ?? null;
    this.city = options.city ?? null;
    this.state = options.state ?? null;
    this.zipCode = options.zipCode ?? null;
  }
  toDict() {
    const countryIsoCode3 = requiredText("country_iso_code3", this.countryIsoCode3);
    if (!matchesRuleRegex(DEFAULT_COUNTRY_TEXT_REGEX, countryIsoCode3)) {
      throw new Error("country_iso_code3 format is invalid.");
    }
    const data = {
      countryIsoCode3
    };
    setOptionalText(data, "streetAddress", this.streetAddress);
    setOptionalText(data, "city", this.city);
    setOptionalText(data, "state", this.state);
    setOptionalText(data, "zipCode", this.zipCode);
    return data;
  }
};
var PayinSenderBankDetailsInput = class {
  accountNumber;
  bankBranchCode;
  bankName;
  constructor(options = {}) {
    this.accountNumber = options.accountNumber ?? null;
    this.bankBranchCode = options.bankBranchCode ?? null;
    this.bankName = options.bankName ?? null;
  }
  toDict() {
    const data = {};
    setOptionalText(data, "accountNumber", this.accountNumber);
    setOptionalText(data, "bankBranchCode", this.bankBranchCode);
    setOptionalText(data, "bankName", this.bankName);
    return data;
  }
};
var PayinSenderIdentificationInput = class {
  number;
  expirationDate;
  identificationTypeName;
  issuedDate;
  constructor(options) {
    this.number = options.number;
    this.expirationDate = options.expirationDate ?? null;
    this.identificationTypeName = options.identificationTypeName ?? null;
    this.issuedDate = options.issuedDate ?? null;
  }
  toDict() {
    const data = {
      number: requiredText("number", this.number)
    };
    setOptionalText(data, "expirationDate", this.expirationDate);
    setOptionalText(data, "identificationTypeName", this.identificationTypeName);
    setOptionalText(data, "issuedDate", this.issuedDate);
    return data;
  }
};
var PayinSenderInput = class {
  entityType;
  emailAddress;
  phoneCountryCode;
  phoneNumber;
  address;
  identification;
  dob;
  gender;
  businessName;
  firstName;
  lastName;
  bankDetails;
  constructor(options) {
    this.entityType = options.entityType;
    this.emailAddress = options.emailAddress;
    this.phoneCountryCode = options.phoneCountryCode;
    this.phoneNumber = options.phoneNumber;
    this.address = options.address ?? null;
    this.identification = options.identification ?? null;
    this.dob = options.dob ?? null;
    this.gender = options.gender ?? null;
    this.businessName = options.businessName ?? null;
    this.firstName = options.firstName ?? null;
    this.lastName = options.lastName ?? null;
    this.bankDetails = options.bankDetails ?? null;
  }
  toDict() {
    const data = {
      entityType: requiredText("entity_type", this.entityType),
      emailAddress: requiredText("email_address", this.emailAddress),
      phoneCountryCode: requiredText("phone_country_code", this.phoneCountryCode),
      phoneNumber: requiredText("phone_number", this.phoneNumber)
    };
    if (this.address !== null) {
      data.address = this.address.toDict();
    }
    if (this.identification !== null) {
      data.identification = this.identification.toDict();
    }
    setOptionalText(data, "dob", this.dob);
    setOptionalText(data, "gender", this.gender);
    setOptionalText(data, "businessName", this.businessName);
    setOptionalText(data, "firstName", this.firstName);
    setOptionalText(data, "lastName", this.lastName);
    if (this.bankDetails !== null) {
      const bankDetails = this.bankDetails.toDict();
      if (Object.keys(bankDetails).length > 0) {
        data.bankDetails = bankDetails;
      }
    }
    return data;
  }
};
var PayinS2sPayInput = class {
  internalRef;
  language;
  paymentMethod;
  sender;
  constructor(options) {
    this.internalRef = options.internalRef;
    this.language = options.language;
    this.paymentMethod = options.paymentMethod;
    this.sender = options.sender;
  }
  toDict() {
    validatePayinCountryRules(this);
    return {
      internalRef: requiredText("internal_ref", this.internalRef),
      language: requiredText("language", this.language),
      paymentMethod: this.paymentMethod.toDict(),
      sender: this.sender.toDict()
    };
  }
};
var PayinS2sPayTransactionInput = class {
  input;
  constructor(options) {
    this.input = options.input;
  }
  toVariables() {
    return {
      input: {
        input: this.input.toDict()
      }
    };
  }
};
var PayoutReceiverInput = class {
  name;
  streetAddress;
  city;
  zipCode;
  state;
  countryIsoCode3;
  emailAddress;
  entityType;
  phoneCountryCode;
  phoneNumber;
  accountNumber;
  bankBranchCode;
  bankName;
  unitNumber;
  constructor(options) {
    this.name = options.name;
    this.streetAddress = options.streetAddress;
    this.city = options.city;
    this.zipCode = options.zipCode;
    this.state = options.state;
    this.countryIsoCode3 = options.countryIsoCode3;
    this.emailAddress = options.emailAddress;
    this.entityType = options.entityType;
    this.phoneCountryCode = options.phoneCountryCode;
    this.phoneNumber = options.phoneNumber;
    this.accountNumber = options.accountNumber;
    this.bankBranchCode = options.bankBranchCode ?? null;
    this.bankName = options.bankName;
    this.unitNumber = options.unitNumber ?? null;
  }
  toDict() {
    const countryIsoCode3 = requiredText("country_iso_code3", this.countryIsoCode3);
    const data = {
      name: requiredText("name", this.name),
      streetAddress: requiredText("street_address", this.streetAddress),
      city: requiredText("city", this.city),
      zipCode: requiredText("zip_code", this.zipCode),
      state: requiredText("state", this.state),
      countryIsoCode3,
      emailAddress: requiredText("email_address", this.emailAddress),
      entityType: requiredText("entity_type", this.entityType),
      phoneCountryCode: requiredText("phone_country_code", this.phoneCountryCode),
      phoneNumber: requiredText("phone_number", this.phoneNumber),
      accountNumber: requiredText("account_number", this.accountNumber)
    };
    const normalizedBankBranchCode = this.bankBranchCode?.trim() ?? null;
    data.bankName = requiredText("bank_name", this.bankName);
    data.bankBranchCode = normalizedBankBranchCode ? normalizedBankBranchCode : null;
    setOptionalText(data, "unitNumber", this.unitNumber);
    return data;
  }
};
var PayoutCreateTransactionInput = class {
  reference;
  fromAmount;
  fromCurrencyCode;
  toCurrencyCode;
  receiver;
  callbackUrl;
  description;
  constructor(options) {
    this.reference = options.reference;
    this.fromAmount = options.fromAmount;
    this.fromCurrencyCode = options.fromCurrencyCode;
    this.toCurrencyCode = options.toCurrencyCode;
    this.receiver = options.receiver;
    this.callbackUrl = options.callbackUrl;
    this.description = options.description ?? null;
  }
  toVariables() {
    return {
      input: {
        reference: requiredText("reference", this.reference),
        fromAmount: this.fromAmount,
        fromCurrencyCode: requiredText("from_currency_code", this.fromCurrencyCode),
        toCurrencyCode: requiredText("to_currency_code", this.toCurrencyCode),
        receiver: this.receiver.toDict(),
        callbackUrl: requiredText("callback_url", this.callbackUrl),
        ...this.description && this.description.trim() !== "" ? { description: this.description.trim() } : {}
      }
    };
  }
};
var PayoutGetBanksQuery = class {
  countryIsoCode3;
  skip;
  take;
  constructor(options) {
    this.countryIsoCode3 = options.countryIsoCode3;
    this.skip = options.skip ?? 0;
    this.take = options.take ?? 100;
  }
  toVariables() {
    if (this.skip < 0) {
      throw new Error("skip cannot be negative.");
    }
    if (this.take <= 0) {
      throw new Error("take must be greater than zero.");
    }
    return {
      countryIsoCode3: requiredText("country_iso_code3", this.countryIsoCode3),
      skip: this.skip,
      take: this.take
    };
  }
};
var PayoutGetFxRateQuery = class {
  fromAmount;
  fromCurrencyCode;
  toCurrencyCode;
  constructor(options) {
    this.fromAmount = options.fromAmount;
    this.fromCurrencyCode = options.fromCurrencyCode;
    this.toCurrencyCode = options.toCurrencyCode;
  }
  toVariables() {
    return {
      fromAmount: this.fromAmount,
      fromCurrencyCode: requiredText("from_currency_code", this.fromCurrencyCode),
      toCurrencyCode: requiredText("to_currency_code", this.toCurrencyCode)
    };
  }
};
var PayoutGetTransactionsQuery = class {
  skip;
  take;
  where;
  order;
  constructor(options = {}) {
    this.skip = options.skip ?? null;
    this.take = options.take ?? 300;
    this.where = options.where ?? null;
    this.order = options.order ?? null;
  }
  toVariables() {
    if (this.take <= 0) {
      throw new Error("take must be greater than zero.");
    }
    return {
      skip: this.skip,
      take: this.take,
      where: this.where,
      order: this.order ?? [{ createdOn: "DESC" }]
    };
  }
};

// src/client.ts
import crypto from "crypto";

// package.json
var package_default = {
  name: "payyd-js-sdk",
  version: "0.1.11",
  description: "Node.js SDK for Payyd Enterprise GraphQL APIs.",
  license: "MIT",
  type: "module",
  engines: {
    node: ">=18"
  },
  main: "./dist/index.cjs",
  module: "./dist/index.js",
  types: "./dist/index.d.ts",
  exports: {
    ".": {
      types: "./dist/index.d.ts",
      import: "./dist/index.js",
      require: "./dist/index.cjs"
    }
  },
  files: [
    "dist/index.js",
    "dist/index.cjs",
    "dist/index.d.ts",
    "dist/index.d.cts",
    "README.md"
  ],
  scripts: {
    sync: "./sync_sdk_assets.sh",
    "generate:operations": "node ./scripts/sync-operations.mjs",
    "generate:rules": "node ./scripts/generate-country-rules-from-php.mjs",
    generate: "npm run generate:operations && npm run generate:rules",
    prebuild: "npm run generate",
    "start:testing": "sh ./start_testing.sh",
    build: "tsup",
    test: "vitest run",
    "test:coverage": "vitest run --coverage",
    "demo:auth": "tsx ./demo_scripts/auth_demo.ts",
    demo: "tsx ./sample_apps/express_demo/src/server.ts",
    "pack:local": "./pack_npm.sh"
  },
  dependencies: {
    ejs: "^3.1.10",
    express: "^5.1.0"
  },
  devDependencies: {
    "@types/ejs": "^3.1.5",
    "@types/express": "^5.0.3",
    "@types/node": "^24.0.0",
    "@types/supertest": "^6.0.3",
    "@vitest/coverage-v8": "^3.2.4",
    supertest: "^7.1.4",
    tsup: "^8.5.0",
    tsx: "^4.20.3",
    typescript: "^5.8.3",
    vitest: "^3.2.4"
  }
};

// src/client.ts
var SDK_VERSION = isPlainObject(package_default) && typeof package_default.version === "string" ? package_default.version : "unknown";
function sdkOs() {
  const system = process.platform.trim().toLowerCase();
  const machine = process.arch.trim().toLowerCase();
  if (system && machine) {
    return `${system}/${machine}`;
  }
  return system || machine || "unknown";
}
function buildUuid4() {
  return crypto.randomUUID();
}
function signMessage(secretKey, message) {
  return crypto.createHmac("sha256", secretKey).update(message, "utf8").digest("hex").toLowerCase();
}
var GraphQLClient = class {
  endpoint;
  timeout;
  apiKey;
  secretKey;
  signRequests;
  fetchImpl;
  defaultHeaders;
  operations;
  constructor(options) {
    if (!options.endpoint || options.endpoint.trim() === "") {
      throw new Error("endpoint is required");
    }
    this.endpoint = options.endpoint;
    this.timeout = options.timeout ?? 3e4;
    this.apiKey = options.apiKey?.trim() ?? null;
    this.secretKey = options.secretKey?.trim() ?? null;
    this.signRequests = options.signRequests ?? (this.apiKey !== null && this.secretKey !== null);
    if (this.signRequests && (!this.apiKey || !this.secretKey)) {
      throw new SigningConfigurationError(
        "Signing is enabled but api_key/secret_key is missing."
      );
    }
    this.fetchImpl = options.fetch ?? fetch;
    this.defaultHeaders = {
      Accept: "application/json",
      "Content-Type": "application/json",
      "X-Payyd-SDK-Type": "nodejs",
      "X-Payyd-SDK-Version": SDK_VERSION,
      "X-Payyd-SDK-OS": sdkOs(),
      ...options.headers ?? {}
    };
    if (options.token?.trim()) {
      this.defaultHeaders.Authorization = `Bearer ${options.token.trim()}`;
    }
    this.operations = deepClone(options.operations ?? {});
  }
  get operationNames() {
    return Object.keys(this.operations).sort();
  }
  setBearerToken(token) {
    if (token && token.trim() !== "") {
      this.defaultHeaders.Authorization = `Bearer ${token.trim()}`;
      return;
    }
    delete this.defaultHeaders.Authorization;
  }
  registerOperation(name, query, options = {}) {
    this.operations[name] = {
      methodName: name,
      displayName: name,
      group: "",
      query,
      operationName: options.operationName ?? "",
      requestId: options.requestId ?? null,
      defaultVariables: deepClone(options.variables ?? {})
    };
  }
  registerOperations(operations) {
    for (const [name, operation] of Object.entries(operations)) {
      this.operations[name] = deepClone(operation);
    }
  }
  async executeResult(query, options = {}) {
    const normalizedVariables = options.variables == null ? null : this.preparePayloadVariables(
      normalizeAmountFields(deepClone(options.variables)),
      options.preservePayoutBankBranchCodeNull ?? false
    );
    const payload = {
      query,
      variables: normalizedVariables
    };
    if (options.operationName) {
      payload.operationName = options.operationName;
    }
    const requestHeaders = {
      ...this.defaultHeaders,
      ...options.extraHeaders ?? {}
    };
    let requestId = requestHeaders["payyd-requestid"] ?? null;
    if (this.signRequests) {
      const bearerToken = extractBearerToken(requestHeaders);
      const signed = this.buildPayydSignatureHeaders(normalizedVariables, bearerToken);
      Object.assign(requestHeaders, signed.headers);
      requestId = signed.requestId;
    }
    const controller = new AbortController();
    const timeoutHandle = setTimeout(() => controller.abort(), this.timeout);
    let response;
    let responseBody = "";
    try {
      response = await this.fetchImpl(this.endpoint, {
        method: "POST",
        headers: requestHeaders,
        body: JSON.stringify(payload),
        signal: controller.signal
      });
      responseBody = await response.text();
    } catch (error) {
      const isAbort = error instanceof DOMException ? error.name === "AbortError" : error instanceof Error && error.name === "AbortError";
      throw new GraphQLRequestError(
        isAbort ? "Request to GraphQL endpoint timed out." : "Request to GraphQL endpoint failed.",
        {
          endpoint: this.endpoint,
          operationName: options.operationName ?? null,
          requestId,
          responseBody: error instanceof Error && error.message ? error.message : null
        }
      );
    } finally {
      clearTimeout(timeoutHandle);
    }
    if (response.status >= 400) {
      throw new GraphQLRequestError(
        `GraphQL endpoint returned HTTP ${response.status}.`,
        {
          statusCode: response.status,
          responseBody,
          endpoint: this.endpoint,
          operationName: options.operationName ?? null,
          requestId
        }
      );
    }
    let body;
    try {
      body = JSON.parse(responseBody);
    } catch {
      throw new GraphQLRequestError(
        "GraphQL endpoint did not return valid JSON.",
        {
          statusCode: response.status,
          responseBody,
          endpoint: this.endpoint,
          operationName: options.operationName ?? null,
          requestId
        }
      );
    }
    if (!isPlainObject(body)) {
      throw new GraphQLRequestError(
        "GraphQL endpoint returned a non-object JSON payload.",
        {
          statusCode: response.status,
          responseBody,
          endpoint: this.endpoint,
          operationName: options.operationName ?? null,
          requestId
        }
      );
    }
    if (body.errors != null) {
      if (Array.isArray(body.errors)) {
        throw new GraphQLError("GraphQL errors returned by endpoint.", {
          errors: body.errors.filter((item) => isPlainObject(item)),
          data: isPlainObject(body.data) ? body.data : null,
          statusCode: response.status,
          endpoint: this.endpoint,
          operationName: options.operationName ?? null,
          requestId
        });
      }
      throw new GraphQLRequestError("GraphQL response has invalid 'errors' format.", {
        statusCode: response.status,
        responseBody,
        endpoint: this.endpoint,
        operationName: options.operationName ?? null,
        requestId
      });
    }
    return {
      data: isPlainObject(body.data) ? body.data : null,
      raw: body,
      statusCode: response.status,
      operationName: options.operationName ?? null,
      requestId
    };
  }
  async execute(query, options = {}) {
    const result = await this.executeResult(query, options);
    return result.data;
  }
  async executePersistedResult(requestIdValue, options = {}) {
    const normalizedVariables = options.variables == null ? null : this.preparePayloadVariables(
      normalizeAmountFields(deepClone(options.variables)),
      options.preservePayoutBankBranchCodeNull ?? false
    );
    const payload = {
      id: requestIdValue,
      variables: normalizedVariables
    };
    const requestHeaders = {
      ...this.defaultHeaders,
      ...options.extraHeaders ?? {}
    };
    let requestId = requestHeaders["payyd-requestid"] ?? null;
    if (this.signRequests) {
      const bearerToken = extractBearerToken(requestHeaders);
      const signed = this.buildPayydSignatureHeaders(normalizedVariables, bearerToken);
      Object.assign(requestHeaders, signed.headers);
      requestId = signed.requestId;
    }
    const controller = new AbortController();
    const timeoutHandle = setTimeout(() => controller.abort(), this.timeout);
    let response;
    let responseBody = "";
    try {
      response = await this.fetchImpl(this.endpoint, {
        method: "POST",
        headers: requestHeaders,
        body: JSON.stringify(payload),
        signal: controller.signal
      });
      responseBody = await response.text();
    } catch (error) {
      const isAbort = error instanceof DOMException ? error.name === "AbortError" : error instanceof Error && error.name === "AbortError";
      throw new GraphQLRequestError(
        isAbort ? "Request to GraphQL endpoint timed out." : "Request to GraphQL endpoint failed.",
        {
          endpoint: this.endpoint,
          operationName: options.operationName ?? null,
          requestId,
          responseBody: error instanceof Error && error.message ? error.message : null
        }
      );
    } finally {
      clearTimeout(timeoutHandle);
    }
    if (response.status >= 400) {
      throw new GraphQLRequestError(
        `GraphQL endpoint returned HTTP ${response.status}.`,
        {
          statusCode: response.status,
          responseBody,
          endpoint: this.endpoint,
          operationName: options.operationName ?? null,
          requestId
        }
      );
    }
    let body;
    try {
      body = JSON.parse(responseBody);
    } catch {
      throw new GraphQLRequestError(
        "GraphQL endpoint did not return valid JSON.",
        {
          statusCode: response.status,
          responseBody,
          endpoint: this.endpoint,
          operationName: options.operationName ?? null,
          requestId
        }
      );
    }
    if (!isPlainObject(body)) {
      throw new GraphQLRequestError(
        "GraphQL endpoint returned a non-object JSON payload.",
        {
          statusCode: response.status,
          responseBody,
          endpoint: this.endpoint,
          operationName: options.operationName ?? null,
          requestId
        }
      );
    }
    if (body.errors != null) {
      if (Array.isArray(body.errors)) {
        throw new GraphQLError("GraphQL errors returned by endpoint.", {
          errors: body.errors.filter((item) => isPlainObject(item)),
          data: isPlainObject(body.data) ? body.data : null,
          statusCode: response.status,
          endpoint: this.endpoint,
          operationName: options.operationName ?? null,
          requestId
        });
      }
      throw new GraphQLRequestError("GraphQL response has invalid 'errors' format.", {
        statusCode: response.status,
        responseBody,
        endpoint: this.endpoint,
        operationName: options.operationName ?? null,
        requestId
      });
    }
    return {
      data: isPlainObject(body.data) ? body.data : null,
      raw: body,
      statusCode: response.status,
      operationName: options.operationName ?? null,
      requestId
    };
  }
  async runResult(operation, variables = null, extraHeaders = null) {
    const selected = this.operations[operation];
    if (!selected) {
      const available = this.operationNames.length > 0 ? this.operationNames.join(", ") : "none";
      throw new OperationNotFoundError(
        `Operation '${operation}' not found. Available operations: ${available}.`
      );
    }
    const mergedVariables = deepClone(selected.defaultVariables ?? {});
    const resolvedVariables = variables == null ? Object.keys(mergedVariables).length > 0 ? mergedVariables : null : { ...mergedVariables, ...variables };
    if (typeof selected.requestId === "string" && selected.requestId.trim() !== "") {
      return this.executePersistedResult(selected.requestId, {
        variables: resolvedVariables,
        operationName: selected.operationName,
        extraHeaders,
        preservePayoutBankBranchCodeNull: operation === "payoutCreateTransaction"
      });
    }
    if (typeof selected.query !== "string" || selected.query.trim() === "") {
      throw new OperationNotFoundError(
        `Operation '${operation}' has neither a persisted id nor a GraphQL query.`
      );
    }
    return this.executeResult(selected.query, {
      variables: resolvedVariables,
      operationName: selected.operationName,
      extraHeaders,
      preservePayoutBankBranchCodeNull: operation === "payoutCreateTransaction"
    });
  }
  preparePayloadVariables(normalizedVariables, preservePayoutBankBranchCodeNull) {
    const payloadVariables = stripNullValues(normalizedVariables);
    if (!preservePayoutBankBranchCodeNull) {
      return payloadVariables;
    }
    const input = normalizedVariables.input;
    if (!isPlainObject(input)) {
      return payloadVariables;
    }
    const receiver = input.receiver;
    if (!isPlainObject(receiver)) {
      return payloadVariables;
    }
    if (!("bankBranchCode" in receiver) || receiver.bankBranchCode !== null) {
      return payloadVariables;
    }
    if (!isPlainObject(payloadVariables.input)) {
      payloadVariables.input = {};
    }
    const payloadInput = payloadVariables.input;
    if (!isPlainObject(payloadInput.receiver)) {
      payloadInput.receiver = {};
    }
    payloadInput.receiver.bankBranchCode = null;
    return payloadVariables;
  }
  async run(operation, variables = null, extraHeaders = null) {
    const result = await this.runResult(operation, variables, extraHeaders);
    return result.data;
  }
  buildPayydSignatureHeaders(variables, bearerToken) {
    if (!this.apiKey || !this.secretKey) {
      throw new SigningConfigurationError(
        "Signing is enabled but api_key/secret_key is missing."
      );
    }
    const requestId = buildUuid4();
    const nonce = `${Date.now()}`;
    let message = `${requestId}::${nonce}::${this.apiKey}`;
    if (variables != null) {
      message += `::${JSON.stringify(variables)}`;
    }
    if (bearerToken) {
      message += `::${bearerToken}`;
    }
    return {
      requestId,
      headers: {
        "payyd-requestid": requestId,
        "x-nonce": nonce,
        "x-api-key": this.apiKey,
        "x-sign": signMessage(this.secretKey, message)
      }
    };
  }
};

// src/generated/payydOperations.json
var payydOperations_default = {
  accountGetBalances: {
    methodName: "accountGetBalances",
    displayName: "Account - Get Balances",
    group: "Account",
    query: null,
    operationName: "EnterpriseAccountBalances",
    requestId: "account-get-balances",
    defaultVariables: {}
  },
  authChangePassword: {
    methodName: "authChangePassword",
    displayName: "Authentication - Change Password",
    group: "Authentication",
    query: null,
    operationName: "AuthenticationChangePassword",
    requestId: "authentication-change-password",
    defaultVariables: {
      email: "some_real_email_address"
    }
  },
  authGetToken: {
    methodName: "authGetToken",
    displayName: "Authentication - Get Token",
    group: "Authentication",
    query: null,
    operationName: "AuthenticationToken",
    requestId: "authentication-get-token",
    defaultVariables: {
      input: {
        userName: "email@domain.com",
        password: "***"
      }
    }
  },
  payinHostedCancelTransaction: {
    methodName: "payinHostedCancelTransaction",
    displayName: "Payin - Cancel Transaction",
    group: "PayIn Transactions (Hosted Page)",
    query: null,
    operationName: "EnterpriseCancelPayinTransaction",
    requestId: "payin-cancel-transaction",
    defaultVariables: {
      input: {
        internalRef: "PIE25U03R14E00U27R23",
        reason: "some reasons"
      }
    }
  },
  payinHostedCreateTransaction: {
    methodName: "payinHostedCreateTransaction",
    displayName: "Payin - Create Transaction",
    group: "PayIn Transactions (Hosted Page)",
    query: null,
    operationName: "EnterpriseAddPayinTransaction",
    requestId: "payin-create-transaction",
    defaultVariables: {
      input: {
        countryIsoCode2: "AD",
        amount: 10,
        currencyCode: "EUR",
        reference: "2506162346",
        callbackUrl: "https://sample.domain/api/sample_callback"
      }
    }
  },
  payinHostedGetTransactionByInternalRef: {
    methodName: "payinHostedGetTransactionByInternalRef",
    displayName: "Payin - Get Transaction By InternalRef",
    group: "PayIn Transactions (Hosted Page)",
    query: null,
    operationName: "GetEnterprisePayinTransactionByInternalRef",
    requestId: "payin-get-transaction-by-internalref",
    defaultVariables: {
      internalRef: "PIE25U06R03E16U31R38"
    }
  },
  payinHostedGetTransactionByReference: {
    methodName: "payinHostedGetTransactionByReference",
    displayName: "Payin - Get Transaction By Reference",
    group: "PayIn Transactions (Hosted Page)",
    query: null,
    operationName: "GetEnterprisePayinTransactionByReference",
    requestId: "payin-get-transaction-by-reference",
    defaultVariables: {
      reference: "2601291101"
    }
  },
  payinHostedGetTransactions: {
    methodName: "payinHostedGetTransactions",
    displayName: "Payin - Get Transactions",
    group: "PayIn Transactions (Hosted Page)",
    query: null,
    operationName: "EnterprisePayinTransactions",
    requestId: "payin-get-transactions",
    defaultVariables: {
      skip: null,
      take: 50,
      where: null,
      order: [
        {
          createdOn: "DESC"
        }
      ]
    }
  },
  payinS2sCancelTransaction: {
    methodName: "payinS2sCancelTransaction",
    displayName: "Payin - Cancel Transaction",
    group: "PayIn Transactions (S2S)",
    query: null,
    operationName: "EnterpriseCancelPayinTransaction",
    requestId: "payin-cancel-transaction",
    defaultVariables: {
      input: {
        internalRef: "PIE25U03R14E00U27R23",
        reason: "some reasons"
      }
    }
  },
  payinS2sCreateTransaction: {
    methodName: "payinS2sCreateTransaction",
    displayName: "Payin - Create Transaction",
    group: "PayIn Transactions (S2S)",
    query: null,
    operationName: "EnterpriseAddPayinTransaction",
    requestId: "payin-create-transaction",
    defaultVariables: {
      input: {
        countryIsoCode2: "AD",
        amount: 10,
        currencyCode: "EUR",
        reference: "2506162346",
        callbackUrl: "https://sample.domain/api/sample_callback"
      }
    }
  },
  payinS2sGetIdentificationTypes: {
    methodName: "payinS2sGetIdentificationTypes",
    displayName: "Payin - Get IdentificationTypes",
    group: "PayIn Transactions (S2S)",
    query: null,
    operationName: "EnterpriseIdentificationTypesByCountryIsoCode3",
    requestId: "payin-get-identification-types",
    defaultVariables: {
      countryIsoCode3: "PER"
    }
  },
  payinS2sGetPaymentMethods: {
    methodName: "payinS2sGetPaymentMethods",
    displayName: "Payin - Get Payment Methods",
    group: "PayIn Transactions (S2S)",
    query: null,
    operationName: "EnteprisePaymentMethodsByCountryIsoCode3",
    requestId: "payin-get-payment-methods",
    defaultVariables: {
      countryIsoCode3: "PER"
    }
  },
  payinS2sGetTransactionByInternalRef: {
    methodName: "payinS2sGetTransactionByInternalRef",
    displayName: "Payin - Get Transaction By InternalRef",
    group: "PayIn Transactions (S2S)",
    query: null,
    operationName: "GetEnterprisePayinTransactionByInternalRef",
    requestId: "payin-get-transaction-by-internalref",
    defaultVariables: {
      internalRef: "PIE25U06R03E16U31R38"
    }
  },
  payinS2sGetTransactionByReference: {
    methodName: "payinS2sGetTransactionByReference",
    displayName: "Payin - Get Transaction By Reference",
    group: "PayIn Transactions (S2S)",
    query: null,
    operationName: "GetEnterprisePayinTransactionByReference",
    requestId: "payin-get-transaction-by-reference",
    defaultVariables: {
      reference: "2601291101"
    }
  },
  payinS2sGetTransactions: {
    methodName: "payinS2sGetTransactions",
    displayName: "Payin - Get Transactions",
    group: "PayIn Transactions (S2S)",
    query: null,
    operationName: "EnterprisePayinTransactions",
    requestId: "payin-get-transactions",
    defaultVariables: {
      skip: null,
      take: 50,
      where: null,
      order: [
        {
          createdOn: "DESC"
        }
      ]
    }
  },
  payinS2sGetBanks: {
    methodName: "payinS2sGetBanks",
    displayName: "Payin - Get Banks",
    group: "PayIn Transactions (S2S)",
    query: null,
    operationName: null,
    requestId: "payin-get-banks",
    defaultVariables: {
      countryIsoCode3: "KOR",
      language: "EN",
      order: [
        {
          name: "ASC"
        }
      ],
      skip: null,
      take: 300
    }
  },
  payinS2sPayTransaction: {
    methodName: "payinS2sPayTransaction",
    displayName: "Payin - Pay Transaction",
    group: "PayIn Transactions (S2S)",
    query: null,
    operationName: "EnterprisePayPayinTransactionV2",
    requestId: "payin-pay-transaction",
    defaultVariables: {
      input: {
        input: {
          internalRef: "PIP25E06N06P09E15N24",
          language: "EN",
          paymentMethod: {
            paymentMethodSource: "T185",
            type: "payid"
          },
          sender: {
            entityType: "BUSINESS",
            emailAddress: "email@domain.com",
            businessName: "Some Business",
            firstName: null,
            lastName: null,
            phoneCountryCode: "55",
            phoneNumber: "131231",
            dob: null,
            gender: null,
            address: {
              streetAddress: null,
              city: null,
              state: null,
              zipCode: null,
              countryIsoCode3: "AUS"
            },
            bankDetails: {
              accountNumber: null,
              bankBranchCode: null,
              bankName: null
            },
            identification: {
              expirationDate: null,
              identificationTypeName: null,
              issuedDate: null,
              number: "11222333000181"
            }
          }
        }
      }
    }
  },
  payoutCreateTransaction: {
    methodName: "payoutCreateTransaction",
    displayName: "Payout - Create Transaction",
    group: "Payout Transactions",
    query: null,
    operationName: "EnterpriseAddPayoutTransaction",
    requestId: "payout-create-transaction",
    defaultVariables: {
      input: {
        reference: "2503252049",
        description: null,
        fromAmount: 5,
        fromCurrencyCode: "USD",
        toCurrencyCode: "INR",
        receiver: {
          name: "Nagarajan Rao",
          unitNumber: null,
          streetAddress: " Flat No 502 Samvai Towers, Lane Behind Tulugu Academy, Narayanaguda",
          city: "Hyderabad",
          zipCode: "500029",
          state: "Andhra Pradesh",
          countryIsoCode3: "IND",
          emailAddress: "nrao.email2@domain.com",
          entityType: "PERSONAL",
          phoneCountryCode: "91",
          phoneNumber: "04066633098",
          accountNumber: "224103907",
          bankBranchCode: "SBIN0030526",
          bankName: "STATE BANK OF INDIA"
        },
        callbackUrl: "https://sample.domain/api/sample_callback"
      }
    }
  },
  payoutGetBanks: {
    methodName: "payoutGetBanks",
    displayName: "Payout - Get Banks",
    group: "Payout Transactions",
    query: null,
    operationName: "EnterpriseUniqueBanksByCountryIsoCode3",
    requestId: "payout-get-banks",
    defaultVariables: {
      countryIsoCode3: "IND",
      skip: 0,
      take: 100
    }
  },
  payoutGetFxRate: {
    methodName: "payoutGetFxRate",
    displayName: "Payout - Get FX Rate",
    group: "Payout Transactions",
    query: null,
    operationName: "EnterpriseFxRate",
    requestId: "payout-get-fx-rates",
    defaultVariables: {
      fromAmount: 100,
      fromCurrencyCode: "USD",
      toCurrencyCode: "INR"
    }
  },
  payoutGetTransaction: {
    methodName: "payoutGetTransaction",
    displayName: "Payout - Get Transaction",
    group: "Payout Transactions",
    query: null,
    operationName: "GetEnterprisePayoutTransactionByReference",
    requestId: "payout-get-transaction-by-reference",
    defaultVariables: {
      reference: "2510290956"
    }
  },
  payoutGetTransactions: {
    methodName: "payoutGetTransactions",
    displayName: "Payout - Get Transactions",
    group: "Payout Transactions",
    query: null,
    operationName: "EnterprisePayoutTransactions",
    requestId: "payout-get-transactions",
    defaultVariables: {
      skip: null,
      take: 300,
      where: null,
      order: [
        {
          createdOn: "DESC"
        }
      ]
    }
  }
};

// src/operations.ts
var PAYYD_OPERATION_DEFINITIONS = payydOperations_default;

// src/enterprise.ts
var PayydEnterpriseClient = class _PayydEnterpriseClient extends GraphQLClient {
  static SANDBOX_ENDPOINT = "https://sandbox-enterprisegateway.payyd.money/graphql";
  static PREPROD_ENDPOINT = "https://preprod-enterprisegateway.payyd.money/graphql";
  static PRODUCTION_ENDPOINT = "https://enterprisegateway.payyd.money/graphql";
  constructor(options) {
    if (options.signRequests === false) {
      throw new SigningConfigurationError(
        "PayydEnterpriseClient requires request signing for all operations."
      );
    }
    super({
      ...options,
      endpoint: options.endpoint ?? _PayydEnterpriseClient.SANDBOX_ENDPOINT,
      signRequests: true,
      operations: PAYYD_OPERATION_DEFINITIONS
    });
  }
  get availableMethods() {
    return this.operationNames;
  }
  defaultVariablesFor(methodName) {
    const definition = PAYYD_OPERATION_DEFINITIONS[methodName];
    if (!definition) {
      throw new Error(`Unknown method name: ${methodName}`);
    }
    return structuredClone(definition.defaultVariables);
  }
  async callRaw(methodName, variables = null) {
    return this.runResult(methodName, variables);
  }
  async callModel(methodName, variables = null) {
    const result = await this.callRaw(methodName, variables);
    return result.data ?? {};
  }
  async accountGetBalances(currencyCode = null, options = {}) {
    if (currencyCode !== null && options.filter !== void 0 && options.filter !== null) {
      throw new Error("Pass either currencyCode or filter, not both.");
    }
    const resolvedFilter = options.filter ?? new AccountGetBalancesFilter({ currencyCode });
    return this.callModel(
      "accountGetBalances",
      resolvedFilter.toVariables()
    );
  }
  async authChangePassword(variables = null) {
    return this.callModel("authChangePassword", variables);
  }
  async authGetToken(username, password) {
    return this.callModel("authGetToken", {
      input: {
        userName: username,
        password
      }
    });
  }
  async payinHostedCancelTransaction(cancel) {
    return this.callModel("payinHostedCancelTransaction", cancel.toVariables());
  }
  async payinHostedCreateTransaction(transaction) {
    return this.callModel("payinHostedCreateTransaction", transaction.toVariables());
  }
  async payinHostedGetTransactionByInternalRef(internalRef) {
    return this.callModel("payinHostedGetTransactionByInternalRef", {
      internalRef: _PayydEnterpriseClient.requireNonEmpty("internal_ref", internalRef)
    });
  }
  async payinHostedGetTransactionByReference(reference) {
    return this.callModel("payinHostedGetTransactionByReference", {
      reference: _PayydEnterpriseClient.requireNonEmpty("reference", reference)
    });
  }
  async payinHostedGetTransactions(query = null) {
    const resolvedQuery = query ?? new PayinGetTransactionsQuery();
    return this.callModel("payinHostedGetTransactions", resolvedQuery.toVariables());
  }
  async payinS2sCancelTransaction(cancel) {
    return this.callModel("payinS2sCancelTransaction", cancel.toVariables());
  }
  async payinS2sCreateTransaction(transaction) {
    return this.callModel("payinS2sCreateTransaction", transaction.toVariables());
  }
  async payinS2sGetIdentificationTypes(countryIsoCode3) {
    return this.callModel(
      "payinS2sGetIdentificationTypes",
      new PayinCountryQuery({ countryIsoCode3 }).toVariables()
    );
  }
  async payinS2sGetPaymentMethods(countryIsoCode3) {
    return this.callModel(
      "payinS2sGetPaymentMethods",
      new PayinCountryQuery({ countryIsoCode3 }).toVariables()
    );
  }
  async payinS2sGetTransactionByInternalRef(internalRef) {
    return this.callModel("payinS2sGetTransactionByInternalRef", {
      internalRef: _PayydEnterpriseClient.requireNonEmpty("internal_ref", internalRef)
    });
  }
  async payinS2sGetTransactionByReference(reference) {
    return this.callModel("payinS2sGetTransactionByReference", {
      reference: _PayydEnterpriseClient.requireNonEmpty("reference", reference)
    });
  }
  async payinS2sGetTransactions(query = null) {
    const resolvedQuery = query ?? new PayinGetTransactionsQuery();
    return this.callModel("payinS2sGetTransactions", resolvedQuery.toVariables());
  }
  async payinS2sGetBanks(query) {
    return this.callModel("payinS2sGetBanks", query.toVariables());
  }
  async payinS2sPayTransaction(transaction) {
    return this.callModel("payinS2sPayTransaction", transaction.toVariables());
  }
  async payoutCreateTransaction(transaction) {
    return this.callModel("payoutCreateTransaction", transaction.toVariables());
  }
  async payoutGetBanks(query) {
    return this.callModel("payoutGetBanks", query.toVariables());
  }
  async payoutGetFxRate(query) {
    return this.callModel("payoutGetFxRate", query.toVariables());
  }
  async payoutGetTransaction(reference) {
    return this.callModel("payoutGetTransaction", {
      reference: _PayydEnterpriseClient.requireNonEmpty("reference", reference)
    });
  }
  async payoutGetTransactions(query = null) {
    const resolvedQuery = query ?? new PayoutGetTransactionsQuery();
    return this.callModel("payoutGetTransactions", resolvedQuery.toVariables());
  }
  static requireNonEmpty(fieldName, value) {
    const normalized = value.trim();
    if (normalized === "") {
      throw new Error(`${fieldName} is required.`);
    }
    return normalized;
  }
};
export {
  AccountGetBalancesFilter,
  DEFAULT_COUNTRY_TEXT_REGEX,
  DEFAULT_EMAIL_REGEX,
  DEFAULT_MOBILE_REGEX,
  GraphQLClient,
  GraphQLError,
  GraphQLRequestError,
  OperationNotFoundError,
  PAYIN_COUNTRY_RULES,
  PAYYD_OPERATION_DEFINITIONS,
  PayinCancelTransactionInput,
  PayinCountryQuery,
  PayinCreateTransactionInput,
  PayinGetBanksQuery,
  PayinGetTransactionsQuery,
  PayinPaymentMethodInput,
  PayinS2sPayInput,
  PayinS2sPayTransactionInput,
  PayinSenderAddressInput,
  PayinSenderBankDetailsInput,
  PayinSenderIdentificationInput,
  PayinSenderInput,
  PayoutCreateTransactionInput,
  PayoutGetBanksQuery,
  PayoutGetFxRateQuery,
  PayoutGetTransactionsQuery,
  PayoutReceiverInput,
  PayydEnterpriseClient,
  PayydSDKError,
  SigningConfigurationError,
  canonicalizeNumber,
  countriesWithSendRules,
  deepClone,
  extractBearerToken,
  getRequiredSenderFieldsForCountry,
  isPlainObject,
  matchesRuleRegex,
  normalizeAmountFields,
  normalizeCountryCode,
  requiredText,
  sanitizeRegex,
  setOptionalText,
  stripNullValues,
  validatePayinCountryRules
};
