var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.Reactotron=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _reactotronReactNative=_interopRequireDefault(require("reactotron-react-native"));var _asyncStorage=_interopRequireDefault(require("@react-native-async-storage/async-storage"));var _mobxStateTree=require("mobx-state-tree");var _reactotronConfig=require("./reactotron-config");var _reactotronMst=require("reactotron-mst");var _storage=require("../../utils/storage");var _navigation=require("../../navigation");var noop=function noop(){return undefined;};if(__DEV__){console.tron=_reactotronReactNative.default;}else{console.tron={benchmark:noop,clear:noop,close:noop,configure:noop,connect:noop,display:noop,error:noop,image:noop,log:noop,logImportant:noop,onCustomCommand:noop,overlay:noop,reportError:noop,send:noop,startTimer:noop,storybookSwitcher:noop,use:noop,useReactNative:noop,warn:noop};}var Reactotron=exports.Reactotron=function(){function Reactotron(){var config=arguments.length>0&&arguments[0]!==undefined?arguments[0]:_reactotronConfig.DEFAULT_REACTOTRON_CONFIG;(0,_classCallCheck2.default)(this,Reactotron);(0,_defineProperty2.default)(this,"config",void 0);(0,_defineProperty2.default)(this,"rootStore",void 0);this.config=(0,_extends2.default)({host:"localhost",useAsyncStorage:true},config,{state:(0,_extends2.default)({initial:false,snapshots:false},config&&config.state)});}return(0,_createClass2.default)(Reactotron,[{key:"setRootStore",value:function setRootStore(rootStore,initialData){if(__DEV__){rootStore=rootStore;this.rootStore=rootStore;var _this$config$state=this.config.state,initial=_this$config$state.initial,snapshots=_this$config$state.snapshots;var name="ROOT STORE";if(initial){console.tron.display({name:name,value:initialData,preview:"Initial State"});}if(snapshots){(0,_mobxStateTree.onSnapshot)(rootStore,function(snapshot){console.tron.display({name:name,value:snapshot,preview:"New State"});});}console.tron.trackMstNode(rootStore);}}},{key:"setup",value:function setup(){var RX;return _regenerator.default.async(function(_context){while(1)switch(_context.prev=_context.next){case 0:if(__DEV__){_reactotronReactNative.default.configure({name:this.config.name||require("../../../package.json").name,host:this.config.host});if(this.config.useAsyncStorage){_reactotronReactNative.default.setAsyncStorageHandler(_asyncStorage.default);}_reactotronReactNative.default.useReactNative({asyncStorage:this.config.useAsyncStorage?undefined:false});RX=/postProcessSnapshot|@APPLY_SNAPSHOT/;_reactotronReactNative.default.use((0,_reactotronMst.mst)({filter:function filter(event){return RX.test(event.name)===false;}}));_reactotronReactNative.default.connect();_reactotronReactNative.default.onCustomCommand({title:"Reset Root Store",description:"Resets the MST store",command:"resetStore",handler:function handler(){console.tron.log("resetting store");(0,_storage.clear)();}});_reactotronReactNative.default.onCustomCommand({title:"Reset Navigation State",description:"Resets the navigation state",command:"resetNavigation",handler:function handler(){console.tron.log("resetting navigation state");_navigation.RootNavigation.resetRoot({routes:[]});}});_reactotronReactNative.default.onCustomCommand({title:"Go Back",description:"Goes back",command:"goBack",handler:function handler(){console.tron.log("Going back");_navigation.RootNavigation.goBack();}});if(this.config.clearOnLoad){_reactotronReactNative.default.clear();}}case 1:case"end":return _context.stop();}},null,this,null,Promise);}}]);}();
//# sourceMappingURL=reactotron.js.map