"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getENV=exports.getUA=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"),apiHelper_1=require("./apiHelper"),getTopBridge=function(){try{if("undefined"!=typeof window&&void 0!==window.top){return window.top.__dingtalk_jsapi_top_platfrom_config__}}catch(e){return}},EDdWeexEnv;!function(e){e.singlePage="singlePage",e.miniApp="miniApp",e.miniWidget="miniWidget"}(EDdWeexEnv||(EDdWeexEnv={})),exports.getUA=function(){var e="";try{"undefined"!=typeof navigator&&(e=navigator&&(navigator.userAgent||navigator.swuserAgent)||"")}catch(t){e=""}return e},exports.getENV=function(){var e,t,i=exports.getUA(),n=/iPhone|iPad|iPod|iOS/i.test(i),d=/Android/i.test(i),a=/OpenHarmony/i.test(i)&&/ArkWeb/i.test(i),r=/DingTalk/i.test(i),_=/dd-web/i.test(i),o="object"==typeof nuva,s="object"==typeof dd&&"function"==typeof dd.dtBridge,E=/TaurusApp/.test(i),p=E&&!r,g=E&&r,l=p&&"undefined"!=typeof my&&null!==my&&void 0!==my.alert,v=E&&/dingtalk-win/.test(i),u=!v&&p&&n,f=!v&&p&&d,k=!v&&g&&n,c=!v&&g&&d,N=s&&n||o&&n,P=r||dingtalk_javascript_env_1.default.isDingTalk,A=n&&P||dingtalk_javascript_env_1.default.isWeexiOS||N,w=d&&P||dingtalk_javascript_env_1.default.isWeexAndroid,U=s,m=_,M=a&&P,y=sdk_1.APP_TYPE.WEB;if(l)y=sdk_1.APP_TYPE.MINI_APP;else if(m)y=sdk_1.APP_TYPE.WEBVIEW_IN_MINIAPP;else if(U)y=sdk_1.APP_TYPE.MINI_APP;else if(dingtalk_javascript_env_1.default.isWeexiOS||dingtalk_javascript_env_1.default.isWeexAndroid)try{var V=weex.config.ddWeexEnv;y=V===EDdWeexEnv.miniWidget?sdk_1.APP_TYPE.WEEX_WIDGET:sdk_1.APP_TYPE.WEEX}catch(e){y=sdk_1.APP_TYPE.WEEX}var x,W="*",S=i.match(/AliApp\(\w+\/([a-zA-Z0-9.-]+)\)/);null===S&&(S=i.match(/DingTalk\/([a-zA-Z0-9.-]+)/));var T;S&&S[1]&&(T=S[1]);var I="";"undefined"!=typeof name&&(I=name);var b=getTopBridge();try{b&&"undefined"!=typeof window&&void 0!==window.top&&window.top!==window&&(I=top.name)}catch(e){}if(I)try{var j=JSON.parse(I);j.hostVersion&&(T=j.hostVersion),W=j.language||navigator.language||"*",x=j.containerId}catch(e){}var h=!!x||"undefined"!=typeof window&&(null===(t=null===(e=null===window||void 0===window?void 0:window.dingtalk)||void 0===e?void 0:e.platform)||void 0===t?void 0:t.invokeAPI);h&&!T&&(S=i.match(/DingTalk\(([a-zA-Z0-9\.-]+)\)/))&&S[1]&&(T=S[1]);var D,B=sdk_1.ENV_ENUM_SUB.noSub;if(v?(D=sdk_1.ENV_ENUM.gdtPc,B=sdk_1.ENV_ENUM_SUB.win):D=u?sdk_1.ENV_ENUM.gdtIos:f?sdk_1.ENV_ENUM.gdtAndroid:k?sdk_1.ENV_ENUM.gdtStandardIos:c?sdk_1.ENV_ENUM.gdtStandardAndroid:A?sdk_1.ENV_ENUM.ios:w&&!M?sdk_1.ENV_ENUM.android:M?sdk_1.ENV_ENUM.harmony:h?sdk_1.ENV_ENUM.pc:b&&b.platform?b.platform:sdk_1.ENV_ENUM.notInDingTalk,D===sdk_1.ENV_ENUM.pc){B=i.indexOf("Macintosh; Intel Mac OS")>-1?sdk_1.ENV_ENUM_SUB.mac:sdk_1.ENV_ENUM_SUB.win}var O=apiHelper_1.getGlobalSelf();return O.__ddSDK&&O.__ddSDK.getEnv?O.__ddSDK.getEnv():{platform:D,platformSub:B,version:T,appType:y,language:W}};