/**
 * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 * 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
 * 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
 */
var ua = window.navigator.userAgent || '';
/**
 * @param versionA
 * @param versionB
 * @returns
 */
export var semverCompare = function semverCompare(versionA, versionB) {
  var splitA = versionA.split('.');
  var splitB = versionB.split('.');
  for (var i = 0; i < 3; i++) {
    var snippetA = Number(splitA[i]);
    var snippetB = Number(splitB[i]);
    if (snippetA > snippetB) return 1;
    if (snippetB > snippetA) return -1;
    // e.g. '1.0.0-rc' -- Number('0-rc') = NaN
    if (!isNaN(snippetA) && isNaN(snippetB)) return 1;
    if (isNaN(snippetA) && !isNaN(snippetB)) return -1;
  }
  return 0;
};
export var getIOSVersion = function getIOSVersion() {
  var version = ua.match(/OS (\d+)_(\d+)_?(\d+)?/);
  return Number.parseInt(version[1], 10);
};
export var isAndroid = /android/i.test(ua);
export var isIOS = /iphone|ipad|ipod/i.test(ua);
export var isOriginalChrome = /chrome\/[\d.]+ mobile safari\/[\d.]+/i.test(ua) && isAndroid && ua.indexOf('Version') < 0;
export var isQQBrowser = /qqbrowser/i.test(ua);
export var isFirefox = /firefox/i.test(ua);
export var isBaidu = /baidubrowser/i.test(ua);
/**
 * @returns boolean
 */
export var haveSchemeToLinkOrFallback = function haveSchemeToLinkOrFallback() {
  return isAndroid || getIOSVersion() < 9;
};