"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.usePlatform = exports.isCloudFileID = exports.isH5Platform = void 0;
// 平台类方法，如 BOM、DOM、区分 h5 和 pc 端
var react_use_1 = require("react-use");
/**
 * 当前环境是否为 H5 端
 */
var isH5Platform = function () {
    var _a;
    if (window.matchMedia) {
        return (_a = window.matchMedia('(max-width: 1024px)')) === null || _a === void 0 ? void 0 : _a.matches;
    }
    else {
        var is = false;
        try {
            var ua = navigator && navigator.userAgent;
            is = /Android|webOS|BlackBerry|iPhone|iPad|iPod|iOS/i.test(ua);
        }
        catch (e) {
            null;
        }
        return is;
    }
};
exports.isH5Platform = isH5Platform;
/**
 * 判断当前是否是 cloud 开头的图片协议
 */
var isCloudFileID = function (url) {
    return /^cloud:\/\/.*/.test(url);
};
exports.isCloudFileID = isCloudFileID;
function usePlatform() {
    var smallScreen = (0, react_use_1.useMedia)('(max-width: 1024px)', (0, exports.isH5Platform)());
    var touchDevice = (0, react_use_1.useMedia)('(pointer:coarse)', smallScreen);
    return (touchDevice || smallScreen) ? 'h5' : 'pc';
}
exports.usePlatform = usePlatform;
//# sourceMappingURL=platform.js.map