text: 'use strict';
  
  var Ids = require('ids');
  
  var SPACE_REGEX = /\s/;
  
  // for QName validation as per http://www.w3.org/TR/REC-xml/#NT-NameChar
  var QNAME_REGEX = /^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i;
  
  // for ID validation as per CMMN Schema (QName - Namespace)
  var ID_REGEX = /^[a-z_][\w-.]*$/i;
  
  var HTML_ESCAPE_MAP = {
    '&': '&amp;',
    '<': '&lt;',
    '>': '&gt;',
    '"': '&quot;',
    '\'': '&#39;'
  };
  
  /**
   * adds an empty option to the list
   */
  function addEmptyParameter(list) {
    return list.push({ 'label': '', 'value': '', 'name': '' });
  }
  
  module.exports.addEmptyParameter = addEmptyParameter;
  
  
  /**
   * checks whether the id value is valid
   *
   * @param {ModdleElement} bo
   * @param {String} idValue
   *
   * @return {String} error message
   */
  function isIdValid(bo, idValue) {
    var assigned = bo.$model.ids.assigned(idValue);
  
    var idExists = assigned && assigned !== bo;
  
    if (!idValue || idExists) {
      return 'Element must have an unique id.';
    }
  
    return validateId(idValue);
  }
  
  module.exports.isIdValid = isIdValid;
  
  
  function validateId(idValue) {
  
    if (containsSpace(idValue)) {
      return 'Id must not contain spaces.';
    }
  
    if (!ID_REGEX.test(idValue)) {
  
      if (QNAME_REGEX.test(idValue)) {
        return 'Id must not contain prefix.';
      }
  
      return 'Id must be a valid QName.';
    }
  }
  
  module.exports.validateId = validateId;
  
  
  function containsSpace(value) {
    return SPACE_REGEX.test(value);
  }
  
  module.exports.containsSpace = containsSpace;
  
  /**
   * generate a semantic id with given prefix
   */
  function nextId(prefix) {
    var ids = new Ids([32,32,1]);
  
    return ids.nextPrefixed(prefix);
  }
  
  module.exports.nextId = nextId;
  
  
  function triggerClickEvent(element) {
    var evt;
    var eventType = 'click';
  
    if (document.createEvent) {
      try {
        // Chrome, Safari, Firefox
        evt = new MouseEvent((eventType), { view: window, bubbles: true, cancelable: true });
      } catch (e) {
        // IE 11, PhantomJS (wat!)
        evt = document.createEvent('MouseEvent');
  
        evt.initEvent((eventType), true, true);
      }
      return element.dispatchEvent(evt);
    } else {
      // Welcome IE
      evt = document.createEventObject();
  
      return element.fireEvent('on' + eventType, evt);
    }
  }
  
  module.exports.triggerClickEvent = triggerClickEvent;
  
  
  function escapeHTML(str) {
    str = '' + str;
  
    return str && str.replace(/[&<>"']/g, function(match) {
      return HTML_ESCAPE_MAP[match];
    });
  }
  
  module.exports.escapeHTML = escapeHTML;
  