(function(l,d){typeof exports=="object"&&typeof module!="undefined"?d(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],d):(l=typeof globalThis!="undefined"?globalThis:l||self,d(l["toju-react-hooks"]={},l.React))})(this,function(l,d){"use strict";var xr=Object.defineProperty;var Le=Object.getOwnPropertySymbols;var Dr=Object.prototype.hasOwnProperty,Ir=Object.prototype.propertyIsEnumerable;var We=(l,d,S)=>d in l?xr(l,d,{enumerable:!0,configurable:!0,writable:!0,value:S}):l[d]=S,L=(l,d)=>{for(var S in d||(d={}))Dr.call(d,S)&&We(l,S,d[S]);if(Le)for(var S of Le(d))Ir.call(d,S)&&We(l,S,d[S]);return l};function S(a){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const i in a)if(i!=="default"){const h=Object.getOwnPropertyDescriptor(a,i);Object.defineProperty(o,i,h.get?h:{enumerable:!0,get:()=>a[i]})}}return o.default=a,Object.freeze(o)}const C=S(d);var Q={exports:{}},Y={};/** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var fe;function Ve(){if(fe)return Y;fe=1;var a=d,o=Symbol.for("react.element"),i=Symbol.for("react.fragment"),h=Object.prototype.hasOwnProperty,m=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,w={key:!0,ref:!0,__self:!0,__source:!0};function y(b,g,I){var R,k={},P=null,E=null;I!==void 0&&(P=""+I),g.key!==void 0&&(P=""+g.key),g.ref!==void 0&&(E=g.ref);for(R in g)h.call(g,R)&&!w.hasOwnProperty(R)&&(k[R]=g[R]);if(b&&b.defaultProps)for(R in g=b.defaultProps,g)k[R]===void 0&&(k[R]=g[R]);return{$$typeof:o,type:b,key:P,ref:E,props:k,_owner:m.current}}return Y.Fragment=i,Y.jsx=y,Y.jsxs=y,Y}var U={};/** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var le;function Ye(){return le||(le=1,process.env.NODE_ENV!=="production"&&function(){var a=d,o=Symbol.for("react.element"),i=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),y=Symbol.for("react.provider"),b=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),k=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),E=Symbol.for("react.offscreen"),z=Symbol.iterator,Z="@@iterator";function ee(e){if(e===null||typeof e!="object")return null;var r=z&&e[z]||e[Z];return typeof r=="function"?r:null}var x=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function _(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n=1&&p>=0&&s[v]!==T[p];)p--;for(;v>=1&&p>=0;v--,p--)if(s[v]!==T[p]){if(v!==1||p!==1)do if(v--,p--,p<0||s[v]!==T[p]){var j=` `+s[v].replace(" at new "," at ");return e.displayName&&j.includes("")&&(j=j.replace("",e.displayName)),typeof e=="function"&&q.set(e,j),j}while(v>=1&&p>=0);break}}}finally{ne=!1,re.current=f,ir(),Error.prepareStackTrace=c}var V=e?e.displayName||e.name:"",$=V?H(V):"";return typeof e=="function"&&q.set(e,$),$}function sr(e,r,t){return Te(e,!1)}function ur(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function G(e,r,t){if(e==null)return"";if(typeof e=="function")return Te(e,ur(e));if(typeof e=="string")return H(e);switch(e){case I:return H("Suspense");case R:return H("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case g:return sr(e.render);case k:return G(e.type,r,t);case P:{var n=e,c=n._payload,f=n._init;try{return G(f(c),r,t)}catch(u){}}}return""}var B=Object.prototype.hasOwnProperty,Oe={},ke=x.ReactDebugCurrentFrame;function X(e){if(e){var r=e._owner,t=G(e.type,e._source,r?r.type:null);ke.setExtraStackFrame(t)}else ke.setExtraStackFrame(null)}function cr(e,r,t,n,c){{var f=Function.call.bind(B);for(var u in e)if(f(e,u)){var s=void 0;try{if(typeof e[u]!="function"){var T=Error((n||"React class")+": "+t+" type `"+u+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[u]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw T.name="Invariant Violation",T}s=e[u](r,u,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(v){s=v}s&&!(s instanceof Error)&&(X(c),_("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,u,typeof s),X(null)),s instanceof Error&&!(s.message in Oe)&&(Oe[s.message]=!0,X(c),_("Failed %s type: %s",t,s.message),X(null))}}}var fr=Array.isArray;function ae(e){return fr(e)}function lr(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function dr(e){try{return Se(e),!1}catch(r){return!0}}function Se(e){return""+e}function Ce(e){if(dr(e))return _("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",lr(e)),Se(e)}var J=x.ReactCurrentOwner,vr={key:!0,ref:!0,__self:!0,__source:!0},je,Pe,ie;ie={};function hr(e){if(B.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function pr(e){if(B.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function br(e,r){if(typeof e.ref=="string"&&J.current&&r&&J.current.stateNode!==r){var t=D(J.current.type);ie[t]||(_('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',D(J.current.type),e.ref),ie[t]=!0)}}function mr(e,r){{var t=function(){je||(je=!0,_("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function gr(e,r){{var t=function(){Pe||(Pe=!0,_("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var Er=function(e,r,t,n,c,f,u){var s={$$typeof:o,type:e,key:r,ref:t,props:u,_owner:f};return s._store={},Object.defineProperty(s._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(s,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(s,"_source",{configurable:!1,enumerable:!1,writable:!1,value:c}),Object.freeze&&(Object.freeze(s.props),Object.freeze(s)),s};function yr(e,r,t,n,c){{var f,u={},s=null,T=null;t!==void 0&&(Ce(t),s=""+t),pr(r)&&(Ce(r.key),s=""+r.key),hr(r)&&(T=r.ref,br(r,c));for(f in r)B.call(r,f)&&!vr.hasOwnProperty(f)&&(u[f]=r[f]);if(e&&e.defaultProps){var v=e.defaultProps;for(f in v)u[f]===void 0&&(u[f]=v[f])}if(s||T){var p=typeof e=="function"?e.displayName||e.name||"Unknown":e;s&&mr(u,p),T&&gr(u,p)}return Er(e,s,T,c,n,J.current,u)}}var oe=x.ReactCurrentOwner,xe=x.ReactDebugCurrentFrame;function W(e){if(e){var r=e._owner,t=G(e.type,e._source,r?r.type:null);xe.setExtraStackFrame(t)}else xe.setExtraStackFrame(null)}var se;se=!1;function ue(e){return typeof e=="object"&&e!==null&&e.$$typeof===o}function De(){{if(oe.current){var e=D(oe.current.type);if(e)return` Check the render method of \``+e+"`."}return""}}function Rr(e){return""}var Ie={};function _r(e){{var r=De();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=` Check the top-level render call using <`+t+">.")}return r}}function Me(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=_r(r);if(Ie[t])return;Ie[t]=!0;var n="";e&&e._owner&&e._owner!==oe.current&&(n=" It was passed a child from "+D(e._owner.type)+"."),W(e),_('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),W(null)}}function Fe(e,r){{if(typeof e!="object")return;if(ae(e))for(var t=0;t",s=" Did you accidentally export a JSX literal instead of a component?"):v=typeof e,_("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",v,s)}var p=yr(e,r,t,c,f);if(p==null)return p;if(u){var j=r.children;if(j!==void 0)if(n)if(ae(j)){for(var V=0;V0?"{key: someKey, "+O.join(": ..., ")+": ...}":"{key: someKey}";if(!Ae[$+ce]){var jr=O.length>0?"{"+O.join(": ..., ")+": ...}":"{}";_(`A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; <%s key={someKey} {...props} />`,ce,$,jr,$),Ae[$+ce]=!0}}return e===h?Tr(p):wr(p),p}}function Or(e,r,t){return $e(e,r,t,!0)}function kr(e,r,t){return $e(e,r,t,!1)}var Sr=kr,Cr=Or;U.Fragment=h,U.jsx=Sr,U.jsxs=Cr}()),U}process.env.NODE_ENV==="production"?Q.exports=Ve():Q.exports=Ye();var de=Q.exports;const Ue=({initialValue:a=0})=>{const[o,i]=C.useState(a);return{value:o,reset:()=>i(a),increment:(y=1)=>i(b=>b+y),decrement:(y=1)=>i(b=>b-y)}},K=a=>{const o=C.useRef(()=>{});return C.useEffect(()=>{o.current=a},[a]),C.useCallback((...i)=>o.current(...i),[])};function ze(a,o){let i;return function(...m){i!==void 0&&clearTimeout(i),i=setTimeout(()=>{a(...m)},o)}}function Ne(a,o){let i;return function(...m){if(i===void 0)return i=setTimeout(()=>{i=void 0},o),a(...m)}}const Be=(a,o)=>{const i=K(a);return ze(i,o)},ve=({ref:a,threshold:o,rootMargin:i})=>{const[h,m]=C.useState(!1);return C.useEffect(()=>{const w=new IntersectionObserver(b=>{const[g]=b;m(g.isIntersecting)},{threshold:o,rootMargin:i}),y=a.current;return y&&w.observe(y),()=>{y&&w.unobserve(y)}},[a,i,o]),h},M={Mobile:"(max-width: 524px)",Tablet:"(min-width: 525px) and (max-width: 1024px)",Desktop:"(min-width: 1025px)",BigDesktop:"(min-width: 1400px)",LessThanDesktop:"(max-width: 1024px)",MoreThanMobile:"(min-width: 525px)"};Object.fromEntries(Object.entries(M).map(([a,o])=>[`is${a}`,`@media ${o}`]));const F=a=>{const o=C.useCallback(()=>typeof window!="undefined"?window.matchMedia(a).matches:!1,[a]),[i,h]=C.useState(o),m=C.useCallback(()=>{h(o())},[o]);return C.useEffect(()=>{const w=window.matchMedia(a);return w.addEventListener("change",m),()=>{w.removeEventListener("change",m)}},[a]),i},Je=()=>{const a=F(M.Mobile),o=F(M.Tablet),i=F(M.Desktop),h=F(M.BigDesktop),m=F(M.LessThanDesktop),w=F(M.MoreThanMobile);return{isMobile:a,isTablet:o,isDesktop:i,isBigDesktop:h,isLessThanDesktop:m,isMoreThanMobile:w}},Ke=(a,o)=>{const i=K(a);return Ne(i,o)},He=()=>{const[a,o]=C.useState({width:window.innerWidth,height:window.innerHeight}),i=()=>{o({width:window.innerWidth,height:window.innerHeight})};return C.useEffect(()=>(window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)),[]),{width:a.width,height:a.height}},qe=(a,o,{trackOnMount:i=!0,trackOnUnmount:h=!0,trackOnClick:m=!0,trackOnMouseEnter:w=!0,trackOnInView:y=!0,additionalData:b={}})=>I=>{const R=d.useRef(null),k=d.useRef(!1),P=d.useRef(!1),E=K(o),z=ve({ref:R});d.useEffect(()=>(E&&!k.current&&i&&(E("trackOnMount",L({component:a.name},b)),k.current=!0),()=>{E&&h&&(E("trackOnUnmount",L({component:a.name},b)),k.current=!1)}),[E]),d.useEffect(()=>{E&&z&&!P.current&&y&&(E("trackOnInView",L({component:a.name},b)),P.current=!0)},[z,E]);const Z=x=>{E&&m&&E("trackOnClick",L({component:a.name,event:x},b))},ee=x=>{E&&w&&E("trackOnMouseEnter",L({component:a.name,event:x},b))};return de.jsx("div",{ref:R,onClick:Z,onMouseEnter:ee,children:de.jsx(a,L({},I))})};l.useCounter=Ue,l.useDebounce=Be,l.useEvent=K,l.useIsInView=ve,l.useMedia=Je,l.useMediaQuery=F,l.useThrottle=Ke,l.useWindowsResize=He,l.withTracking=qe,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}); //# sourceMappingURL=toju-react-hooks.umd.cjs.map