"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.localize = localize;
exports.replaceUnTranslatedDefaultProps = replaceUnTranslatedDefaultProps;
exports.replaceUnTranslatedString = replaceUnTranslatedString;
exports.playMessage = exports.getScrollbarWidth = exports.scrollToTop = exports.showNotification = exports.showConfirmation = exports.showAlert = exports.closePopup = exports.showPopup = void 0;

var _lodash = _interopRequireDefault(require("lodash"));

var _Alert = require("./popups/Alert");

var _AutosuggestControl = require("./form/AutosuggestControl");

var _Confirm = require("./popups/Confirm");

var _PurePagination = require("./list/PurePagination");

var _HeaderToolbar = require("./HeaderToolbar");

var _Note = require("./Note");

var _CounterText = require("./list/CounterText");

var _PureListLayout = require("./list/PureListLayout");

var _ListLayout = require("./list/withStore/ListLayout");

var _SelectedRecordsSwitcher = require("./SelectedRecordsSwitcher");

var _PureList = require("./list/PureList");

var _List = require("./list/withStore/List");

var _CommonListSorter = require("./list/common/CommonListSorter");

var _GridHeaderCell = require("./list/withStore/GridHeaderCell");

var _Wizard = require("./Wizard");

var _WizardStep = require("./WizardStep");

var _MultiSelect = require("./form/MultiSelect");

var _Menu = require("./Menu");

var _FileUploadControl = require("./form/FileUploadControl");

var _DatePickerControl = require("./form/DatePickerControl");

var _DateRangePickerControl = require("./form/DateRangePickerControl");

var _AudioPlayer = require("./media/AudioPlayer");

var _AudioRecorder = require("./media/AudioRecorder");

var _CollapsibleToolbar = require("./CollapsibleToolbar");

var _Dropzone = require("./Dropzone");

var _VolumeControl = require("./media/VolumeControl");

var _Panel = require("./Panel");

var _Filter = require("./Filter");

var _SplitButton = require("./SplitButton");

var _Banner = require("./Banner");

var _Popup = require("./popups/Popup");

var _TiledGrid = require("./TiledGrid");

var _ListControlCheckbox = require("./list/withStore/ListControlCheckbox");

var _InputCounterControl = require("./form/InputCounterControl");

var _CTADropdown = require("./CTADropdown");

var _SingleDatePickerInputControl = require("./form/DateTimePicker/SingleDatePickerInputControl");

var _DayRangePickerControl = require("./form/DateTimePicker/DayRangePickerControl");

var _TreeFilterControl = require("./form/TreeFilterControl");

var _DateRangePickerWithPresets = require("./form/DateRangePickerWithPresets");

var _catalog = require("./catalog");

var _Search = require("./Search");

var _ToolsMenu = require("./ToolsMenu");

var _keyboardSortableListItem = require("../../dnd/keyboardSortableListItem");

var _utils = require("./utils");

exports.showPopup = _utils.showPopup;
exports.closePopup = _utils.closePopup;
exports.showAlert = _utils.showAlert;
exports.showConfirmation = _utils.showConfirmation;
exports.showNotification = _utils.showNotification;
exports.scrollToTop = _utils.scrollToTop;
exports.getScrollbarWidth = _utils.getScrollbarWidth;

var _playMessage = require("../utils/playMessage");

exports.playMessage = _playMessage.playMessage;

function localize(strings) {
  replaceUnTranslatedDefaultProps(_SingleDatePickerInputControl.SingleDatePickerInputControl, strings);
  replaceUnTranslatedString(_SingleDatePickerInputControl.SingleDatePickerInputControl.defaultProps.dayPickerPhrase, strings);
  replaceUnTranslatedDefaultProps(_DayRangePickerControl.DayRangePickerControl, strings);
  replaceUnTranslatedString(_DayRangePickerControl.DayRangePickerControl.defaultProps.dayPickerPhrase, strings);
  replaceUnTranslatedDefaultProps(_DateRangePickerWithPresets.DateRangePickerWithPresets, strings);
  _PurePagination.PurePagination.defaultProps.allText = strings.ALL;
  _PurePagination.PurePagination.defaultProps.pageSizeSelectorText = strings.SHOW;
  _PurePagination.PurePagination.defaultProps.goToPageLabel = strings.GO_TO_PAGE;
  _PurePagination.PurePagination.defaultProps.currentPageLabel = strings.CURRENT_PAGE;
  _PurePagination.PurePagination.defaultProps.pageNextLabel = strings.GO_TO_NEXT_PAGE;
  _PurePagination.PurePagination.defaultProps.pagePrevLabel = strings.GO_TO_PREV_PAGE;
  replaceUnTranslatedDefaultProps(_MultiSelect.MultiSelect, strings);
  replaceUnTranslatedDefaultProps(_TreeFilterControl.TreeFilterControl, strings);
  replaceUnTranslatedDefaultProps(_Menu.Menu, strings);
  _HeaderToolbar.HeaderToolbar.defaultProps.backText = strings.BACK;
  _HeaderToolbar.HeaderToolbar.defaultProps.detailSettingForArialLabel = strings.DETAIL_SETTING_FOR_ARIA_LABEL;
  _Note.Note.defaultProps.noteText = strings.NOTE;
  _SelectedRecordsSwitcher.SelectedRecordsSwitcher.defaultProps.showAllText = strings.SHOW_ALL;
  _SelectedRecordsSwitcher.SelectedRecordsSwitcher.defaultProps.showSelectedText = strings.SHOW_SELECTED;
  _CounterText.CounterText.defaultProps.template = strings.TOTAL_AMOUNT;
  _PureListLayout.PureListLayout.defaultProps.storeCounterText = strings.TOTAL_AMOUNT;
  _ListLayout.ListLayout.defaultProps.storeCounterText = strings.TOTAL_AMOUNT;
  _Wizard.Wizard.confirmWizardRestore = strings.CONFIRM_WIZARD_RESTORE;
  _WizardStep.WizardStep.defaultProps.backText = strings.BACK;
  _WizardStep.WizardStep.defaultProps.nextText = strings.NEXT;
  _WizardStep.WizardStep.defaultProps.cancelText = strings.CANCEL;
  _PureList.PureList.defaultProps.noResultsText = strings.NO_RESULTS;
  _PureList.PureList.defaultProps.blockedText = strings.PLEASE_WAIT_WHILE_LOADING;
  _List.List.defaultProps.noResultsText = strings.NO_RESULTS;
  _List.List.defaultProps.blockedText = strings.PLEASE_WAIT_WHILE_LOADING;
  _Alert.Alert.defaultProps.title = strings.ALERT;
  _Alert.Alert.defaultProps.submitText = strings.OK;
  _CollapsibleToolbar.CollapsibleToolbar.defaultProps.moreButtonText = strings.MORE;
  _CollapsibleToolbar.CollapsibleToolbar.defaultProps.moreButtonLabel = strings.MORE_ADVANCED_FILTERS;
  _Confirm.Confirm.defaultProps.title = strings.CONFIRMATION;
  _Confirm.Confirm.defaultProps.submitText = strings.YES;
  _Confirm.Confirm.defaultProps.cancelText = strings.NO;
  _AudioPlayer.AudioPlayer.defaultProps.loadingError = strings.CANNOT_OPEN_AUDIO;
  _AudioPlayer.AudioPlayer.defaultProps.playLabel = strings.PLAY;
  _AudioPlayer.AudioPlayer.defaultProps.pauseLabel = strings.PAUSE;
  _AudioPlayer.AudioPlayer.defaultProps.timeSlider = strings.TIMELINE_SLIDER;
  _AudioPlayer.AudioPlayer.defaultProps.recordLabel = strings.RECORD;
  _AudioPlayer.AudioPlayer.defaultProps.downloadLabel = strings.DOWNLOAD;
  _FileUploadControl.FileUploadControl.defaultProps.uploadText = strings.UPLOAD;
  _AudioRecorder.AudioRecorder.defaultProps.unsupportText = strings.MICROPHONE_NOT_SUPPORTED;
  _AudioRecorder.AudioRecorder.defaultProps.volumeMeterTitle = strings.MICROPHONE_TEST;
  _AudioRecorder.AudioRecorder.defaultProps.volumeMeterText = strings.MICROPHONE_TEST_TEXT;
  _AudioRecorder.AudioRecorder.defaultProps.processorTitle = strings.RECORDING;
  _AudioRecorder.AudioRecorder.defaultProps.processorText = strings.RECORDING_IN_PROGRESS;
  _AudioRecorder.AudioRecorder.defaultProps.completedTitle = strings.RECORDING;
  _AudioRecorder.AudioRecorder.defaultProps.completedText = strings.MICROPHONE_RECORD_COMPLETE;
  _AudioRecorder.AudioRecorder.defaultProps.audioRecordError = strings.MICROPHONE_RECORD_ERROR;
  _AudioRecorder.AudioRecorder.defaultProps.deviceNotFoundError = strings.MICROPHONE_NOT_FOUND_ERROR;
  _AudioRecorder.AudioRecorder.defaultProps.uploadLabel = strings.UPLOAD_RECORD;
  _AutosuggestControl.AutosuggestControl.defaultProps.suggestionPromptLabel = strings.AUTO_SUGGEST_SUGGESTION_PROMPT_LABEL;
  _AutosuggestControl.AutosuggestControl.defaultProps.noSuggestionPromptLabel = strings.NO_SUGGESTION_PROMPT_LABEL;
  _CommonListSorter.CommonListSorter.defaultProps.ascendingText = strings.SORT_BY_ASCENDING;
  _CommonListSorter.CommonListSorter.defaultProps.descendingText = strings.SORT_BY_DESCENDING;
  _CommonListSorter.CommonListSorter.defaultProps.sorterTitleText = strings.CLICK_TO_SORT;
  _GridHeaderCell.GridHeaderCell.defaultProps.ascendingText = strings.SORT_BY_ASCENDING;
  _GridHeaderCell.GridHeaderCell.defaultProps.descendingText = strings.SORT_BY_DESCENDING;
  _GridHeaderCell.GridHeaderCell.defaultProps.sorterTitleText = strings.CLICK_TO_SORT;
  _VolumeControl.VolumeControl.defaultProps.muteLabel = strings.MUTE;
  _VolumeControl.VolumeControl.defaultProps.unmuteLabel = strings.UNMUTE;
  _VolumeControl.VolumeControl.defaultProps.volumeSlider = strings.VOLUME_SLIDER;
  _AudioRecorder.RecorderVolumeMeter.defaultProps.startRecordingLabel = strings.START_RECORDING;
  _AudioRecorder.RecorderProcessor.defaultProps.stopRecordingLabel = strings.STOP_RECORDING;
  _Panel.Panel.defaultProps.closeLabel = strings.CLOSE;
  _DateRangePickerControl.DateRangePickerCtrl.defaultProps.ariaLabel = strings.CHOOSE_DATE_RANGE;
  _DateRangePickerControl.DateRangePickerCtrl.defaultProps.setPrevMonthText = strings.SET_PREV_MONTH;
  _DateRangePickerControl.DateRangePickerCtrl.defaultProps.setNextMonthText = strings.SET_NEXT_MONTH;
  _DatePickerControl.DatePickerControl.defaultProps.setPrevMonthText = strings.SET_PREV_MONTH;
  _DatePickerControl.DatePickerControl.defaultProps.setNextMonthText = strings.SET_NEXT_MONTH;
  _DatePickerControl.DatePickerControl.defaultProps.setPrevYearText = strings.SET_PREV_YEAR;
  _DatePickerControl.DatePickerControl.defaultProps.setNextYearText = strings.SET_NEXT_YEAR;
  _DatePickerControl.DatePickerControl.defaultProps.setPrevDecadeText = strings.SET_PREV_DECADE;
  _DatePickerControl.DatePickerControl.defaultProps.setNextDecadeText = strings.SET_NEXT_DECADE;
  _DatePickerControl.DatePickerControl.defaultProps.changeMonthText = strings.CHANGE_MONTH;
  _DatePickerControl.DatePickerControl.defaultProps.changeYearText = strings.CHANGE_YEAR;
  _DatePickerControl.DatePickerControl.defaultProps.setPrevHourText = strings.SET_PREV_HOUR;
  _DatePickerControl.DatePickerControl.defaultProps.setNextHourText = strings.SET_NEXT_HOUR;
  _DatePickerControl.DatePickerControl.defaultProps.setPrevMinuteText = strings.SET_PREV_MINUTE;
  _DatePickerControl.DatePickerControl.defaultProps.setNextMinuteText = strings.SET_NEXT_MINUTE;
  _DatePickerControl.DatePickerControl.defaultProps.toggleAMPMText = strings.TOGGLE_AM_PM;
  _Filter.Filter.defaultProps.ariaLabel = strings.SEARCH;
  _SplitButton.SplitButton.defaultProps.splitToggleLabel = strings.MORE_OPTIONS;
  _Banner.Banner.defaultProps.closeLabel = strings.CLOSE;
  _Popup.Popup.defaultProps.closeLabel = strings.CLOSE;
  _Dropzone.Dropzone.defaultProps.orText = strings.OR;
  _Dropzone.Dropzone.defaultProps.dragText = strings.DRAG_FILES_HERE;
  _TiledGrid.TiledGrid.defaultProps.closeLabel = strings.CLOSE;
  _InputCounterControl.InputCounterControl.defaultProps.decreaseLabel = strings.DECREASE;
  _InputCounterControl.InputCounterControl.defaultProps.increaseLabel = strings.INCREASE;
  _CTADropdown.CTADropdown.defaultProps.toggleMoreLabel = strings.MORE_SETTINGS;
  _ListControlCheckbox.ListControlCheckbox.defaultProps.label = strings.SELECT_ALL;
  _catalog.CatalogListDetails.defaultProps.textDetails = strings.DETAILS;
  _catalog.CatalogListDetails.defaultProps.textPurchase = strings.PURCHASE;
  _catalog.CatalogSimplePrice.defaultProps.textFrom = strings.FROM;
  _catalog.CatalogSimplePrice.defaultProps.textOr = strings.OR;
  _catalog.CatalogSimplePrice.defaultProps.textPerMonth = strings.MONTH;
  _catalog.CatalogSimplePrice.defaultProps.textPerYear = strings.YEAR;
  _catalog.CatalogSimplePrice.defaultProps.textOff = strings.OFF;
  _Search.Search.defaultProps.textNoResults = strings.FASTSEARCH_NO_RESULTS;
  _Search.Search.defaultProps.textSearchPlaceholder = strings.FASTSEARCH_PLACEHOLDER;
  _Search.Search.defaultProps.textShowAllResults = strings.FASTSEARCH_SHOW_ALL;
  _Search.Search.defaultProps.textSearchLabel = strings.SEARCH;
  _Search.Search.defaultProps.textClearLabel = strings.CLEAR;
  _keyboardSortableListItem.keyboardSortableDesc.onFocusDesc = strings.DRAG_ITEM_ON_FOCUS_DESC;
  _keyboardSortableListItem.keyboardSortableDesc.onGrabDescA = strings.DRAG_ITEM_ON_GRAB_DESC_A;
  _keyboardSortableListItem.keyboardSortableDesc.onGrabDescB = strings.DRAG_ITEM_ON_GRAB_DESC_B;
  _keyboardSortableListItem.keyboardSortableDesc.onDragDesc = strings.DRAG_ITEM_ON_DRAG_DESC;
  _keyboardSortableListItem.keyboardSortableDesc.onDropDesc = strings.DRAG_ITEM_ON_DROP_DESC;
  _keyboardSortableListItem.keyboardSortableDesc.onCancelDesc = strings.DRAG_ITEM_ON_CANCEL_DESC;
  _keyboardSortableListItem.keyboardSortableListItemDefaultProps.dragItemName = strings.DRAGGABLE_ITEM;
  _ToolsMenu.ToolsMenu.defaultProps.current = strings.CURRENT;
}

var NeedTranslatedPrefix = 'TRANSLATE:';

function replaceUnTranslatedDefaultProps(Component, langPack) {
  var defaultProps = Component.defaultProps;
  replaceUnTranslatedString(defaultProps, langPack);
}

function replaceUnTranslatedString(obj, langPack) {
  _lodash.default.map(obj, function (value, key) {
    if (value && _lodash.default.isString(value) && value.indexOf(NeedTranslatedPrefix) === 0) {
      var resourceKey = value.replace(NeedTranslatedPrefix, '');

      var translatedString = _lodash.default.get(langPack, resourceKey);

      if (!_lodash.default.isEmpty(translatedString)) {
        obj[key] = translatedString;
      }
    }
  });
}