{"version":3,"sources":["src/common.speech/IntentConnectionFactory.ts"],"names":[],"mappings":"AAOA,OAAO,EACH,WAAW,EAEd,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EACH,qBAAqB,EACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACH,QAAQ,EACR,gBAAgB,EAEnB,MAAM,WAAW,CAAC;AAGnB,qBAAa,uBAAwB,SAAQ,qBAAqB;IAEvD,MAAM,WACD,gBAAgB,YACd,QAAQ,iBACH,MAAM,KAAG,WAAW,CA2BtC;IAED,OAAO,CAAC,+BAA+B;CAsD1C","file":"IntentConnectionFactory.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n    ProxyInfo,\r\n    WebsocketConnection,\r\n} from \"../common.browser/Exports\";\r\nimport {\r\n    IConnection,\r\n    IStringDictionary\r\n} from \"../common/Exports\";\r\nimport {\r\n    PropertyId\r\n} from \"../sdk/Exports\";\r\nimport {\r\n    ConnectionFactoryBase\r\n} from \"./ConnectionFactoryBase\";\r\nimport {\r\n    AuthInfo,\r\n    RecognizerConfig,\r\n    WebsocketMessageFormatter,\r\n} from \"./Exports\";\r\nimport { HeaderNames } from \"./HeaderNames\";\r\n\r\nexport class IntentConnectionFactory extends ConnectionFactoryBase {\r\n\r\n    public create = (\r\n        config: RecognizerConfig,\r\n        authInfo: AuthInfo,\r\n        connectionId?: string): IConnection => {\r\n\r\n        let endpoint: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint);\r\n        if (!endpoint) {\r\n            const region: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_IntentRegion);\r\n            const hostSuffix: string = ConnectionFactoryBase.getHostSuffix(region);\r\n            const host: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Host, \"wss://\" + region + \".sr.speech\" + hostSuffix);\r\n            endpoint = host + \"/speech/recognition/interactive/cognitiveservices/v1\";\r\n        }\r\n\r\n        const queryParams: IStringDictionary<string> = {\r\n            format: \"simple\",\r\n            language: config.parameters.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage),\r\n        };\r\n\r\n        this.setCommonUrlParams(config, queryParams, endpoint);\r\n\r\n        const headers: IStringDictionary<string> = {};\r\n        if (authInfo.token !== undefined && authInfo.token !== \"\") {\r\n            headers[authInfo.headerName] = authInfo.token;\r\n        }\r\n        headers[HeaderNames.ConnectionId] = connectionId;\r\n\r\n        config.parameters.setProperty(PropertyId.SpeechServiceConnection_Url, endpoint);\r\n\r\n        const enableCompression: boolean = config.parameters.getProperty(\"SPEECH-EnableWebsocketCompression\", \"false\") === \"true\";\r\n        return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, connectionId);\r\n    }\r\n\r\n    private getSpeechRegionFromIntentRegion(intentRegion: string): string {\r\n        switch (intentRegion) {\r\n            case \"West US\":\r\n            case \"US West\":\r\n            case \"westus\":\r\n                return \"uswest\";\r\n            case \"West US 2\":\r\n            case \"US West 2\":\r\n            case \"westus2\":\r\n                return \"uswest2\";\r\n            case \"South Central US\":\r\n            case \"US South Central\":\r\n            case \"southcentralus\":\r\n                return \"ussouthcentral\";\r\n            case \"West Central US\":\r\n            case \"US West Central\":\r\n            case \"westcentralus\":\r\n                return \"uswestcentral\";\r\n            case \"East US\":\r\n            case \"US East\":\r\n            case \"eastus\":\r\n                return \"useast\";\r\n            case \"East US 2\":\r\n            case \"US East 2\":\r\n            case \"eastus2\":\r\n                return \"useast2\";\r\n            case \"West Europe\":\r\n            case \"Europe West\":\r\n            case \"westeurope\":\r\n                return \"europewest\";\r\n            case \"North Europe\":\r\n            case \"Europe North\":\r\n            case \"northeurope\":\r\n                return \"europenorth\";\r\n            case \"Brazil South\":\r\n            case \"South Brazil\":\r\n            case \"southbrazil\":\r\n                return \"brazilsouth\";\r\n            case \"Australia East\":\r\n            case \"East Australia\":\r\n            case \"eastaustralia\":\r\n                return \"australiaeast\";\r\n            case \"Southeast Asia\":\r\n            case \"Asia Southeast\":\r\n            case \"southeastasia\":\r\n                return \"asiasoutheast\";\r\n            case \"East Asia\":\r\n            case \"Asia East\":\r\n            case \"eastasia\":\r\n                return \"asiaeast\";\r\n            default:\r\n                return intentRegion;\r\n        }\r\n    }\r\n}\r\n"]}