{"version":3,"sources":["src/common.speech/ConnectionFactoryBase.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAgB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAmB,gBAAgB,EAA6B,MAAM,WAAW,CAAC;AAGvH,8BAAsB,qBAAsB,YAAW,kBAAkB;WAEvD,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;aAYnC,MAAM,CAClB,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,QAAQ,EAClB,YAAY,CAAC,EAAE,MAAM,GAAG,WAAW;IAEvC,SAAS,CAAC,kBAAkB,CACxB,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,iBAAiB,CAAC,MAAM,CAAC,EACtC,QAAQ,EAAE,MAAM,GAAG,IAAI;IA6C3B,SAAS,CAAC,eAAe,CACrB,MAAM,EAAE,UAAU,EAClB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,iBAAiB,CAAC,MAAM,CAAC,EACtC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAS9B","file":"ConnectionFactoryBase.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n    ServicePropertiesPropertyName,\r\n} from \"../common.speech/Exports\";\r\nimport { IConnection, IStringDictionary } from \"../common/Exports\";\r\nimport { OutputFormat, PropertyId } from \"../sdk/Exports\";\r\nimport { AuthInfo, IConnectionFactory, RecognitionMode, RecognizerConfig, WebsocketMessageFormatter } from \"./Exports\";\r\nimport { QueryParameterNames } from \"./QueryParameterNames\";\r\n\r\nexport abstract class ConnectionFactoryBase implements IConnectionFactory {\r\n\r\n    public static getHostSuffix(region: string): string {\r\n        if (!!region) {\r\n            if (region.toLowerCase().startsWith(\"china\")) {\r\n                return \".azure.cn\";\r\n            }\r\n            if (region.toLowerCase().startsWith(\"usgov\")) {\r\n                return \".azure.us\";\r\n            }\r\n        }\r\n        return \".microsoft.com\";\r\n    }\r\n\r\n    public abstract create(\r\n        config: RecognizerConfig,\r\n        authInfo: AuthInfo,\r\n        connectionId?: string): IConnection;\r\n\r\n    protected setCommonUrlParams(\r\n        config: RecognizerConfig,\r\n        queryParams: IStringDictionary<string>,\r\n        endpoint: string): void {\r\n\r\n        this.setUrlParameter(PropertyId.SpeechServiceConnection_EnableAudioLogging,\r\n            QueryParameterNames.EnableAudioLogging,\r\n            config,\r\n            queryParams,\r\n            endpoint);\r\n\r\n        this.setUrlParameter(PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,\r\n            QueryParameterNames.EnableWordLevelTimestamps,\r\n            config,\r\n            queryParams,\r\n            endpoint);\r\n\r\n        this.setUrlParameter(PropertyId.SpeechServiceResponse_ProfanityOption,\r\n            QueryParameterNames.Profanity,\r\n            config,\r\n            queryParams,\r\n            endpoint);\r\n\r\n        this.setUrlParameter(PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,\r\n            QueryParameterNames.InitialSilenceTimeoutMs,\r\n            config,\r\n            queryParams,\r\n            endpoint);\r\n\r\n        this.setUrlParameter(PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs,\r\n            QueryParameterNames.EndSilenceTimeoutMs,\r\n            config,\r\n            queryParams,\r\n            endpoint);\r\n\r\n        this.setUrlParameter(PropertyId.SpeechServiceResponse_StablePartialResultThreshold,\r\n            QueryParameterNames.StableIntermediateThreshold,\r\n            config,\r\n            queryParams,\r\n            endpoint);\r\n\r\n        const serviceProperties: IStringDictionary<string> = JSON.parse(config.parameters.getProperty(ServicePropertiesPropertyName, \"{}\"));\r\n\r\n        Object.keys(serviceProperties).forEach((value: string, num: number, array: string[]) => {\r\n            queryParams[value] = serviceProperties[value];\r\n        });\r\n    }\r\n\r\n    protected setUrlParameter(\r\n        propId: PropertyId,\r\n        parameterName: string,\r\n        config: RecognizerConfig,\r\n        queryParams: IStringDictionary<string>,\r\n        endpoint: string): void {\r\n\r\n        const value: string = config.parameters.getProperty(propId, undefined);\r\n\r\n        if (value && (!endpoint || endpoint.search(parameterName) === -1)) {\r\n            queryParams[parameterName] = value.toLocaleLowerCase();\r\n        }\r\n    }\r\n\r\n}\r\n"]}