text: 'use strict';Object.defineProperty(exports,"__esModule",{value:!0});function _interopDefault(a){return a&&"object"==typeof a&&"default"in a?a["default"]:a}var reactNative=require("react-native"),reactotronCoreClient=require("reactotron-core-client"),getHost=_interopDefault(require("rn-host-detect")),React=require("react"),React__default=_interopDefault(React),XHRInterceptor=_interopDefault(require("react-native/Libraries/Network/XHRInterceptor")),queryString=_interopDefault(require("query-string"));function _typeof(a){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),a}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread2(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(b,!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(b).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _inherits(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),b&&_setPrototypeOf(a,b)}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _possibleConstructorReturn(a,b){return b&&("object"==typeof b||"function"==typeof b)?b:_assertThisInitialized(a)}function getReactNativeVersionWithModules(a){try{if(!a.PlatformConstants)return null;if(!a.PlatformConstants.reactNativeVersion)return null;var b=a.PlatformConstants.reactNativeVersion.major,c=a.PlatformConstants.reactNativeVersion.minor,d=a.PlatformConstants.reactNativeVersion.patch,e=a.PlatformConstants.reactNativeVersion.prerelease;if("number"!=typeof b)return null;var f=[];return f.push("".concat(b,".").concat(c,".").concat(d)),e&&f.push("-".concat(e)),f.join("")}catch(a){}return null}function getReactNativeVersion(){return getReactNativeVersionWithModules(reactNative.NativeModules)}function getReactNativeDimensionsWithDimensions(a,b){var c=Math.ceil;try{var d={},e={};return a&&(d={screenWidth:c(a.width),screenHeight:c(a.height),screenScale:a.scale,screenFontScale:a.fontScale}),b&&(e={windowWidth:c(b.width),windowHeight:c(b.height),windowScale:b.scale,windowFontScale:b.fontScale}),_objectSpread2({},d,{},e)}catch(a){}return null}function getReactNativeDimensions(){var a=null,b=null;try{a=reactNative.Dimensions.get("screen")}catch(a){}try{b=reactNative.Dimensions.get("window")}catch(a){}return getReactNativeDimensionsWithDimensions(a,b)}var PLUGIN_DEFAULTS={ignore:[]},asyncStorage=function(a){return function(b){var c,d,e,f,g,h,i,j=Object.assign({},PLUGIN_DEFAULTS,a||{}),k=j.ignore||PLUGIN_DEFAULTS.ignore,l=!1,m=function(a,c){b.send("asyncStorage.mutation",{action:a,data:c})},n=function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b,d,e){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:try{0>k.indexOf(b)&&m("setItem",{key:b,value:d})}catch(a){}return a.abrupt("return",c(b,d,e));case 2:case"end":return a.stop();}},a)}));return function(){return a.apply(this,arguments)}}(),o=function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b,c){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:try{0>k.indexOf(b)&&m("removeItem",{key:b})}catch(a){}return a.abrupt("return",d(b,c));case 2:case"end":return a.stop();}},a)}));return function(){return a.apply(this,arguments)}}(),p=function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b,c,d){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:try{0>k.indexOf(b)&&m("mergeItem",{key:b,value:c})}catch(a){}return a.abrupt("return",e(b,c,d));case 2:case"end":return a.stop();}},a)}));return function(){return a.apply(this,arguments)}}(),q=function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:try{m("clear")}catch(a){}return a.abrupt("return",f(b));case 2:case"end":return a.stop();}},a)}));return function(){return a.apply(this,arguments)}}(),r=function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b,c){var d;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:try{d=(b||[]).filter(function(a){return a&&a[0]&&0>k.indexOf(a[0])}),0<d.length&&m("multiSet",{pairs:d})}catch(a){}return a.abrupt("return",g(b,c));case 2:case"end":return a.stop();}},a)}));return function(){return a.apply(this,arguments)}}(),s=function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b,c){var d;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:try{d=(b||[]).filter(function(a){return 0>k.indexOf(a)}),0<d.length&&m("multiRemove",{keys:d})}catch(a){}return a.abrupt("return",h(b,c));case 2:case"end":return a.stop();}},a)}));return function(){return a.apply(this,arguments)}}(),t=function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b,c){var d;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:try{d=(b||[]).filter(function(a){return a&&a[0]&&0>k.indexOf(a[0])}),0<d.length&&m("multiMerge",{pairs:d})}catch(a){}return a.abrupt("return",i(b,c));case 2:case"end":return a.stop();}},a)}));return function(){return a.apply(this,arguments)}}(),u=function(){l||(c=b.asyncStorageHandler.setItem,b.asyncStorageHandler.setItem=n,d=b.asyncStorageHandler.removeItem,b.asyncStorageHandler.removeItem=o,e=b.asyncStorageHandler.mergeItem,b.asyncStorageHandler.mergeItem=p,f=b.asyncStorageHandler.clear,b.asyncStorageHandler.clear=q,g=b.asyncStorageHandler.multiSet,b.asyncStorageHandler.multiSet=r,h=b.asyncStorageHandler.multiRemove,b.asyncStorageHandler.multiRemove=s,i=b.asyncStorageHandler.multiMerge,b.asyncStorageHandler.multiMerge=t,l=!0)},v=function(){l&&(b.asyncStorageHandler.setItem=c,b.asyncStorageHandler.removeItem=d,b.asyncStorageHandler.mergeItem=e,b.asyncStorageHandler.clear=f,b.asyncStorageHandler.multiSet=g,b.asyncStorageHandler.multiRemove=h,b.asyncStorageHandler.multiMerge=i,l=!1)};return b.asyncStorageHandler&&u(),{features:{trackAsyncStorage:u,untrackAsyncStorage:v}}}};function mitt(a){return a=a||Object.create(null),{on:function(b,c){(a[b]||(a[b]=[])).push(c)},off:function(b,c){a[b]&&a[b].splice(a[b].indexOf(c)>>>0,1)},emit:function(b,c){(a[b]||[]).slice().map(function(a){a(c)}),(a["*"]||[]).slice().map(function(a){a(b,c)})}}}var parseErrorStack,symbolicateStackTrace,Styles={container:{position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:1e3,opacity:.25}},FullScreenOverlay=function(a){function b(a){var c;return _classCallCheck(this,b),c=_possibleConstructorReturn(this,_getPrototypeOf(b).call(this,a)),c.state={opacity:Styles.container.opacity,uri:null,justifyContent:"center",alignItems:"center"},a.emitter.on("overlay",function(a){c.setState(_objectSpread2({},c.state,{},a))}),c}return _inherits(b,a),_createClass(b,[{key:"createContainerStyle",value:function(){var a=this.state,b=a.opacity,c=a.justifyContent,d=a.alignItems,e=reactNative.Dimensions.get("window"),f=e.width,g=e.height,h=_objectSpread2({},Styles.container,{opacity:b,width:f,height:g,justifyContent:c,alignItems:d});return h}},{key:"render",value:function(){var a=this.state,b=a.uri,c=a.width,d=a.height,e=a.growToWindow,f=a.resizeMode,g=a.marginLeft,h=void 0===g?0:g,i=a.marginRight,j=void 0===i?0:i,k=a.marginTop,l=void 0===k?0:k,m=a.marginBottom,n=void 0===m?0:m,o={width:c,height:d,marginTop:l,marginRight:j,marginBottom:n,marginLeft:h};if(e){var p=reactNative.Dimensions.get("window");o.width=p.width,o.height=p.height}var q=b?React__default.createElement(reactNative.Image,{source:{uri:b},style:o,resizeMode:e?f:null}):React__default.createElement(reactNative.View,null);return React__default.createElement(reactNative.View,{style:this.createContainerStyle(),pointerEvents:"none"},q)}}]),b}(React.Component),overlay=function(){return function(){var a=new mitt;return{onCommand:function(b){"overlay"!==b.type||a.emit("overlay",b.payload)},features:{overlay:function(b){return function(c){return React__default.createElement(reactNative.View,{style:{flex:1}},React__default.createElement(b,c),React__default.createElement(FullScreenOverlay,{emitter:a}))}}}}}},DEFAULTS={url:"http://localhost:8081"},openInEditor=function(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{};return function(){var b=Object.assign({},DEFAULTS,a);return{onCommand:function(a){if("editor.open"===a.type){var c=a.payload,d=c.file,e=c.lineNumber,f="".concat(b.url,"/open-stack-frame");fetch(f,{method:"POST",body:JSON.stringify({file:d,lineNumber:e||1})})}}}}},PLUGIN_DEFAULTS$1={veto:null},trackGlobalErrors=function(a){return function(b){function c(a,c,d){h(a,c,d);try{var e=c.map(function(a){return{functionName:"<unknown>"===a.methodName?null:a.methodName,lineNumber:a.lineNumber,columnNumber:a.column,fileName:a.file}});g.veto&&(e=e.filter(function(a){return g.veto(a)})),b.error(a,e)}catch(a){}}function d(){i||!reactNative.NativeModules.ExceptionsManager||(h=reactNative.NativeModules.ExceptionsManager.updateExceptionMessage,reactNative.NativeModules.ExceptionsManager.updateExceptionMessage=c,i=!0)}function e(){h&&reactNative.NativeModules.ExceptionsManager&&(reactNative.NativeModules.ExceptionsManager.updateExceptionMessage=h,i=!1)}function f(a){try{if(parseErrorStack=parseErrorStack||require("react-native/Libraries/Core/Devtools/parseErrorStack"),symbolicateStackTrace=symbolicateStackTrace||require("react-native/Libraries/Core/Devtools/symbolicateStackTrace"),parseErrorStack&&symbolicateStackTrace){var c=parseErrorStack(a);symbolicateStackTrace(c).then(function(c){var d=c.map(function(a){return{fileName:a.file,functionName:a.methodName,lineNumber:a.lineNumber}});g.veto&&(d=d.filter(function(a){return g.veto(a)})),b.error(a.message,d)})}}catch(a){}}var g=Object.assign({},PLUGIN_DEFAULTS$1,a||{}),h=null,i=!1;return d(),{features:{reportError:f,trackGlobalErrors:d,untrackGlobalErrors:e}}}},DEFAULT_CONTENT_TYPES_RX=/^(image)\/.*$/i,DEFAULTS$1={},networking=function(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{};return function(b){function c(a,c){return e.ignoreUrls&&e.ignoreUrls.test(c._url)?void(c._skipReactotron=!0):void(g++,c._trackingName=g,h[g]={data:a,xhr:c,stopTimer:b.startTimer()})}function d(a,c,d,e,g,i){if(!i._skipReactotron){var j=null,k=e?e.indexOf("?"):-1;-1<k&&(j=queryString.parse(e.substr(k)));var l=i._trackingName,m=h[l]||{};h[l]=null;var n=m.data,o=m.stopTimer,p={url:e||m.xhr._url,method:i._method||null,data:n,headers:i._headers||null,params:j},q=i.responseHeaders&&i.responseHeaders["content-type"]||i.responseHeaders&&i.responseHeaders["Content-Type"]||"",r=function(c){var e="~~~ skipped ~~~";if(c)try{e=JSON.parse(c)}catch(a){e=d}var f={body:e,status:a,headers:i.responseHeaders||null};b.apiResponse(p,f,o())},s=("string"==typeof d||"object"===_typeof(d))&&!f.test(q||"");if(!s)r("");else if("blob"===g&&"undefined"!=typeof FileReader&&d){var t=new FileReader,u=function a(){r(t.result),t.removeEventListener("loadend",a)};t.addEventListener("loadend",u),t.readAsText(d)}else r(d)}}var e=Object.assign({},DEFAULTS$1,a),f=e.ignoreContentTypes||DEFAULT_CONTENT_TYPES_RX,g=1e3,h={};return XHRInterceptor.setSendCallback(c),XHRInterceptor.setResponseCallback(d),XHRInterceptor.enableInterception(),{}}},StorybookSwitcher=function(a){function b(a){var c;return _classCallCheck(this,b),c=_possibleConstructorReturn(this,_getPrototypeOf(b).call(this,a)),c.state={showStorybook:!1},a.emitter.on("storybook",function(a){c.setState({showStorybook:a})}),c}return _inherits(b,a),_createClass(b,[{key:"render",value:function(){var a=this.state.showStorybook,b=this.props,c=b.storybookUi,d=b.children;return React__default.createElement(reactNative.View,{style:{flex:1}},a?React__default.createElement(c,null):d)}}]),b}(React.Component),storybook=function(){return function(){var a=new mitt;return{onCommand:function(b){"storybook"!==b.type||a.emit("storybook",b.payload)},features:{storybookSwitcher:function(b){return function(c){return function(d){return React__default.createElement(StorybookSwitcher,{storybookUi:b,emitter:a},React__default.createElement(c,d))}}}}}}},devTools=function(){return function(){return{onCommand:function(a){"devtools.open"!==a.type&&"devtools.reload"!==a.type||("devtools.open"===a.type&&reactNative.NativeModules.DevMenu.show(),"devtools.reload"===a.type&&reactNative.NativeModules.DevMenu.reload())}}}},constants=reactNative.NativeModules.PlatformConstants||{},REACTOTRON_ASYNC_CLIENT_ID="@REACTOTRON/clientId",tempClientId=null,DEFAULTS$2={createSocket:function(a){return new WebSocket(a)},host:getHost("localhost"),port:9090,name:"React Native App",environment:process.env.NODE_ENV||(__DEV__?"development":"production"),client:_objectSpread2({reactotronLibraryName:"reactotron-react-native",reactotronLibraryVersion:"REACTOTRON_REACT_NATIVE_VERSION",platform:reactNative.Platform.OS,platformVersion:reactNative.Platform.Version,osRelease:constants.Release,model:constants.Model,serverHost:constants.ServerHost,forceTouch:constants.forceTouchAvailable||!1,interfaceIdiom:constants.interfaceIdiom,systemName:constants.systemName,uiMode:constants.uiMode,serial:constants.Serial,androidId:constants.androidID,reactNativeVersion:getReactNativeVersion()},getReactNativeDimensions()),getClientId:function(){return reactotron.asyncStorageHandler?reactotron.asyncStorageHandler.getItem(REACTOTRON_ASYNC_CLIENT_ID):new Promise(function(a){return a(tempClientId)})},setClientId:function(a){return reactotron.asyncStorageHandler?reactotron.asyncStorageHandler.setItem(REACTOTRON_ASYNC_CLIENT_ID,a):(tempClientId=a,Promise.resolve())},proxyHack:!0},reactotron=reactotronCoreClient.createClient(DEFAULTS$2);function getPluginOptions(a){return"object"===_typeof(a)?a:null}reactotron.useReactNative=function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return!1!==a.errors&&reactotron.use(trackGlobalErrors(getPluginOptions(a.errors))),!1!==a.editor&&reactotron.use(openInEditor(getPluginOptions(a.editor))),!1!==a.overlay&&reactotron.use(overlay()),!1!==a.asyncStorage&&reactotron.use(asyncStorage(getPluginOptions(a.asyncStorage))),!1!==a.networking&&reactotron.use(networking(getPluginOptions(a.networking))),!1!==a.storybook&&reactotron.use(storybook()),!1!==a.devTools&&reactotron.use(devTools()),reactotron},reactotron.setAsyncStorageHandler=function(a){return reactotron.asyncStorageHandler=a,reactotron},exports.asyncStorage=asyncStorage,exports.default=reactotron,exports.devTools=devTools,exports.networking=networking,exports.openInEditor=openInEditor,exports.overlay=overlay,exports.storybook=storybook,exports.trackGlobalErrors=trackGlobalErrors;
  