UNPKG

@azure/functions

Version:
1 lines 65.3 kB
(()=>{"use strict";var e={8157(e,t,r){var n,o,i,s=this&&this.__classPrivateFieldSet||function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},a=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.InvocationContext=void 0;const c=r(5396);t.InvocationContext=class{constructor(e){var t,r,o,i;n.set(this,void 0),e=e||{};const a="unknown";this.invocationId=e.invocationId||a,this.functionName=e.functionName||a,this.extraInputs=new u,this.extraOutputs=new p,this.retryContext=e.retryContext,this.traceContext=e.traceContext,this.triggerMetadata=e.triggerMetadata,this.options={trigger:(null===(t=e.options)||void 0===t?void 0:t.trigger)||{name:a,type:a},return:null===(r=e.options)||void 0===r?void 0:r.return,extraInputs:(null===(o=e.options)||void 0===o?void 0:o.extraInputs)||[],extraOutputs:(null===(i=e.options)||void 0===i?void 0:i.extraOutputs)||[]},s(this,n,e.logHandler||c.fallbackLogHandler,"f")}log(...e){a(this,n,"f").call(this,"information",...e)}trace(...e){a(this,n,"f").call(this,"trace",...e)}debug(...e){a(this,n,"f").call(this,"debug",...e)}info(...e){a(this,n,"f").call(this,"information",...e)}warn(...e){a(this,n,"f").call(this,"warning",...e)}error(...e){a(this,n,"f").call(this,"error",...e)}},n=new WeakMap;class u{constructor(){o.set(this,{})}get(e){const t="string"==typeof e?e:e.name;return a(this,o,"f")[t]}set(e,t){const r="string"==typeof e?e:e.name;a(this,o,"f")[r]=t}}o=new WeakMap;class p{constructor(){i.set(this,{})}get(e){const t="string"==typeof e?e:e.name;return a(this,i,"f")[t]}set(e,t){const r="string"==typeof e?e:e.name;a(this,i,"f")[r]=t}}i=new WeakMap},6691(e,t,r){var n,o,i,s,a,c,u,p,l,d,f,y=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((n=n.apply(e,t||[])).next())})},g=this&&this.__classPrivateFieldSet||function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},m=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.InvocationModel=void 0;const h=r(8354),v=r(6921),b=r(5521),w=r(1776),P=r(4714),O=r(679),T=r(917),C=r(2288),x=r(5064),j=r(4454),S=r(725),M=r(2337),_=r(7992),k=r(8157),R=r(9572),E=r(337),N=r(9898),A=r(9168);t.InvocationModel=class{constructor(e){n.add(this),o.set(this,!1),i.set(this,void 0),s.set(this,void 0),a.set(this,void 0),c.set(this,void 0),g(this,i,e,"f"),g(this,s,(0,A.nonNullProp)(e.metadata,"name"),"f"),g(this,a,(0,A.nonNullProp)(e.metadata,"bindings"),"f");const t=(0,A.nonNullValue)(Object.values(m(this,a,"f")).find(e=>(0,N.isTrigger)(e.type)),"triggerBinding");g(this,c,(0,A.nonNullProp)(t,"type"),"f")}getArguments(){return y(this,void 0,void 0,function*(){const e=m(this,i,"f").request,t=new k.InvocationContext({invocationId:(0,A.nonNullProp)(m(this,i,"f"),"invocationId"),functionName:m(this,s,"f"),logHandler:(e,...t)=>m(this,n,"m",f).call(this,e,...t),retryContext:(0,w.fromRpcRetryContext)(e.retryContext),traceContext:(0,w.fromRpcTraceContext)(e.traceContext),triggerMetadata:(0,P.fromRpcTriggerMetadata)(e.triggerMetadata,m(this,c,"f")),options:(0,b.fromRpcBindings)(m(this,a,"f"))}),r=[];if(e.inputData)for(const n of e.inputData){const o=(0,A.nonNullProp)(n,"name"),s=m(this,a,"f")[o];if(!s)throw new S.AzFuncSystemError(`Failed to find binding "${o}" in bindings "${Object.keys(m(this,a,"f")).join(", ")}".`);const c=s.type;let u;if((0,N.isHttpTrigger)(c)&&E.enableHttpStream){const t=yield(0,M.waitForProxyRequest)(m(this,i,"f").invocationId);u=(0,_.createStreamRequest)(t,(0,A.nonNullProp)(e,"triggerMetadata"))}else u=(0,O.fromRpcTypedData)(n.data);(0,N.isTimerTrigger)(c)&&(u=(0,T.toCamelCaseValue)(u)),(0,N.isMcpPromptTrigger)(c)&&(u=new R.PromptInvocationContext(u)),(0,N.isTrigger)(c)?r.push(u):t.extraInputs.set(o,u)}return{context:t,inputs:r}})}invokeFunction(e,t,r){return y(this,void 0,void 0,function*(){try{return yield Promise.resolve(r(...t,e))}finally{g(this,o,!0,"f")}})}getResponse(e,t){return y(this,void 0,void 0,function*(){const r={invocationId:m(this,i,"f").invocationId,outputData:[]};let o=!1;for(const[i,s]of Object.entries(m(this,a,"f")))if("out"===s.direction)if(i===v.returnBindingKey)r.returnValue=(0,N.isMcpToolTrigger)(m(this,c,"f"))?m(this,n,"m",p).call(this,e,t):yield m(this,n,"m",u).call(this,e.invocationId,s,t),o=!0;else{const t=yield m(this,n,"m",u).call(this,e.invocationId,s,e.extraOutputs.get(i));(0,A.isDefined)(t)&&r.outputData.push({name:i,data:t})}return o||(0,N.isHttpTrigger)(m(this,c,"f"))||(r.returnValue=m(this,n,"m",p).call(this,e,t)),r})}},o=new WeakMap,i=new WeakMap,s=new WeakMap,a=new WeakMap,c=new WeakMap,n=new WeakSet,u=function(e,t,r){var n;return y(this,void 0,void 0,function*(){return"http"===(null===(n=t.type)||void 0===n?void 0:n.toLowerCase())?(0,x.toRpcHttp)(e,r):(0,j.toRpcTypedData)(r)})},p=function(e,t){if(!(0,N.isMcpToolTrigger)(m(this,c,"f")))return(0,j.toRpcTypedData)(t);const r=(0,C.toMcpToolResult)(t,e);return null==r?r:{string:"string"==typeof r?r:JSON.stringify(r)}},l=function(e,t,...r){m(this,i,"f").log(e,t,(0,h.format)(...r))},d=function(e,...t){m(this,n,"m",l).call(this,e,"system",...t)},f=function(e,...t){if(m(this,o,"f")&&"postInvocationHooks"!==m(this,i,"f").state){let e="Warning: Unexpected call to 'log' on the context object after function execution has completed. Please check for asynchronous calls that are not awaited. ";e+=`Function name: ${m(this,s,"f")}. Invocation Id: ${m(this,i,"f").invocationId}.`,m(this,n,"m",d).call(this,"warning",e)}m(this,n,"m",l).call(this,e,"user",...t)}},520(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.ProgrammingModel=void 0;const o=r(6921),i=r(2337),s=r(6691),a=r(337);t.ProgrammingModel=class{constructor(){this.name="@azure/functions",this.version=o.version}getInvocationModel(e){return new s.InvocationModel(e)}getCapabilities(e){return n(this,void 0,void 0,function*(){if((0,a.lockSetup)(),a.enableHttpStream){const t=yield(0,i.setupHttpProxy)();e.HttpUri=t}return Object.assign(e,a.capabilities),e})}}},6693(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.addBindingName=void 0;const n=r(4169);t.addBindingName=function(e,t){if(!e.name){let r=e.type;r.toLowerCase().endsWith(t.toLowerCase())||(r+=t),e.name=r+(0,n.getStringHash)(JSON.stringify(e))}return e}},1859(e,t,r){var n=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.generic=t.mcpPrompt=t.mcpResource=t.mcpTool=t.webPubSub=t.mySql=t.sql=t.warmup=t.cosmosDB=t.eventGrid=t.eventHub=t.serviceBusTopic=t.serviceBusQueue=t.storageQueue=t.storageBlob=t.timer=t.http=t.deleteRequest=t.patch=t.post=t.put=t.get=t.setup=t.hook=void 0;const o=r(2757),i=r(811),s=r(520),a=r(2888),c=r(3476);t.hook=r(6765);var u=r(337);Object.defineProperty(t,"setup",{enumerable:!0,get:function(){return u.setup}});let p=!1;function l(e,t){const r="function"==typeof e?{handler:e}:e;return r.methods=[t],r}function d(e,t){const{handler:r,return:o,trigger:i,extraInputs:s,extraOutputs:a,retry:c}=e,u=n(e,["handler","return","trigger","extraInputs","extraOutputs","retry"]);return{trigger:null!=i?i:t(u),return:o,retry:c,extraInputs:s,extraOutputs:a,handler:r}}function f(e,t){t.return||(t.return=i.http({})),y(e,d(t,a.http))}function y(e,t){p||function(){const e=(0,c.tryGetCoreApiLazy)();e?e.setProgrammingModel(new s.ProgrammingModel):console.warn('WARNING: Failed to detect the Azure Functions runtime. Switching "@azure/functions" package to test mode - not all features are supported.'),p=!0}();const r=(0,c.tryGetCoreApiLazy)();r?r.registerFunction((0,o.toCoreFunctionMetadata)(e,t),t.handler):console.warn(`WARNING: Skipping call to register function "${e}" because the "@azure/functions" package is in test mode.`)}t.get=function(e,t){f(e,l(t,"GET"))},t.put=function(e,t){f(e,l(t,"PUT"))},t.post=function(e,t){f(e,l(t,"POST"))},t.patch=function(e,t){f(e,l(t,"PATCH"))},t.deleteRequest=function(e,t){f(e,l(t,"DELETE"))},t.http=f,t.timer=function(e,t){y(e,d(t,a.timer))},t.storageBlob=function(e,t){y(e,d(t,a.storageBlob))},t.storageQueue=function(e,t){y(e,d(t,a.storageQueue))},t.serviceBusQueue=function(e,t){y(e,d(t,a.serviceBusQueue))},t.serviceBusTopic=function(e,t){y(e,d(t,a.serviceBusTopic))},t.eventHub=function(e,t){y(e,d(t,a.eventHub))},t.eventGrid=function(e,t){y(e,d(t,a.eventGrid))},t.cosmosDB=function(e,t){y(e,d(t,a.cosmosDB))},t.warmup=function(e,t){y(e,d(t,a.warmup))},t.sql=function(e,t){y(e,d(t,a.sql))},t.mySql=function(e,t){y(e,d(t,a.mySql))},t.webPubSub=function(e,t){y(e,d(t,a.webPubSub))},t.mcpTool=function(e,t){y(e,d(t,a.mcpTool))},t.mcpResource=function(e,t){y(e,d(t,a.mcpResource))},t.mcpPrompt=function(e,t){y(e,d(t,a.mcpPrompt))},t.generic=y},6921(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.returnBindingKey=t.version=void 0,t.version="4.14.0",t.returnBindingKey="$return"},5521(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.fromRpcBindings=void 0;const n=r(6921),o=r(9898),i=r(9168);function s(e,t){return Object.assign(Object.assign({},t),{type:(0,i.nonNullProp)(t,"type"),name:e})}t.fromRpcBindings=function(e){let t,r;const a=[],c=[];for(const[u,p]of Object.entries((0,i.nonNullValue)(e,"bindings")))(0,o.isTrigger)(p.type)?t=s(u,p):u===n.returnBindingKey?r=s(u,p):"in"===p.direction?a.push(s(u,p)):"out"===p.direction&&c.push(s(u,p));return{trigger:(0,i.nonNullValue)(t,"trigger"),return:r,extraInputs:a,extraOutputs:c}}},1776(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.fromRpcTraceContext=t.fromRpcRetryContext=void 0;const n=r(9168);t.fromRpcRetryContext=function(e){if(e){const t={retryCount:(0,n.nonNullProp)(e,"retryCount"),maxRetryCount:(0,n.nonNullProp)(e,"maxRetryCount")};return e.exception&&(t.exception=function(e){const t={};return(0,n.copyPropIfDefined)(e,t,"message"),(0,n.copyPropIfDefined)(e,t,"source"),(0,n.copyPropIfDefined)(e,t,"stackTrace"),t}(e.exception)),t}},t.fromRpcTraceContext=function(e){if(e){const t={};return(0,n.copyPropIfDefined)(e,t,"traceParent"),(0,n.copyPropIfDefined)(e,t,"traceState"),e.attributes&&(t.attributes=e.attributes),t}}},5138(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.fromNullableMapping=void 0,t.fromNullableMapping=function(e,t){var r;let n={};if(e&&Object.keys(e).length>0)for(const t in e)n[t]=(null===(r=e[t])||void 0===r?void 0:r.value)||"";else t&&Object.keys(t).length>0&&(n=t);return n}},4714(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.fromRpcTriggerMetadata=void 0;const n=r(9898),o=r(679),i=r(917);t.fromRpcTriggerMetadata=function(e,t){if(e&&!(0,n.isHttpTrigger)(t)&&!(0,n.isTimerTrigger)(t)){const t={};for(const[r,n]of Object.entries(e))t[(0,i.toCamelCaseKey)(r)]=(0,i.toCamelCaseValue)((0,o.fromRpcTypedData)(n));return t}}},679(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.fromRpcTypedData=void 0;const n=r(6490),o=r(7992),i=r(9168);function s(e){try{return JSON.parse(e)}catch(t){return e}}t.fromRpcTypedData=function(e){var t;if(e){if((0,i.isDefined)(e.string))return s(e.string);if((0,i.isDefined)(e.json))return JSON.parse(e.json);if((0,i.isDefined)(e.bytes))return Buffer.from(e.bytes);if((0,i.isDefined)(e.stream))return Buffer.from(e.stream);if((0,i.isDefined)(e.http))return new o.HttpRequest(e.http);if((0,i.isDefined)(e.int))return e.int;if((0,i.isDefined)(e.double))return e.double;if(e.collectionBytes&&(0,i.isDefined)(e.collectionBytes.bytes))return e.collectionBytes.bytes.map(e=>Buffer.from(e));if(e.collectionString&&(0,i.isDefined)(e.collectionString.string))return e.collectionString.string.map(s);if(e.collectionDouble&&(0,i.isDefined)(e.collectionDouble.double))return e.collectionDouble.double;if(e.collectionSint64&&(0,i.isDefined)(e.collectionSint64.sint64))return e.collectionSint64.sint64;if(e.modelBindingData&&(0,i.isDefined)(e.modelBindingData.content))try{return n.ResourceFactoryResolver.getInstance().createClient(e.modelBindingData.source,e.modelBindingData)}catch(e){throw new Error(`Unable to create client. Please register the extensions library with your function app. Error: ${e instanceof Error?e.message:String(e)}`)}else if(e.collectionModelBindingData&&(0,i.isDefined)(e.collectionModelBindingData.modelBindingData)&&e.collectionModelBindingData.modelBindingData.length>0)try{return n.ResourceFactoryResolver.getInstance().createClient(null===(t=e.collectionModelBindingData.modelBindingData[0])||void 0===t?void 0:t.source,e.collectionModelBindingData.modelBindingData)}catch(e){throw new Error(`Unable to create client. Please register the extensions library with your function app. Error: ${e instanceof Error?e.message:String(e)}`)}}}},917(e,t){function r(e){return e.charAt(0).toLowerCase()+e.slice(1)}Object.defineProperty(t,"__esModule",{value:!0}),t.toCamelCaseKey=t.toCamelCaseValue=void 0,t.toCamelCaseValue=function e(t){if("object"!=typeof t||null===t)return t;if(Array.isArray(t))return t.map(e);{const n={};for(const[o,i]of Object.entries(t))n[r(o)]=e(i);return n}},t.toCamelCaseKey=r},2757(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.addSdkBindingsFlag=t.toCoreFunctionMetadata=void 0;const n=r(6921),o=r(725),i=r(9898),s=r(4893),a=r(8360);function c(e,t,r,n,o){if(void 0!==e&&!0===e){const e={operation:"EnableDeferredBinding",properties:{functionName:t||"unknown",entityType:o?"binding":"trigger",triggerType:r||"unknown",bindingOrTriggerName:n||"unknown",supportsDeferredBinding:!0},message:`Enabled Deferred Binding of type '${r||"unknown"}' for function '${t||"unknown"}'`};return(0,s.workerSystemLog)("information",JSON.stringify(e)),{supportsDeferredBinding:"true"}}return{supportsDeferredBinding:"false"}}t.toCoreFunctionMetadata=function(e,t){var r;const s={},u=[],p=t.trigger;if(s[p.name]=Object.assign(Object.assign({},p),{direction:"in",type:(0,i.isTrigger)(p.type)?p.type:p.type+"Trigger",properties:c(null===(r=t.trigger)||void 0===r?void 0:r.sdkBinding,e,p.type,p.name,!1)}),u.push(p.name),t.extraInputs)for(const r of t.extraInputs)s[r.name]=Object.assign(Object.assign({},r),{direction:"in",properties:c(null==r?void 0:r.sdkBinding,e,r.type,r.name,!0)}),u.push(r.name);if(t.return&&(s[n.returnBindingKey]=Object.assign(Object.assign({},t.return),{direction:"out"}),u.push(n.returnBindingKey)),t.extraOutputs)for(const e of t.extraOutputs)s[e.name]=Object.assign(Object.assign({},e),{direction:"out"}),u.push(e.name);if(u.filter((e,t)=>u.indexOf(e)!==t).length>0)throw new o.AzFuncSystemError(`Duplicate bindings found for function "${e}". Remove a duplicate binding or manually specify the "name" property to make it unique.`);let l;return t.retry&&(l=Object.assign(Object.assign({},t.retry),{retryStrategy:t.retry.strategy,delayInterval:(0,a.toRpcDuration)(t.retry.delayInterval,"retry.delayInterval"),maximumInterval:(0,a.toRpcDuration)(t.retry.maximumInterval,"retry.maximumInterval"),minimumInterval:(0,a.toRpcDuration)(t.retry.minimumInterval,"retry.minimumInterval")})),{name:e,bindings:s,retryOptions:l}},t.addSdkBindingsFlag=c},5111(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.convertToMcpPromptTriggerOptionsToRpc=void 0;const n=r(9855);t.convertToMcpPromptTriggerOptionsToRpc=function(e){if(!e.promptName||"string"!=typeof e.promptName||""===e.promptName.trim())throw new Error('MCP Prompt trigger requires a valid "promptName" property.');const t=function(e){if(!e)return"[]";const t=Array.isArray(e)?e:Object.entries(e).map(([e,t])=>{if(!(t instanceof n.McpPromptArgumentBuilder))throw new Error('MCP Prompt trigger "promptArguments" record values must be created with `promptArg.describe(...)`.');return t.toPromptArgument(e)});if(0===t.length)return"[]";const r=t.map(e=>{var t;if(!e.name||"string"!=typeof e.name||""===e.name.trim())throw new Error('MCP Prompt trigger "promptArguments" entries require a non-empty "name".');return{name:e.name,description:null!==(t=e.description)&&void 0!==t?t:null,required:!0===e.required}});return JSON.stringify(r)}(e.promptArguments),r={promptName:e.promptName,promptArguments:t};if(void 0!==e.title&&(r.title=e.title),void 0!==e.description&&(r.description=e.description),void 0!==e.metadata&&"string"==typeof e.metadata&&""!==e.metadata.trim()){try{JSON.parse(e.metadata)}catch(e){throw new Error('MCP Prompt trigger "metadata" must be a valid JSON string.')}r.metadata=e.metadata}if(void 0!==e.icons&&"string"==typeof e.icons&&""!==e.icons.trim()){try{JSON.parse(e.icons)}catch(e){throw new Error('MCP Prompt trigger "icons" must be a valid JSON string.')}r.icons=e.icons}return r}},8329(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.convertToMcpResourceTriggerOptionsToRpc=void 0,t.convertToMcpResourceTriggerOptionsToRpc=function(e){if(!e.uri||"string"!=typeof e.uri||""===e.uri.trim())throw new Error('MCP Resource trigger requires a valid "uri" property.');if(!e.resourceName||"string"!=typeof e.resourceName||""===e.resourceName.trim())throw new Error('MCP Resource trigger requires a valid "resourceName" property.');const t={uri:e.uri,resourceName:e.resourceName};if(void 0!==e.title&&(t.title=e.title),void 0!==e.description&&(t.description=e.description),void 0!==e.mimeType&&(t.mimeType=e.mimeType),void 0!==e.size){if("number"!=typeof e.size||e.size<0)throw new Error('MCP Resource trigger "size" must be a non-negative number.');t.size=e.size}if(void 0!==e.metadata&&"string"==typeof e.metadata&&""!==e.metadata.trim()){try{JSON.parse(e.metadata)}catch(e){throw new Error('MCP Resource trigger "metadata" must be a valid JSON string.')}t.metadata=e.metadata}return t}},2288(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.toMcpToolResult=void 0;const n=r(8642),o=r(5665),i=r(6199),s="text";function a(e){const t=function(e){if(null===e.structuredContent||void 0===e.structuredContent)return e.content;if(e.content.some(e=>e instanceof n.McpTextContent))return e.content;const t="string"==typeof e.structuredContent?e.structuredContent:JSON.stringify(e.structuredContent);return[...e.content,new n.McpTextContent(t)]}(e);let r,o;if(1===t.length){const[e]=t;r=e.type,o=JSON.stringify(e)}else r="multi_content_result",o=JSON.stringify(t);const i={type:r,content:o};return void 0!==e.structuredContent&&null!==e.structuredContent&&(i.structuredContent="string"==typeof e.structuredContent?e.structuredContent:JSON.stringify(e.structuredContent)),i}t.toMcpToolResult=function(e,t){if(null==e)return e;if(e instanceof n.McpToolResponse)return a(e);if(e instanceof n.McpContentBlock)return a(new n.McpToolResponse({content:[e]}));if(Array.isArray(e)&&e.length>0&&e.every(e=>e instanceof n.McpContentBlock))return a(new n.McpToolResponse({content:e}));(0,o.warnIfLooksLikeMcpSdkValue)(e,t);const r="string"==typeof e?e:JSON.stringify(e),c={type:s,content:JSON.stringify({type:s,text:r})};return(0,i.shouldCreateStructuredContentMarker)(e)&&(c.structuredContent=JSON.stringify(e)),c}},5571(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.converToMcpToolTriggerOptionsToRpc=void 0;const n=r(7175);t.converToMcpToolTriggerOptionsToRpc=function(e){let t,r;if(void 0!==e.metadata&&"string"==typeof e.metadata&&""!==e.metadata.trim())try{JSON.parse(e.metadata),t=e.metadata}catch(e){throw new Error('MCP Tool trigger "metadata" must be a valid JSON string.')}if(void 0!==e.resultSchema&&"string"==typeof e.resultSchema&&""!==e.resultSchema.trim())try{JSON.parse(e.resultSchema),r=e.resultSchema}catch(e){throw new Error('MCP Tool trigger "resultSchema" must be a valid JSON string.')}const o=Object.assign(Object.assign({toolName:e.toolName,description:e.description,useResultSchema:!0},void 0!==t&&{metadata:t}),void 0!==r&&{resultSchema:r});let i;try{i=(0,n.normalizeToolProperties)(e.toolProperties)}catch(e){if(e instanceof Error&&(e.message.includes("Property type is required")||e.message.includes("Property type must be specified")))throw e;i=void 0}if(void 0!==i)return Object.assign(Object.assign({},o),{toolProperties:JSON.stringify(i)});throw new Error(`Invalid toolProperties for tool '${e.toolName}': Expected an array of McpToolProperty or ToolProps objects or ToolProps need a type defined.`)}},8360(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.toRpcDuration=void 0;const n=r(725),o=r(9168);t.toRpcDuration=function(e,t){if((0,o.isDefined)(e)){try{let t;if("object"==typeof e){const r=(e.minutes||0)+60*(e.hours||0),n=(e.seconds||0)+60*r;t=(e.milliseconds||0)+1e3*n}else"number"==typeof e&&(t=e);if((0,o.isDefined)(t)&&t>=0)return{seconds:Math.round(t/1e3)}}catch(e){}throw new n.AzFuncSystemError(`A 'number' or 'Duration' object was expected instead of a '${typeof e}'. Cannot parse value of '${t}'.`)}}},5064(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.toRpcHttp=void 0;const o=r(725),i=r(2337),s=r(8950),a=r(337),c=r(7866),u=r(4454);t.toRpcHttp=function(e,t){return n(this,void 0,void 0,function*(){if(null==t)return t;if("object"!=typeof t)throw new o.AzFuncSystemError('The HTTP response must be an object with optional properties "body", "status", "headers", and "cookies".');const r=t instanceof s.HttpResponse?t:new s.HttpResponse(t);if(a.enableHttpStream)return void(yield(0,i.sendProxyResponse)(e,r));const n={};n.statusCode=r.status.toString(),n.headers={};for(const[e,t]of r.headers.entries())n.headers[e]=t;n.cookies=[];for(const e of r.cookies)n.cookies.push((0,c.toRpcHttpCookie)(e));n.enableContentNegotiation=r.enableContentNegotiation;const p=yield r.arrayBuffer();return n.body=(0,u.toRpcTypedData)(p),{http:n}})}},7866(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.toRpcHttpCookie=void 0;const n=r(1705);t.toRpcHttpCookie=function(e){let t="none";if(e&&e.sameSite){const r=e.sameSite.toLocaleLowerCase();"lax"===r?t="lax":"strict"===r?t="strict":"none"===r&&(t="explicitNone")}return{name:e&&(0,n.toRpcString)(e.name,"cookie.name"),value:e&&(0,n.toRpcString)(e.value,"cookie.value"),domain:(0,n.toNullableString)(e&&e.domain,"cookie.domain"),path:(0,n.toNullableString)(e&&e.path,"cookie.path"),expires:(0,n.toNullableTimestamp)(e&&e.expires,"cookie.expires"),secure:(0,n.toNullableBool)(e&&e.secure,"cookie.secure"),httpOnly:(0,n.toNullableBool)(e&&e.httpOnly,"cookie.httpOnly"),sameSite:t,maxAge:(0,n.toNullableDouble)(e&&e.maxAge,"cookie.maxAge")}}},1705(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.toNullableTimestamp=t.toNullableString=t.toRpcString=t.toNullableDouble=t.toNullableBool=void 0;const n=r(725),o=r(9168);t.toNullableBool=function(e,t){if("boolean"==typeof e)return{value:e};if((0,o.isDefined)(e))throw new n.AzFuncSystemError(`A 'boolean' type was expected instead of a '${typeof e}' type. Cannot parse value of '${t}'.`)},t.toNullableDouble=function(e,t){if("number"==typeof e)return{value:e};if("string"==typeof e&&!isNaN(Number(e)))return{value:parseFloat(e)};if((0,o.isDefined)(e))throw new n.AzFuncSystemError(`A 'number' type was expected instead of a '${typeof e}' type. Cannot parse value of '${t}'.`)},t.toRpcString=function(e,t){if("string"==typeof e)return e;if((0,o.isDefined)(e))throw new n.AzFuncSystemError(`A 'string' type was expected instead of a '${typeof e}' type. Cannot parse value of '${t}'.`);return""},t.toNullableString=function(e,t){if("string"==typeof e)return{value:e};if((0,o.isDefined)(e))throw new n.AzFuncSystemError(`A 'string' type was expected instead of a '${typeof e}' type. Cannot parse value of '${t}'.`)},t.toNullableTimestamp=function(e,t){if((0,o.isDefined)(e))try{const t="number"==typeof e?e:e.getTime();if(t&&t>=0)return{value:{seconds:Math.round(t/1e3)}}}catch(r){throw new n.AzFuncSystemError(`A 'number' or 'Date' input was expected instead of a '${typeof e}'. Cannot parse value of '${t}'.`)}}},4454(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.toRpcTypedData=void 0,t.toRpcTypedData=function(e){return null==e?e:"string"==typeof e?{string:e}:Buffer.isBuffer(e)?{bytes:e}:ArrayBuffer.isView(e)?{bytes:new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}:e instanceof ArrayBuffer?{bytes:new Uint8Array(e)}:"number"==typeof e?Number.isInteger(e)?{int:e}:{double:e}:{json:JSON.stringify(e)}}},725(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isError=t.trySetErrorMessage=t.ensureErrorType=t.ReadOnlyError=t.AzFuncRangeError=t.AzFuncTypeError=t.AzFuncSystemError=void 0;class r extends Error{constructor(){super(...arguments),this.isAzureFunctionsSystemError=!0}}t.AzFuncSystemError=r;class n extends TypeError{constructor(){super(...arguments),this.isAzureFunctionsSystemError=!0}}t.AzFuncTypeError=n;class o extends RangeError{constructor(){super(...arguments),this.isAzureFunctionsSystemError=!0}}t.AzFuncRangeError=o,t.ReadOnlyError=class extends n{constructor(e){super(`Cannot assign to read only property '${e}'`)}},t.ensureErrorType=function(e){if(e instanceof Error)return e;{let t;return t=null==e?"Unknown error":"string"==typeof e?e:"object"==typeof e?JSON.stringify(e):String(e),new Error(t)}},t.trySetErrorMessage=function(e,t){try{e.message=t}catch(e){}},t.isError=function(e){return null!=e}},7531(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.AppStartContext=void 0;const n=r(5789);class o extends n.HookContext{}t.AppStartContext=o},4586(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.AppTerminateContext=void 0;const n=r(5789);class o extends n.HookContext{}t.AppTerminateContext=o},5789(e,t,r){var n,o=this&&this.__classPrivateFieldSet||function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},i=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.HookContext=void 0;const s=r(725),a=r(9168);t.HookContext=class{constructor(e){var t,r;n.set(this,void 0),o(this,n,null!=e?e:{},"f"),null!==(t=(r=i(this,n,"f")).hookData)&&void 0!==t||(r.hookData={})}get hookData(){return(0,a.nonNullProp)(i(this,n,"f"),"hookData")}set hookData(e){throw new s.ReadOnlyError("hookData")}},n=new WeakMap},9463(e,t,r){var n,o=this&&this.__classPrivateFieldSet||function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},i=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.InvocationHookContext=void 0;const s=r(725),a=r(8157),c=r(9168),u=r(5789);class p extends u.HookContext{constructor(e){var t,r,s,c;super(e),n.set(this,void 0),o(this,n,null!=e?e:{},"f"),null!==(t=(s=i(this,n,"f")).inputs)&&void 0!==t||(s.inputs=[]),null!==(r=(c=i(this,n,"f")).invocationContext)&&void 0!==r||(c.invocationContext=new a.InvocationContext)}get invocationContext(){return(0,c.nonNullProp)(i(this,n,"f"),"invocationContext")}set invocationContext(e){throw new s.ReadOnlyError("invocationContext")}get inputs(){return(0,c.nonNullProp)(i(this,n,"f"),"inputs")}set inputs(e){i(this,n,"f").inputs=e}}t.InvocationHookContext=p,n=new WeakMap},5407(e,t,r){var n,o=this&&this.__classPrivateFieldSet||function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},i=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogHookContext=void 0;const s=r(725),a=r(9168),c=r(5789);class u extends c.HookContext{constructor(e){var t,r,s,a,c,u;super(e),n.set(this,void 0),o(this,n,null!=e?e:{},"f"),null!==(t=(a=i(this,n,"f")).level)&&void 0!==t||(a.level="information"),null!==(r=(c=i(this,n,"f")).message)&&void 0!==r||(c.message="unknown"),null!==(s=(u=i(this,n,"f")).category)&&void 0!==s||(u.category="user")}get level(){return(0,a.nonNullProp)(i(this,n,"f"),"level")}set level(e){i(this,n,"f").level=e}get message(){return(0,a.nonNullProp)(i(this,n,"f"),"message")}set message(e){i(this,n,"f").message=e}get category(){return(0,a.nonNullProp)(i(this,n,"f"),"category")}set category(e){throw new s.ReadOnlyError("category")}get invocationContext(){return i(this,n,"f").invocationContext}set invocationContext(e){throw new s.ReadOnlyError("invocationContext")}}t.LogHookContext=u,n=new WeakMap},7508(e,t,r){var n,o=this&&this.__classPrivateFieldSet||function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},i=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.PostInvocationContext=void 0;const s=r(9463);class a extends s.InvocationHookContext{constructor(e){super(e),n.set(this,void 0),o(this,n,null!=e?e:{},"f")}get result(){return i(this,n,"f").result}set result(e){i(this,n,"f").result=e}get error(){return i(this,n,"f").error}set error(e){i(this,n,"f").error=e}}t.PostInvocationContext=a,n=new WeakMap},8561(e,t,r){var n,o=this&&this.__classPrivateFieldSet||function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},i=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.PreInvocationContext=void 0;const s=r(9168),a=r(9463);class c extends a.InvocationHookContext{constructor(e){var t,r;super(e),n.set(this,void 0),o(this,n,null!=e?e:{},"f"),null!==(t=(r=i(this,n,"f")).functionCallback)&&void 0!==t||(r.functionCallback=()=>{})}get functionHandler(){return(0,s.nonNullProp)(i(this,n,"f"),"functionCallback")}set functionHandler(e){i(this,n,"f").functionCallback=e}}t.PreInvocationContext=c,n=new WeakMap},6765(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.log=t.postInvocation=t.preInvocation=t.appTerminate=t.appStart=void 0;const n=r(725),o=r(1898),i=r(3476),s=r(7531),a=r(4586),c=r(5407),u=r(7508),p=r(8561);function l(e,t){const r=(0,i.tryGetCoreApiLazy)();return r?r.registerHook(e,t):(console.warn(`WARNING: Skipping call to register ${e} hook because the "@azure/functions" package is in test mode.`),new o.Disposable(()=>{console.warn(`WARNING: Skipping call to dispose ${e} hook because the "@azure/functions" package is in test mode.`)}))}t.appStart=function(e){return l("appStart",t=>e(new s.AppStartContext(t)))},t.appTerminate=function(e){return l("appTerminate",t=>e(new a.AppTerminateContext(t)))},t.preInvocation=function(e){return l("preInvocation",t=>e(new p.PreInvocationContext(t)))},t.postInvocation=function(e){return l("postInvocation",t=>e(new u.PostInvocationContext(t)))},t.log=function(e){try{return l("log",t=>e(new c.LogHookContext(t)))}catch(e){const t=(0,n.ensureErrorType)(e);throw"RangeError"===t.name&&t.isAzureFunctionsSystemError?new n.AzFuncSystemError("Log hooks require Azure Functions Host v4.34 or higher."):e}}},7992(e,t,r){var n,o,i,s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((n=n.apply(e,t||[])).next())})},a=this&&this.__classPrivateFieldSet||function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},c=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)},u=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.createStreamRequest=t.HttpRequest=void 0;const p=r(9551),l=r(5138),d=r(679),f=r(725),y=r(9168),g=r(8529);class m{constructor(e){var t,r,s;n.set(this,void 0),o.set(this,void 0),i.set(this,void 0),a(this,i,e,"f");let u=e.nativeRequest;if(!u){const n=(0,y.nonNullProp)(e,"url");let o;(null===(t=e.body)||void 0===t?void 0:t.bytes)?o=Buffer.from(null===(r=e.body)||void 0===r?void 0:r.bytes):(null===(s=e.body)||void 0===s?void 0:s.string)&&(o=e.body.string),u=new Request(n,{body:o,method:(0,y.nonNullProp)(e,"method"),headers:(0,l.fromNullableMapping)(e.nullableHeaders,e.headers)})}a(this,o,u,"f"),e.nullableQuery||e.query?this.query=new p.URLSearchParams((0,l.fromNullableMapping)(e.nullableQuery,e.query)):this.query=new URL(c(this,o,"f").url).searchParams,this.params=(0,l.fromNullableMapping)(e.nullableParams,e.params)}get url(){return c(this,o,"f").url}get method(){return c(this,o,"f").method}get headers(){return c(this,o,"f").headers}get user(){return void 0===c(this,n,"f")&&a(this,n,(0,g.extractHttpUserFromHeaders)(this.headers),"f"),c(this,n,"f")}get body(){return c(this,o,"f").body}get bodyUsed(){return c(this,o,"f").bodyUsed}arrayBuffer(){return s(this,void 0,void 0,function*(){return c(this,o,"f").arrayBuffer()})}blob(){return s(this,void 0,void 0,function*(){return c(this,o,"f").blob()})}formData(){return s(this,void 0,void 0,function*(){return c(this,o,"f").formData()})}json(){return s(this,void 0,void 0,function*(){return c(this,o,"f").json()})}text(){return s(this,void 0,void 0,function*(){return c(this,o,"f").text()})}clone(){const e=c(this,i,"f"),{nativeRequest:t}=e,r=u(e,["nativeRequest"]),n=structuredClone(r);return n.nativeRequest=c(this,o,"f").clone(),new m(n)}}t.HttpRequest=m,n=new WeakMap,o=new WeakMap,i=new WeakMap,t.createStreamRequest=function(e,t){var r;const n="x-forwarded-host",o="x-forwarded-proto",i=e.headers[n],s=e.headers[o];if("string"!=typeof i||"string"!=typeof s)throw new f.AzFuncSystemError(`Expected headers "${n}" and "${o}" to be set.`);const a=`${s}://${i}${(0,y.nonNullProp)(e,"url")}`;let c;const p=null===(r=e.method)||void 0===r?void 0:r.toLowerCase();"get"!==p&&"head"!==p&&(c=e);const{Query:l,Headers:g}=t,h=u(t,["Query","Headers"]);let v;const b=(0,d.fromRpcTypedData)(g);"object"==typeof b&&(0,y.isDefined)(b)&&(v=b);const w=new Request(a,{body:c,duplex:"half",method:(0,y.nonNullProp)(e,"method"),headers:v}),P={};for(const[e,t]of Object.entries(h))(0,y.isDefined)(t.string)&&(P[e]=t.string);return new m({nativeRequest:w,params:P})}},8950(e,t,r){var n,o,i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((n=n.apply(e,t||[])).next())})},s=this&&this.__classPrivateFieldSet||function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},a=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.HttpResponse=void 0;const c=r(9168);class u{constructor(e){var t;if(n.set(this,void 0),o.set(this,void 0),null!=e||(e={}),s(this,o,e,"f"),e.nativeResponse)s(this,n,e.nativeResponse,"f");else{const t={status:e.status,headers:e.headers};if((0,c.isDefined)(e.jsonBody)){const r=JSON.stringify(e.jsonBody),o=new Headers(t.headers);o.has("content-type")||o.set("content-type","application/json"),s(this,n,new Response(r,Object.assign(Object.assign({},t),{headers:o})),"f")}else s(this,n,new Response(e.body,t),"f")}this.cookies=null!==(t=e.cookies)&&void 0!==t?t:[],this.enableContentNegotiation=!!e.enableContentNegotiation}get status(){return a(this,n,"f").status}get headers(){return a(this,n,"f").headers}get body(){return a(this,n,"f").body}get bodyUsed(){return a(this,n,"f").bodyUsed}arrayBuffer(){return i(this,void 0,void 0,function*(){return a(this,n,"f").arrayBuffer()})}blob(){return i(this,void 0,void 0,function*(){return a(this,n,"f").blob()})}formData(){return i(this,void 0,void 0,function*(){return a(this,n,"f").formData()})}json(){return i(this,void 0,void 0,function*(){return a(this,n,"f").json()})}text(){return i(this,void 0,void 0,function*(){return a(this,n,"f").text()})}clone(){const e=structuredClone(a(this,o,"f"));return e.nativeResponse=a(this,n,"f").clone(),new u(e)}}t.HttpResponse=u,n=new WeakMap,o=new WeakMap},8529(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.extractHttpUserFromHeaders=void 0;const n=r(9168);t.extractHttpUserFromHeaders=function(e){let t=null;const r=e.get("x-ms-client-principal");if(r){const o=JSON.parse(Buffer.from(r,"base64").toString("utf-8"));t=o.identityProvider?{type:"StaticWebApps",id:o.userId,username:o.userDetails,identityProvider:o.identityProvider,claimsPrincipalData:o}:{type:"AppService",id:(0,n.nonNullValue)(e.get("x-ms-client-principal-id"),"user-id"),username:(0,n.nonNullValue)(e.get("x-ms-client-principal-name"),"user-name"),identityProvider:(0,n.nonNullValue)(e.get("x-ms-client-principal-idp"),"user-idp"),claimsPrincipalData:o}}return t}},2337(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((n=n.apply(e,t||[])).next())})},o=this&&this.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,o){!function(e,t,r,n){Promise.resolve(n).then(function(t){e({value:t,done:r})},t)}(n,o,(t=e[r](t)).done,t.value)})}}};Object.defineProperty(t,"__esModule",{value:!0}),t.setupHttpProxy=t.sendProxyResponse=t.waitForProxyRequest=void 0;const i=r(5096),s=r(4735),a=r(1630),c=r(1645),u=r(725),p=r(9168),l=r(4893),d={},f={},y=new s.EventEmitter;t.waitForProxyRequest=function(e){return n(this,void 0,void 0,function*(){return new Promise((t,r)=>{const n=d[e];n?(t(n),delete d[e]):y.once(e,()=>{const r=d[e];r&&(t(r),delete d[e])})})})};const g="x-ms-invocation-id";t.sendProxyResponse=function(e,t){var r,s,a,c;return n(this,void 0,void 0,function*(){const n=(0,p.nonNullProp)(f,e);delete f[e];for(const[e,r]of t.headers.entries())n.setHeader(e,r);if(n.setHeader(g,e),n.statusCode=t.status,t.cookies.length>0&&function(e,t){const r=e.cookies.map(e=>{let t;switch(e.sameSite){case"Lax":t="lax";break;case"None":t="none";break;case"Strict":t="strict";break;default:t=e.sameSite}return(0,i.serialize)(e.name,e.value,{domain:e.domain,path:e.path,expires:"number"==typeof e.expires?new Date(e.expires):e.expires,secure:e.secure,httpOnly:e.httpOnly,sameSite:t,maxAge:e.maxAge})});t.setHeader("Set-Cookie",r)}(t,n),t.body)try{for(var u,l=!0,d=o(t.body.values());u=yield d.next(),!(r=u.done);){c=u.value,l=!1;try{const e=c;n.write(e)}finally{l=!0}}}catch(e){s={error:e}}finally{try{l||r||!(a=d.return)||(yield a.call(d))}finally{if(s)throw s.error}}n.end()})},t.setupHttpProxy=function(){return n(this,void 0,void 0,function*(){return new Promise((e,t)=>{const r=a.createServer();r.on("request",(e,t)=>{const r=e.headers[g];"string"==typeof r?(d[r]=e,f[r]=t,y.emit(r)):(0,l.workerSystemLog)("error",`Http proxy request missing header ${g}`)}),r.on("error",e=>{e=(0,u.ensureErrorType)(e),(0,l.workerSystemLog)("error",`Http proxy error: ${e.stack||e.message}`)}),r.listen(()=>{const n=r.address();null!==n&&"object"==typeof n?0===n.port?((0,l.workerSystemLog)("debug","Port 0 assigned. Finding open port."),function(e){const t=c.createServer();!function r(n){if(n>55025)throw new u.AzFuncSystemError("No available ports found between 55000 and 55025. To enable HTTP streaming, please open a port in this range.");t.once("error",()=>{r(n+1)}),t.once("listening",()=>{const r=t.address();null!==r&&"object"==typeof r&&(n=r.port,t.close(),e(n))}),t.listen(n)}(55e3)}(t=>{r.close(),r.listen(t,()=>{(0,l.workerSystemLog)("debug",`Server is now listening on found open port: ${t}`)}),e(`http://localhost:${t}/`)})):((0,l.workerSystemLog)("debug",`Auto-assigned port is valid. Port: ${n.port}`),e(`http://localhost:${n.port}/`)):t(new u.AzFuncSystemError("Unexpected server address during http proxy setup"))}),r.on("close",()=>{(0,l.workerSystemLog)("information","Http proxy closing")})})})}},8156(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.MySqlChangeOperation=t.SqlChangeOperation=t.arg=t.McpContent=t.Disposable=t.trigger=t.output=t.PromptInvocationContext=t.McpToolResponse=t.McpTextContent=t.McpResourceLinkContent=t.McpResourceContent=t.McpImageContent=t.McpContentBlock=t.McpAudioContent=t.promptArg=t.InvocationContext=t.input=t.HttpResponse=t.HttpRequest=t.PreInvocationContext=t.PostInvocationContext=t.LogHookContext=t.InvocationHookContext=t.HookContext=t.AppTerminateContext=t.AppStartContext=t.app=void 0,t.app=r(1859);var n=r(7531);Object.defineProperty(t,"AppStartContext",{enumerable:!0,get:function(){return n.AppStartContext}});var o=r(4586);Object.defineProperty(t,"AppTerminateContext",{enumerable:!0,get:function(){return o.AppTerminateContext}});var i=r(5789);Object.defineProperty(t,"HookContext",{enumerable:!0,get:function(){return i.HookContext}});var s=r(9463);Object.defineProperty(t,"InvocationHookContext",{enumerable:!0,get:function(){return s.InvocationHookContext}});var a=r(5407);Object.defineProperty(t,"LogHookContext",{enumerable:!0,get:function(){return a.LogHookContext}});var c=r(7508);Object.defineProperty(t,"PostInvocationContext",{enumerable:!0,get:function(){return c.PostInvocationContext}});var u=r(8561);Object.defineProperty(t,"PreInvocationContext",{enumerable:!0,get:function(){return u.PreInvocationContext}});var p=r(7992);Object.defineProperty(t,"HttpRequest",{enumerable:!0,get:function(){return p.HttpRequest}});var l=r(8950);Object.defineProperty(t,"HttpResponse",{enumerable:!0,get:function(){return l.HttpResponse}}),t.input=r(4788);var d=r(8157);Object.defineProperty(t,"InvocationContext",{enumerable:!0,get:function(){return d.InvocationContext}});var f=r(9855);Object.defineProperty(t,"promptArg",{enumerable:!0,get:function(){return f.promptArg}});var y=r(8642);Object.defineProperty(t,"McpAudioContent",{enumerable:!0,get:function(){return y.McpAudioContent}}),Object.defineProperty(t,"McpContentBlock",{enumerable:!0,get:function(){return y.McpContentBlock}}),Object.defineProperty(t,"McpImageContent",{enumerable:!0,get:function(){return y.McpImageContent}}),Object.defineProperty(t,"McpResourceContent",{enumerable:!0,get:function(){return y.McpResourceContent}}),Object.defineProperty(t,"McpResourceLinkContent",{enumerable:!0,get:function(){return y.McpResourceLinkContent}}),Object.defineProperty(t,"McpTextContent",{enumerable:!0,get:function(){return y.McpTextContent}}),Object.defineProperty(t,"McpToolResponse",{enumerable:!0,get:function(){return y.McpToolResponse}});var g=r(9572);Object.defineProperty(t,"PromptInvocationContext",{enumerable:!0,get:function(){return g.PromptInvocationContext}}),t.output=r(811),t.trigger=r(2888);var m=r(1898);Object.defineProperty(t,"Disposable",{enumerable:!0,get:function(){return m.Disposable}});var h=r(6199);Object.defineProperty(t,"McpContent",{enumerable:!0,get:function(){return h.McpContent}});var v,b,w=r(7175);Object.defineProperty(t,"arg",{enumerable:!0,get:function(){return w.arg}}),(b=t.SqlChangeOperation||(t.SqlChangeOperation={}))[b.Insert=0]="Insert",b[b.Update=1]="Update",b[b.Delete=2]="Delete",(v=t.MySqlChangeOperation||(t.MySqlChangeOperation={}))[v.Update=0]="Update"},4788(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.generic=t.webPubSubContext=t.webPubSubConnection=t.mySql=t.sql=t.cosmosDB=t.table=t.storageBlob=void 0;const n=r(6693);function o(e){return(0,n.addBindingName)(e,"Input")}t.storageBlob=function(e){return o(Object.assign(Object.assign({},e),{type:"blob"}))},t.table=function(e){return o(Object.assign(Object.assign({},e),{type:"table"}))},t.cosmosDB=function(e){return o(Object.assign(Object.assign({},e),{type:"cosmosDB"}))},t.sql=function(e){return o(Object.assign(Object.assign({},e),{type:"sql"}))},t.mySql=function(e){return o(Object.assign(Object.assign({},e),{type:"mysql"}))},t.webPubSubConnection=function(e){return o(Object.assign(Object.assign({},e),{type:"webPubSubConnection"}))},t.webPubSubContext=function(e){return o(Object.assign(Object.assign({},e),{type:"webPubSubContext"}))},t.generic=function(e){return o(e)}},9855(e,t){Object.defineP