text: /**
   * Build styles
   */
  require('./index.css').toString();
  
  /**
   * Inline Code Tool for the Editor.js
   *
   * Allows to wrap inline fragment and style it somehow.
   */
  class InlineCode {
    /**
     * Class name for term-tag
     *
     * @type {string}
     */
    static get CSS() {
      return 'inline-code';
    };
  
    /**
     */
    constructor({api}) {
      this.api = api;
  
      /**
       * Toolbar Button
       *
       * @type {HTMLElement|null}
       */
      this.button = null;
  
      /**
       * Tag represented the term
       *
       * @type {string}
       */
      this.tag = 'CODE';
  
      /**
       * CSS classes
       */
      this.iconClasses = {
        base: this.api.styles.inlineToolButton,
        active: this.api.styles.inlineToolButtonActive
      };
    }
  
    /**
     * Specifies Tool as Inline Toolbar Tool
     *
     * @return {boolean}
     */
    static get isInline() {
      return true;
    }
  
    /**
     * Create button element for Toolbar
     *
     * @return {HTMLElement}
     */
    render() {
      this.button = document.createElement('button');
      this.button.type = 'button';
      this.button.classList.add(this.iconClasses.base);
      this.button.innerHTML = this.toolboxIcon;
  
      return this.button;
    }
  
    /**
     * Wrap/Unwrap selected fragment
     *
     * @param {Range} range - selected fragment
     */
    surround(range) {
      if (!range) {
        return;
      }
  
      let termWrapper = this.api.selection.findParentTag(this.tag, InlineCode.CSS);
  
      /**
       * If start or end of selection is in the highlighted block
       */
      if (termWrapper) {
        this.unwrap(termWrapper);
      } else {
        this.wrap(range);
      }
    }
  
    /**
     * Wrap selection with term-tag
     *
     * @param {Range} range - selected fragment
     */
    wrap(range) {
      /**
       * Create a wrapper for highlighting
       */
      let span = document.createElement(this.tag);
  
      span.classList.add(InlineCode.CSS);
  
      /**
       * SurroundContent throws an error if the Range splits a non-Text node with only one of its boundary points
       * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Range/surroundContents}
       *
       * // range.surroundContents(span);
       */
      span.appendChild(range.extractContents());
      range.insertNode(span);
  
      /**
       * Expand (add) selection to highlighted block
       */
      this.api.selection.expandToTag(span);
    }
  
    /**
     * Unwrap term-tag
     *
     * @param {HTMLElement} termWrapper - term wrapper tag
     */
    unwrap(termWrapper) {
      /**
       * Expand selection to all term-tag
       */
      this.api.selection.expandToTag(termWrapper);
  
      let sel = window.getSelection();
      let range = sel.getRangeAt(0);
  
      let unwrappedContent = range.extractContents();
  
      /**
       * Remove empty term-tag
       */
      termWrapper.parentNode.removeChild(termWrapper);
  
      /**
       * Insert extracted content
       */
      range.insertNode(unwrappedContent);
  
      /**
       * Restore selection
       */
      sel.removeAllRanges();
      sel.addRange(range);
    }
  
    /**
     * Check and change Term's state for current selection
     */
    checkState(selection, hasMath) {
      const termTag = this.api.selection.findParentTag(this.tag, InlineCode.CSS);
      
      this.button.classList.toggle(this.iconClasses.active, !!termTag);
      this.button.disabled = hasMath;
    }
  
    /**
     * Get Tool icon's SVG
     * @return {string}
     */
    get toolboxIcon() {
      return '<svg width="19" height="13" viewBox="0 0 19 13" xmlns="http://www.w3.org/2000/svg"><path d="M17.839 5.525a1.105 1.105 0 0 1-.015 1.547l-4.943 4.943a1.105 1.105 0 1 1-1.562-1.562l4.137-4.137-4.078-4.078A1.125 1.125 0 1 1 12.97.648l4.796 4.796c.026.026.05.053.074.08zm-14.952.791l4.137 4.137a1.105 1.105 0 1 1-1.562 1.562L.519 7.072a1.105 1.105 0 0 1-.015-1.547c.023-.028.048-.055.074-.081L5.374.647a1.125 1.125 0 0 1 1.591 1.591L2.887 6.316z" id="a"/></svg>';
    }
  
    /**
     * Sanitizer rule
     * @return {{span: {class: string}}}
     */
    static get sanitize() {
      return {
        code: {
          class: InlineCode.CSS
        }
      };
    }
  }
  
  module.exports = InlineCode;
  