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F,CAcA,qBAAO8K,CAAe4B,GAClB,GACuB,iBAAZA,GACK,OAAZA,GACA,aAAcA,GACd,YAAaA,GAC4C,iBAAjDA,EAAoCC,UAC5ClM,OAAOC,SAAUgM,EAAoCxL,SACvD,CACE,MAAM,SAAEyL,EAAQ,QAAEzL,GAAYwL,EAG9B,OACWxL,C,CAMf,OAAOwL,CACX,CASQ,gCAAOZ,CAA0Bc,GACrC,GAAIA,QAKJ,OAAIA,aAA2BhI,KACpBgI,EAIoB,iBAApBA,GAA2D,iBAApBA,EACvC,IAAIhI,KAAKgI,QADpB,CAMJ,ECjNJ,MAAMC,EAAoB,iCCuBpBC,EAAc,IAAIC,YAAY,QAAS,CAAEC,OAAO,IAU/C,SAASC,EAAkB3M,GAC9B,MAAMuK,EAAgBvK,EAAQuK,KAC9B,OAAIpK,OAAOC,SAASmK,GACTiC,EAAY7L,OAAO4J,GAEV,iBAATA,EACAA,EAEJqC,KAAKC,UAAUtC,EAC1B,CAWO,SAASuC,EACZ9M,EACA+M,GAEA,OAAOH,KAAKrI,MAAMoI,EAAkB3M,GAAU+M,EAClD,EDzDO,WACH,IACI,MAAMC,EAA0B,EAAAC,wBAAwBjF,cAEnDgF,EAAwBE,mBAAmBX,IAC5CS,EAAwBG,wBACpBZ,EACCxC,GACUF,EAA8BC,2CAA2CC,G,CAI9F,MAAOpG,GACL,MAAM,IAAI7C,MACN,sDACI6C,aAAiB7C,MAAQ6C,EAAM3D,QAAU2B,OAAOgC,K,CAIhE,CErBAyJ,U","sources":["webpack://@azure/functions-extensions-servicebus/external node-commonjs \"rhea\"","webpack://@azure/functions-extensions-servicebus/webpack/bootstrap","webpack://@azure/functions-extensions-servicebus/webpack/runtime/compat get default export","webpack://@azure/functions-extensions-servicebus/webpack/runtime/define property getters","webpack://@azure/functions-extensions-servicebus/webpack/runtime/hasOwnProperty shorthand","webpack://@azure/functions-extensions-servicebus/external node-commonjs \"@azure/functions-extensions-base\"","webpack://@azure/functions-extensions-servicebus/external node-commonjs \"@azure/core-amqp\"","webpack://@azure/functions-extensions-servicebus/external node-commonjs \"long\"","webpack://@azure/functions-extensions-servicebus/./src/util/lockTokenUtil.ts","webpack://@azure/functions-extensions-servicebus/./src/util/serviceBusMessageDecoder.ts","webpack://@azure/functions-extensions-servicebus/external node-commonjs \"@grpc/grpc-js\"","webpack://@azure/functions-extensions-servicebus/external node-commonjs \"@grpc/proto-loader\"","webpack://@azure/functions-extensions-servicebus/external node-commonjs \"fs\"","webpack://@azure/functions-extensions-servicebus/external node-commonjs \"os\"","webpack://@azure/functions-extensions-servicebus/external node-commonjs \"path\"","webpack://@azure/functions-extensions-servicebus/./src/grpcClientFactory.ts","webpack://@azure/functions-extensions-servicebus/./src/util/amqpPropertyEncoder.ts","webpack://@azure/functions-extensions-servicebus/external node-commonjs \"node:util\"","webpack://@azure/functions-extensions-servicebus/./src/util/grpcUriBuilder.ts","webpack://@azure/functions-extensions-servicebus/./src/servicebus/ServiceBusMessageActions.ts","webpack://@azure/functions-extensions-servicebus/./src/constants/settlementProtoConstant.ts","webpack://@azure/functions-extensions-servicebus/./src/servicebus/azureServiceBusMessageFactory.ts","webpack://@azure/functions-extensions-servicebus/./src/servicebus/registerServiceBusMessageFactory.ts","webpack://@azure/functions-extensions-servicebus/./src/util/messageBodyParser.ts","webpack://@azure/functions-extensions-servicebus/./src/index.ts"],"sourcesContent":["module.exports = __WEBPACK_EXTERNAL_createRequire_require(\"rhea\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire_require(\"@azure/functions-extensions-base\");","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire_require(\"@azure/core-amqp\");","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire_require(\"long\");","// Copyright (c) .NET Foundation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\r\n/**\r\n * Utility class for handling lock tokens in Azure Service Bus messages.\r\n * Provides methods to convert lock tokens to string format and extract them from messages.\r\n */\r\nexport class LockTokenUtil {\r\n    static readonly X_OPT_LOCK_TOKEN = Buffer.from('x-opt-lock-token');\r\n\r\n    /**\r\n     * Converts a lock token from a Buffer to a string format.\r\n     * The lock token is expected to be in a specific byte order.\r\n     * @param lockToken - The lock token as a Buffer.\r\n     * @returns The lock token as a formatted string.\r\n     */\r\n    static convertToString(lockToken: Buffer): string {\r\n        return [\r\n            lockToken.subarray(0, 4).reverse().toString('hex'),\r\n            lockToken.subarray(4, 6).reverse().toString('hex'),\r\n            lockToken.subarray(6, 8).reverse().toString('hex'),\r\n            lockToken.subarray(8, 10).toString('hex'),\r\n            lockToken.subarray(10).toString('hex'),\r\n        ].join('-');\r\n    }\r\n\r\n    /**\r\n     * Extracts the lock token from a Service Bus message.\r\n     * @param message - The Service Bus message as a Buffer.\r\n     * @param index - The index at which the lock token is located.\r\n     * @returns The extracted lock token as a string.\r\n     */\r\n    static extractFromMessage(message: Buffer | any[], index: number): string {\r\n        const raw = Buffer.isBuffer(message) ? message.subarray(0, index) : new Uint8Array(message.slice(0, index));\r\n\r\n        return this.convertToString(Buffer.from(raw.subarray(0, 16)));\r\n    }\r\n}\r\n","// Copyright (c) .NET Foundation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\r\nimport rhea from 'rhea';\r\nimport { LockTokenUtil } from './lockTokenUtil';\r\n\r\nexport class ServiceBusMessageDecoder {\r\n    /**\r\n     * Decodes a Service Bus message from a buffer.\r\n     * @param content Buffer that contains the Service Bus message with lock token\r\n     * @returns An object containing the decoded message and the lock token\r\n     */\r\n    static decode(content: Buffer): { decodedMessage: rhea.Message; lockToken: string } {\r\n        if (!content || content.length === 0) throw new Error('Content buffer is empty');\r\n\r\n        const index = content.indexOf(LockTokenUtil.X_OPT_LOCK_TOKEN);\r\n        if (index === -1) throw new Error('Lock token not found in content');\r\n\r\n        const lockToken = LockTokenUtil.extractFromMessage(content, index);\r\n        const amqpSlice = content.subarray(16);\r\n\r\n        // Suppress rhea warnings about message structure by temporarily overriding console.warn\r\n        // This prevents warnings like \"WARNING: expected described message section got {...}\"\r\n        const originalWarn = console.warn;\r\n        try {\r\n            console.warn = () => {};\r\n            // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any\r\n            const decodedMessage = rhea.message.decode(amqpSlice);\r\n            return { decodedMessage: decodedMessage as unknown as rhea.Message & { body: unknown }, lockToken };\r\n        } finally {\r\n            console.warn = originalWarn;\r\n        }\r\n    }\r\n}\r\n","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire_require(\"@grpc/grpc-js\");","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire_require(\"@grpc/proto-loader\");","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire_require(\"fs\");","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire_require(\"os\");","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire_require(\"path\");","// Copyright (c) .NET Foundation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\r\nimport * as grpc from '@grpc/grpc-js';\r\nimport * as protoLoader from '@grpc/proto-loader';\r\nimport * as fs from 'fs';\r\nimport * as os from 'os';\r\nimport * as path from 'path';\r\nimport { SETTLEMENT_PROTO_CONTENT } from './constants/settlementProtoConstant';\r\n\r\n// Cache for the loaded package definition to avoid repeated parsing\r\nlet cachedPackageDefinition: grpc.GrpcObject | null = null;\r\n\r\n/**\r\n * Creates and returns a gRPC client for the Settlement service using embedded proto definition.\r\n * This approach completely eliminates the need for external .proto files by creating a temporary\r\n * proto file from the embedded content, loading it, and then cleaning up.\r\n *\r\n * @template T - The type of gRPC client to create, extends grpc.Client\r\n *\r\n * @param options - The configuration options for creating the gRPC client\r\n * @param options.serviceName - Name of the service in the proto definition\r\n * @param options.address - The server address to connect to (e.g., \"localhost:50051\")\r\n * @param options.credentials - gRPC channel credentials to use for secure communication (defaults to insecure)\r\n * @param options.grpcMaxMessageLength - Maximum message length in bytes for both sending and receiving gRPC messages\r\n *\r\n * @returns A new instance of the specified gRPC client\r\n */\r\nexport function createGrpcClient<T extends grpc.Client = grpc.Client>({\r\n    serviceName,\r\n    address,\r\n    credentials = grpc.credentials.createInsecure(),\r\n    grpcMaxMessageLength,\r\n}: {\r\n    serviceName: string;\r\n    address: string;\r\n    credentials?: grpc.ChannelCredentials;\r\n    grpcMaxMessageLength: number;\r\n}): T {\r\n    // Load the embedded proto definition if not already cached\r\n    if (!cachedPackageDefinition) {\r\n        // Create a temporary proto file from the embedded content\r\n        const tempDir = os.tmpdir();\r\n        const tempProtoFile = path.join(tempDir, `settlement.proto`);\r\n\r\n        try {\r\n            // Write the proto content to a temporary file\r\n            fs.writeFileSync(tempProtoFile, SETTLEMENT_PROTO_CONTENT);\r\n\r\n            // Load the proto definition from the temporary file\r\n            const packageDefinition = protoLoader.loadSync(tempProtoFile, {\r\n                keepCase: false,\r\n                longs: String,\r\n                enums: String,\r\n                defaults: true,\r\n                oneofs: true,\r\n                includeDirs: [tempDir],\r\n            });\r\n\r\n            cachedPackageDefinition = grpc.loadPackageDefinition(packageDefinition);\r\n        } finally {\r\n            // Clean up the temporary file\r\n            try {\r\n                fs.unlinkSync(tempProtoFile);\r\n            } catch {\r\n                // Ignore cleanup errors\r\n            }\r\n        }\r\n    }\r\n\r\n    // Retrieve the service client constructor from the loaded gRPC object\r\n    // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\r\n    const ServiceClientConstructor = (cachedPackageDefinition as any)[serviceName] as grpc.ServiceClientConstructor;\r\n\r\n    // Throw an error if the service is not found\r\n    if (!ServiceClientConstructor) {\r\n        throw new Error(`Service \"${serviceName}\" not found in embedded proto definition`);\r\n    }\r\n\r\n    const clientOptions: grpc.ChannelOptions = {\r\n        'grpc.max_send_message_length': grpcMaxMessageLength,\r\n        'grpc.max_receive_message_length': grpcMaxMessageLength,\r\n    };\r\n\r\n    // Create and return a new instance of the service client\r\n    return new ServiceClientConstructor(address, credentials, clientOptions) as unknown as T;\r\n}\r\n","// Copyright (c) .NET Foundation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\r\n/**\r\n * AMQP Property Encoder Utility\r\n *\r\n * Converts TypeScript/JavaScript property values to AMQP-encoded byte arrays.\r\n * Date objects are automatically converted to UTC ISO format for cross-platform compatibility.\r\n */\r\n\r\n/**\r\n * Supported AMQP property types\r\n */\r\nenum AmqpType {\r\n    Null = 'null',\r\n    Byte = 'byte',\r\n    SByte = 'sbyte',\r\n    Char = 'char',\r\n    Int16 = 'int16',\r\n    UInt16 = 'uint16',\r\n    Int32 = 'int32',\r\n    UInt32 = 'uint32',\r\n    Int64 = 'int64',\r\n    UInt64 = 'uint64',\r\n    Single = 'single',\r\n    Double = 'double',\r\n    Decimal = 'decimal',\r\n    Boolean = 'boolean',\r\n    Guid = 'guid',\r\n    String = 'string',\r\n    Uri = 'uri',\r\n    DateTime = 'datetime',\r\n    DateTimeOffset = 'datetimeoffset',\r\n    TimeSpan = 'timespan',\r\n    Stream = 'stream',\r\n    Array = 'array',\r\n    Unknown = 'unknown',\r\n}\r\n\r\n/**\r\n * Type mapping from JavaScript primitive types to AMQP types\r\n */\r\nconst PRIMITIVE_TYPE_MAP = new Map<string, AmqpType>([\r\n    ['number', AmqpType.Double],\r\n    ['boolean', AmqpType.Boolean],\r\n    ['string', AmqpType.String],\r\n    ['bigint', AmqpType.Int64],\r\n]);\r\n\r\n/**\r\n * Type conversion utilities for specific AMQP types\r\n *\r\n * Contains validation functions to determine if JavaScript values fit within\r\n * specific AMQP type ranges and formats.\r\n */\r\nconst TypeConverters = {\r\n    /** Checks if number fits in unsigned 8-bit range (0-255) */\r\n    isByte: (value: number): boolean => Number.isInteger(value) && value >= 0 && value <= 255,\r\n    /** Checks if number fits in signed 8-bit range (-128 to 127) */\r\n    isSByte: (value: number): boolean => Number.isInteger(value) && value >= -128 && value <= 127,\r\n    /** Checks if number fits in signed 16-bit range (-32,768 to 32,767) */\r\n    isInt16: (value: number): boolean => Number.isInteger(value) && value >= -32768 && value <= 32767,\r\n    /** Checks if number fits in unsigned 16-bit range (0 to 65,535) */\r\n    isUInt16: (value: number): boolean => Number.isInteger(value) && value >= 0 && value <= 65535,\r\n    /** Checks if number fits in signed 32-bit range (-2,147,483,648 to 2,147,483,647) */\r\n    isInt32: (value: number): boolean => Number.isInteger(value) && value >= -2147483648 && value <= 2147483647,\r\n    /** Checks if number fits in unsigned 32-bit range (0 to 4,294,967,295) */\r\n    isUInt32: (value: number): boolean => Number.isInteger(value) && value >= 0 && value <= 4294967295,\r\n    /** Checks if floating-point number fits in 32-bit single precision range */\r\n    isSingle: (value: number): boolean => !Number.isInteger(value) && Math.abs(value) <= 3.4028235e38,\r\n\r\n    /** Checks if string is a single character */\r\n    isChar: (value: string): boolean => value.length === 1,\r\n    /** Checks if string matches GUID/UUID format (8-4-4-4-12 hex digits) */\r\n    isGuid: (value: string): boolean =>\r\n        /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value),\r\n    /** Checks if string is a valid URI by attempting URL construction */\r\n    isUri: (value: string): boolean => {\r\n        try {\r\n            new URL(value);\r\n            return true;\r\n        } catch {\r\n            return false;\r\n        }\r\n    },\r\n    /** Checks if string can be parsed as a date */\r\n    isDateTime: (value: string): boolean => !isNaN(Date.parse(value)),\r\n    /** Checks if string matches TimeSpan format ([-][d.]hh:mm:ss[.fffffff]) */\r\n    isTimeSpan: (value: string): boolean => /^-?(\\d+\\.)?(\\d{2}:)?(\\d{2}:)?\\d{2}(\\.\\d{1,7})?$/.test(value),\r\n};\r\n\r\n/**\r\n * Checks if an object represents a decimal-like value structure\r\n * @param obj - The object to check\r\n * @returns True if the object has properties indicating it's a decimal type\r\n */\r\nfunction isDecimalLike(obj: unknown): boolean {\r\n    return (\r\n        obj !== null &&\r\n        typeof obj === 'object' &&\r\n        'toString' in obj &&\r\n        ('precision' in obj || 'scale' in obj || 'value' in obj)\r\n    );\r\n}\r\n\r\n/**\r\n * Wraps a value with the appropriate AMQP type using the rhea library\r\n * @param type - The AMQP type string identifier\r\n * @param value - The value to wrap\r\n * @returns The wrapped value ready for AMQP encoding\r\n */\r\nfunction wrapAmqpValue(type: string, value: unknown): unknown {\r\n    // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment\r\n    const rhea = require('rhea');\r\n\r\n    switch (type) {\r\n        case 'null':\r\n            return null;\r\n        case 'boolean':\r\n            return value;\r\n        case 'byte':\r\n        case 'sbyte':\r\n        case 'int16':\r\n        case 'uint16':\r\n        case 'int32':\r\n        case 'uint32':\r\n        case 'single':\r\n        case 'double':\r\n            return value;\r\n        case 'int64':\r\n        case 'uint64':\r\n            // Convert BigInt to number for rhea compatibility\r\n            if (typeof value === 'bigint') {\r\n                // For BigInt values that are within safe integer range, convert to number\r\n                if (value >= BigInt(Number.MIN_SAFE_INTEGER) && value <= BigInt(Number.MAX_SAFE_INTEGER)) {\r\n                    // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\r\n                    return rhea.types.wrap_long(Number(value));\r\n                } else {\r\n                    // For very large values, handle as number but this may lose precision\r\n                    // This is a limitation of the JavaScript-AMQP bridge\r\n                    console.warn(`BigInt value ${value} is outside safe integer range, precision may be lost`);\r\n                    // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\r\n                    return rhea.types.wrap_long(Number(value));\r\n                }\r\n            }\r\n            // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\r\n            return rhea.types.wrap_long(value);\r\n        case 'decimal':\r\n            // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\r\n            return rhea.types.wrap_decimal128(value);\r\n        case 'char':\r\n        case 'string':\r\n        case 'guid':\r\n        case 'uri':\r\n        case 'datetime':\r\n        case 'datetimeoffset':\r\n        case 'timespan':\r\n            return value;\r\n        case 'stream':\r\n            // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\r\n            return rhea.types.wrap_binary(value);\r\n        default:\r\n            return value;\r\n    }\r\n}\r\n\r\nconst SUPPORTED_TYPES_MESSAGE =\r\n    'Supported types: ' +\r\n    'Primitives: null, boolean, string (including char, guid, uri, datetime, timespan), ' +\r\n    'Numbers: byte, sbyte, int16, uint16, int32, uint32, int64, uint64, single, double, decimal, ' +\r\n    'Objects: Date (datetimeoffset), URL (uri), Buffer/Uint8Array (stream), arrays of supported types';\r\n\r\n/**\r\n * Converts a Record<string, any> to AMQP-encoded byte array\r\n *\r\n * @param propertiesToModify - The properties to encode\r\n * @returns Uint8Array containing AMQP-encoded properties\r\n */\r\nexport function convertPropertiesToAmqpBytes(propertiesToModify: Record<string, any>): Uint8Array {\r\n    const amqpMap = new Map<string, unknown>();\r\n\r\n    for (const [key, value] of Object.entries(propertiesToModify)) {\r\n        const amqpValue = tryCreateAmqpPropertyValue(value);\r\n        if (amqpValue !== null) {\r\n            amqpMap.set(key, amqpValue);\r\n        } else {\r\n            const error = new Error(\r\n                `The key '${key}' has a value of type '${typeof value}' which is not supported for AMQP transport. ${SUPPORTED_TYPES_MESSAGE}`\r\n            );\r\n            throw error;\r\n        }\r\n    }\r\n\r\n    const encodedBytes = encodeAmqpMap(amqpMap);\r\n    return encodedBytes;\r\n}\r\n\r\n/**\r\n * Encodes properties for Service Bus message operations with proper error handling\r\n *\r\n * This function provides a safe wrapper around AMQP property encoding specifically\r\n * designed for Service Bus message operations (abandon, deadletter, defer).\r\n * It handles null/undefined properties and provides operation-specific error messages.\r\n *\r\n * @param propertiesToModify - Optional properties to modify on the message\r\n * @param operationName - The name of the operation (for error messages)\r\n * @returns Encoded properties as Uint8Array, or empty array if no properties provided\r\n * @throws Error with operation-specific context if encoding fails\r\n *\r\n * @example\r\n * ```typescript\r\n * // For abandon operation\r\n * const encoded = encodePropertiesForOperation(\r\n *   { messageId: 'test-123', priority: 1 },\r\n *   'abandon'\r\n * );\r\n *\r\n * // For operations without properties\r\n * const empty = encodePropertiesForOperation(undefined, 'defer');\r\n * // Returns: new Uint8Array()\r\n * ```\r\n */\r\nexport function encodePropertiesForOperation(\r\n    propertiesToModify: Record<string, any> | undefined,\r\n    operationName: string\r\n): Uint8Array {\r\n    // Return empty array if no properties provided\r\n    if (!propertiesToModify || Object.keys(propertiesToModify).length === 0) {\r\n        return new Uint8Array();\r\n    }\r\n\r\n    try {\r\n        return new Uint8Array(convertPropertiesToAmqpBytes(propertiesToModify));\r\n    } catch (error) {\r\n        throw new Error(\r\n            `Failed to encode properties for ${operationName} operation: ${\r\n                error instanceof Error ? error.message : String(error)\r\n            }`\r\n        );\r\n    }\r\n}\r\n\r\n/**\r\n * Attempts to create an AMQP property value from a JavaScript value with intelligent type detection\r\n *\r\n * Performs automatic type detection and conversion:\r\n * - Numbers: Detects optimal integer types (byte, int16, int32, int64) or floating point (single, double)\r\n * - Strings: Detects char, GUID, URI, DateTime, TimeSpan patterns\r\n * - Objects: Handles Date, URL, Buffer/Uint8Array, decimal-like objects, arrays\r\n * - Primitives: Boolean, BigInt, null/undefined\r\n *\r\n * @param propertyValue - The JavaScript value to convert to AMQP format\r\n * @returns Typed AMQP value object with { type, value } structure, or null if conversion fails\r\n */\r\nfunction tryCreateAmqpPropertyValue(propertyValue: unknown): unknown {\r\n    if (propertyValue === null || propertyValue === undefined) {\r\n        return { type: 'null', value: null };\r\n    }\r\n\r\n    const valueType = typeof propertyValue;\r\n\r\n    switch (valueType) {\r\n        case 'string': {\r\n            const strValue = propertyValue as string;\r\n\r\n            if (strValue === '') return { type: 'string', value: strValue };\r\n            if (TypeConverters.isChar(strValue)) return { type: 'char', value: strValue };\r\n            if (TypeConverters.isGuid(strValue)) return { type: 'guid', value: strValue };\r\n            if (TypeConverters.isUri(strValue)) return { type: 'uri', value: strValue };\r\n            if (TypeConverters.isTimeSpan(strValue)) return { type: 'timespan', value: strValue };\r\n            if (TypeConverters.isDateTime(strValue)) return { type: 'datetime', value: strValue };\r\n\r\n            return { type: 'string', value: strValue };\r\n        }\r\n\r\n        case 'number': {\r\n            const numValue = propertyValue as number;\r\n\r\n            if (!Number.isFinite(numValue)) {\r\n                return numValue;\r\n            }\r\n            if (Number.isInteger(numValue)) {\r\n                if (TypeConverters.isByte(numValue)) return { type: 'byte', value: numValue };\r\n                if (TypeConverters.isSByte(numValue)) return { type: 'sbyte', value: numValue };\r\n                if (TypeConverters.isInt16(numValue)) return { type: 'int16', value: numValue };\r\n                if (TypeConverters.isUInt16(numValue)) return { type: 'uint16', value: numValue };\r\n                if (TypeConverters.isInt32(numValue)) return { type: 'int32', value: numValue };\r\n                if (TypeConverters.isUInt32(numValue)) return { type: 'uint32', value: numValue };\r\n                return { type: 'int64', value: BigInt(numValue) };\r\n            }\r\n            if (TypeConverters.isSingle(numValue)) {\r\n                return { type: 'single', value: numValue };\r\n            }\r\n\r\n            return { type: 'double', value: numValue };\r\n        }\r\n\r\n        case 'boolean':\r\n            return { type: 'boolean', value: propertyValue as boolean };\r\n\r\n        case 'bigint': {\r\n            const bigintValue = propertyValue as bigint;\r\n            if (bigintValue >= BigInt(0) && bigintValue <= BigInt('18446744073709551615')) {\r\n                return { type: 'uint64', value: bigintValue };\r\n            }\r\n            return { type: 'int64', value: bigintValue };\r\n        }\r\n\r\n        case 'object': {\r\n            if (propertyValue instanceof Date) {\r\n                return { type: 'datetimeoffset', value: propertyValue.toISOString() };\r\n            }\r\n\r\n            if (propertyValue instanceof Buffer || propertyValue instanceof Uint8Array) {\r\n                return { type: 'stream', value: propertyValue };\r\n            }\r\n\r\n            if (propertyValue instanceof URL) {\r\n                return { type: 'uri', value: propertyValue.href };\r\n            }\r\n\r\n            if (isDecimalLike(propertyValue)) {\r\n                return { type: 'decimal', value: propertyValue };\r\n            }\r\n\r\n            if (Array.isArray(propertyValue)) {\r\n                return propertyValue.map((item: unknown) => tryCreateAmqpPropertyValue(item));\r\n            }\r\n\r\n            return null;\r\n        }\r\n\r\n        default:\r\n            return null;\r\n    }\r\n}\r\n\r\n/**\r\n * Encodes an AMQP map to byte array using proper AMQP encoding\r\n *\r\n * Uses the rhea library to create AMQP-encoded bytes compatible with .NET AMQP decoders.\r\n * Handles typed values by applying appropriate AMQP type wrappers before encoding.\r\n *\r\n * @param amqpMap - Map of string keys to AMQP-compatible values\r\n * @returns Uint8Array containing the AMQP-encoded map\r\n * @throws Error if encoding fails\r\n */\r\nfunction encodeAmqpMap(amqpMap: Map<string, unknown>): Uint8Array {\r\n    try {\r\n        // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment\r\n        const rhea = require('rhea');\r\n        const objectMap: Record<string, unknown> = {};\r\n        for (const [key, value] of amqpMap.entries()) {\r\n            if (value && typeof value === 'object' && 'type' in value && 'value' in value) {\r\n                const typedValue = value as { type: string; value: unknown };\r\n                objectMap[key] = wrapAmqpValue(typedValue.type, typedValue.value);\r\n            } else {\r\n                objectMap[key] = value;\r\n            }\r\n        }\r\n        // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\r\n        const wrappedMap = rhea.types.wrap_map(objectMap);\r\n\r\n        // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\r\n        const writer = new rhea.types.Writer();\r\n\r\n        // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\r\n        writer.write(wrappedMap);\r\n\r\n        // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\r\n        const buffer = writer.toBuffer();\r\n\r\n        // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\r\n        const result = new Uint8Array(buffer);\r\n\r\n        return result;\r\n    } catch (error) {\r\n        throw new Error(`Failed to encode AMQP map: ${error instanceof Error ? error.message : String(error)}`);\r\n    }\r\n}\r\n\r\n/**\r\n * Gets the AMQP type identifier for a given value\r\n *\r\n * Analyzes the value to determine its corresponding AMQP type. Handles both\r\n * typed values (from tryCreateAmqpPropertyValue) and raw JavaScript values.\r\n *\r\n * @param value - The value to analyze\r\n * @returns The corresponding AmqpType enum value\r\n */\r\nfunction getAmqpTypeIdentifier(value: unknown): AmqpType {\r\n    if (value === null || value === undefined) {\r\n        return AmqpType.Null;\r\n    }\r\n\r\n    if (value && typeof value === 'object' && 'type' in value && 'value' in value) {\r\n        const typedValue = value as { type: string; value: unknown };\r\n        const amqpType = Object.values(AmqpType).find((type) => type === typedValue.type);\r\n        return amqpType || AmqpType.Unknown;\r\n    }\r\n\r\n    const jsType = typeof value;\r\n    const primitiveType = PRIMITIVE_TYPE_MAP.get(jsType);\r\n\r\n    if (primitiveType) {\r\n        return primitiveType;\r\n    }\r\n\r\n    if (jsType === 'object') {\r\n        if (value instanceof Date) {\r\n            return AmqpType.DateTimeOffset;\r\n        } else if (value instanceof URL) {\r\n            return AmqpType.Uri;\r\n        } else if (value instanceof Buffer || value instanceof Uint8Array) {\r\n            return AmqpType.Stream;\r\n        } else if (Array.isArray(value)) {\r\n            // Arrays are supported, determine their type by content\r\n            return AmqpType.Array;\r\n        }\r\n    }\r\n\r\n    return AmqpType.Unknown;\r\n}\r\n\r\n/**\r\n * Validates that all properties in the record are supported AMQP types\r\n *\r\n * @param properties - The properties to validate\r\n * @throws Error if any property has an unsupported type\r\n */\r\nexport function validateAmqpProperties(properties: Record<string, any>): void {\r\n    for (const [key, value] of Object.entries(properties)) {\r\n        const amqpType = getAmqpTypeIdentifier(value);\r\n\r\n        if (amqpType === AmqpType.Unknown) {\r\n            const error = new Error(\r\n                `Property '${key}' has unsupported type '${typeof value}' for AMQP transport. ${SUPPORTED_TYPES_MESSAGE}`\r\n            );\r\n            throw error;\r\n        }\r\n    }\r\n}\r\n","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire_require(\"node:util\");","// Copyright (c) .NET Foundation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\r\nimport { parseArgs } from 'node:util';\r\n/**\r\n *  GrpcUriBuilder is a utility class to build a gRPC URI from command line arguments.\r\n *  It expects two arguments: 'host' and 'port'.\r\n */\r\nexport class GrpcUriBuilder {\r\n    /**\r\n     *  Builds a gRPC URI from command line arguments.\r\n     *  The expected arguments are 'host' and 'port'.\r\n     * @returns A string representing the gRPC URI in the format \"host:port\".\r\n     * @throws Error if 'host' or 'port' arguments are missing.\r\n     */\r\n    static build(): { uri: string; grpcMaxMessageLength: number } {\r\n        const { values: parsedArgs } = parseArgs({\r\n            args: process.argv.slice(2),\r\n            options: {\r\n                host: { type: 'string' },\r\n                port: { type: 'string' },\r\n                'functions-grpc-max-message-length': { type: 'string' },\r\n            },\r\n            strict: false,\r\n        });\r\n\r\n        const { host, port, 'functions-grpc-max-message-length': grpcMaxMessageLength } = parsedArgs;\r\n\r\n        const missing: string[] = [];\r\n        if (!host) missing.push(\"'host'\");\r\n        if (!port) missing.push(\"'port'\");\r\n        if (!grpcMaxMessageLength) missing.push(\"'functions-grpc-max-message-length'\");\r\n        if (missing.length) {\r\n            throw new Error(`Missing required arguments: ${missing.join(', ')}`);\r\n        }\r\n\r\n        return { uri: `${String(host)}:${String(port)}`, grpcMaxMessageLength: Number(grpcMaxMessageLength) };\r\n    }\r\n}\r\n","// Copyright (c) .NET Foundation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\r\nimport { ServiceBusReceivedMessage } from '@azure/service-bus';\r\nimport * as grpc from '@grpc/grpc-js';\r\nimport {\r\n    AbandonRequest,\r\n    CompleteRequest,\r\n    DeadletterRequest,\r\n    DeferRequest,\r\n    IServiceBusMessageActions,\r\n    ReleaseSessionRequest,\r\n    RenewMessageLockRequest,\r\n    RenewSessionLockRequest,\r\n    RenewSessionLockResponse,\r\n    SetSessionStateRequest,\r\n    SettlementServiceClient,\r\n} from '../../types/settlement-types';\r\nimport { createGrpcClient } from '../grpcClientFactory';\r\nimport { encodePropertiesForOperation } from '../util/amqpPropertyEncoder';\r\nimport { GrpcUriBuilder } from '../util/grpcUriBuilder';\r\n\r\n// Using the original proto-loader approach with better path resolution\r\n\r\n// Client implementation with Promise-based methods\r\nexport class ServiceBusMessageActions implements IServiceBusMessageActions {\r\n    private static instance: ServiceBusMessageActions | null = null;\r\n    private client: SettlementServiceClient;\r\n\r\n    private constructor() {\r\n        const { uri, grpcMaxMessageLength } = GrpcUriBuilder.build();\r\n        this.client = createGrpcClient<SettlementServiceClient>({\r\n            serviceName: 'Settlement',\r\n            address: uri,\r\n            credentials: grpc.credentials.createInsecure(),\r\n            grpcMaxMessageLength,\r\n        });\r\n    }\r\n\r\n    static getInstance(): ServiceBusMessageActions {\r\n        if (!ServiceBusMessageActions.instance) {\r\n            ServiceBusMessageActions.instance = new ServiceBusMessageActions();\r\n        }\r\n        return ServiceBusMessageActions.instance;\r\n    }\r\n\r\n    // Add this private helper method to the ServiceBusMessageActions class\r\n    private validateLockToken(message: ServiceBusReceivedMessage): string {\r\n        const locktoken = message.lockToken;\r\n        if (!locktoken) {\r\n            throw new Error('ArgumentException: lockToken is required in ServiceBusReceivedMessage.');\r\n        }\r\n        return locktoken;\r\n    }\r\n\r\n    /**\r\n     * Completes (settles) the specified message, removing it from the queue or subscription.\r\n     *\r\n     * @param message - The received Service Bus message to complete.\r\n     * @returns A promise that resolves when the operation is successful.\r\n     * @throws Error if the lockToken is missing or the gRPC call fails.\r\n     */\r\n    async complete(message: ServiceBusReceivedMessage): Promise<void> {\r\n        const locktoken = this.validateLockToken(message);\r\n        return new Promise((resolve, reject) => {\r\n            const request: CompleteRequest = { locktoken };\r\n            this.client.complete(request, (error: grpc.ServiceError | null) => {\r\n                if (error) {\r\n                    console.error('Complete request failed:', {\r\n                        code: error.code,\r\n                        message: error.message,\r\n                        details: error.details,\r\n                    });\r\n                    reject(error);\r\n                } else {\r\n                    resolve();\r\n                }\r\n            });\r\n        });\r\n    }\r\n\r\n    /**\r\n     * Abandons the specified message, making it available again for processing.\r\n     *\r\n     * @param message - The received Service Bus message to abandon.\r\n     * @param propertiesToModify - Optional properties to modify on the message.\r\n     * @returns A promise that resolves when the operation is successful.\r\n     * @throws Error if the lockToken is missing or the gRPC call fails.\r\n     */\r\n    async abandon(message: ServiceBusReceivedMessage, propertiesToModify?: Record<string, any>): Promise<void> {\r\n        const locktoken = this.validateLockToken(message);\r\n        const encodedProperties = encodePropertiesForOperation(propertiesToModify, 'abandon');\r\n\r\n        return new Promise((resolve, reject) => {\r\n            const request: AbandonRequest = {\r\n                locktoken,\r\n                propertiesToModify: encodedProperties,\r\n            };\r\n\r\n            this.client.abandon(request, (error: grpc.ServiceError | null) => {\r\n                if (error) {\r\n                    console.error('Abandon request failed:', {\r\n                        code: error.code,\r\n                        message: error.message,\r\n                        details: error.details,\r\n                    });\r\n                    reject(error);\r\n                } else {\r\n                    resolve();\r\n                }\r\n            });\r\n        });\r\n    }\r\n\r\n    /**\r\n     * Deadletters the specified message, moving it to the dead-letter queue.\r\n     *\r\n     * @param message - The received Service Bus message to deadletter.\r\n     * @param propertiesToModify - Optional properties to modify on the message.\r\n     * @param deadletterReason - Optional reason for deadlettering the message.\r\n     * @param deadletterErrorDescription - Optional error description for deadlettering.\r\n     * @returns A promise that resolves when the operation is successful.\r\n     * @throws Error if the lockToken is missing or the gRPC call fails.\r\n     */\r\n    async deadletter(\r\n        message: ServiceBusReceivedMessage,\r\n        propertiesToModify?: Record<string, any>,\r\n        deadletterReason?: string,\r\n        deadletterErrorDescription?: string\r\n    ): Promise<void> {\r\n        const locktoken = this.validateLockToken(message);\r\n        const encodedProperties = encodePropertiesForOperation(propertiesToModify, 'deadletter');\r\n\r\n        return new Promise((resolve, reject) => {\r\n            const request: DeadletterRequest = {\r\n                locktoken,\r\n                propertiesToModify: encodedProperties,\r\n                deadletterReason: deadletterReason ? { value: deadletterReason } : undefined,\r\n                deadletterErrorDescription: deadletterErrorDescription\r\n                    ? { value: deadletterErrorDescription }\r\n                    : undefined,\r\n            };\r\n\r\n            this.client.deadletter(request, (error: grpc.ServiceError | null) => {\r\n                if (error) {\r\n                    console.error('Deadletter request failed:', {\r\n                        code: error.code,\r\n                        message: error.message,\r\n                        details: error.details,\r\n                    });\r\n                    reject(error);\r\n                } else {\r\n                    resolve();\r\n                }\r\n            });\r\n        });\r\n    }\r\n\r\n    /**\r\n     * Defers the specified message, making it invisible until retrieved by sequence number.\r\n     *\r\n     * @param message - The received Service Bus message to defer.\r\n     * @param propertiesToModify - Optional properties to modify on the message.\r\n     * @returns A promise that resolves when the operation is successful.\r\n     * @throws Error if the lockToken is missing or the gRPC call fails.\r\n     */\r\n    async defer(message: ServiceBusReceivedMessage, propertiesToModify?: Record<string, any>): Promise<void> {\r\n        const locktoken = this.validateLockToken(message);\r\n        const encodedProperties = encodePropertiesForOperation(propertiesToModify, 'defer');\r\n\r\n        return new Promise((resolve, reject) => {\r\n            const request: DeferRequest = {\r\n                locktoken,\r\n                propertiesToModify: encodedProperties,\r\n            };\r\n\r\n            this.client.defer(request, (error: grpc.ServiceError | null) => {\r\n                if (error) {\r\n                    console.error('Defer request failed:', {\r\n                        code: error.code,\r\n                        message: error.message,\r\n                        details: error.details,\r\n                    });\r\n                    reject(error);\r\n                } else {\r\n                    resolve();\r\n                }\r\n            });\r\n        });\r\n    }\r\n\r\n    /**\r\n     * Renews the lock on the specified message, extending its lock duration.\r\n     *\r\n     * @param message - The received Service Bus message whose lock should be renewed.\r\n     * @returns A promise that resolves when the operation is successful.\r\n     * @throws Error if the lockToken is missing or the gRPC call fails.\r\n     */\r\n    async renewMessageLock(message: ServiceBusReceivedMessage): Promise<void> {\r\n        const locktoken = this.validateLockToken(message);\r\n        return new Promise((resolve, reject) => {\r\n            const request: RenewMessageLockRequest = { locktoken };\r\n\r\n            this.client.renewMessageLock(request, (error: grpc.ServiceError | null) => {\r\n                if (error) {\r\n                    console.error('Renew message lock request failed:', {\r\n                        code: error.code,\r\n                        message: error.message,\r\n                        details: error.details,\r\n                    });\r\n                    reject(error);\r\n                } else {\r\n                    resolve();\r\n                }\r\n            });\r\n        });\r\n    }\r\n\r\n    /**\r\n     * Sets the state for the specified session.\r\n     *\r\n     * @param sessionId - The session ID for which to set the state.\r\n     * @param sessionState - The state to set for the session.\r\n     * @returns A promise that resolves when the operation is successful.\r\n     * @throws Error if the gRPC call fails.\r\n     */\r\n    async setSessionState(sessionId: string, sessionState: Uint8Array): Promise<void> {\r\n        return new Promise((resolve, reject) => {\r\n            const request: SetSessionStateRequest = { sessionId, sessionState };\r\n\r\n            this.client.setSessionState(request, (error: grpc.ServiceError | null) => {\r\n                if (error) {\r\n                    console.error('Set session state request failed:', {\r\n                        code: error.code,\r\n                        message: error.message,\r\n                        details: error.details,\r\n                    });\r\n                    reject(error);\r\n                } else {\r\n                    resolve();\r\n                }\r\n            });\r\n        });\r\n    }\r\n\r\n    /**\r\n     * Releases the specified session, making it available for other receivers.\r\n     *\r\n     * @param sessionId - The session ID to release.\r\n     * @returns A promise that resolves when the operation is successful.\r\n     * @throws Error if the gRPC call fails.\r\n     */\r\n    async releaseSession(sessionId: string): Promise<void> {\r\n        return new Promise((resolve, reject) => {\r\n            const request: ReleaseSessionRequest = { sessionId };\r\n\r\n            this.client.releaseSession(request, (error: grpc.ServiceError | null) => {\r\n                if (error) {\r\n                    console.error('Release session request failed:', {\r\n                        code: error.code,\r\n                        message: error.message,\r\n                        details: error.details,\r\n                    });\r\n                    reject(error);\r\n                } else {\r\n                    resolve();\r\n                }\r\n            });\r\n        });\r\n    }\r\n\r\n    /**\r\n     * Renews the lock on the specified session, extending its lock duration.\r\n     *\r\n     * @param sessionId - The session ID whose lock should be renewed.\r\n     * @returns A promise that resolves to the new locked-until date.\r\n     * @throws Error if the gRPC call fails or if no response is returned.\r\n     */\r\n    async renewSessionLock(sessionId: string): Promise<Date> {\r\n        return new Promise((resolve, reject) => {\r\n            const request: RenewSessionLockRequest = { sessionId };\r\n\r\n            this.client.renewSessionLock(\r\n                request,\r\n                (error: grpc.ServiceError | null, response?: RenewSessionLockResponse) => {\r\n                    if (error) {\r\n                        console.error('Renew session lock request failed:', {\r\n                            code: error.code,\r\n                            message: error.message,\r\n                            details: error.details,\r\n                        });\r\n                        reject(error);\r\n                    } else if (response && response.lockedUntil) {\r\n                        resolve(response.lockedUntil);\r\n                    } else {\r\n                        const err = new Error('No response or lockedUntil returned from renewSessionLock');\r\n                        reject(err);\r\n                    }\r\n                }\r\n            );\r\n        });\r\n    }\r\n\r\n    /**\r\n     * Resets the singleton instance (for testing purposes).\r\n     */\r\n    static resetInstance(): void {\r\n        ServiceBusMessageActions.instance = null;\r\n    }\r\n}\r\n","// Copyright (c) .NET Foundation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\r\n/**\r\n * Embedded protobuf definition for the Settlement service.\r\n * This eliminates the need for external .proto files by providing the complete\r\n * proto definition as a string constant.\r\n */\r\nexport const SETTLEMENT_PROTO_CONTENT = `\r\nsyntax = \"proto3\";\r\n\r\nimport \"google/protobuf/empty.proto\";\r\nimport \"google/protobuf/wrappers.proto\";\r\nimport \"google/protobuf/timestamp.proto\";\r\n\r\n// this namespace will be shared between isolated worker and WebJobs extension so make it somewhat generic\r\noption csharp_namespace = \"Microsoft.Azure.ServiceBus.Grpc\";\r\n\r\n// The settlement service definition.\r\nservice Settlement {\r\n  // Completes a message\r\n  rpc Complete (CompleteRequest) returns (google.protobuf.Empty) {}\r\n\r\n  // Abandons a message\r\n  rpc Abandon (AbandonRequest) returns (google.protobuf.Empty) {}\r\n\r\n  // Deadletters a message\r\n  rpc Deadletter (DeadletterRequest) returns (google.protobuf.Empty) {}\r\n\r\n  // Defers a message\r\n  rpc Defer (DeferRequest) returns (google.protobuf.Empty) {}\r\n\r\n  // Renew message lock\r\n  rpc RenewMessageLock (RenewMessageLockRequest) returns (google.protobuf.Empty) {}\r\n\r\n  // Get session state\r\n  rpc GetSessionState (GetSessionStateRequest) returns (GetSessionStateResponse) {}\r\n\r\n  // Set session state\r\n  rpc SetSessionState (SetSessionStateRequest) returns (google.protobuf.Empty) {}\r\n\r\n  // Release session\r\n  rpc ReleaseSession (ReleaseSessionRequest) returns (google.protobuf.Empty) {}\r\n\r\n  // Renew session lock\r\n  rpc RenewSessionLock (RenewSessionLockRequest) returns (RenewSessionLockResponse) {}\r\n}\r\n\r\n// The complete message request containing the locktoken.\r\nmessage CompleteRequest {\r\n  string locktoken = 1;\r\n}\r\n\r\n// The abandon message request containing the locktoken and properties to modify.\r\nmessage AbandonRequest {\r\n  string locktoken = 1;\r\n  bytes propertiesToModify = 2;\r\n}\r\n\r\n// The deadletter message request containing the locktoken and properties to modify along with the reason/description.\r\nmessage DeadletterRequest {\r\n  string locktoken = 1;\r\n  bytes propertiesToModify = 2;\r\n  google.protobuf.StringValue deadletterReason = 3;\r\n  google.protobuf.StringValue deadletterErrorDescription = 4;\r\n}\r\n\r\n// The defer message request containing the locktoken and properties to modify.\r\nmessage DeferRequest {\r\n  string locktoken = 1;\r\n  bytes propertiesToModify = 2;\r\n}\r\n\r\n// The renew message lock request containing the locktoken.\r\nmessage RenewMessageLockRequest {\r\n  string locktoken = 1;\r\n}\r\n\r\n// The get message request.\r\nmessage GetSessionStateRequest {\r\n  string sessionId = 1;\r\n}\r\n\r\n// The set message request.\r\nmessage SetSessionStateRequest {\r\n  string sessionId = 1;\r\n  bytes sessionState = 2;\r\n}\r\n\r\n// Get response containing the session state.\r\nmessage GetSessionStateResponse {\r\n  bytes sessionState = 1;\r\n}\r\n\r\n// Release session.\r\nmessage ReleaseSessionRequest {\r\n  string sessionId = 1;\r\n}\r\n\r\n// Renew session lock.\r\nmessage RenewSessionLockRequest {\r\n  string sessionId = 1;\r\n}\r\n\r\n// Renew session lock.\r\nmessage RenewSessionLockResponse {\r\n  google.protobuf.Timestamp lockedUntil = 1;\r\n}\r\n`;\r\n","// Copyright (c) .NET Foundation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\r\nimport { AmqpAnnotatedMessage } from '@azure/core-amqp';\r\nimport { ModelBindingData } from '@azure/functions-extensions-base';\r\nimport { ServiceBusReceivedMessage } from '@azure/service-bus';\r\nimport LongActual from 'long';\r\nimport rhea from 'rhea';\r\nimport { ServiceBusMessageContext } from '../../types';\r\nimport { ServiceBusMessageDecoder } from '../util/serviceBusMessageDecoder';\r\nimport { ServiceBusMessageActions } from './ServiceBusMessageActions';\r\n\r\nconst ENQUEUED_TIME_ANNOTATION = 'x-opt-enqueued-time';\r\nconst LOCKED_UNTIL_ANNOTATION = 'x-opt-locked-until';\r\nconst SEQUENCE_NUMBER_ANNOTATION = 'x-opt-sequence-number';\r\nconst ENQUEUED_SEQUENCE_NUMBER_ANNOTATION = 'x-opt-offset';\r\nconst DEAD_LETTER_SOURCE_ANNOTATION = 'x-opt-deadletter-source';\r\nconst DEAD_LETTER_REASON_ANNOTATION = 'DeadLetterReason';\r\nconst DEAD_LETTER_ERROR_DESCRIPTION_ANNOTATION = 'DeadLetterErrorDescription';\r\n\r\n/**\r\n * Factory class for creating and processing Azure Service Bus messages Manager.\r\n *\r\n * This factory class provides methods to:\r\n * - Build ServiceBusMessage instances from model binding data in Azure Functions\r\n * - Convert between different message formats (AMQP, Rhea)\r\n * - Extract and decode message body content with proper type handling\r\n *\r\n * The factory handles all necessary transformations of message properties,\r\n * annotations, and content to ensure proper integration with the Azure\r\n * Service Bus messaging system.\r\n */\r\nexport class AzureServiceBusMessageFactory {\r\n    /**\r\n     * Builds a ServiceBusMessageContext instance from model binding data.\r\n     * This method extracts the Service Bus message content from the provided model binding data,\r\n     * @param modelBindingData - The model binding data containing the Service Bus message content.\r\n     * This can be a single ModelBindingData object or an array of ModelBindingData objects.\r\n     * @returns A ServiceBusMessageContext instance with messages always returned as an array.\r\n     */\r\n    static buildServiceBusMessageFromModelBindingData(\r\n        modelBindingData: ModelBindingData | ModelBindingData[]\r\n    ): ServiceBusMessageContext {\r\n        const client = ServiceBusMessageActions.getInstance();\r\n\r\n        const toMessage = (data: ModelBindingData) => {\r\n            if (!data.content) {\r\n                throw new Error('ModelBindingData.content is null or undefined.');\r\n            }\r\n\r\n            const { decodedMessage, lockToken } = ServiceBusMessageDecoder.decode(data.content);\r\n            return this.createServiceBusReceivedMessageFromRhea(decodedMessage, lockToken);\r\n        };\r\n\r\n        const messages = Array.isArray(modelBindingData)\r\n            ? modelBindingData.map(toMessage)\r\n            : [toMessage(modelBindingData)];\r\n\r\n        return {\r\n            messages,\r\n            actions: client,\r\n        };\r\n    }\r\n\r\n    /**\r\n     * Creates a ServiceBusReceivedMessage from an AMQP annotated message.\r\n     * This method extracts relevant properties and formats them into the ServiceBusReceivedMessage structure.\r\n     *\r\n     * @param amqpMessage - The AMQP annotated message to convert.\r\n     * @param lockToken - lock token for the message.\r\n     * @returns A ServiceBusReceivedMessage object.\r\n     */\r\n    static createServiceBusReceivedMessageFromAmqp(\r\n        amqpMessage: AmqpAnnotatedMessage,\r\n        lockToken: string\r\n    ): ServiceBusReceivedMessage {\r\n        // Extract common properties from the AMQP message\r\n        const receivedMessage: ServiceBusReceivedMessage = {\r\n            // Message body - return raw Buffer without automatic parsing\r\n            body: AzureServiceBusMessageFactory.decodeAmqpBody(amqpMessage.body),\r\n\r\n            // Message properties\r\n            messageId: amqpMessage.properties?.messageId?.toString(),\r\n            correlationId: amqpMessage.properties?.correlationId?.toString(),\r\n            contentType: amqpMessage.properties?.contentType,\r\n            subject: amqpMessage.properties?.subject,\r\n            to: amqpMessage.properties?.to,\r\n            replyTo: amqpMessage.properties?.replyTo,\r\n            replyToSessionId: amqpMessage.properties?.replyToGroupId,\r\n            sessionId: amqpMessage.properties?.groupId,\r\n            timeToLive: amqpMessage.header?.timeToLive,\r\n\r\n            // Application properties\r\n            applicationProperties: amqpMessage.applicationProperties || {},\r\n\r\n            // Message annotations and delivery annotations\r\n            deliveryCount: amqpMessage.header?.deliveryCount || 0,\r\n\r\n            // Lock token (if provided)\r\n            lockToken: lockToken,\r\n\r\n            // AMQP annotated message for full access\r\n            _rawAmqpMessage: amqpMessage,\r\n\r\n            // Timestamps (convert from AMQP format if available)\r\n            enqueuedTimeUtc: AzureServiceBusMessageFactory.extractDateFromAnnotation(\r\n                amqpMessage.messageAnnotations?.[ENQUEUED_TIME_ANNOTATION]\r\n            ),\r\n\r\n            lockedUntilUtc: AzureServiceBusMessageFactory.extractDateFromAnnotation(\r\n                amqpMessage.messageAnnotations?.[LOCKED_UNTIL_ANNOTATION]\r\n            ),\r\n\r\n            // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\r\n            sequenceNumber:\r\n                amqpMessage.messageAnnotations?.[SEQUENCE_NUMBER_ANNOTATION] !== undefined\r\n                    ? // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\r\n                      LongActual.fromNumber(Number(amqpMessage.messageAnnotations[SEQUENCE_NUMBER_ANNOTATION]))\r\n                    : undefined,\r\n\r\n            enqueuedSequenceNumber:\r\n                amqpMessage.messageAnnotations?.[ENQUEUED_SEQUENCE_NUMBER_ANNOTATION] !== undefined\r\n                    ? Number(amqpMessage.messageAnnotations[ENQUEUED_SEQUENCE_NUMBER_ANNOTATION])\r\n                    : amqpMessage.messageAnnotations?.[SEQUENCE_NUMBER_ANNOTATION] !== undefined\r\n                    ? Number(amqpMessage.messageAnnotations[SEQUENCE_NUMBER_ANNOTATION])\r\n                    : undefined,\r\n\r\n            // Dead letter properties\r\n            deadLetterReason: amqpMessage.applicationProperties?.[DEAD_LETTER_REASON_ANNOTATION] as string | undefined,\r\n            deadLetterErrorDescription: amqpMessage.applicationProperties?.[\r\n                DEAD_LETTER_ERROR_DESCRIPTION_ANNOTATION\r\n            ] as string | undefined,\r\n            deadLetterSource: amqpMessage.messageAnnotations?.[DEAD_LETTER_SOURCE_ANNOTATION] as string | undefined,\r\n\r\n            // State\r\n            state: 'active' as const,\r\n        };\r\n\r\n        return receivedMessage;\r\n    }\r\n\r\n    /**\r\n     * Creates a ServiceBusReceivedMessage from a Rhea message.\r\n     * This method extracts relevant properties and formats them into the ServiceBusReceivedMessage structure.\r\n     *\r\n     * @param rheaMessage - The Rhea message to convert.\r\n     * @param lockToken - Optional lock token for the message.\r\n     * @returns A ServiceBusReceivedMessage object.\r\n     */\r\n    static createServiceBusReceivedMessageFromRhea(\r\n        rheaMessage: rhea.Message,\r\n        lockToken: string\r\n    ): ServiceBusReceivedMessage {\r\n        const amqpMessage = AmqpAnnotatedMessage.fromRheaMessage(rheaMessage);\r\n        return AzureServiceBusMessageFactory.createServiceBusReceivedMessageFromAmqp(amqpMessage, lockToken);\r\n    }\r\n\r\n    /**\r\n     * Decodes the body of an AMQP message section based on its typecode.\r\n     * Returns the raw binary content as a Buffer without any automatic parsing.\r\n     *\r\n     * This approach aligns with the Python Azure Functions Extension behavior,\r\n     * where the message body is returned as-is without automatic JSON parsing.\r\n     * Users who need to parse JSON can do so explicitly with their own logic,\r\n     * allowing for custom revivers and full control over the parsing process.\r\n     *\r\n     * @param section - The AMQP message section containing a typecode and content buffer.\r\n     * @returns The raw Buffer content for binary messages, or the original section if not a valid AMQP body.\r\n     */\r\n    static decodeAmqpBody(section: unknown): Buffer | unknown {\r\n        if (\r\n            typeof section === 'object' &&\r\n            section !== null &&\r\n            'typecode' in section &&\r\n            'content' in section &&\r\n            typeof (section as Record<string, unknown>).typecode === 'number' &&\r\n            Buffer.isBuffer((section as Record<string, unknown>).content)\r\n        ) {\r\n            const { typecode, content } = section as { typecode: number; content: Buffer };\r\n            // typecode = 117 is Binary content\r\n            // Return raw Buffer without any parsing - consistent with Python Extension behavior\r\n            if (typecode === 117) {\r\n                return content;\r\n            }\r\n\r\n            return content;\r\n        }\r\n        // Not a valid AMQP body section\r\n        return section;\r\n    }\r\n\r\n    /**\r\n     * Extracts a Date from an AMQP message annotation value.\r\n     * Handles cases where the value is already a Date, or is a string/number that can be converted to a Date.\r\n     *\r\n     * @param annotationValue - The annotation value from messageAnnotations\r\n     * @returns A Date object if the value can be converted, undefined otherwise\r\n     */\r\n    private static extractDateFromAnnotation(annotationValue: unknown): Date | undefined {\r\n        if (annotationValue === undefined || annotationValue === null) {\r\n            return undefined;\r\n        }\r\n\r\n        // If it's already a Date object, return it\r\n        if (annotationValue instanceof Date) {\r\n            return annotationValue;\r\n        }\r\n\r\n        // If it's a string or number, try to convert it to a Date\r\n        if (typeof annotationValue === 'string' || typeof annotationValue === 'number') {\r\n            return new Date(annotationValue);\r\n        }\r\n\r\n        // For any other type, return undefined\r\n        return undefined;\r\n    }\r\n}\r\n","// Copyright (c) .NET Foundation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\r\nimport { ModelBindingData, ResourceFactoryResolver } from '@azure/functions-extensions-base';\r\nimport { AzureServiceBusMessageFactory } from './azureServiceBusMessageFactory';\r\n\r\nconst AZURE_SERVICE_BUS = 'AzureServiceBusReceivedMessage';\r\nexport function registerServiceBusMessageFactory(): void {\r\n    try {\r\n        const resourceFactoryResolver = ResourceFactoryResolver.getInstance();\r\n        // Check if a factory is already registered to avoid conflicts\r\n        if (!resourceFactoryResolver.hasResourceFactory(AZURE_SERVICE_BUS)) {\r\n            resourceFactoryResolver.registerResourceFactory(\r\n                AZURE_SERVICE_BUS,\r\n                (modelBindingData: ModelBindingData | ModelBindingData[]) => {\r\n                    return AzureServiceBusMessageFactory.buildServiceBusMessageFromModelBindingData(modelBindingData);\r\n                }\r\n            );\r\n        }\r\n    } catch (error) {\r\n        throw new Error(\r\n            `Service Bus Message Factory initialization failed: ${\r\n                error instanceof Error ? error.message : String(error)\r\n            }`\r\n        );\r\n    }\r\n}\r\n","// Copyright (c) .NET Foundation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\r\n/**\r\n * Body parsing utility functions for Service Bus messages.\r\n *\r\n * With @azure/functions-extensions-servicebus v0.4.0, `message.body` is returned\r\n * as a raw Buffer instead of being auto-parsed. These helpers provide a simple,\r\n * one-line experience for the most common use cases (JSON text messages).\r\n *\r\n * @example\r\n * ```typescript\r\n * import { messageBodyAsJson, messageBodyAsText } from '@azure/functions-extensions-servicebus';\r\n *\r\n * // Parse JSON body with type safety\r\n * interface OrderMessage { orderId: string; amount: number; }\r\n * const data = messageBodyAsJson<OrderMessage>(message);\r\n *\r\n * // Get raw text\r\n * const text = messageBodyAsText(message);\r\n *\r\n * // With custom reviver (e.g., Date conversion)\r\n * const data = messageBodyAsJson<MyType>(message, (key, value) => {\r\n *     if (key === 'createdAt' && typeof value === 'string') return new Date(value);\r\n *     return value;\r\n * });\r\n * ```\r\n */\r\n\r\nconst utf8Decoder = new TextDecoder('utf-8', { fatal: true });\r\n\r\n/**\r\n * Returns the message body as a UTF-8 string.\r\n * Handles Buffer, string, and object body types.\r\n *\r\n * @param message - A message object with a `body` property (e.g., ServiceBusReceivedMessage)\r\n * @returns The body as a UTF-8 string\r\n * @throws TypeError if the body is a Buffer containing invalid UTF-8 bytes\r\n */\r\nexport function messageBodyAsText(message: { body: unknown }): string {\r\n    const body: unknown = message.body;\r\n    if (Buffer.isBuffer(body)) {\r\n        return utf8Decoder.decode(body);\r\n    }\r\n    if (typeof body === 'string') {\r\n        return body;\r\n    }\r\n    return JSON.stringify(body);\r\n}\r\n\r\n/**\r\n * Parses the message body as JSON and returns a typed result.\r\n *\r\n * @param message - A message object with a `body` property (e.g., ServiceBusReceivedMessage)\r\n * @param reviver - Optional JSON reviver function for custom deserialization\r\n * @returns The parsed body as type T\r\n * @throws TypeError if the body is a Buffer containing invalid UTF-8 bytes\r\n * @throws SyntaxError if the body is not valid JSON\r\n */\r\nexport function messageBodyAsJson<T = unknown>(\r\n    message: { body: unknown },\r\n    reviver?: (key: string, value: unknown) => unknown\r\n): T {\r\n    return JSON.parse(messageBodyAsText(message), reviver) as T;\r\n}\r\n","// Copyright (c) .NET Foundation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\r\nimport { registerServiceBusMessageFactory } from './servicebus/registerServiceBusMessageFactory';\r\n\r\nregisterServiceBusMessageFactory();\r\n\r\n// Export types for customer consumption\r\nexport type { ServiceBusMessageContext } from '../types';\r\nexport type { IServiceBusMessageActions } from '../types/settlement-types';\r\n\r\n// Export AMQP property encoding utilities\r\nexport { convertPropertiesToAmqpBytes, validateAmqpProperties } from './util/amqpPropertyEncoder';\r\n\r\n// Export body parsing helper utilities\r\nexport { messageBodyAsJson, messageBodyAsText } from './util/messageBodyParser';\r\n"],"names":["module","exports","__WEBPACK_EXTERNAL_createRequire_require","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","LockTokenUtil","convertToString","lockToken","subarray","reverse","toString","join","extractFromMessage","message","index","raw","Buffer","isBuffer","Uint8Array","slice","this","from","X_OPT_LOCK_TOKEN","ServiceBusMessageDecoder","decode","content","length","Error","indexOf","amqpSlice","originalWarn","console","warn","decodedMessage","cachedPackageDefinition","AmqpType","PRIMITIVE_TYPE_MAP","Map","Double","Boolean","String","Int64","wrapAmqpValue","type","value","rhea","BigInt","Number","MIN_SAFE_INTEGER","MAX_SAFE_INTEGER","types","wrap_long","wrap_decimal128","wrap_binary","SUPPORTED_TYPES_MESSAGE","convertPropertiesToAmqpBytes","propertiesToModify","amqpMap","entries","amqpValue","tryCreateAmqpPropertyValue","set","encodedBytes","objectMap","typedValue","wrappedMap","wrap_map","writer","Writer","write","buffer","toBuffer","error","encodeAmqpMap","encodePropertiesForOperation","operationName","keys","propertyValue","strValue","test","TypeConverters","URL","isNaN","Date","parse","numValue","isFinite","isInteger","Math","abs","bigintValue","toISOString","href","Array","isArray","map","item","getAmqpTypeIdentifier","Null","values","find","Unknown","jsType","primitiveType","DateTimeOffset","Uri","Stream","validateAmqpProperties","properties","GrpcUriBuilder","build","parsedArgs","parseArgs","args","process","argv","options","host","port","strict","grpcMaxMessageLength","missing","push","uri","ServiceBusMessageActions","client","serviceName","address","credentials","createInsecure","tempDir","tempProtoFile","packageDefinition","keepCase","longs","enums","defaults","oneofs","includeDirs","ServiceClientConstructor","createGrpcClient","getInstance","instance","validateLockToken","locktoken","complete","Promise","resolve","reject","request","code","details","abandon","encodedProperties","deadletter","deadletterReason","deadletterErrorDescription","defer","renewMessageLock","setSessionState","sessionId","sessionState","releaseSession","renewSessionLock","response","lockedUntil","err","resetInstance","SEQUENCE_NUMBER_ANNOTATION","ENQUEUED_SEQUENCE_NUMBER_ANNOTATION","AzureServiceBusMessageFactory","buildServiceBusMessageFromModelBindingData","modelBindingData","toMessage","data","createServiceBusReceivedMessageFromRhea","messages","actions","createServiceBusReceivedMessageFromAmqp","amqpMessage","body","decodeAmqpBody","messageId","correlationId","contentType","subject","to","replyTo","replyToSessionId","replyToGroupId","groupId","timeToLive","header","applicationProperties","deliveryCount","_rawAmqpMessage","enqueuedTimeUtc","extractDateFromAnnotation","messageAnnotations","lockedUntilUtc","sequenceNumber","enqueuedSequenceNumber","deadLetterReason","deadLetterErrorDescription","deadLetterSource","state","rheaMessage","AmqpAnnotatedMessage","fromRheaMessage","section","typecode","annotationValue","AZURE_SERVICE_BUS","utf8Decoder","TextDecoder","fatal","messageBodyAsText","JSON","stringify","messageBodyAsJson","reviver","resourceFactoryResolver","ResourceFactoryResolver","hasResourceFactory","registerResourceFactory","registerServiceBusMessageFactory"],"sourceRoot":""}