(function(define = null) { // Copy the following from unpkg !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).ODO={})}(this,(function(e){"use strict";var t={ready:"odo:trigger:ready",finish:"odo:trigger:finish"},n=function(e){return function(t,n){var r;((null===(r=e.ReactNativeWebView)||void 0===r?void 0:r.postMessage)||e.postMessage)(JSON.stringify({event:t,args:n}),"*")}};function r(e){return void 0===e&&(e=1e10),Math.floor(Math.random()*Math.floor(e))}var i=function(e,t){return function(i,s){return new Promise((function(o,a){var u="odo:data:saveResponse:"+r();e.document.addEventListener("message",(function(e){var t=JSON.parse(e.detail);t.event===u&&(t.success?o(t):a(t))})),n(e)("odo:data:"+t,{returnEvent:u,key:i,data:s})}))}},s=function(e,t){return function(i){return new Promise((function(s,o){var a="odo:data:getResponse:"+r();e.document.addEventListener("message",(function(e){var t=JSON.parse(e.detail);t.event===a&&(t.success?s(t):o(t))})),n(e)("odo:data:"+t,{returnEvent:a,key:i})}))}},o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function a(){for(var e=0,t=0,n=arguments.length;t0&&o.length>i){o.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=e,f.type=t,f.count=o.length,a=f,"function"==typeof console.warn?console.warn(a):console.log(a)}}else o=s[t]=n,++e._eventsCount;return e}function y(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function m(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function w(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}u.prototype=Object.create(null),f.EventEmitter=f,f.usingDomains=!1,f.prototype.domain=void 0,f.prototype._events=void 0,f.prototype._maxListeners=void 0,f.defaultMaxListeners=10,f.init=function(){this.domain=null,f.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new u,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},f.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},f.prototype.getMaxListeners=function(){return l(this)},f.prototype.emit=function(e){var t,n,r,i,s,o,a,u="error"===e;if(o=this._events)u=u&&null==o.error;else if(!u)return!1;if(a=this.domain,u){if(t=arguments[1],!a){if(t instanceof Error)throw t;var f=new Error('Uncaught, unspecified "error" event. ('+t+")");throw f.context=t,f}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(n=o[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:v(n,l,this);break;case 2:c(n,l,this,arguments[1]);break;case 3:d(n,l,this,arguments[1],arguments[2]);break;case 4:h(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),s=1;s0;)if(n[s]===t||n[s].listener&&n[s].listener===t){o=n[s].listener,i=s;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new u,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r0?Reflect.ownKeys(this._events):[]};var L={start:"odo:event:start",restart:"odo:event:restart"},_=function(e){function t(t){var n=e.call(this)||this;return n.storage=t,n}return function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(t,e),t.prototype.on=function(e,t){return f.prototype.on.call(this,e.toString(),t),e===L.start&&this.storage.isStarted&&t(),this},t.prototype.off=function(e,t){return f.prototype.removeListener.call(this,e.toString(),t),this},t.prototype.emit=function(e){for(var t,n=[],r=1;r-1&&!v&&!0===(null==e?void 0:e.useLocalStorageInDev)&&f.emit("message",{detail:JSON.stringify(r)})}},v="undefined"==typeof window?l.navigator.userAgent.indexOf("odo")>-1:window.navigator.userAgent.indexOf("odo")>-1;function c(e){var t,n=JSON.parse(e.detail);null!==(t=n.isODO)&&void 0!==t&&t&&"string"==typeof n.event&&f.emit(n.event,n.args)}return"undefined"!=typeof window&&v&&(l=window),v||(u.isStarted=!0),v||!0!==(null==e?void 0:e.useLocalStorageInDev)||(o=new E(f)),l.document.addEventListener("message",c),{events:f,trigger:n(l),data:{save:i(l,"save"),saveForPlayer:i(l,"saveForPlayer"),get:s(l,"get"),getForPlayer:s(l,"getForPlayer")},track:(a=l,function(e,t){n(a)("odo:track",{key:e,data:t})}),destroy:function(){f.removeAllListeners(),l.document.removeEventListener("message",c),o&&o.destroy()},version:"1.0.0"}},Object.defineProperty(e,"__esModule",{value:!0})})); })(); // ODO api calls var odo = ODO.init({ useLocalStorageInDev: true }); odo.events.on(ODO.Events.start, () => { // if you need to do anything on game start, you can do it here console.log('successfully triggered start'); }); odo.events.on(ODO.Events.restart, () => { // any code you'd like for "restarting the game", Twine handles restarts quite nicely }); odo.trigger(ODO.Triggers.ready);