"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getMiniSdkVideoRecreateConfig=exports.getMiniSdkVideoConfig=exports.getMiniSdkLiveConfig=exports.getMiniSdkConfigNumber=exports.getMiniSdkConfigBoolean=exports.getMiniSdkBackgroundPlaybackConfig=void 0;var _utils=require("../../utils/utils"),_constants=require("./constants"),getMiniSdkConfig=function(e,i,t){var n,a=null==e||null===(n=e.get)||void 0===n?void 0:n.call(e,"miniSdkConfig"),r=(0,_utils.isPlainObject)(a)?(0,_utils.deepGet)(a,i):void 0,o=(0,_utils.deepGet)(_constants.DEFAULT_MINI_SDK_CONFIG,i);return"function"==typeof t?t(r,o):void 0===r?o:r},getMiniSdkConfigNumber=function(e,i){return getMiniSdkConfig(e,i,function(e,i){return(0,_utils.toSafeInt)(e,i)})};exports.getMiniSdkConfigNumber=getMiniSdkConfigNumber;var getMiniSdkConfigBoolean=function(e,i){return getMiniSdkConfig(e,i,function(e,i){return!0===e||!1===e?e:1===e||0!==e&&!!i})};exports.getMiniSdkConfigBoolean=getMiniSdkConfigBoolean;var getMiniSdkLiveConfig=function(e){var i="player.live",t=function(t){return getMiniSdkConfigNumber(e,"".concat(i,".").concat(t))},n=function(t){return getMiniSdkConfigBoolean(e,"".concat(i,".").concat(t))},a=getMiniSdkConfig(e,"".concat(i,".engine.mode")),r="video"===a||"live-player"===a?a:"auto",o=getMiniSdkConfig(e,"".concat(i,".engine.forceUseVideoDevices")),c=Array.isArray(o)?o:[];return{buffer:{minCache:t("buffer.minCache"),maxCache:t("buffer.maxCache")},stability:{firstFrameTimeoutMs:t("stability.firstFrameTimeoutMs"),successCode:t("stability.successCode"),loadingTimeoutMs:t("stability.loadingTimeoutMs"),stallWindowMs:t("stability.stall.windowMs"),stallThreshold:t("stability.stall.threshold"),videoWaitingThreshold:t("stability.videoWaitingThreshold"),perfDebounceMs:t("stability.perfDebounceMs")},strategy:{enableQualityDowngrade:n("strategy.enableQualityDowngrade"),enableStreamSwitch:n("strategy.enableStreamSwitch"),enableStreamSwitchOnPerfIssue:n("strategy.enableStreamSwitchOnPerfIssue"),streamSwitchRoundMax:t("strategy.streamSwitchRoundMax"),reduceQualityOnWeakNetAtStart:n("strategy.reduceQualityOnWeakNetAtStart"),reduceQualityOnLowPerformanceDeviceAtStart:n("strategy.reduceQualityOnLowPerformanceDeviceAtStart")},engine:{mode:r,forceUseVideoDevices:c}}};exports.getMiniSdkLiveConfig=getMiniSdkLiveConfig;var getMiniSdkVideoConfig=function(e){var i="player.video",t=function(t){return getMiniSdkConfigBoolean(e,"".concat(i,".").concat(t))};return{stability:{firstFrameTimeoutMs:getMiniSdkConfigNumber(e,"".concat(i,".").concat("stability.firstFrameTimeoutMs"))},strategy:{enableStreamSwitch:t("strategy.enableStreamSwitch"),reduceQualityOnWeakNetAtStart:t("strategy.reduceQualityOnWeakNetAtStart"),reduceQualityOnLowPerformanceDeviceAtStart:t("strategy.reduceQualityOnLowPerformanceDeviceAtStart")}}};exports.getMiniSdkVideoConfig=getMiniSdkVideoConfig;var getMiniSdkVideoRecreateConfig=function(e){var i="player.videoRecreate",t=getMiniSdkConfig(e,"".concat(i,".appShowRecreateDevices")),n=getMiniSdkConfig(e,"".concat(i,".pageShowRecreateDevices")),a=getMiniSdkConfig(e,"".concat(i,".videoErrorCallbackRecreateDevices"));return{backgroundThresholdMs:getMiniSdkConfigNumber(e,"".concat(i,".backgroundThresholdMs")),unexpectedPauseRecreate:getMiniSdkConfigBoolean(e,"".concat(i,".unexpectedPauseRecreate")),appShowRecreateDevices:Array.isArray(t)?t:[],pageShowRecreateDevices:Array.isArray(n)?n:[],videoErrorCallbackRecreateDevices:Array.isArray(a)?a:[]}};exports.getMiniSdkVideoRecreateConfig=getMiniSdkVideoRecreateConfig;var getMiniSdkBackgroundPlaybackConfig=function(e){var i="player.backgroundPlayback",t=getMiniSdkConfig(e,"".concat(i,".enabledDevices")),n=getMiniSdkConfig(e,"".concat(i,".disabledDevices"));return{enabledDevices:Array.isArray(t)?t:[],disabledDevices:Array.isArray(n)?n:[]}};exports.getMiniSdkBackgroundPlaybackConfig=getMiniSdkBackgroundPlaybackConfig;