'use strict';

function safeDecorator(fn) {
  // eslint-disable-next-line func-names
  return function (...args) {
    try {
      return fn.apply(this, args);
    }
    catch (error) {
      if (error instanceof DOMException &&
        error.message.includes('has already been used with this registry') || error.message.includes('Cannot define multiple custom elements with the same tag name')) {
        return false;
      }
      throw error;
    }
  };
}
customElements.define = safeDecorator(customElements.define);
