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I,MAAM,CAErC;IAED,IAAW,UAAU,IAAI,kBAAkB,CAE1C;IAED,IAAW,uBAAuB,IAAI,uBAAuB,CAE5D;IAED,IAAW,YAAY,IAAI,MAAM,CAEhC;WAEa,6BAA6B,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,oBAAoB,EAAE,CAAA;KAAE,GAAG,4BAA4B,EAAE;WAatG,2BAA2B,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,oBAAoB,EAAE,CAAA;KAAE,GAAG,4BAA4B,EAAE;IAalH,OAAO,CAAC,MAAM,CAAC,wBAAwB;IAavC,OAAO,CAAC,MAAM,CAAC,sBAAsB;CAaxC;AAED;;GAEG;AACH,qBAAa,yCAA0C,SAAQ,uBAAuB;IAElF,OAAO;IAIP;;;;;;;OAOG;WACW,UAAU,CAAC,MAAM,EAAE,4BAA4B,GAAG,yCAAyC;CAU5G","file":"VoiceProfileEnrollmentResult.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/* eslint-disable max-classes-per-file */\r\nimport { CancellationErrorCodePropertyName } from \"../common.speech/Exports.js\";\r\nimport {\r\n    CancellationDetailsBase,\r\n    CancellationErrorCode,\r\n    CancellationReason,\r\n    PropertyCollection,\r\n    ResultReason\r\n} from \"./Exports.js\";\r\n\r\nexport interface EnrollmentResultDetails {\r\n    profileId: string;\r\n    enrollmentsCount: number;\r\n    enrollmentsLength: number;\r\n    enrollmentsSpeechLength: number;\r\n    remainingEnrollmentsCount: number;\r\n    remainingEnrollmentsSpeechLength: number;\r\n    audioLength: number;\r\n    audioSpeechLength: number;\r\n    enrollmentStatus: string;\r\n}\r\n\r\nexport interface EnrollmentResultJSON {\r\n    profileId: string;\r\n    enrollmentsCount: number;\r\n    enrollmentsLength: string;\r\n    enrollmentsSpeechLength: string;\r\n    remainingEnrollmentsCount: number;\r\n    remainingEnrollmentsSpeechLength: string;\r\n    audioLength: string;\r\n    audioSpeechLength: string;\r\n    enrollmentStatus: string;\r\n    remainingEnrollments?: number;\r\n    identificationProfileId?: string;\r\n    verificationProfileId?: string;\r\n}\r\n\r\n/**\r\n * Output format\r\n * @class VoiceProfileEnrollmentResult\r\n */\r\nexport class VoiceProfileEnrollmentResult {\r\n    private privReason: ResultReason;\r\n    private privDetails: EnrollmentResultDetails;\r\n    private privProperties: PropertyCollection;\r\n    private privErrorDetails: string;\r\n\r\n    public constructor(reason: ResultReason, json: string, statusText: string) {\r\n        this.privReason = reason;\r\n        this.privProperties = new PropertyCollection();\r\n        if (this.privReason !== ResultReason.Canceled) {\r\n            if (!!json) {\r\n                this.privDetails = JSON.parse(json) as EnrollmentResultDetails;\r\n                if (this.privDetails.enrollmentStatus.toLowerCase() === \"enrolling\") {\r\n                    this.privReason = ResultReason.EnrollingVoiceProfile;\r\n                }\r\n            }\r\n        } else {\r\n            this.privErrorDetails = statusText;\r\n            this.privProperties.setProperty(CancellationErrorCodePropertyName, CancellationErrorCode[CancellationErrorCode.ServiceError]);\r\n        }\r\n    }\r\n\r\n    public get reason(): ResultReason {\r\n        return this.privReason;\r\n    }\r\n\r\n    public get enrollmentsCount(): number {\r\n        return this.privDetails.enrollmentsCount;\r\n    }\r\n\r\n    public get enrollmentsLength(): number {\r\n        return this.privDetails.enrollmentsLength;\r\n    }\r\n\r\n    public get properties(): PropertyCollection {\r\n        return this.privProperties;\r\n    }\r\n\r\n    public get enrollmentResultDetails(): EnrollmentResultDetails {\r\n        return this.privDetails;\r\n    }\r\n\r\n    public get errorDetails(): string {\r\n        return this.privErrorDetails;\r\n    }\r\n\r\n    public static FromIdentificationProfileList(json: { value: EnrollmentResultJSON[] }): VoiceProfileEnrollmentResult[] {\r\n        const results: VoiceProfileEnrollmentResult[] = [];\r\n        for (const item of json.value) {\r\n            const reason: ResultReason = item.enrollmentStatus.toLowerCase() === \"enrolling\" ?\r\n                ResultReason.EnrollingVoiceProfile : item.enrollmentStatus.toLowerCase() === \"enrolled\" ?\r\n                ResultReason.EnrolledVoiceProfile : ResultReason.Canceled;\r\n            const result = new VoiceProfileEnrollmentResult(reason, null, null);\r\n            result.privDetails = this.getIdentificationDetails(item) as EnrollmentResultDetails;\r\n            results.push(result);\r\n        }\r\n        return results;\r\n    }\r\n\r\n    public static FromVerificationProfileList(json: { value: EnrollmentResultJSON[] }): VoiceProfileEnrollmentResult[] {\r\n        const results: VoiceProfileEnrollmentResult[] = [];\r\n        for (const item of json.value) {\r\n            const reason: ResultReason = item.enrollmentStatus.toLowerCase() === \"enrolling\" ?\r\n                ResultReason.EnrollingVoiceProfile : item.enrollmentStatus.toLowerCase() === \"enrolled\" ?\r\n                ResultReason.EnrolledVoiceProfile : ResultReason.Canceled;\r\n            const result = new VoiceProfileEnrollmentResult(reason, null, null);\r\n            result.privDetails = this.getVerificationDetails(item) as EnrollmentResultDetails;\r\n            results.push(result);\r\n        }\r\n        return results;\r\n    }\r\n\r\n    private static getIdentificationDetails(json: EnrollmentResultJSON): unknown {\r\n        return {\r\n            audioLength: json.audioLength ? parseFloat(json.audioLength) : 0,\r\n            audioSpeechLength: json.audioSpeechLength ? parseFloat(json.audioSpeechLength) : 0,\r\n            enrollmentStatus: json.enrollmentStatus,\r\n            enrollmentsCount: json.enrollmentsCount || 0,\r\n            enrollmentsLength: json.enrollmentsLength ? parseFloat(json.enrollmentsLength) : 0,\r\n            enrollmentsSpeechLength: json.enrollmentsSpeechLength ? parseFloat(json.enrollmentsSpeechLength) : 0,\r\n            profileId: json.profileId || json.identificationProfileId,\r\n            remainingEnrollmentsSpeechLength: json.remainingEnrollmentsSpeechLength ? parseFloat(json.remainingEnrollmentsSpeechLength) : 0\r\n        };\r\n    }\r\n\r\n    private static getVerificationDetails(json: EnrollmentResultJSON): unknown {\r\n        return {\r\n            audioLength: json.audioLength ? parseFloat(json.audioLength) : 0,\r\n            audioSpeechLength: json.audioSpeechLength ? parseFloat(json.audioSpeechLength) : 0,\r\n            enrollmentStatus: json.enrollmentStatus,\r\n            enrollmentsCount: json.enrollmentsCount,\r\n            enrollmentsLength: json.enrollmentsLength ? parseFloat(json.enrollmentsLength) : 0,\r\n            enrollmentsSpeechLength: json.enrollmentsSpeechLength ? parseFloat(json.enrollmentsSpeechLength) : 0,\r\n            profileId: json.profileId || json.verificationProfileId,\r\n            remainingEnrollmentsCount: json.remainingEnrollments || json.remainingEnrollmentsCount,\r\n            remainingEnrollmentsSpeechLength: json.remainingEnrollmentsSpeechLength ? parseFloat(json.remainingEnrollmentsSpeechLength) : 0\r\n        };\r\n    }\r\n}\r\n\r\n/**\r\n * @class VoiceProfileEnrollmentCancellationDetails\r\n */\r\nexport class VoiceProfileEnrollmentCancellationDetails extends CancellationDetailsBase {\r\n\r\n    private constructor(reason: CancellationReason, errorDetails: string, errorCode: CancellationErrorCode) {\r\n        super(reason, errorDetails, errorCode);\r\n    }\r\n\r\n    /**\r\n     * Creates an instance of VoiceProfileEnrollmentCancellationDetails object for the canceled VoiceProfileEnrollmentResult.\r\n     * @member VoiceProfileEnrollmentCancellationDetails.fromResult\r\n     * @function\r\n     * @public\r\n     * @param {VoiceProfileEnrollmentResult} result - The result that was canceled.\r\n     * @returns {VoiceProfileEnrollmentCancellationDetails} The cancellation details object being created.\r\n     */\r\n    public static fromResult(result: VoiceProfileEnrollmentResult): VoiceProfileEnrollmentCancellationDetails {\r\n        const reason = CancellationReason.Error;\r\n        let errorCode: CancellationErrorCode = CancellationErrorCode.NoError;\r\n\r\n        if (!!result.properties) {\r\n            errorCode = (CancellationErrorCode as any)[result.properties.getProperty(CancellationErrorCodePropertyName, CancellationErrorCode[CancellationErrorCode.NoError])]; //eslint-disable-line\r\n        }\r\n\r\n        return new VoiceProfileEnrollmentCancellationDetails(reason, result.errorDetails, errorCode);\r\n    }\r\n}\r\n"]}