export const DEFAULT_ACTION = 'app/v2Containers/WebPush/DEFAULT_ACTION';

export const CREATE_TEMPLATE_REQUEST = 'app/v2Containers/WebPush/Create/CREATE_TEMPLATE_REQUEST';
export const CREATE_TEMPLATE_SUCCESS = 'app/v2Containers/WebPush/Create/CREATE_TEMPLATE_SUCCESS';
export const CREATE_TEMPLATE_FAILURE = 'app/v2Containers/WebPush/Create/CREATE_TEMPLATE_FAILURE';

export const CLEAR_CREATE_RESPONSE_REQUEST = 'app/v2Containers/WebPush/Create/CLEAR_CREATE_RESPONSE_REQUEST';
export const CLEAR_CREATE_RESPONSE_SUCCESS = 'app/v2Containers/WebPush/Create/CLEAR_CREATE_RESPONSE_SUCCESS';
export const CLEAR_CREATE_RESPONSE_FAILURE = 'app/v2Containers/WebPush/Create/CLEAR_CREATE_RESPONSE_FAILURE';

export const EDIT_TEMPLATE_REQUEST = 'app/v2Containers/WebPush/Edit/EDIT_TEMPLATE_REQUEST';
export const EDIT_TEMPLATE_SUCCESS = 'app/v2Containers/WebPush/Edit/EDIT_TEMPLATE_SUCCESS';
export const EDIT_TEMPLATE_FAILURE = 'app/v2Containers/WebPush/Edit/EDIT_TEMPLATE_FAILURE';

export const CLEAR_EDIT_RESPONSE_REQUEST = 'app/v2Containers/WebPush/Edit/CLEAR_EDIT_RESPONSE_REQUEST';
export const CLEAR_EDIT_RESPONSE_SUCCESS = 'app/v2Containers/WebPush/Edit/CLEAR_EDIT_RESPONSE_SUCCESS';
export const CLEAR_EDIT_RESPONSE_FAILURE = 'app/v2Containers/WebPush/Edit/CLEAR_EDIT_RESPONSE_FAILURE';

// Media Types
export const WEBPUSH_MEDIA_TYPES = {
  NONE: "NONE",
  IMAGE: "IMAGE",
};

export const WEBPUSH_MEDIA_TYPES_OPTIONS = [
  { label: "None", value: WEBPUSH_MEDIA_TYPES.NONE },
  { label: "Image", value: WEBPUSH_MEDIA_TYPES.IMAGE },
];

// Image Upload Constants
export const ALLOWED_IMAGE_EXTENSIONS_REGEX = /\.(jpe?g|png)$/i;
export const WEBPUSH_IMG_SIZE = 5000000; // 5MB

// Note: image width/height validation will be ignored for the web push channel inside CapImageUpload
export const WEBPUSH_RECOMMENDED_DIMENSIONS = [
  { width: 1440, height: 720 },
  { width: 512, height: 256 },
];

// Brand Icon Options
export const BRAND_ICON_OPTIONS = {
  DONT_SHOW: 'DONT_SHOW',
  UPLOAD_IMAGE: 'UPLOAD_IMAGE',
  ADD_IMAGE_URL: 'ADD_IMAGE_URL',
};

// Brand Icon Upload Constants
export const WEBPUSH_BRAND_ICON_SIZE = 1000000; // 1MB
// Note: image width/height validation will be ignored for the web push channel inside CapImageUpload
export const WEBPUSH_BRAND_ICON_RECOMMENDED_DIMENSIONS = [
  { width: 192, height: 192 },
  { width: 256, height: 256 },
];

// Image Upload Methods
export const IMAGE_UPLOAD_METHODS = {
  UPLOAD_IMAGE: 'UPLOAD_IMAGE',
  ADD_IMAGE_URL: 'ADD_IMAGE_URL',
};

// Upload Asset Actions
const prefix = "app/v2Containers/WebPush";
export const UPLOAD_WEBPUSH_ASSET_REQUEST = `${prefix}/UPLOAD_WEBPUSH_ASSET_REQUEST`;
export const UPLOAD_WEBPUSH_ASSET_SUCCESS = `${prefix}/UPLOAD_WEBPUSH_ASSET_SUCCESS`;
export const UPLOAD_WEBPUSH_ASSET_FAILURE = `${prefix}/UPLOAD_WEBPUSH_ASSET_FAILURE`;
export const CLEAR_WEBPUSH_ASSET = `${prefix}/CLEAR_WEBPUSH_ASSET`;

// Upload Field Identifiers
export const UPLOAD_FIELD_TYPES = {
  IMAGE: 'image',
  BRAND_ICON: 'brandIcon',
};

// Button Types
export const WEBPUSH_BUTTON_TYPES = {
  PRIMARY: 'primary',
  SECONDARY: 'secondary',
};

// OnClick Behaviour Options
export const ON_CLICK_BEHAVIOUR_OPTIONS = {
  SITE_URL: 'SITE_URL',
  REDIRECT_TO_URL: 'REDIRECT_TO_URL',
};

// Action Types
export const ACTION_TYPES = {
  URL: 'URL',
  SITE_URL: 'SITE_URL',
};

// WebPush Content Field Names
// Field names used in template data structure (versions.base.content.webpush)
export const WEBPUSH_CONTENT_FIELDS = {
  TITLE: 'title',
  MESSAGE: 'message',
  IMAGE: 'image',
  BRAND_ICON: 'brandIcon',
  MEDIA_TYPE: 'mediaType',
  ON_CLICK_ACTION: 'onClickAction',
  CTAS: 'ctas',
};

// Template Data Path Constants
export const WEBPUSH_TEMPLATE_PATHS = {
  CONTENT: 'versions.base.content.webpush',
  NAME: 'name',
};

// Character Count Configuration
export const SHOW_CHARACTER_COUNT = true;

// Maximum Character Limits for Web Push Fields
export const NOTIFICATION_TITLE_MAX_LENGTH = 65;
export const MESSAGE_MAX_LENGTH = 240;
export const BUTTON_TEXT_MAX_LENGTH = 20;

// URL Validation Constants
export const SUPPORTED_PROTOCOLS = new Set(['http:', 'https:']);
export const HTTP_URL_PATTERN = /^https?:\/\/.+/i;
// Pattern to ensure URL has a TLD (Top Level Domain): protocol://domain.tld
// Requires at least one dot in the domain part, followed by 2+ word characters
// before path separator (/), query (?), hash (#), port (:), or end of string
export const TLD_PATTERN = /^https?:\/\/[^/?#:]+\.\w{2,}(?:\/|$|\?|#|:)/i;

// Utility Constants
// Stable empty array to prevent unnecessary re-renders when used as default prop values
export const EMPTY_ARRAY = [];

export const EXTERNAL_URL = 'EXTERNAL_URL';
export const SITE_URL = 'SITE_URL';
export const URL = 'URL';