export function fireEvent(node, eventName) {
  let doc = {};
  if (node.ownerDocument) {
    doc = node.ownerDocument;
  } else if (node.nodeType === 9) {
    doc = node;
  }
  if (node.dispatchEvent) {
    let eventClass = '';
    switch (eventName) {
      case 'click':
      case 'mousedown':
      case 'mouseup':
        eventClass = 'MouseEvents';
        break;
      case 'focus':
      case 'change':
      case 'blur':
      case 'select':
        eventClass = 'HTMLEvents';
        break;
      default:
        break;
    }
    const event = doc.createEvent(eventClass);
    event.initEvent(eventName, true, true); // All events created as bubbling and cancelable.

    event.synthetic = true; // allow detection of synthetic events
    // The second parameter says go ahead with the default action
    node.dispatchEvent(event, true);
  } else if (node.fireEvent) {
    // IE-old school style
    const event = doc.createEventObject();
    event.synthetic = true; // allow detection of synthetic events
    node.fireEvent('on' + eventName, event);
  }
}

export function executionEnvironment() {
  const canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);

  return {
    canUseDOM,
    canUseWorkers: typeof Worker !== 'undefined',
    canUseEventListeners:
    canUseDOM && !!(window.addEventListener || window.attachEvent),
    canUseViewport: canUseDOM && !!window.screen
  };
}

export function getWindowHeight() {
  if (!executionEnvironment().canUseDOM) {
    return 0;
  }
  const w = window;
  const d = document;
  const e = d.documentElement;
  const g = d.getElementsByTagName('body')[0];
  return w.innerHeight || e.clientHeight || g.clientHeight;
}

export function getWindowWidth() {
  if (!executionEnvironment().canUseDOM) {
    return 0;
  }
  const w = window;
  const d = document;
  const e = d.documentElement;
  const g = d.getElementsByTagName('body')[0];
  return w.innerWidth || e.clientWidth || g.clientWidth;
}

export function getDeviceType() {
  if (!executionEnvironment().canUseDOM) {
    return 0;
  }
  const w = window || null;
  const d = document;
  const e = d.documentElement;
  const g = d.getElementsByTagName('body')[0];
  const witdh = w.innerWidth || e.clientWidth || g.clientWidth;
  if (witdh < 768) {
    return 'mobile';
  }
  if (witdh >= 768 && witdh < 1024) {
    return 'tablet';
  }
  return 'desktop';
}

@@ -2408,12 +2408,1324 @@
 desktop';%0A%7D%0A
+%0A/* eslint-disable */%0A// https://learn.javascript.ru/cookie#%D1%84%D1%83%D0%BD%D0%BA%D1%86%D0%B8%D1%8F-getcookie-name%0Afunction getCookie(name) %7B%0A  if (!executionEnvironment().canUseDOM) return;%0A%0A  var matches = document.cookie.match(new RegExp(%0A    %22(?:%5E%7C; )%22 + name.replace(/(%5B%5C.$?*%7C%7B%7D%5C(%5C)%5C%5B%5C%5D%5C%5C%5C/%5C+%5E%5D)/g, '%5C%5C$1') + %22=(%5B%5E;%5D*)%22%0A  ));%0A  return matches ? decodeURIComponent(matches%5B1%5D) : undefined;%0A%7D%0A%0A// https://learn.javascript.ru/cookie#%D1%84%D1%83%D0%BD%D0%BA%D1%86%D0%B8%D1%8F-setcookie-name-value-options%0Afunction setCookie(name, value, options) %7B%0A  if (!executionEnvironment().canUseDOM) return;%0A%0A  options = options %7C%7C %7B%7D;%0A%0A  var expires = options.expires;%0A%0A  if (typeof expires == %22number%22 && expires) %7B%0A    var d = new Date();%0A    d.setTime(d.getTime() + expires * 1000);%0A    expires = options.expires = d;%0A  %7D%0A  if (expires && expires.toUTCString) %7B%0A    options.expires = expires.toUTCString();%0A  %7D%0A%0A  value = encodeURIComponent(value);%0A%0A  var updatedCookie = name + %22=%22 + value;%0A%0A  for (var propName in options) %7B%0A    updatedCookie += %22; %22 + propName;%0A    var propValue = options%5BpropName%5D;%0A    if (propValue !== true) %7B%0A      updatedCookie += %22=%22 + propValue;%0A    %7D%0A  %7D%0A%0A  document.cookie = updatedCookie;%0A%7D%0A%0A// https://learn.javascript.ru/cookie#%D1%84%D1%83%D0%BD%D0%BA%D1%86%D0%B8%D1%8F-deletecookie-name%0Afunction deleteCookie(name) %7B%0A  setCookie(name, %22%22, %7B%0A    expires: -1%0A  %7D)%0A%7D%0A/* eslint-enable */%0A

add cookie helpers