import{b as $}from"./chunk-3RJU5ZQH.js";import{a as S}from"./chunk-4Z6FRN6X.js";import{L as E,n as M,s as R}from"./chunk-D3R64VAA.js";import m,{createContext as _,isValidElement as F,memo as p,useCallback as V,useContext as j,useMemo as v}from"react";function q(e){return e?.$$typeof?.toString()==="Symbol(react.context)"}function A(e){return e?.$$typeof?.toString()==="Symbol(react.provider)"}function T(e){return e?.toString()==="Symbol(react.fragment)"}function B(e){return typeof e=="function"?!0:U(e)}function U(e){return e?.$$typeof?.toString()==="Symbol(react.memo)"&&B(e.type)}function I(e){return typeof e=="object"&&typeof e?.render=="function"}function D(e){return B(e)||I(e)||T(e)||q(e)||A(e)}var G=D;function H(e={}){let c=_({get enhancer(){},useBuildComponentCallback(r,t){if(!t?.fallbackComponent)throw new Error("This component/hook cannot be used outside of its corresponding <Provider>");return t.fallbackComponent}});function y({children:r,init:t,middleware:n}){if(!Array.isArray(n)||n.some(i=>typeof i!="function"))throw new Error("middleware prop must be an array of functions");let u=Object.freeze(n?n.map(i=>h=>{let z=i(h);return N=>w=>{let O,s=z(k=>{if(O)throw new Error("next() cannot be called after the function had returned synchronously");return!e.passModifiedRequest&&k!==w&&console.warn('react-chain-of-responsibility: "options.passModifiedRequest" must be set to true to pass a different request object to next().'),N(e.passModifiedRequest?k:w)})(w);if(O=!0,F(s))throw new Error("middleware must not return React element directly");if(s!==!1&&s!==null&&typeof s<"u"&&!G(s))throw new Error("middleware must return false, null, undefined, function component, or class component");return s}}):[]),{enhancer:o}=j(c),a=v(()=>S(...u,...o?[()=>o]:[])(t),[t,n,o]),l=V((i,h={})=>a(()=>h.fallbackComponent)(i)||void 0,[a]),C=v(()=>({enhancer:a,useBuildComponentCallback:l}),[a,l]);return m.createElement(c.Provider,{value:C},r)}let f=()=>j(c).useBuildComponentCallback;function d({fallbackComponent:r,request:t,...n}){let o=f()(t,{fallbackComponent:r});return o?m.createElement(o,{...n}):null}return Object.freeze({asMiddleware:r=>t=>n=>u=>{let o=n(u),a=l=>{let C=v(()=>Object.freeze({init:t,Next:p(o?i=>m.createElement(o,{...l,...i}):()=>null),request:u}),[]);return m.createElement(r,{...l,middleware:C})};return a.displayName=`MiddlewareOf<${r.displayName||""}>`,p(a)},Provider:p(y),Proxy:p(d),types:Object.freeze({middlewareComponentProps:void 0,init:void 0,middleware:void 0,props:void 0,proxyProps:void 0,request:void 0}),useBuildComponentCallback:f})}var x=H;import J,{memo as K}from"react";var L=M(R()),g=Symbol(),Q=e=>E(L,e).success,W=Object.freeze([]);function X(e){let P=r=>{let t=n=>n===e&&r;return t[g]=g,t},c=$(`Middleware passed for extraction of "${e}" must be an array of function`),y=r=>{if(r){if(Q(r))return Object.freeze(r.map(t=>{let n=t(e);return typeof n!="function"&&n!==!1?(console.warn(`botframework-webchat: ${e}.middleware must return enhancer function or false`),!1):n}).filter(t=>!!t).map(t=>()=>t));c()}return W},{Provider:f,Proxy:d}=x(),b=K(function({children:r,middleware:t}){return J.createElement(f,{init:e,middleware:t},r)});return b.displayName=`${e}Provider`,d.displayName=`${e}Proxy`,{createMiddleware:P,extractMiddleware:y,Provider:b,Proxy:d,"~types":void 0}}var se=X;export{x as a,g as b,se as c};
//# sourceMappingURL=chunk-INTD3ZAR.js.map
