import React from 'react';
import { FormattedMessage } from 'react-intl';
import messages from "./messages";

export const RCS = 'RCS';
export const SMS = 'SMS';
export const MEDIUM = 'MEDIUM';
export const VERTICAL = 'VERTICAL';
export const RIGHT = 'HORIZONTAL_RIGHT';
export const LEFT = 'HORIZONTAL_LEFT';
export const HORIZONTAL = 'HORIZONTAL';
export const STANDALONE = 'STANDALONE';
export const SMALL = 'SMALL';
export const RICHCARD = 'RICHCARD';
export const TITLE_TEXT = 'title';
export const MESSAGE_TEXT = 'message';
export const titletype='title';
export const descType='description';
export const TEMPLATE_HEADER_MAX_LENGTH = 60;
export const TEMPLATE_MESSAGE_MAX_LENGTH = 1024;
export const UNSUBSCRIBE_TEXT_LENGTH = 36;

export const RCS_DLT_MODE = {
  TEMPLATES: 'templates',
  EDIT: 'editTemplate',
};

export const RCS_STATUSES = {
  approved: 'approved',
  rejected: 'rejected',
  created: 'created',
  pending: 'pending',
  unavailable: 'unavailable',
  awaitingApproval: 'awaitingApproval',
};

export const contentType = {
  text_message: 'text_message',
  rich_card: 'rich_card',
  carousel: 'carousel',
};

export const STATUS_OPTIONS = [
  // {
  //   key: 'created',
  //   value: RCS_STATUSES.awaitingApproval,
  //   label: <FormattedMessage {...messages.created} />,
  // },
  {
    key: 'approved',
    value: RCS_STATUSES.approved,
    label: <FormattedMessage {...messages.approved} />,
  },
  {
    key: 'rejected',
    value: RCS_STATUSES.rejected,
    label: <FormattedMessage {...messages.rejected} />,
  },
  {
    key: 'pending',
    value: RCS_STATUSES.pending,
    label: <FormattedMessage {...messages.pending} />,
  },
  {
    key: 'unavailable',
    value: RCS_STATUSES.unavailable,
    label: <FormattedMessage {...messages.unavailable} />,
  },
];

export const RCS_MEDIA_TYPES = {
  NONE: 'NONE',
  IMAGE: 'IMAGE',
  VIDEO: 'VIDEO',
};

export const rcsVarRegex = /\{\{\w+\}\}/g;
export const rcsVarTestRegex = /\{\{\w+\}\}/;
export const TEMPLATE_DESC_MAX_LENGTH = 2500;
export const FALLBACK_MESSAGE_MAX_LENGTH = 160;
export const TEMPLATE_TITLE_MAX_LENGTH = 200;
export const TEMPLATE_BUTTON_TEXT_MAX_LENGTH = 25;
export const CTA = 'CTA';
export const QUICK_REPLY = 'QUICK_REPLY';
export const TAG = 'TAG';
export const EMBEDDED = 'embedded';
export const DEFAULT = 'default';
export const FULL = 'full';
export const ALL = 'all';
export const LIBRARY = 'library';
export const ALLOWED_IMAGE_EXTENSIONS_REGEX = (/\.(png|jpg|jpeg|gif)$/i);
export const RCS_IMG_WIDTH = 1440;
export const RCS_IMG_HEIGHT = 1024;
export const RCS_IMG_SIZE = 2000000; // 2MB
export const MAX_FILE_SIZE_MB = 10;
export const MAX_FILE_SIZE_BYTES = MAX_FILE_SIZE_MB * 1024 * 1024;
export const ALLOWED_EXTENSIONS_VIDEO_REGEX = (/\.(mp4)$/i);
export const RCS_VIDEO_SIZE = 10 * 1024 * 1024;
export const RCS_THUMBNAIL_MIN_SIZE = 40 * 1024;
export const RCS_THUMBNAIL_MAX_SIZE = 100 * 1024;

export const RCS_IMAGE_DIMENSIONS = {
  SHORT_HEIGHT: {
    width: 1440,
    height: 480,
    type: 'SHORT_HEIGHT',
    heightType: 'SHORT',
    label: 'Vertical Short',
    description: 'Image (1440 x 480)',
    orientation: 'VERTICAL',
    maxFileSize: 2 * 1024 * 1024,
  },
  MEDIUM_HEIGHT: {
    width: 1440,
    height: 720,
    type: 'MEDIUM_HEIGHT',
    heightType: 'MEDIUM',
    label: 'Vertical Medium',
    description: 'Image (1440 x 720)',
    orientation: 'VERTICAL',
    maxFileSize: 2 * 1024 * 1024,
  },
  HORIZONTAL_LEFT: {
    width: 768,
    height: 1024,
    type: 'HORIZONTAL_LEFT',
    alignment: 'LEFT',
    label: 'Horizontal- Media to the left',
    description: 'Image (768 x 1024)',
    orientation: 'HORIZONTAL',
    maxFileSize: 2 * 1024 * 1024,
  },
  HORIZONTAL_RIGHT: {
    width: 768,
    height: 1024,
    type: 'HORIZONTAL_RIGHT',
    alignment: 'RIGHT',
    label: 'Horizontal- Media to the right',
    description: 'Image (768 x 1024)',
    orientation: 'HORIZONTAL',
    maxFileSize: 2 * 1024 * 1024,
  },
};

export const RCS_VIDEO_THUMBNAIL_DIMENSIONS = {
  SHORT_HEIGHT: {
    width: 770,
    height: 257,
    type: 'SHORT_HEIGHT',
    heightType: 'SHORT',
    label: 'Vertical Short',
    description: 'Thumbnail (770 x 257)',
    orientation: 'VERTICAL',
    maxFileSize: 100 * 1024,
    minImgSize: 40 * 1024,
  },
  MEDIUM_HEIGHT: {
    width: 770,
    height: 335,
    type: 'MEDIUM_HEIGHT',
    heightType: 'MEDIUM',
    label: 'Vertical Medium',
    description: 'Thumbnail (770 x 335)',
    orientation: 'VERTICAL',
    maxFileSize: 100 * 1024,
    minImgSize: 40 * 1024,
  },
  HORIZONTAL_LEFT: {
    width: 250,
    height: 330,
    type: 'HORIZONTAL_LEFT',
    label: 'Horizontal- Media to the left',
    description: 'Thumbnail (250 x 330)',
    orientation: 'HORIZONTAL',
    alignment: 'LEFT',
    maxFileSize: 100 * 1024,
    minImgSize: 40 * 1024,
  },
  HORIZONTAL_RIGHT: {
    width: 250,
    height: 330,
    type: 'HORIZONTAL_RIGHT',
    label: 'Horizontal- Media to the right',
    description: 'Thumbnail (250 x 330)',
    orientation: 'HORIZONTAL',
    alignment: 'RIGHT',
    maxFileSize: 100 * 1024,
    minImgSize: 40 * 1024,
  },
};

const prefix = 'app/v2Containers/Rcs';
export const UPLOAD_RCS_ASSET_REQUEST = `${prefix}/UPLOAD_RCS_ASSET_REQUEST`;
export const UPLOAD_RCS_ASSET_SUCCESS = `${prefix}/UPLOAD_RCS_ASSET_SUCCESS`;
export const UPLOAD_RCS_ASSET_FAILURE = `${prefix}/UPLOAD_RCS_ASSET_FAILURE`;
export const CLEAR_RCS_ASSET = `${prefix}/CLEAR_RCS_ASSET`;
export const CLEAR_RCS_MEDIA_ASSET = `${prefix}/CLEAR_RCS_MEDIA_ASSET`;
export const CLEAR_RCS_TEMPLATE_SUCCESS = `${prefix}/CLEAR_RCS_TEMPLATE_SUCCESS`;
export const CLEAR_RCS_TEMPLATE_FAILURE = `${prefix}/CLEAR_RCS_TEMPLATE_FAILURE`;

export const CREATE_RCS_TEMPLATE_REQUEST = `${prefix}/CREATE_RCS_TEMPLATE_REQUEST`;
export const CREATE_RCS_TEMPLATE_SUCCESS = `${prefix}/CREATE_RCS_TEMPLATE_SUCCESS`;
export const CREATE_RCS_TEMPLATE_FAILURE = `${prefix}/CREATE_RCS_TEMPLATE_FAILURE`;
export const CLEAR_CREATE_RESPONSE_REQUEST = `${prefix}/Create/CLEAR_CREATE_RESPONSE_REQUEST`;


export const GET_RCS_TEMPLATE_DETAILS_REQUEST = `${prefix}/GET_RCS_TEMPLATE_DETAILS_REQUEST`;
export const GET_RCS_TEMPLATE_DETAILS_SUCCESS = `${prefix}/GET_RCS_TEMPLATE_DETAILS_SUCCESS`;
export const GET_RCS_TEMPLATE_DETAILS_FAILURE = `${prefix}/GET_RCS_TEMPLATE_DETAILS_FAILURE`;

export const EDIT_RCS_TEMPLATE_REQUEST = `${prefix}/EDIT_RCS_TEMPLATE_REQUEST`;
export const EDIT_RCS_TEMPLATE_SUCCESS = `${prefix}/EDIT_RCS_TEMPLATE_SUCCESS`;
export const EDIT_RCS_TEMPLATE_FAILURE = `${prefix}/EDIT_RCS_TEMPLATE_FAILURE`;
export const CLEAR_EDIT_RESPONSE_REQUEST = `${prefix}/Edit/CLEAR_EDIT_RESPONSE_REQUEST`;
export const AI_CONTENT_BOT_DISABLED = "AI_CONTENT_BOT_DISABLED";

export const RCS_TEXT_MESSAGE_MAX_LENGTH = 160;
export const RCS_RICH_CARD_MAX_LENGTH = 2000;
export const MAX_BUTTONS = 4;

export const STOP = 'stop';
export const PHONE_NUMBER = 'PHONE_NUMBER';
export const INITIAL_SUGGESTIONS = [
  {
    index: 0,
    type: QUICK_REPLY,
    text: '',
    phoneNumber: '',
    url: null,
    postback: '',
    isSaved: false,
  },
];

export const INITIAL_SUGGESTIONS_DATA_STOP = [
  {
    index: 0,
    type: QUICK_REPLY,
    text: STOP,
    phoneNumber: '',
    url: null,
    postback: STOP,
    isSaved: true,
  },
];

export const RCS_BUTTON_TYPES = {
  NONE: 'NONE',
  QUICK_REPLY: 'QUICK_REPLY',
  PHONE_NUMBER: 'PHONE_NUMBER',
  CTA: 'CTA',
};
