import { GraphQLBoolean, GraphQLFloat, GraphQLInputObjectType, GraphQLInt, GraphQLList, GraphQLString } from 'graphql';

import { createModuleNameFromMetaUrl } from '../../../_helpers/common';

export const PAYLOAD_NAME = createModuleNameFromMetaUrl(import.meta.url);

export default new GraphQLInputObjectType({
  name: PAYLOAD_NAME,
  fields: {
    id: {
      type: GraphQLInt,
    },
    publisherId: {
      type: GraphQLInt,
    },
    xrayCampaignId: {
      type: GraphQLInt,
    },
    name: {
      type: GraphQLString,
    },
    status: {
      type: GraphQLInt,
    },
    priority: {
      type: GraphQLInt,
    },
    xrayCreatives: {
      type: new GraphQLList(GraphQLInt),
    },
    startTime: {
      type: GraphQLFloat,
    },
    endTime: {
      type: GraphQLFloat,
    },
    timezoneId: {
      type: GraphQLInt,
    },
    rate: {
      type: GraphQLInt,
    },
    impressionsBudget: {
      type: GraphQLInt,
    },
    spendBudget: {
      type: GraphQLInt,
    },
    watchId: {
      type: GraphQLInt,
    },
    watchChannelId: {
      type: GraphQLInt,
    },
    playerId: {
      type: GraphQLInt,
    },
    videoName: {
      type: GraphQLString,
    },
    videoUid: {
      type: GraphQLString,
    },
    videoFromTimestamp: {
      type: GraphQLInt,
    },
    videoToTimestamp: {
      type: GraphQLInt,
    },
    targeting: {
      type: new GraphQLInputObjectType({
        name: `${PAYLOAD_NAME}_xrayLineItemTargeting`,
        fields: {
          domains: {
            type: new GraphQLInputObjectType({
              name: `${PAYLOAD_NAME}_xrayLineItemTargetingDomains`,
              fields: {
                include: {
                  type: new GraphQLList(GraphQLString),
                },
                exclude: {
                  type: new GraphQLList(GraphQLString),
                },
              },
            }),
          },
          devices: {
            type: new GraphQLList(GraphQLInt),
          },
          geography: {
            type: new GraphQLInputObjectType({
              name: `${PAYLOAD_NAME}_xrayLineItemTargetingGeography`,
              fields: {
                include: {
                  type: new GraphQLList(GraphQLInt),
                },
                exclude: {
                  type: new GraphQLList(GraphQLInt),
                },
              },
            }),
          },
          inview: {
            type: GraphQLBoolean,
          },
          notInview: {
            type: GraphQLBoolean,
          },
          iabCategories: {
            type: new GraphQLInputObjectType({
              name: `${PAYLOAD_NAME}_xrayLineItemTargetingIabCategories`,
              fields: {
                include: {
                  type: new GraphQLList(GraphQLString),
                },
                exclude: {
                  type: new GraphQLList(GraphQLString),
                },
              },
            }),
          },
          people: {
            type: new GraphQLInputObjectType({
              name: `${PAYLOAD_NAME}_xrayLineItemTargetingPeople`,
              fields: {
                include: {
                  type: new GraphQLList(
                    new GraphQLInputObjectType({
                      name: `${PAYLOAD_NAME}_xrayLineItemTargetingPeopleInclude`,
                      fields: {
                        name: {
                          type: GraphQLString,
                        },
                        taxonomyId: {
                          type: GraphQLString,
                        },
                      },
                    }),
                  ),
                },
                exclude: {
                  type: new GraphQLList(
                    new GraphQLInputObjectType({
                      name: `${PAYLOAD_NAME}_xrayLineItemTargetingPeopleExclude`,
                      fields: {
                        name: {
                          type: GraphQLString,
                        },
                        taxonomyId: {
                          type: GraphQLString,
                        },
                      },
                    }),
                  ),
                },
              },
            }),
          },
          brands: {
            type: new GraphQLInputObjectType({
              name: `${PAYLOAD_NAME}_xrayLineItemTargetingBrands`,
              fields: {
                include: {
                  type: new GraphQLList(
                    new GraphQLInputObjectType({
                      name: `${PAYLOAD_NAME}_xrayLineItemTargetingBrandsInclude`,
                      fields: {
                        name: {
                          type: GraphQLString,
                        },
                        taxonomyId: {
                          type: GraphQLString,
                        },
                      },
                    }),
                  ),
                },
                exclude: {
                  type: new GraphQLList(
                    new GraphQLInputObjectType({
                      name: `${PAYLOAD_NAME}_xrayLineItemTargetingBrandsExclude`,
                      fields: {
                        name: {
                          type: GraphQLString,
                        },
                        taxonomyId: {
                          type: GraphQLString,
                        },
                      },
                    }),
                  ),
                },
              },
            }),
          },
          keywords: {
            type: new GraphQLInputObjectType({
              name: `${PAYLOAD_NAME}_xrayLineItemTargetingKeywords`,
              fields: {
                include: {
                  type: new GraphQLList(
                    new GraphQLInputObjectType({
                      name: `${PAYLOAD_NAME}_xrayLineItemTargetingKeywordsInclude`,
                      fields: {
                        name: {
                          type: GraphQLString,
                        },
                        taxonomyId: {
                          type: GraphQLString,
                        },
                      },
                    }),
                  ),
                },
                exclude: {
                  type: new GraphQLList(
                    new GraphQLInputObjectType({
                      name: `${PAYLOAD_NAME}_xrayLineItemTargetingKeywordsExclude`,
                      fields: {
                        name: {
                          type: GraphQLString,
                        },
                        taxonomyId: {
                          type: GraphQLString,
                        },
                      },
                    }),
                  ),
                },
              },
            }),
          },
          labels: {
            type: new GraphQLInputObjectType({
              name: `${PAYLOAD_NAME}_xrayLineItemTargetingLabels`,
              fields: {
                include: {
                  type: new GraphQLList(
                    new GraphQLInputObjectType({
                      name: `${PAYLOAD_NAME}_xrayLineItemTargetingLabelsInclude`,
                      fields: {
                        name: {
                          type: GraphQLString,
                        },
                        value: {
                          type: GraphQLString,
                        },
                        color: {
                          type: GraphQLString,
                        },
                        taxonomyId: {
                          type: GraphQLString,
                        },
                      },
                    }),
                  ),
                },
                exclude: {
                  type: new GraphQLList(
                    new GraphQLInputObjectType({
                      name: `${PAYLOAD_NAME}_xrayLineItemTargetingLabelsExclude`,
                      fields: {
                        name: {
                          type: GraphQLString,
                        },
                        value: {
                          type: GraphQLString,
                        },
                        color: {
                          type: GraphQLString,
                        },
                        taxonomyId: {
                          type: GraphQLString,
                        },
                      },
                    }),
                  ),
                },
              },
            }),
          },
          brandSafety: {
            type: new GraphQLInputObjectType({
              name: `${PAYLOAD_NAME}_xrayLineItemTargetingBrandSafety`,
              fields: {
                include: {
                  type: new GraphQLList(GraphQLInt),
                },
                exclude: {
                  type: new GraphQLList(GraphQLInt),
                },
              },
            }),
          },
          playerSizes: {
            type: new GraphQLList(GraphQLInt),
          },
        },
      }),
    },
  },
});
