"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.defaultLocalization = exports.LocalizationProvider = exports.LocalizationContext = void 0;

var _clientUtils = require("@sensenet/client-utils");

var _react = _interopRequireWildcard(require("react"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

const defaultLocalization = {
  common: {
    cancel: 'Cancel'
  },
  menubar: {
    typography: 'Heading',
    bold: 'Bold',
    italic: 'Italic',
    underline: 'Underline',
    blockquote: 'Block quote',
    code: 'Code',
    alignLeft: 'Align left',
    alignCenter: 'Align center',
    alignRight: 'Align right',
    alignJustify: 'Justify',
    bulletList: 'Bullet list',
    orderedList: 'Ordered list',
    link: 'Link',
    table: 'Insert table',
    clearFormat: 'Clear format',
    undo: 'Undo',
    redo: 'Redo'
  },
  bubbleMenu: {
    removeImage: 'remove image',
    removeLink: 'remove link'
  },
  contextMenu: {
    deleteTable: 'Delete table',
    deleteRow: 'Delete row',
    deleteCol: 'Delete column',
    addRowAbove: 'Add row above',
    addRowBelow: 'Add row below',
    addColBefore: 'Add column before',
    addColAfter: 'Add column after',
    toggleHeaderRow: 'Toggle header row',
    toggleHeaderCol: 'Toggle header column',
    mergeCells: 'Merge cells',
    splitCell: 'Split cell'
  },
  imageControl: {
    title: 'Insert image',
    submit: 'Insert'
  },
  linkControl: {
    title: 'Insert a link',
    url: 'Url',
    openInNewTab: 'Open link in a new tab',
    submit: 'Insert'
  },
  tableControl: {
    title: 'Insert table',
    rows: 'Rows',
    cols: 'Cols',
    hasHeader: 'Has header',
    submit: 'Insert'
  },
  typographyControl: {
    paragraph: 'Paragraph',
    heading: 'Heading'
  }
};
exports.defaultLocalization = defaultLocalization;
const LocalizationContext = /*#__PURE__*/(0, _react.createContext)(defaultLocalization);
exports.LocalizationContext = LocalizationContext;

const LocalizationProvider = props => {
  const [currentValue, setCurrentValue] = (0, _react.useState)((0, _clientUtils.deepMerge)(defaultLocalization, props.localization));
  (0, _react.useEffect)(() => {
    setCurrentValue((0, _clientUtils.deepMerge)(defaultLocalization, props.localization));
  }, [props.localization]);
  return /*#__PURE__*/_react.default.createElement(LocalizationContext.Provider, {
    value: currentValue
  }, props.children);
};

exports.LocalizationProvider = LocalizationProvider;
//# sourceMappingURL=localization-context.js.map