"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getENV=exports.getUA=exports.ENV_ENUM_SUB=exports.APP_TYPE=exports.ENV_ENUM=void 0;var sdk_1=require("./sdk"),sdk_2=require("./sdk");Object.defineProperty(exports,"ENV_ENUM",{enumerable:!0,get:function(){return sdk_2.ENV_ENUM}}),Object.defineProperty(exports,"APP_TYPE",{enumerable:!0,get:function(){return sdk_2.APP_TYPE}}),Object.defineProperty(exports,"ENV_ENUM_SUB",{enumerable:!0,get:function(){return sdk_2.ENV_ENUM_SUB}});var dingtalk_javascript_env_1=require("./packages/dingtalk-javascript-env"),EDdWeexEnv;!function(e){e.singlePage="singlePage",e.miniApp="miniApp",e.miniWidget="miniWidget"}(EDdWeexEnv||(EDdWeexEnv={}));var getUA=function(){var e="";try{"undefined"!=typeof navigator&&(e=navigator&&(navigator.userAgent||navigator.swuserAgent)||"")}catch(t){e=""}return e};exports.getUA=getUA;var getENV=function(){var e=exports.getUA(),t=/iPhone|iPad|iPod|iOS/i.test(e),i=/Android/i.test(e),n=/Nebula/i.test(e),a=/DingTalk/i.test(e),r=/dd-web/i.test(e),d="object"==typeof nuva,s="object"==typeof dd&&"function"==typeof dd.dtBridge,_=s&&t||d&&t,E=a||dingtalk_javascript_env_1.default.isDingTalk,o=t&&E||dingtalk_javascript_env_1.default.isWeexiOS||_,g=i&&E||dingtalk_javascript_env_1.default.isWeexAndroid,p=n&&E||s,v=r,P=sdk_1.APP_TYPE.WEB;if(v)P=sdk_1.APP_TYPE.WEBVIEW_IN_MINIAPP;else if(p)P=sdk_1.APP_TYPE.MINI_APP;else if(dingtalk_javascript_env_1.default.isWeexiOS||dingtalk_javascript_env_1.default.isWeexAndroid)try{var l=weex.config.ddWeexEnv;P=l===EDdWeexEnv.miniWidget?sdk_1.APP_TYPE.WEEX_WIDGET:sdk_1.APP_TYPE.WEEX}catch(e){P=sdk_1.APP_TYPE.WEEX}var u,c="*",N=e.match(/AliApp\(\w+\/([a-zA-Z0-9.-]+)\)/);null===N&&(N=e.match(/DingTalk\/([a-zA-Z0-9.-]+)/));var f;N&&N[1]&&(f=N[1]);var k="";if("undefined"!=typeof name&&(k=name),k)try{var A=JSON.parse(k);A.hostVersion&&(f=A.hostVersion),c=A.language||navigator.language||"*",u=A.containerId}catch(e){}var U=!!u;U&&!f&&(N=e.match(/DingTalk\(([a-zA-Z0-9\.-]+)\)/))&&N[1]&&(f=N[1]);var x,V=sdk_1.ENV_ENUM_SUB.noSub;if(o)x=sdk_1.ENV_ENUM.ios;else if(g)x=sdk_1.ENV_ENUM.android;else if(U){var W=e.indexOf("Macintosh; Intel Mac OS")>-1;V=W?sdk_1.ENV_ENUM_SUB.mac:sdk_1.ENV_ENUM_SUB.win,x=sdk_1.ENV_ENUM.pc}else x=sdk_1.ENV_ENUM.notInDingTalk;return{platform:x,platformSub:V,version:f,appType:P,language:c}};exports.getENV=getENV;