// 平台类方法，如 BOM、DOM、区分 h5 和 pc 端
import { useMedia } from 'react-use';
/**
 * 当前环境是否为 H5 端
 */
export 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;
    }
};
/**
 * 判断当前是否是 cloud 开头的图片协议
 */
export var isCloudFileID = function (url) {
    return /^cloud:\/\/.*/.test(url);
};
export function usePlatform() {
    var smallScreen = useMedia('(max-width: 1024px)', isH5Platform());
    var touchDevice = useMedia('(pointer:coarse)', smallScreen);
    return (touchDevice || smallScreen) ? 'h5' : 'pc';
}
//# sourceMappingURL=platform.js.map