const { default: axios } = require("axios");
const cryptoJs = require("crypto-js");
const qs = require("qs");



class BaiduDH {
    constructor() {

    }

    async init(param) {
        this.host = dh_config.baidu.host;

        var dhConf = [];
        var setting = [];

        var dh_style = param['dh']['params']['dh_style'];
        var tts_style = param['dh']['params']['tts_style'];
        param = {
            "appId": dh_config.baidu.appId,
            "appKey": dh_config.baidu.appKey,
            "directLogin": 1,
            "showQueryText": false,
            "showReplyText": false,
            "showWidget": false,
            "showControl": false
        }


        var addr = this.host + "?" + qs.stringify(param);
        var display = '<display><background><type>' + dh_style['background']['bg_kind'] + '</type><source>' + dh_style['background']['bg_source'] + '</source><value>' + dh_style['background']['bg_value'] + '</value></background><resolution><horizontal>' + dh_style['resolution']['width'] + '</horizontal><vertical>' + dh_style['resolution']['height'] + '</vertical></resolution><camera><id>' + dh_style['camera_position'] + '</id></camera></display>';
        var display = display + '<character><hair><style>' + dh_style['hair'] + '</style></hair><clothing><style>' + dh_style['clothing'] + '</style></clothing></character>';
        var result = {
            addr: addr,
            display: display
        };
        return result;

    }
}






//                 $setting['ttsSpeed'] = $tts_style['speed'];
//                 $setting['ttsPitch'] = $tts_style['pitch'];
//                 $setting['ttsVolume'] = $tts_style['volumn'];

//                 $setting['resolutionWidth'] = $dh_style['resolution']['width'];
//                 $setting['resolutionHeight'] = $dh_style['resolution']['height'];

//                 if(empty($setting['resolutionWidth'])){
//                     $setting['resolutionWidth'] = 540;
//                 }

//                 if(empty($setting['resolutionHeight'])){
//                     $setting['resolutionWidth'] = 960;
//                 }

//                 $setting = array_merge($setting, $this->tmpAccount[$supplier]);
exports.BaiduDH = BaiduDH;