/*! bxs-vue-ui v3.3.0 */
'use strict';

var indexOf = require('./index-of.js');

var ua = navigator.userAgent;
var env = {
  isAndroid: /Android/i.test(ua),
  isIos: /(iPhone|iPad|iPod)/i.test(ua),
  supportTouch: function isSupportTouch() {
    return !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch);
  }()
};

var isIphoneX = function isIphoneX() {
  return /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 3 && (window.screen.width === 375 && window.screen.height === 812 || window.screen.height === 375 && window.screen.width === 812);
};

var isIphoneXR = function isIphoneXR() {
  return /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 2 && (window.screen.width === 414 && window.screen.height === 896 || window.screen.height === 414 && window.screen.width === 896);
};

var iphoneXSMax = function iphoneXSMax() {
  return /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 3 && (window.screen.width === 414 && window.screen.height === 896 || window.screen.height === 414 && window.screen.width === 896);
};

var isAfterIphoneX = function isAfterIphoneX() {
  return isIphoneX() || isIphoneXR() || iphoneXSMax();
};
function addXSupport() {
  var $viewport = document.querySelector('meta[name=viewport]');

  if (!$viewport || !isAfterIphoneX()) {
    return false;
  }

  var content = $viewport.getAttribute('content');

  if (indexOf._indexOfInstanceProperty(content).call(content, 'viewport-fit') !== -1) {
    return false;
  }

  content += ',viewport-fit=cover';
  $viewport.setAttribute('content', content);
  return true;
}

exports.Env = env;
exports.addXSupport = addXSupport;
exports.isAfterIphoneX = isAfterIphoneX;
