!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("xstate")):"function"==typeof define&&define.amd?define(["exports","react","xstate"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).XStateReact={},t.React,t.XState)}(this,(function(t,e,n){"use strict";function r(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function u(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var o=r(e),a=u(e),i=function(){return(i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){u={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(u)throw u.error}}return a}function s(t){var e={exports:{}};return t(e,e.exports),e.exports /** * @license React * use-sync-external-store-shim.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 f="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},l=o.default.useState,v=o.default.useEffect,d=o.default.useLayoutEffect,p=o.default.useDebugValue;function b(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!f(t,n)}catch(t){return!0}}var h="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(t,e){var n=e(),r=l({inst:{value:n,getSnapshot:e}}),u=r[0].inst,o=r[1];return d((function(){u.value=n,u.getSnapshot=e,b(u)&&o({inst:u})}),[t,n,e]),v((function(){return b(u)&&o({inst:u}),t((function(){b(u)&&o({inst:u})}))}),[t]),p(n),n},y={useSyncExternalStore:void 0!==o.default.useSyncExternalStore?o.default.useSyncExternalStore:h}; /** * @license React * use-sync-external-store-shim.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. */ s((function(t,e){}));var S=s((function(t){t.exports=y})); /** * @license React * use-sync-external-store-shim/with-selector.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 g="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},O=S.useSyncExternalStore,j=o.default.useRef,x=o.default.useEffect,m=o.default.useMemo,E=o.default.useDebugValue,w={useSyncExternalStoreWithSelector:function(t,e,n,r,u){var o=j(null);if(null===o.current){var a={hasValue:!1,value:null};o.current=a}else a=o.current;o=m((function(){function t(t){if(!c){if(c=!0,o=t,t=r(t),void 0!==u&&a.hasValue){var e=a.value;if(u(e,t))return i=e}return i=t}if(e=i,g(o,t))return e;var n=r(t);return void 0!==u&&u(e,n)?e:(o=t,i=n)}var o,i,c=!1,s=void 0===n?null:n;return[function(){return t(e())},null===s?void 0:function(){return t(s())}]}),[e,n,r,u]);var i=O(t,o[0],o[1]);return x((function(){a.hasValue=!0,a.value=i}),[i]),E(i),i}}; /** * @license React * use-sync-external-store-shim/with-selector.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. */ s((function(t,e){}));var k=s((function(t){t.exports=w})),C=e.useLayoutEffect;function P(t){var e=a.useRef();return e.current||(e.current={v:t()}),e.current.v}function R(t,e){var r=P((function(){return"function"==typeof t?t():t})),u=e.context,o=e.guards,a=e.actions,c=e.activities,s=e.services,f=e.delays;e.state;var l=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var u=0;for(r=Object.getOwnPropertySymbols(t);u0||"boolean"==typeof e.changed);return!(r.changed||u)}function W(t){return t}function _(t){return t}function q(t){return"state"in t}function D(t){return"deferred"in t}function L(t){return"getSnapshot"in t?V(t)?I(t):t.getSnapshot():q(t)?t.state:void 0}function T(t,n){void 0===n&&(n=L);var r=e.useRef(t),u=e.useRef([]),o=e.useCallback((function(e){return t.subscribe(e).unsubscribe}),[t]),a=e.useCallback((function(){return n(t)}),[t,n]),i=e.useCallback((function(e,n){return V(t)?M(t,e,n):e===n}),[t]),c=k.useSyncExternalStoreWithSelector(o,a,a,_,i),s=P((function(){return function(){for(var t=[],e=0;e0;){var e=u.current.shift();t.send(e)}}),[t]),[c,s]}var X=function(t,e){return t===e};function z(t,n,r,u){void 0===r&&(r=X);var o=e.useRef(null),a=e.useCallback((function(e){return t.subscribe(e).unsubscribe}),[t]),i=e.useCallback((function(){return u?u(t):function(t,e){if(V(t)){if(0===t.status&&e.current)return e.current;var n=I(t);return e.current=0===t.status?n:null,n}return q(t)?t.state:void 0}(t,o)}),[t,u]);return k.useSyncExternalStoreWithSelector(a,i,i,n,r)}t.createActorContext=function(t,e,n){var r=a.createContext(null),u=r.Provider;function o(r){var o=r.children,c=r.machine,s=void 0===c?t:c,f=r.options,l=N(s,i(i({},e),f),n);return a.createElement(u,{value:l},o)}function c(){var t=a.useContext(r);if(!t)throw new Error('You used a hook from "'.concat(o.displayName,"\" but it's not inside a <").concat(o.displayName,"> component."));return t}return o.displayName="ActorProvider(".concat(t.id,")"),{Provider:o,useActorRef:c,useActor:function(){return T(c())},useSelector:function(t,e){return z(c(),t,e)}}},t.shallowEqual=function(t,e){if(A(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;var n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(var u=0;u