(function(g,P){typeof exports=="object"&&typeof module<"u"?P(exports,require("react"),require("react/jsx-runtime")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime"],P):(g=typeof globalThis<"u"?globalThis:g||self,P(g.ContextHelper={},g.React,g.jsxRuntime))})(this,function(g,P,z){"use strict";function y(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n3?t.i-4:t.i:Array.isArray(e)?1:U(e)?2:q(e)?3:0}function k(e,t){return I(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function me(e,t){return I(e)===2?e.get(t):e[t]}function ne(e,t,r){var n=I(e);n===2?e.set(t,r):n===3?(e.delete(t),e.add(r)):e[t]=r}function oe(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t}function U(e){return we&&e instanceof Map}function q(e){return xe&&e instanceof Set}function A(e){return e.o||e.t}function J(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=de(e);delete t[p];for(var r=F(t),n=0;n1&&(e.set=e.add=e.clear=e.delete=be),Object.freeze(e),t&&C(e,function(r,n){return T(n,!0)},!0)),e}function be(){y(2)}function G(e){return e==null||typeof e!="object"||Object.isFrozen(e)}function x(e){var t=te[e];return t||y(18,e),t}function ge(e,t){te[e]||(te[e]=t)}function H(){return process.env.NODE_ENV==="production"||M||y(0),M}function X(e,t){t&&(x("Patches"),e.u=[],e.s=[],e.v=t)}function R(e){B(e),e.p.forEach(Pe),e.p=null}function B(e){e===M&&(M=e.l)}function ie(e){return M={p:[],l:M,h:e,m:!0,_:0}}function Pe(e){var t=e[p];t.i===0||t.i===1?t.j():t.O=!0}function L(e,t){t._=t.p.length;var r=t.p[0],n=e!==void 0&&e!==r;return t.h.g||x("ES5").S(t,e,n),n?(r[p].P&&(R(t),y(4)),_(e)&&(e=W(t,e),t.l||$(t,e)),t.u&&x("Patches").M(r[p].t,e,t.u,t.s)):e=W(t,r,[]),R(t),t.u&&t.v(t.u,t.s),e!==le?e:void 0}function W(e,t,r){if(G(t))return t;var n=t[p];if(!n)return C(t,function(u,i){return ue(e,n,t,u,i,r)},!0),t;if(n.A!==e)return t;if(!n.P)return $(e,n.t,!0),n.t;if(!n.I){n.I=!0,n.A._--;var o=n.i===4||n.i===5?n.o=J(n.k):n.o;C(n.i===3?new Set(o):o,function(u,i){return ue(e,n,o,u,i,r)}),$(e,o,!1),r&&e.u&&x("Patches").R(n,r,e.u,e.s)}return n.o}function ue(e,t,r,n,o,u){if(process.env.NODE_ENV!=="production"&&o===r&&y(5),S(o)){var i=W(e,o,u&&t&&t.i!==3&&!k(t.D,n)?u.concat(n):void 0);if(ne(r,n,i),!S(i))return;e.m=!1}if(_(o)&&!G(o)){if(!e.h.F&&e._<1)return;W(e,o),t&&t.A.l||$(e,o)}}function $(e,t,r){r===void 0&&(r=!1),e.h.F&&e.m&&T(t,r)}function Q(e,t){var r=e[p];return(r?A(r):e)[t]}function ae(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}function D(e){e.P||(e.P=!0,e.l&&D(e.l))}function Y(e){e.o||(e.o=J(e.t))}function Z(e,t,r){var n=U(t)?x("MapSet").N(t,r):q(t)?x("MapSet").T(t,r):e.g?function(o,u){var i=Array.isArray(o),a={i:i?1:0,A:u?u.A:H(),P:!1,I:!1,D:{},l:u,t:o,k:null,o:null,j:null,C:!1},f=a,c=V;i&&(f=[a],c=K);var s=Proxy.revocable(f,c),d=s.revoke,l=s.proxy;return a.k=l,a.j=d,l}(t,r):x("ES5").J(t,r);return(r?r.A:H()).p.push(n),n}function Oe(e){return S(e)||y(22,e),function t(r){if(!_(r))return r;var n,o=r[p],u=I(r);if(o){if(!o.P&&(o.i<4||!x("ES5").K(o)))return o.t;o.I=!0,n=ce(r,u),o.I=!1}else n=ce(r,u);return C(n,function(i,a){o&&me(o.t,i)===a||ne(n,i,t(a))}),u===3?new Set(n):n}(e)}function ce(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return J(e)}function je(){function e(i,a){var f=u[i];return f?f.enumerable=a:u[i]=f={configurable:!0,enumerable:a,get:function(){var c=this[p];return process.env.NODE_ENV!=="production"&&o(c),V.get(c,i)},set:function(c){var s=this[p];process.env.NODE_ENV!=="production"&&o(s),V.set(s,i,c)}},f}function t(i){for(var a=i.length-1;a>=0;a--){var f=i[a][p];if(!f.P)switch(f.i){case 5:n(f)&&D(f);break;case 4:r(f)&&D(f)}}}function r(i){for(var a=i.t,f=i.k,c=F(f),s=c.length-1;s>=0;s--){var d=c[s];if(d!==p){var l=a[d];if(l===void 0&&!k(a,d))return!0;var v=f[d],h=v&&v[p];if(h?h.t!==l:!oe(v,l))return!0}}var m=!!a[p];return c.length!==F(a).length+(m?0:1)}function n(i){var a=i.k;if(a.length!==i.t.length)return!0;var f=Object.getOwnPropertyDescriptor(a,a.length-1);if(f&&!f.get)return!0;for(var c=0;c1?j-1:0),w=1;w1?s-1:0),l=1;l=0;o--){var u=n[o];if(u.path.length===0&&u.op==="replace"){r=u.value;break}}o>-1&&(n=n.slice(o+1));var i=x("Patches").$;return S(r)?i(r,n):this.produce(r,function(a){return i(a,n)})},e}(),b=new Ee,Ne=b.produce;b.produceWithPatches.bind(b),b.setAutoFreeze.bind(b),b.setUseProxies.bind(b),b.applyPatches.bind(b),b.createDraft.bind(b),b.finishDraft.bind(b);function Se(e){var t=P.useState(function(){return T(typeof e=="function"?e():e,!0)}),r=t[1];return[t[0],P.useCallback(function(n){r(typeof n=="function"?Ne(n):T(n))},[])]}je();const re=({value:e,contextObj:t,children:r})=>{const[n,o]=Se(e),u=P.useCallback(f=>{o(c=>{Object.assign(c,f)})},[o]),i=P.useCallback(f=>{o(c=>{f.forEach(s=>{delete c[s]})})},[o]),a=P.useMemo(()=>({...n,updateContext:u,removeFromContext:i}),[n,u,i]);return z.jsx(t.Provider,{value:a,children:r})},ve=(e,t,r)=>{const n=P.useContext(t),o=r.filter(a=>Object.prototype.hasOwnProperty.call(n,a)).map(a=>[a,n[a]]),u=Object.fromEntries(o),[i]=P.useState(P.memo(e));return[i,u]},he=e=>e.displayName||e.name||"Component",_e=(e,t,r={})=>{const n=({children:o,...u})=>z.jsx(re,{contextObj:t,value:r,children:e===re?o:z.jsx(e,{...u,children:o})});return n.displayName=`WithContextProvider(${he(e)})`,n},Ce=(e,t,r)=>{const n=({children:o,...u})=>{const[i,a]=ve(e,t,r);return z.jsx(i,{...a,...u,children:o})};return n.displayName=`WithOptimizedConsumer(${he(e)})`,n},Ie=(...e)=>({children:t})=>e.reduce((r,n)=>z.jsx(n,{children:r}),t);g.ContextProvider=re,g.composeProviders=Ie,g.useMemoConsumer=ve,g.withContextProvider=_e,g.withOptimizedConsumer=Ce,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});