(function (wp, wc) {
  const { registerPaymentMethod } = wc.wcBlocksRegistry;
  const { getPaymentMethodData } = wc.wcSettings;
  const { decodeEntities } = wp.htmlEntities;
  const { createElement: el } = wp.element;
  const { __ } = wp.i18n;

  const settings = getPaymentMethodData('uplatnica', {});

  const label = decodeEntities(settings.title || '') || __('Opšta uplatnica', 'wooplatnica');

  const Content = () => {
    const description = decodeEntities(settings.description || '');

    return description
      ? el('div', { className: 'wc-wooplatnica-description' }, description)
      : null;
  };

  const Label = () => {
    return el('span', { className: 'wc-wooplatnica-label' }, label);
  };

  registerPaymentMethod({
    name: 'uplatnica',
    label: el(Label),
    content: el(Content),
    edit: el(Content),
    canMakePayment: () => true,
    ariaLabel: label,
    supports: {
      features: settings.supports || [],
    },
  });
})(window.wp, window.wc);
