import { HttpRequest as __HttpRequest , HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http" ; import { expectInt32 as __expectInt32 , expectString as __expectString , LazyJsonString as __LazyJsonString , limitedParseFloat32 as __limitedParseFloat32 , } from "@aws-sdk/smithy-client" ; import { Endpoint as __Endpoint , HeaderBag as __HeaderBag , MetadataBearer as __MetadataBearer , ResponseMetadata as __ResponseMetadata , SerdeContext as __SerdeContext , SmithyException as __SmithyException , } from "@aws-sdk/types" ; import { AnalyzeDocumentCommandInput , AnalyzeDocumentCommandOutput } from "../commands/AnalyzeDocumentCommand" ; import { AnalyzeExpenseCommandInput , AnalyzeExpenseCommandOutput } from "../commands/AnalyzeExpenseCommand" ; import { AnalyzeIDCommandInput , AnalyzeIDCommandOutput } from "../commands/AnalyzeIDCommand" ; import { DetectDocumentTextCommandInput , DetectDocumentTextCommandOutput } from "../commands/DetectDocumentTextCommand" ; import { GetDocumentAnalysisCommandInput , GetDocumentAnalysisCommandOutput , } from "../commands/GetDocumentAnalysisCommand" ; import { GetDocumentTextDetectionCommandInput , GetDocumentTextDetectionCommandOutput , } from "../commands/GetDocumentTextDetectionCommand" ; import { GetExpenseAnalysisCommandInput , GetExpenseAnalysisCommandOutput } from "../commands/GetExpenseAnalysisCommand" ; import { StartDocumentAnalysisCommandInput , StartDocumentAnalysisCommandOutput , } from "../commands/StartDocumentAnalysisCommand" ; import { StartDocumentTextDetectionCommandInput , StartDocumentTextDetectionCommandOutput , } from "../commands/StartDocumentTextDetectionCommand" ; import { StartExpenseAnalysisCommandInput , StartExpenseAnalysisCommandOutput , } from "../commands/StartExpenseAnalysisCommand" ; import { AccessDeniedException , AnalyzeDocumentRequest , AnalyzeDocumentResponse , AnalyzeExpenseRequest , AnalyzeExpenseResponse , AnalyzeIDDetections , AnalyzeIDRequest , AnalyzeIDResponse , BadDocumentException , Block , BoundingBox , ContentClassifier , DetectDocumentTextRequest , DetectDocumentTextResponse , Document , DocumentLocation , DocumentMetadata , DocumentTooLargeException , EntityType , ExpenseDetection , ExpenseDocument , ExpenseField , ExpenseType , FeatureType , Geometry , GetDocumentAnalysisRequest , GetDocumentAnalysisResponse , GetDocumentTextDetectionRequest , GetDocumentTextDetectionResponse , GetExpenseAnalysisRequest , GetExpenseAnalysisResponse , HumanLoopActivationOutput , HumanLoopConfig , HumanLoopDataAttributes , HumanLoopQuotaExceededException , IdempotentParameterMismatchException , IdentityDocument , IdentityDocumentField , InternalServerError , InvalidJobIdException , InvalidKMSKeyException , InvalidParameterException , InvalidS3ObjectException , LimitExceededException , LineItemFields , LineItemGroup , NormalizedValue , NotificationChannel , OutputConfig , Point , ProvisionedThroughputExceededException , Relationship , S3Object , StartDocumentAnalysisRequest , StartDocumentAnalysisResponse , StartDocumentTextDetectionRequest , StartDocumentTextDetectionResponse , StartExpenseAnalysisRequest , StartExpenseAnalysisResponse , ThrottlingException , UnsupportedDocumentException , Warning , } from "../models/models_0" ; export const serializeAws_json1_1AnalyzeDocumentCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Textract.AnalyzeDocument" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1AnalyzeDocumentRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1AnalyzeExpenseCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Textract.AnalyzeExpense" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1AnalyzeExpenseRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1AnalyzeIDCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Textract.AnalyzeID" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1AnalyzeIDRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DetectDocumentTextCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Textract.DetectDocumentText" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DetectDocumentTextRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1GetDocumentAnalysisCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Textract.GetDocumentAnalysis" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1GetDocumentAnalysisRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1GetDocumentTextDetectionCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Textract.GetDocumentTextDetection" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1GetDocumentTextDetectionRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1GetExpenseAnalysisCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Textract.GetExpenseAnalysis" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1GetExpenseAnalysisRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1StartDocumentAnalysisCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Textract.StartDocumentAnalysis" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1StartDocumentAnalysisRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1StartDocumentTextDetectionCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Textract.StartDocumentTextDetection" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1StartDocumentTextDetectionRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1StartExpenseAnalysisCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Textract.StartExpenseAnalysis" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1StartExpenseAnalysisRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const deserializeAws_json1_1AnalyzeDocumentCommand = async ( output , context ) : Promise < AnalyzeDocumentCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1AnalyzeDocumentCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1AnalyzeDocumentResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1AnalyzeDocumentCommandError = async ( output , context ) : Promise < AnalyzeDocumentCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.textract#AccessDeniedException" : response = { ... ( await deserializeAws_json1_1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "BadDocumentException" : case "com.amazonaws.textract#BadDocumentException" : response = { ... ( await deserializeAws_json1_1BadDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DocumentTooLargeException" : case "com.amazonaws.textract#DocumentTooLargeException" : response = { ... ( await deserializeAws_json1_1DocumentTooLargeExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "HumanLoopQuotaExceededException" : case "com.amazonaws.textract#HumanLoopQuotaExceededException" : response = { ... ( await deserializeAws_json1_1HumanLoopQuotaExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerError" : case "com.amazonaws.textract#InternalServerError" : response = { ... ( await deserializeAws_json1_1InternalServerErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.textract#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidS3ObjectException" : case "com.amazonaws.textract#InvalidS3ObjectException" : response = { ... ( await deserializeAws_json1_1InvalidS3ObjectExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ProvisionedThroughputExceededException" : case "com.amazonaws.textract#ProvisionedThroughputExceededException" : response = { ... ( await deserializeAws_json1_1ProvisionedThroughputExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.textract#ThrottlingException" : response = { ... ( await deserializeAws_json1_1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnsupportedDocumentException" : case "com.amazonaws.textract#UnsupportedDocumentException" : response = { ... ( await deserializeAws_json1_1UnsupportedDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1AnalyzeExpenseCommand = async ( output , context ) : Promise < AnalyzeExpenseCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1AnalyzeExpenseCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1AnalyzeExpenseResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1AnalyzeExpenseCommandError = async ( output , context ) : Promise < AnalyzeExpenseCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.textract#AccessDeniedException" : response = { ... ( await deserializeAws_json1_1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "BadDocumentException" : case "com.amazonaws.textract#BadDocumentException" : response = { ... ( await deserializeAws_json1_1BadDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DocumentTooLargeException" : case "com.amazonaws.textract#DocumentTooLargeException" : response = { ... ( await deserializeAws_json1_1DocumentTooLargeExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerError" : case "com.amazonaws.textract#InternalServerError" : response = { ... ( await deserializeAws_json1_1InternalServerErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.textract#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidS3ObjectException" : case "com.amazonaws.textract#InvalidS3ObjectException" : response = { ... ( await deserializeAws_json1_1InvalidS3ObjectExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ProvisionedThroughputExceededException" : case "com.amazonaws.textract#ProvisionedThroughputExceededException" : response = { ... ( await deserializeAws_json1_1ProvisionedThroughputExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.textract#ThrottlingException" : response = { ... ( await deserializeAws_json1_1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnsupportedDocumentException" : case "com.amazonaws.textract#UnsupportedDocumentException" : response = { ... ( await deserializeAws_json1_1UnsupportedDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1AnalyzeIDCommand = async ( output , context ) : Promise < AnalyzeIDCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1AnalyzeIDCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1AnalyzeIDResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1AnalyzeIDCommandError = async ( output , context ) : Promise < AnalyzeIDCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.textract#AccessDeniedException" : response = { ... ( await deserializeAws_json1_1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "BadDocumentException" : case "com.amazonaws.textract#BadDocumentException" : response = { ... ( await deserializeAws_json1_1BadDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DocumentTooLargeException" : case "com.amazonaws.textract#DocumentTooLargeException" : response = { ... ( await deserializeAws_json1_1DocumentTooLargeExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerError" : case "com.amazonaws.textract#InternalServerError" : response = { ... ( await deserializeAws_json1_1InternalServerErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.textract#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidS3ObjectException" : case "com.amazonaws.textract#InvalidS3ObjectException" : response = { ... ( await deserializeAws_json1_1InvalidS3ObjectExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ProvisionedThroughputExceededException" : case "com.amazonaws.textract#ProvisionedThroughputExceededException" : response = { ... ( await deserializeAws_json1_1ProvisionedThroughputExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.textract#ThrottlingException" : response = { ... ( await deserializeAws_json1_1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnsupportedDocumentException" : case "com.amazonaws.textract#UnsupportedDocumentException" : response = { ... ( await deserializeAws_json1_1UnsupportedDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1DetectDocumentTextCommand = async ( output , context ) : Promise < DetectDocumentTextCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DetectDocumentTextCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DetectDocumentTextResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DetectDocumentTextCommandError = async ( output , context ) : Promise < DetectDocumentTextCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.textract#AccessDeniedException" : response = { ... ( await deserializeAws_json1_1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "BadDocumentException" : case "com.amazonaws.textract#BadDocumentException" : response = { ... ( await deserializeAws_json1_1BadDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DocumentTooLargeException" : case "com.amazonaws.textract#DocumentTooLargeException" : response = { ... ( await deserializeAws_json1_1DocumentTooLargeExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerError" : case "com.amazonaws.textract#InternalServerError" : response = { ... ( await deserializeAws_json1_1InternalServerErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.textract#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidS3ObjectException" : case "com.amazonaws.textract#InvalidS3ObjectException" : response = { ... ( await deserializeAws_json1_1InvalidS3ObjectExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ProvisionedThroughputExceededException" : case "com.amazonaws.textract#ProvisionedThroughputExceededException" : response = { ... ( await deserializeAws_json1_1ProvisionedThroughputExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.textract#ThrottlingException" : response = { ... ( await deserializeAws_json1_1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnsupportedDocumentException" : case "com.amazonaws.textract#UnsupportedDocumentException" : response = { ... ( await deserializeAws_json1_1UnsupportedDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1GetDocumentAnalysisCommand = async ( output , context ) : Promise < GetDocumentAnalysisCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1GetDocumentAnalysisCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1GetDocumentAnalysisResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1GetDocumentAnalysisCommandError = async ( output , context ) : Promise < GetDocumentAnalysisCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.textract#AccessDeniedException" : response = { ... ( await deserializeAws_json1_1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerError" : case "com.amazonaws.textract#InternalServerError" : response = { ... ( await deserializeAws_json1_1InternalServerErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidJobIdException" : case "com.amazonaws.textract#InvalidJobIdException" : response = { ... ( await deserializeAws_json1_1InvalidJobIdExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidKMSKeyException" : case "com.amazonaws.textract#InvalidKMSKeyException" : response = { ... ( await deserializeAws_json1_1InvalidKMSKeyExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.textract#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidS3ObjectException" : case "com.amazonaws.textract#InvalidS3ObjectException" : response = { ... ( await deserializeAws_json1_1InvalidS3ObjectExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ProvisionedThroughputExceededException" : case "com.amazonaws.textract#ProvisionedThroughputExceededException" : response = { ... ( await deserializeAws_json1_1ProvisionedThroughputExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.textract#ThrottlingException" : response = { ... ( await deserializeAws_json1_1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1GetDocumentTextDetectionCommand = async ( output , context ) : Promise < GetDocumentTextDetectionCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1GetDocumentTextDetectionCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1GetDocumentTextDetectionResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1GetDocumentTextDetectionCommandError = async ( output , context ) : Promise < GetDocumentTextDetectionCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.textract#AccessDeniedException" : response = { ... ( await deserializeAws_json1_1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerError" : case "com.amazonaws.textract#InternalServerError" : response = { ... ( await deserializeAws_json1_1InternalServerErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidJobIdException" : case "com.amazonaws.textract#InvalidJobIdException" : response = { ... ( await deserializeAws_json1_1InvalidJobIdExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidKMSKeyException" : case "com.amazonaws.textract#InvalidKMSKeyException" : response = { ... ( await deserializeAws_json1_1InvalidKMSKeyExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.textract#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidS3ObjectException" : case "com.amazonaws.textract#InvalidS3ObjectException" : response = { ... ( await deserializeAws_json1_1InvalidS3ObjectExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ProvisionedThroughputExceededException" : case "com.amazonaws.textract#ProvisionedThroughputExceededException" : response = { ... ( await deserializeAws_json1_1ProvisionedThroughputExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.textract#ThrottlingException" : response = { ... ( await deserializeAws_json1_1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1GetExpenseAnalysisCommand = async ( output , context ) : Promise < GetExpenseAnalysisCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1GetExpenseAnalysisCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1GetExpenseAnalysisResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1GetExpenseAnalysisCommandError = async ( output , context ) : Promise < GetExpenseAnalysisCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.textract#AccessDeniedException" : response = { ... ( await deserializeAws_json1_1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerError" : case "com.amazonaws.textract#InternalServerError" : response = { ... ( await deserializeAws_json1_1InternalServerErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidJobIdException" : case "com.amazonaws.textract#InvalidJobIdException" : response = { ... ( await deserializeAws_json1_1InvalidJobIdExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidKMSKeyException" : case "com.amazonaws.textract#InvalidKMSKeyException" : response = { ... ( await deserializeAws_json1_1InvalidKMSKeyExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.textract#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidS3ObjectException" : case "com.amazonaws.textract#InvalidS3ObjectException" : response = { ... ( await deserializeAws_json1_1InvalidS3ObjectExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ProvisionedThroughputExceededException" : case "com.amazonaws.textract#ProvisionedThroughputExceededException" : response = { ... ( await deserializeAws_json1_1ProvisionedThroughputExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.textract#ThrottlingException" : response = { ... ( await deserializeAws_json1_1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1StartDocumentAnalysisCommand = async ( output , context ) : Promise < StartDocumentAnalysisCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1StartDocumentAnalysisCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1StartDocumentAnalysisResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1StartDocumentAnalysisCommandError = async ( output , context ) : Promise < StartDocumentAnalysisCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.textract#AccessDeniedException" : response = { ... ( await deserializeAws_json1_1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "BadDocumentException" : case "com.amazonaws.textract#BadDocumentException" : response = { ... ( await deserializeAws_json1_1BadDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DocumentTooLargeException" : case "com.amazonaws.textract#DocumentTooLargeException" : response = { ... ( await deserializeAws_json1_1DocumentTooLargeExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "IdempotentParameterMismatchException" : case "com.amazonaws.textract#IdempotentParameterMismatchException" : response = { ... ( await deserializeAws_json1_1IdempotentParameterMismatchExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerError" : case "com.amazonaws.textract#InternalServerError" : response = { ... ( await deserializeAws_json1_1InternalServerErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidKMSKeyException" : case "com.amazonaws.textract#InvalidKMSKeyException" : response = { ... ( await deserializeAws_json1_1InvalidKMSKeyExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.textract#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidS3ObjectException" : case "com.amazonaws.textract#InvalidS3ObjectException" : response = { ... ( await deserializeAws_json1_1InvalidS3ObjectExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "LimitExceededException" : case "com.amazonaws.textract#LimitExceededException" : response = { ... ( await deserializeAws_json1_1LimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ProvisionedThroughputExceededException" : case "com.amazonaws.textract#ProvisionedThroughputExceededException" : response = { ... ( await deserializeAws_json1_1ProvisionedThroughputExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.textract#ThrottlingException" : response = { ... ( await deserializeAws_json1_1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnsupportedDocumentException" : case "com.amazonaws.textract#UnsupportedDocumentException" : response = { ... ( await deserializeAws_json1_1UnsupportedDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1StartDocumentTextDetectionCommand = async ( output , context ) : Promise < StartDocumentTextDetectionCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1StartDocumentTextDetectionCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1StartDocumentTextDetectionResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1StartDocumentTextDetectionCommandError = async ( output , context ) : Promise < StartDocumentTextDetectionCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.textract#AccessDeniedException" : response = { ... ( await deserializeAws_json1_1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "BadDocumentException" : case "com.amazonaws.textract#BadDocumentException" : response = { ... ( await deserializeAws_json1_1BadDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DocumentTooLargeException" : case "com.amazonaws.textract#DocumentTooLargeException" : response = { ... ( await deserializeAws_json1_1DocumentTooLargeExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "IdempotentParameterMismatchException" : case "com.amazonaws.textract#IdempotentParameterMismatchException" : response = { ... ( await deserializeAws_json1_1IdempotentParameterMismatchExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerError" : case "com.amazonaws.textract#InternalServerError" : response = { ... ( await deserializeAws_json1_1InternalServerErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidKMSKeyException" : case "com.amazonaws.textract#InvalidKMSKeyException" : response = { ... ( await deserializeAws_json1_1InvalidKMSKeyExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.textract#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidS3ObjectException" : case "com.amazonaws.textract#InvalidS3ObjectException" : response = { ... ( await deserializeAws_json1_1InvalidS3ObjectExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "LimitExceededException" : case "com.amazonaws.textract#LimitExceededException" : response = { ... ( await deserializeAws_json1_1LimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ProvisionedThroughputExceededException" : case "com.amazonaws.textract#ProvisionedThroughputExceededException" : response = { ... ( await deserializeAws_json1_1ProvisionedThroughputExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.textract#ThrottlingException" : response = { ... ( await deserializeAws_json1_1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnsupportedDocumentException" : case "com.amazonaws.textract#UnsupportedDocumentException" : response = { ... ( await deserializeAws_json1_1UnsupportedDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1StartExpenseAnalysisCommand = async ( output , context ) : Promise < StartExpenseAnalysisCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1StartExpenseAnalysisCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1StartExpenseAnalysisResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1StartExpenseAnalysisCommandError = async ( output , context ) : Promise < StartExpenseAnalysisCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.textract#AccessDeniedException" : response = { ... ( await deserializeAws_json1_1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "BadDocumentException" : case "com.amazonaws.textract#BadDocumentException" : response = { ... ( await deserializeAws_json1_1BadDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DocumentTooLargeException" : case "com.amazonaws.textract#DocumentTooLargeException" : response = { ... ( await deserializeAws_json1_1DocumentTooLargeExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "IdempotentParameterMismatchException" : case "com.amazonaws.textract#IdempotentParameterMismatchException" : response = { ... ( await deserializeAws_json1_1IdempotentParameterMismatchExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerError" : case "com.amazonaws.textract#InternalServerError" : response = { ... ( await deserializeAws_json1_1InternalServerErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidKMSKeyException" : case "com.amazonaws.textract#InvalidKMSKeyException" : response = { ... ( await deserializeAws_json1_1InvalidKMSKeyExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.textract#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidS3ObjectException" : case "com.amazonaws.textract#InvalidS3ObjectException" : response = { ... ( await deserializeAws_json1_1InvalidS3ObjectExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "LimitExceededException" : case "com.amazonaws.textract#LimitExceededException" : response = { ... ( await deserializeAws_json1_1LimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ProvisionedThroughputExceededException" : case "com.amazonaws.textract#ProvisionedThroughputExceededException" : response = { ... ( await deserializeAws_json1_1ProvisionedThroughputExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.textract#ThrottlingException" : response = { ... ( await deserializeAws_json1_1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnsupportedDocumentException" : case "com.amazonaws.textract#UnsupportedDocumentException" : response = { ... ( await deserializeAws_json1_1UnsupportedDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; const deserializeAws_json1_1AccessDeniedExceptionResponse = async ( parsedOutput , context ) : Promise < AccessDeniedException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1AccessDeniedException ( body , context ) ; const contents = { name : "AccessDeniedException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1BadDocumentExceptionResponse = async ( parsedOutput , context ) : Promise < BadDocumentException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1BadDocumentException ( body , context ) ; const contents = { name : "BadDocumentException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1DocumentTooLargeExceptionResponse = async ( parsedOutput , context ) : Promise < DocumentTooLargeException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1DocumentTooLargeException ( body , context ) ; const contents = { name : "DocumentTooLargeException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1HumanLoopQuotaExceededExceptionResponse = async ( parsedOutput , context ) : Promise < HumanLoopQuotaExceededException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1HumanLoopQuotaExceededException ( body , context ) ; const contents = { name : "HumanLoopQuotaExceededException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1IdempotentParameterMismatchExceptionResponse = async ( parsedOutput , context ) : Promise < IdempotentParameterMismatchException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1IdempotentParameterMismatchException ( body , context ) ; const contents = { name : "IdempotentParameterMismatchException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1InternalServerErrorResponse = async ( parsedOutput , context ) : Promise < InternalServerError > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1InternalServerError ( body , context ) ; const contents = { name : "InternalServerError" , $fault : "server" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1InvalidJobIdExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidJobIdException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1InvalidJobIdException ( body , context ) ; const contents = { name : "InvalidJobIdException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1InvalidKMSKeyExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidKMSKeyException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1InvalidKMSKeyException ( body , context ) ; const contents = { name : "InvalidKMSKeyException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1InvalidParameterExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidParameterException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1InvalidParameterException ( body , context ) ; const contents = { name : "InvalidParameterException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1InvalidS3ObjectExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidS3ObjectException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1InvalidS3ObjectException ( body , context ) ; const contents = { name : "InvalidS3ObjectException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1LimitExceededExceptionResponse = async ( parsedOutput , context ) : Promise < LimitExceededException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1LimitExceededException ( body , context ) ; const contents = { name : "LimitExceededException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1ProvisionedThroughputExceededExceptionResponse = async ( parsedOutput , context ) : Promise < ProvisionedThroughputExceededException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1ProvisionedThroughputExceededException ( body , context ) ; const contents = { name : "ProvisionedThroughputExceededException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1ThrottlingExceptionResponse = async ( parsedOutput , context ) : Promise < ThrottlingException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1ThrottlingException ( body , context ) ; const contents = { name : "ThrottlingException" , $fault : "server" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1UnsupportedDocumentExceptionResponse = async ( parsedOutput , context ) : Promise < UnsupportedDocumentException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1UnsupportedDocumentException ( body , context ) ; const contents = { name : "UnsupportedDocumentException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const serializeAws_json1_1AnalyzeDocumentRequest = ( input , context ) : any => { return { ... ( input . Document !== undefined && input . Document !== null && { Document : serializeAws_json1_1Document ( input . Document , context ) } ) , ... ( input . FeatureTypes !== undefined && input . FeatureTypes !== null && { FeatureTypes : serializeAws_json1_1FeatureTypes ( input . FeatureTypes , context ) } ) , ... ( input . HumanLoopConfig !== undefined && input . HumanLoopConfig !== null && { HumanLoopConfig : serializeAws_json1_1HumanLoopConfig ( input . HumanLoopConfig , context ) , } ) , } ; } ; const serializeAws_json1_1AnalyzeExpenseRequest = ( input , context ) : any => { return { ... ( input . Document !== undefined && input . Document !== null && { Document : serializeAws_json1_1Document ( input . Document , context ) } ) , } ; } ; const serializeAws_json1_1AnalyzeIDRequest = ( input , context ) : any => { return { ... ( input . DocumentPages !== undefined && input . DocumentPages !== null && { DocumentPages : serializeAws_json1_1DocumentPages ( input . DocumentPages , context ) , } ) , } ; } ; const serializeAws_json1_1ContentClassifiers = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_json1_1DetectDocumentTextRequest = ( input , context ) : any => { return { ... ( input . Document !== undefined && input . Document !== null && { Document : serializeAws_json1_1Document ( input . Document , context ) } ) , } ; } ; const serializeAws_json1_1Document = ( input , context ) : any => { return { ... ( input . Bytes !== undefined && input . Bytes !== null && { Bytes : context . base64Encoder ( input . Bytes ) } ) , ... ( input . S3Object !== undefined && input . S3Object !== null && { S3Object : serializeAws_json1_1S3Object ( input . S3Object , context ) } ) , } ; } ; const serializeAws_json1_1DocumentLocation = ( input , context ) : any => { return { ... ( input . S3Object !== undefined && input . S3Object !== null && { S3Object : serializeAws_json1_1S3Object ( input . S3Object , context ) } ) , } ; } ; const serializeAws_json1_1DocumentPages = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_json1_1Document ( entry , context ) ; } ) ; } ; const serializeAws_json1_1FeatureTypes = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_json1_1GetDocumentAnalysisRequest = ( input , context ) : any => { return { ... ( input . JobId !== undefined && input . JobId !== null && { JobId : input . JobId } ) , ... ( input . MaxResults !== undefined && input . MaxResults !== null && { MaxResults : input . MaxResults } ) , ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , } ; } ; const serializeAws_json1_1GetDocumentTextDetectionRequest = ( input , context ) : any => { return { ... ( input . JobId !== undefined && input . JobId !== null && { JobId : input . JobId } ) , ... ( input . MaxResults !== undefined && input . MaxResults !== null && { MaxResults : input . MaxResults } ) , ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , } ; } ; const serializeAws_json1_1GetExpenseAnalysisRequest = ( input , context ) : any => { return { ... ( input . JobId !== undefined && input . JobId !== null && { JobId : input . JobId } ) , ... ( input . MaxResults !== undefined && input . MaxResults !== null && { MaxResults : input . MaxResults } ) , ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , } ; } ; const serializeAws_json1_1HumanLoopConfig = ( input , context ) : any => { return { ... ( input . DataAttributes !== undefined && input . DataAttributes !== null && { DataAttributes : serializeAws_json1_1HumanLoopDataAttributes ( input . DataAttributes , context ) , } ) , ... ( input . FlowDefinitionArn !== undefined && input . FlowDefinitionArn !== null && { FlowDefinitionArn : input . FlowDefinitionArn } ) , ... ( input . HumanLoopName !== undefined && input . HumanLoopName !== null && { HumanLoopName : input . HumanLoopName } ) , } ; } ; const serializeAws_json1_1HumanLoopDataAttributes = ( input , context ) : any => { return { ... ( input . ContentClassifiers !== undefined && input . ContentClassifiers !== null && { ContentClassifiers : serializeAws_json1_1ContentClassifiers ( input . ContentClassifiers , context ) , } ) , } ; } ; const serializeAws_json1_1NotificationChannel = ( input , context ) : any => { return { ... ( input . RoleArn !== undefined && input . RoleArn !== null && { RoleArn : input . RoleArn } ) , ... ( input . SNSTopicArn !== undefined && input . SNSTopicArn !== null && { SNSTopicArn : input . SNSTopicArn } ) , } ; } ; const serializeAws_json1_1OutputConfig = ( input , context ) : any => { return { ... ( input . S3Bucket !== undefined && input . S3Bucket !== null && { S3Bucket : input . S3Bucket } ) , ... ( input . S3Prefix !== undefined && input . S3Prefix !== null && { S3Prefix : input . S3Prefix } ) , } ; } ; const serializeAws_json1_1S3Object = ( input , context ) : any => { return { ... ( input . Bucket !== undefined && input . Bucket !== null && { Bucket : input . Bucket } ) , ... ( input . Name !== undefined && input . Name !== null && { Name : input . Name } ) , ... ( input . Version !== undefined && input . Version !== null && { Version : input . Version } ) , } ; } ; const serializeAws_json1_1StartDocumentAnalysisRequest = ( input , context ) : any => { return { ... ( input . ClientRequestToken !== undefined && input . ClientRequestToken !== null && { ClientRequestToken : input . ClientRequestToken } ) , ... ( input . DocumentLocation !== undefined && input . DocumentLocation !== null && { DocumentLocation : serializeAws_json1_1DocumentLocation ( input . DocumentLocation , context ) , } ) , ... ( input . FeatureTypes !== undefined && input . FeatureTypes !== null && { FeatureTypes : serializeAws_json1_1FeatureTypes ( input . FeatureTypes , context ) } ) , ... ( input . JobTag !== undefined && input . JobTag !== null && { JobTag : input . JobTag } ) , ... ( input . KMSKeyId !== undefined && input . KMSKeyId !== null && { KMSKeyId : input . KMSKeyId } ) , ... ( input . NotificationChannel !== undefined && input . NotificationChannel !== null && { NotificationChannel : serializeAws_json1_1NotificationChannel ( input . NotificationChannel , context ) , } ) , ... ( input . OutputConfig !== undefined && input . OutputConfig !== null && { OutputConfig : serializeAws_json1_1OutputConfig ( input . OutputConfig , context ) } ) , } ; } ; const serializeAws_json1_1StartDocumentTextDetectionRequest = ( input , context ) : any => { return { ... ( input . ClientRequestToken !== undefined && input . ClientRequestToken !== null && { ClientRequestToken : input . ClientRequestToken } ) , ... ( input . DocumentLocation !== undefined && input . DocumentLocation !== null && { DocumentLocation : serializeAws_json1_1DocumentLocation ( input . DocumentLocation , context ) , } ) , ... ( input . JobTag !== undefined && input . JobTag !== null && { JobTag : input . JobTag } ) , ... ( input . KMSKeyId !== undefined && input . KMSKeyId !== null && { KMSKeyId : input . KMSKeyId } ) , ... ( input . NotificationChannel !== undefined && input . NotificationChannel !== null && { NotificationChannel : serializeAws_json1_1NotificationChannel ( input . NotificationChannel , context ) , } ) , ... ( input . OutputConfig !== undefined && input . OutputConfig !== null && { OutputConfig : serializeAws_json1_1OutputConfig ( input . OutputConfig , context ) } ) , } ; } ; const serializeAws_json1_1StartExpenseAnalysisRequest = ( input , context ) : any => { return { ... ( input . ClientRequestToken !== undefined && input . ClientRequestToken !== null && { ClientRequestToken : input . ClientRequestToken } ) , ... ( input . DocumentLocation !== undefined && input . DocumentLocation !== null && { DocumentLocation : serializeAws_json1_1DocumentLocation ( input . DocumentLocation , context ) , } ) , ... ( input . JobTag !== undefined && input . JobTag !== null && { JobTag : input . JobTag } ) , ... ( input . KMSKeyId !== undefined && input . KMSKeyId !== null && { KMSKeyId : input . KMSKeyId } ) , ... ( input . NotificationChannel !== undefined && input . NotificationChannel !== null && { NotificationChannel : serializeAws_json1_1NotificationChannel ( input . NotificationChannel , context ) , } ) , ... ( input . OutputConfig !== undefined && input . OutputConfig !== null && { OutputConfig : serializeAws_json1_1OutputConfig ( input . OutputConfig , context ) } ) , } ; } ; const deserializeAws_json1_1AccessDeniedException = ( output , context ) : AccessDeniedException => { return { Code : __expectString ( output . Code ) , Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1AnalyzeDocumentResponse = ( output , context ) : AnalyzeDocumentResponse => { return { AnalyzeDocumentModelVersion : __expectString ( output . AnalyzeDocumentModelVersion ) , Blocks : output . Blocks !== undefined && output . Blocks !== null ? deserializeAws_json1_1BlockList ( output . Blocks , context ) : undefined , DocumentMetadata : output . DocumentMetadata !== undefined && output . DocumentMetadata !== null ? deserializeAws_json1_1DocumentMetadata ( output . DocumentMetadata , context ) : undefined , HumanLoopActivationOutput : output . HumanLoopActivationOutput !== undefined && output . HumanLoopActivationOutput !== null ? deserializeAws_json1_1HumanLoopActivationOutput ( output . HumanLoopActivationOutput , context ) : undefined , } as any ; } ; const deserializeAws_json1_1AnalyzeExpenseResponse = ( output , context ) : AnalyzeExpenseResponse => { return { DocumentMetadata : output . DocumentMetadata !== undefined && output . DocumentMetadata !== null ? deserializeAws_json1_1DocumentMetadata ( output . DocumentMetadata , context ) : undefined , ExpenseDocuments : output . ExpenseDocuments !== undefined && output . ExpenseDocuments !== null ? deserializeAws_json1_1ExpenseDocumentList ( output . ExpenseDocuments , context ) : undefined , } as any ; } ; const deserializeAws_json1_1AnalyzeIDDetections = ( output , context ) : AnalyzeIDDetections => { return { Confidence : __limitedParseFloat32 ( output . Confidence ) , NormalizedValue : output . NormalizedValue !== undefined && output . NormalizedValue !== null ? deserializeAws_json1_1NormalizedValue ( output . NormalizedValue , context ) : undefined , Text : __expectString ( output . Text ) , } as any ; } ; const deserializeAws_json1_1AnalyzeIDResponse = ( output , context ) : AnalyzeIDResponse => { return { AnalyzeIDModelVersion : __expectString ( output . AnalyzeIDModelVersion ) , DocumentMetadata : output . DocumentMetadata !== undefined && output . DocumentMetadata !== null ? deserializeAws_json1_1DocumentMetadata ( output . DocumentMetadata , context ) : undefined , IdentityDocuments : output . IdentityDocuments !== undefined && output . IdentityDocuments !== null ? deserializeAws_json1_1IdentityDocumentList ( output . IdentityDocuments , context ) : undefined , } as any ; } ; const deserializeAws_json1_1BadDocumentException = ( output , context ) : BadDocumentException => { return { Code : __expectString ( output . Code ) , Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1Block = ( output , context ) : Block => { return { BlockType : __expectString ( output . BlockType ) , ColumnIndex : __expectInt32 ( output . ColumnIndex ) , ColumnSpan : __expectInt32 ( output . ColumnSpan ) , Confidence : __limitedParseFloat32 ( output . Confidence ) , EntityTypes : output . EntityTypes !== undefined && output . EntityTypes !== null ? deserializeAws_json1_1EntityTypes ( output . EntityTypes , context ) : undefined , Geometry : output . Geometry !== undefined && output . Geometry !== null ? deserializeAws_json1_1Geometry ( output . Geometry , context ) : undefined , Id : __expectString ( output . Id ) , Page : __expectInt32 ( output . Page ) , Relationships : output . Relationships !== undefined && output . Relationships !== null ? deserializeAws_json1_1RelationshipList ( output . Relationships , context ) : undefined , RowIndex : __expectInt32 ( output . RowIndex ) , RowSpan : __expectInt32 ( output . RowSpan ) , SelectionStatus : __expectString ( output . SelectionStatus ) , Text : __expectString ( output . Text ) , TextType : __expectString ( output . TextType ) , } as any ; } ; const deserializeAws_json1_1BlockList = ( output , context ) : Block [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1Block ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1BoundingBox = ( output , context ) : BoundingBox => { return { Height : __limitedParseFloat32 ( output . Height ) , Left : __limitedParseFloat32 ( output . Left ) , Top : __limitedParseFloat32 ( output . Top ) , Width : __limitedParseFloat32 ( output . Width ) , } as any ; } ; const deserializeAws_json1_1DetectDocumentTextResponse = ( output , context ) : DetectDocumentTextResponse => { return { Blocks : output . Blocks !== undefined && output . Blocks !== null ? deserializeAws_json1_1BlockList ( output . Blocks , context ) : undefined , DetectDocumentTextModelVersion : __expectString ( output . DetectDocumentTextModelVersion ) , DocumentMetadata : output . DocumentMetadata !== undefined && output . DocumentMetadata !== null ? deserializeAws_json1_1DocumentMetadata ( output . DocumentMetadata , context ) : undefined , } as any ; } ; const deserializeAws_json1_1DocumentMetadata = ( output , context ) : DocumentMetadata => { return { Pages : __expectInt32 ( output . Pages ) , } as any ; } ; const deserializeAws_json1_1DocumentTooLargeException = ( output , context ) : DocumentTooLargeException => { return { Code : __expectString ( output . Code ) , Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1EntityTypes = ( output , context ) : ( EntityType | string ) [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectString ( entry ) as any ; } ) ; } ; const deserializeAws_json1_1ExpenseDetection = ( output , context ) : ExpenseDetection => { return { Confidence : __limitedParseFloat32 ( output . Confidence ) , Geometry : output . Geometry !== undefined && output . Geometry !== null ? deserializeAws_json1_1Geometry ( output . Geometry , context ) : undefined , Text : __expectString ( output . Text ) , } as any ; } ; const deserializeAws_json1_1ExpenseDocument = ( output , context ) : ExpenseDocument => { return { ExpenseIndex : __expectInt32 ( output . ExpenseIndex ) , LineItemGroups : output . LineItemGroups !== undefined && output . LineItemGroups !== null ? deserializeAws_json1_1LineItemGroupList ( output . LineItemGroups , context ) : undefined , SummaryFields : output . SummaryFields !== undefined && output . SummaryFields !== null ? deserializeAws_json1_1ExpenseFieldList ( output . SummaryFields , context ) : undefined , } as any ; } ; const deserializeAws_json1_1ExpenseDocumentList = ( output , context ) : ExpenseDocument [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1ExpenseDocument ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1ExpenseField = ( output , context ) : ExpenseField => { return { LabelDetection : output . LabelDetection !== undefined && output . LabelDetection !== null ? deserializeAws_json1_1ExpenseDetection ( output . LabelDetection , context ) : undefined , PageNumber : __expectInt32 ( output . PageNumber ) , Type : output . Type !== undefined && output . Type !== null ? deserializeAws_json1_1ExpenseType ( output . Type , context ) : undefined , ValueDetection : output . ValueDetection !== undefined && output . ValueDetection !== null ? deserializeAws_json1_1ExpenseDetection ( output . ValueDetection , context ) : undefined , } as any ; } ; const deserializeAws_json1_1ExpenseFieldList = ( output , context ) : ExpenseField [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1ExpenseField ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1ExpenseType = ( output , context ) : ExpenseType => { return { Confidence : __limitedParseFloat32 ( output . Confidence ) , Text : __expectString ( output . Text ) , } as any ; } ; const deserializeAws_json1_1Geometry = ( output , context ) : Geometry => { return { BoundingBox : output . BoundingBox !== undefined && output . BoundingBox !== null ? deserializeAws_json1_1BoundingBox ( output . BoundingBox , context ) : undefined , Polygon : output . Polygon !== undefined && output . Polygon !== null ? deserializeAws_json1_1Polygon ( output . Polygon , context ) : undefined , } as any ; } ; const deserializeAws_json1_1GetDocumentAnalysisResponse = ( output , context ) : GetDocumentAnalysisResponse => { return { AnalyzeDocumentModelVersion : __expectString ( output . AnalyzeDocumentModelVersion ) , Blocks : output . Blocks !== undefined && output . Blocks !== null ? deserializeAws_json1_1BlockList ( output . Blocks , context ) : undefined , DocumentMetadata : output . DocumentMetadata !== undefined && output . DocumentMetadata !== null ? deserializeAws_json1_1DocumentMetadata ( output . DocumentMetadata , context ) : undefined , JobStatus : __expectString ( output . JobStatus ) , NextToken : __expectString ( output . NextToken ) , StatusMessage : __expectString ( output . StatusMessage ) , Warnings : output . Warnings !== undefined && output . Warnings !== null ? deserializeAws_json1_1Warnings ( output . Warnings , context ) : undefined , } as any ; } ; const deserializeAws_json1_1GetDocumentTextDetectionResponse = ( output , context ) : GetDocumentTextDetectionResponse => { return { Blocks : output . Blocks !== undefined && output . Blocks !== null ? deserializeAws_json1_1BlockList ( output . Blocks , context ) : undefined , DetectDocumentTextModelVersion : __expectString ( output . DetectDocumentTextModelVersion ) , DocumentMetadata : output . DocumentMetadata !== undefined && output . DocumentMetadata !== null ? deserializeAws_json1_1DocumentMetadata ( output . DocumentMetadata , context ) : undefined , JobStatus : __expectString ( output . JobStatus ) , NextToken : __expectString ( output . NextToken ) , StatusMessage : __expectString ( output . StatusMessage ) , Warnings : output . Warnings !== undefined && output . Warnings !== null ? deserializeAws_json1_1Warnings ( output . Warnings , context ) : undefined , } as any ; } ; const deserializeAws_json1_1GetExpenseAnalysisResponse = ( output , context ) : GetExpenseAnalysisResponse => { return { AnalyzeExpenseModelVersion : __expectString ( output . AnalyzeExpenseModelVersion ) , DocumentMetadata : output . DocumentMetadata !== undefined && output . DocumentMetadata !== null ? deserializeAws_json1_1DocumentMetadata ( output . DocumentMetadata , context ) : undefined , ExpenseDocuments : output . ExpenseDocuments !== undefined && output . ExpenseDocuments !== null ? deserializeAws_json1_1ExpenseDocumentList ( output . ExpenseDocuments , context ) : undefined , JobStatus : __expectString ( output . JobStatus ) , NextToken : __expectString ( output . NextToken ) , StatusMessage : __expectString ( output . StatusMessage ) , Warnings : output . Warnings !== undefined && output . Warnings !== null ? deserializeAws_json1_1Warnings ( output . Warnings , context ) : undefined , } as any ; } ; const deserializeAws_json1_1HumanLoopActivationOutput = ( output , context ) : HumanLoopActivationOutput => { return { HumanLoopActivationConditionsEvaluationResults : output . HumanLoopActivationConditionsEvaluationResults !== undefined && output . HumanLoopActivationConditionsEvaluationResults !== null ? new __LazyJsonString ( output . HumanLoopActivationConditionsEvaluationResults ) : undefined , HumanLoopActivationReasons : output . HumanLoopActivationReasons !== undefined && output . HumanLoopActivationReasons !== null ? deserializeAws_json1_1HumanLoopActivationReasons ( output . HumanLoopActivationReasons , context ) : undefined , HumanLoopArn : __expectString ( output . HumanLoopArn ) , } as any ; } ; const deserializeAws_json1_1HumanLoopActivationReasons = ( output , context ) : string [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectString ( entry ) as any ; } ) ; } ; const deserializeAws_json1_1HumanLoopQuotaExceededException = ( output , context ) : HumanLoopQuotaExceededException => { return { Code : __expectString ( output . Code ) , Message : __expectString ( output . Message ) , QuotaCode : __expectString ( output . QuotaCode ) , ResourceType : __expectString ( output . ResourceType ) , ServiceCode : __expectString ( output . ServiceCode ) , } as any ; } ; const deserializeAws_json1_1IdempotentParameterMismatchException = ( output , context ) : IdempotentParameterMismatchException => { return { Code : __expectString ( output . Code ) , Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1IdentityDocument = ( output , context ) : IdentityDocument => { return { DocumentIndex : __expectInt32 ( output . DocumentIndex ) , IdentityDocumentFields : output . IdentityDocumentFields !== undefined && output . IdentityDocumentFields !== null ? deserializeAws_json1_1IdentityDocumentFieldList ( output . IdentityDocumentFields , context ) : undefined , } as any ; } ; const deserializeAws_json1_1IdentityDocumentField = ( output , context ) : IdentityDocumentField => { return { Type : output . Type !== undefined && output . Type !== null ? deserializeAws_json1_1AnalyzeIDDetections ( output . Type , context ) : undefined , ValueDetection : output . ValueDetection !== undefined && output . ValueDetection !== null ? deserializeAws_json1_1AnalyzeIDDetections ( output . ValueDetection , context ) : undefined , } as any ; } ; const deserializeAws_json1_1IdentityDocumentFieldList = ( output , context ) : IdentityDocumentField [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1IdentityDocumentField ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1IdentityDocumentList = ( output , context ) : IdentityDocument [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1IdentityDocument ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1IdList = ( output , context ) : string [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectString ( entry ) as any ; } ) ; } ; const deserializeAws_json1_1InternalServerError = ( output , context ) : InternalServerError => { return { Code : __expectString ( output . Code ) , Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1InvalidJobIdException = ( output , context ) : InvalidJobIdException => { return { Code : __expectString ( output . Code ) , Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1InvalidKMSKeyException = ( output , context ) : InvalidKMSKeyException => { return { Code : __expectString ( output . Code ) , Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1InvalidParameterException = ( output , context ) : InvalidParameterException => { return { Code : __expectString ( output . Code ) , Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1InvalidS3ObjectException = ( output , context ) : InvalidS3ObjectException => { return { Code : __expectString ( output . Code ) , Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1LimitExceededException = ( output , context ) : LimitExceededException => { return { Code : __expectString ( output . Code ) , Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1LineItemFields = ( output , context ) : LineItemFields => { return { LineItemExpenseFields : output . LineItemExpenseFields !== undefined && output . LineItemExpenseFields !== null ? deserializeAws_json1_1ExpenseFieldList ( output . LineItemExpenseFields , context ) : undefined , } as any ; } ; const deserializeAws_json1_1LineItemGroup = ( output , context ) : LineItemGroup => { return { LineItemGroupIndex : __expectInt32 ( output . LineItemGroupIndex ) , LineItems : output . LineItems !== undefined && output . LineItems !== null ? deserializeAws_json1_1LineItemList ( output . LineItems , context ) : undefined , } as any ; } ; const deserializeAws_json1_1LineItemGroupList = ( output , context ) : LineItemGroup [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1LineItemGroup ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1LineItemList = ( output , context ) : LineItemFields [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1LineItemFields ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1NormalizedValue = ( output , context ) : NormalizedValue => { return { Value : __expectString ( output . Value ) , ValueType : __expectString ( output . ValueType ) , } as any ; } ; const deserializeAws_json1_1Pages = ( output , context ) : number [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectInt32 ( entry ) as any ; } ) ; } ; const deserializeAws_json1_1Point = ( output , context ) : Point => { return { X : __limitedParseFloat32 ( output . X ) , Y : __limitedParseFloat32 ( output . Y ) , } as any ; } ; const deserializeAws_json1_1Polygon = ( output , context ) : Point [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1Point ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1ProvisionedThroughputExceededException = ( output , context ) : ProvisionedThroughputExceededException => { return { Code : __expectString ( output . Code ) , Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1Relationship = ( output , context ) : Relationship => { return { Ids : output . Ids !== undefined && output . Ids !== null ? deserializeAws_json1_1IdList ( output . Ids , context ) : undefined , Type : __expectString ( output . Type ) , } as any ; } ; const deserializeAws_json1_1RelationshipList = ( output , context ) : Relationship [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1Relationship ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1StartDocumentAnalysisResponse = ( output , context ) : StartDocumentAnalysisResponse => { return { JobId : __expectString ( output . JobId ) , } as any ; } ; const deserializeAws_json1_1StartDocumentTextDetectionResponse = ( output , context ) : StartDocumentTextDetectionResponse => { return { JobId : __expectString ( output . JobId ) , } as any ; } ; const deserializeAws_json1_1StartExpenseAnalysisResponse = ( output , context ) : StartExpenseAnalysisResponse => { return { JobId : __expectString ( output . JobId ) , } as any ; } ; const deserializeAws_json1_1ThrottlingException = ( output , context ) : ThrottlingException => { return { Code : __expectString ( output . Code ) , Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1UnsupportedDocumentException = ( output , context ) : UnsupportedDocumentException => { return { Code : __expectString ( output . Code ) , Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1Warning = ( output , context ) : Warning => { return { ErrorCode : __expectString ( output . ErrorCode ) , Pages : output . Pages !== undefined && output . Pages !== null ? deserializeAws_json1_1Pages ( output . Pages , context ) : undefined , } as any ; } ; const deserializeAws_json1_1Warnings = ( output , context ) : Warning [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1Warning ( entry , context ) ; } ) ; } ; const deserializeMetadata = ( output ) : __ResponseMetadata => ( { httpStatusCode : output . statusCode , requestId : output . headers [ "x-amzn-requestid" ] ?? output . headers [ "x-amzn-request-id" ] , extendedRequestId : output . headers [ "x-amz-id-2" ] , cfId : output . headers [ "x-amz-cf-id" ] , } ) ; const collectBody = ( streamBody = new Uint8Array ( ) , context ) : Promise < Uint8Array > => { if ( streamBody instanceof Uint8Array ) { return Promise . resolve ( streamBody ) ; } return context . streamCollector ( streamBody ) || Promise . resolve ( new Uint8Array ( ) ) ; } ; const collectBodyString = ( streamBody , context ) : Promise < string > => collectBody ( streamBody , context ) . then ( ( body ) => context . utf8Encoder ( body ) ) ; const buildHttpRpcRequest = async ( context , headers , path , resolvedHostname , body ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const contents = { protocol , hostname , port , method : "POST" , path : basePath . endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) + path : basePath + path , headers , } ; if ( resolvedHostname !== undefined ) { contents . hostname = resolvedHostname ; } if ( body !== undefined ) { contents . body = body ; } return new __HttpRequest ( contents ) ; } ; const parseBody = ( streamBody , context ) : any => collectBodyString ( streamBody , context ) . then ( ( encoded ) => { if ( encoded . length ) { return JSON . parse ( encoded ) ; } return { } ; } ) ; /**
 * Load an error code for the aws.rest-json-1.1 protocol.
 */ const loadRestJsonErrorCode = ( output , data ) : string => { const findKey = ( object , key ) => Object . keys ( object ) . find ( ( k ) => k . toLowerCase ( ) === key . toLowerCase ( ) ) ; const sanitizeErrorCode = ( rawValue ) : string => { let cleanValue = rawValue ; if ( cleanValue . indexOf ( ":" ) >= 0 ) { cleanValue = cleanValue . split ( ":" ) [ 0 ] ; } if ( cleanValue . indexOf ( "#" ) >= 0 ) { cleanValue = cleanValue . split ( "#" ) [ 1 ] ; } return cleanValue ; } ; const headerKey = findKey ( output . headers , "x-amzn-errortype" ) ; if ( headerKey !== undefined ) { return sanitizeErrorCode ( output . headers [ headerKey ] ) ; } if ( data . code !== undefined ) { return sanitizeErrorCode ( data . code ) ; } if ( data [ "__type" ] !== undefined ) { return sanitizeErrorCode ( data [ "__type" ] ) ; } return "" ; } ;