import { ArOverlayFindAndPickConfiguration } from '../barcode/ArTrackingOverlayConfiguration';
import { ArOverlayGeneralConfiguration } from '../barcode/ArTrackingOverlayConfiguration';
import { ArOverlayPolygonConfiguration } from '../barcode/ArTrackingOverlayConfiguration';
import { BackgroundStyle } from '../common/Common';
import { BadgeStyle } from '../common/Common';
import { BadgedButton } from '../common/Common';
import { BarcodeInfoMapping } from '../barcode/BarcodeInfoMapping';
import { BarcodeItemConfiguration } from '../barcode/ArTrackingOverlayConfiguration';
import { BarcodeItemErrorState } from '../barcode/BarcodeInfoMapping';
import { BarcodeItemInfoPosition } from '../barcode/ArTrackingOverlayConfiguration';
import { BarcodeItemMapper } from '../BarcodeItemMapper';
import { BarcodeUseCase } from '../barcode/BarcodeUseCase';
import { ButtonConfiguration } from '../common/Common';
import { CollapsedVisibleHeight } from '../barcode/MultipleScanningModeUseCase';
import { DeepPartial, PartiallyConstructible } from '../../utils';
import { ExpectedBarcode } from '../barcode/FindAndPickScanningModeUseCase';
import { FindAndPickArOverlayPolygonConfiguration } from '../barcode/ArTrackingOverlayConfiguration';
import { FindAndPickBadgeConfiguration } from '../barcode/ArTrackingOverlayConfiguration';
import { FindAndPickScanningMode } from '../barcode/FindAndPickScanningModeUseCase';
import { ForegroundStyle } from '../common/Common';
import { IconStyle } from '../common/Common';
import { ManualCountEditDialog } from '../barcode/MultipleScanningModeUseCase';
import { MultipleBarcodesScanningMode } from '../barcode/MultipleScanningModeUseCase';
import { MultipleScanningMode } from '../barcode/MultipleScanningModeUseCase';
import { PolygonStyle } from '../common/Common';
import { ScanbotAlertDialog } from '../common/ScanbotAlertDialog';
import { SheetContent } from '../barcode/MultipleScanningModeUseCase';
import { SheetMode } from '../barcode/MultipleScanningModeUseCase';
import { Sheet } from '../barcode/MultipleScanningModeUseCase';
import { StyledText } from '../common/Common';
import { SwipeToDelete } from '../barcode/MultipleScanningModeUseCase';

/**
Configuration of the single barcode scanning mode.
*/
export class SingleScanningMode extends PartiallyConstructible {
  public readonly _type: 'SingleScanningMode' = 'SingleScanningMode';
  /**
    If enabled, the confirmation sheet will be shown after the barcode has been scanned.
    Default is false
    */
  public confirmationSheetEnabled: boolean = false;
  /**
    If enabled, the barcode image will be shown on the confirmation sheet.
    Default is true
    */
  public barcodeImageVisible: boolean = true;
  /**
    Color of the confirmation sheet's background.
    Default is "?sbColorSurface"
    */
  public sheetColor: string = '?sbColorSurface';
  /**
    Color of the divider and separator lines in the confirmation sheet.
    Default is "?sbColorOutline"
    */
  public dividerColor: string = '?sbColorOutline';
  /**
    Background color of the overlay surrounding the confirmation sheet.
    Default is "?sbColorModalOverlay"
    */
  public modalOverlayColor: string = '?sbColorModalOverlay';
  /**
    Appearance of the barcode title (the barcode's value) on the confirmation sheet.
    */
  public barcodeTitle: StyledText = new StyledText({
    text: 'BARCODE_TITLE',
    color: '?sbColorOnSurface',
  });
  /**
    Appearance of the barcode subtitle (the barcode's symbology) on the confirmation sheet.
    */
  public barcodeSubtitle: StyledText = new StyledText({
    text: 'BARCODE_SUBTITLE',
    color: '?sbColorOnSurfaceVariant',
  });
  /**
    Appearance of the confirm button on the confirmation sheet.
    */
  public submitButton: ButtonConfiguration = new ButtonConfiguration({
    visible: true,
    text: '?sheetSubmitButton',
    background: new BackgroundStyle({
      strokeColor: '?sbColorPrimary',
      fillColor: '?sbColorPrimary',
      strokeWidth: 1.0,
    }),
    foreground: new ForegroundStyle({ iconVisible: true, color: '?sbColorOnPrimary' }),
  });
  /**
    Appearance of the cancel button on the confirmation sheet.
    */
  public cancelButton: ButtonConfiguration = new ButtonConfiguration({
    visible: true,
    text: '?singleModeConfirmationCancelButton',
    background: new BackgroundStyle({
      strokeColor: '#00000000',
      fillColor: '#00000000',
      strokeWidth: 1.0,
    }),
    foreground: new ForegroundStyle({ iconVisible: false, color: '?sbColorPrimary' }),
  });
  /**
    Appearance of the barcode info mapping.
    */
  public barcodeInfoMapping: BarcodeInfoMapping = new BarcodeInfoMapping({
    sheetColor: '?sbColorSurface',
    dividerColor: '?sbColorOutline',
    modalOverlayColor: '?sbColorModalOverlay',
    loadingMessage: new StyledText({
      text: '?barcodeInfoMappingLoadingMessage',
      color: '?sbColorPrimary',
    }),
    errorState: new BarcodeItemErrorState({
      title: new StyledText({
        text: '?barcodeInfoMappingErrorStateTitle',
        color: '?sbColorOnSurface',
      }),
      subtitle: new StyledText({
        text: '?barcodeInfoMappingErrorStateSubtitle',
        color: '?sbColorOnSurfaceVariant',
      }),
      retryButton: new ButtonConfiguration({
        visible: true,
        text: '?barcodeInfoMappingErrorStateRetryButton',
        background: new BackgroundStyle({
          strokeColor: '?sbColorPrimary',
          fillColor: '?sbColorPrimary',
          strokeWidth: 1.0,
        }),
        foreground: new ForegroundStyle({ iconVisible: true, color: '?sbColorOnPrimary' }),
      }),
      cancelButton: new ButtonConfiguration({
        text: '?barcodeInfoMappingErrorStateCancelButton',
        background: new BackgroundStyle({
          strokeColor: '#00000000',
          fillColor: '#00000000',
          strokeWidth: 1.0,
        }),
        foreground: new ForegroundStyle({ iconVisible: false, color: '?sbColorPrimary' }),
      }),
    }),
  });
  /**
    Configuration of the AR overlay.
    */
  public arOverlay: ArOverlayGeneralConfiguration = new ArOverlayGeneralConfiguration({
    visible: false,
    counterBadge: new BadgeStyle({
      visible: true,
      background: new BackgroundStyle({
        strokeColor: '#000000FF',
        fillColor: '?sbColorPositive',
        strokeWidth: 0.0,
      }),
      foregroundColor: '?sbColorOnSurface',
    }),
    automaticSelectionEnabled: false,
    barcodeItemInfoPosition: 'BELOW',
    polygon: new ArOverlayPolygonConfiguration({
      visible: true,
      deselected: new PolygonStyle({
        strokeColor: '?sbColorSurface',
        fillColor: '#00000000',
        strokeWidth: 3.0,
        cornerRadius: 5.0,
      }),
      selected: new PolygonStyle({
        strokeColor: '?sbColorPositive',
        fillColor: '#00000000',
        strokeWidth: 3.0,
        cornerRadius: 5.0,
      }),
    }),
    barcodeItemConfiguration: new BarcodeItemConfiguration({
      imageVisible: true,
      titleSelected: new StyledText({ text: 'BARCODE_TITLE', color: '?sbColorOnSurface' }),
      subtitleSelected: new StyledText({
        text: 'BARCODE_SUBTITLE',
        color: '?sbColorOnSurfaceVariant',
      }),
      titleDeselected: new StyledText({ text: 'BARCODE_TITLE', color: '?sbColorOnSurface' }),
      subtitleDeselected: new StyledText({
        visible: true,
        text: 'BARCODE_SUBTITLE',
        color: '?sbColorOnSurfaceVariant',
        useShadow: false,
      }),
      backgroundSelected: new PolygonStyle({
        strokeColor: '?sbColorPositive',
        fillColor: '?sbColorPositive',
        strokeWidth: 1.0,
        cornerRadius: 5.0,
      }),
      backgroundDeselected: new PolygonStyle({
        strokeColor: '?sbColorSurface',
        fillColor: '?sbColorSurface',
        strokeWidth: 1.0,
        cornerRadius: 5.0,
      }),
    }),
  });

  /** @param source {@displayType `DeepPartial<SingleScanningMode>`} */
  public constructor(source: DeepPartial<SingleScanningMode> = {}) {
    super();
    if (source.confirmationSheetEnabled !== undefined) {
      this.confirmationSheetEnabled = source.confirmationSheetEnabled;
    }
    if (source.barcodeImageVisible !== undefined) {
      this.barcodeImageVisible = source.barcodeImageVisible;
    }
    if (source.sheetColor !== undefined) {
      this.sheetColor = source.sheetColor;
    }
    if (source.dividerColor !== undefined) {
      this.dividerColor = source.dividerColor;
    }
    if (source.modalOverlayColor !== undefined) {
      this.modalOverlayColor = source.modalOverlayColor;
    }
    if (source.barcodeTitle !== undefined) {
      this.barcodeTitle = new StyledText(source.barcodeTitle);
    }
    if (source.barcodeSubtitle !== undefined) {
      this.barcodeSubtitle = new StyledText(source.barcodeSubtitle);
    }
    if (source.submitButton !== undefined) {
      this.submitButton = new ButtonConfiguration(source.submitButton);
    }
    if (source.cancelButton !== undefined) {
      this.cancelButton = new ButtonConfiguration(source.cancelButton);
    }
    if (source.barcodeInfoMapping !== undefined) {
      this.barcodeInfoMapping = new BarcodeInfoMapping(source.barcodeInfoMapping);
    }
    if (source.arOverlay !== undefined) {
      this.arOverlay = new ArOverlayGeneralConfiguration(source.arOverlay);
    }
  }
}
