text: "use strict";var scope="undefined"!=typeof global?global:"undefined"!=typeof window?window:{},eventRegistry=scope.__eventRegistry=scope.__eventRegistry||{};function trigger(e){var t=arguments;if(eventRegistry[e])for(var n,r=0,o=eventRegistry[e].length;n=eventRegistry[e][r],r<o;r+=1){if(!1===n.apply(this,Array.prototype.slice.call(t,1)))break}}function on(e,t){eventRegistry[e]||(eventRegistry[e]=[]),eventRegistry[e].push(t)}function off(e,t){if(eventRegistry[e])if("function"==typeof t){var n=eventRegistry[e].indexOf(t);n>=0&&eventRegistry[e].splice(n,1)}else eventRegistry[e]=[]}function one(e,t){var n=this,r=function(){off(e,r),t.apply(n,Array.prototype.slice.call(arguments))};on(e,r)}function resetEvents(){eventRegistry=scope.__eventRegistry={}}var events=Object.freeze({trigger:trigger,on:on,off:off,one:one,resetEvents:resetEvents}),scope$1="undefined"!=typeof window?window:{},data=scope$1.__glassbilStoreData=scope$1.__glassbilStoreData||{},trigger$1=trigger;function mirror(){return this}function getProperty(e,t){for(var n=t,r=e.split(".");n&&r.length>0;)n=n[r.shift()];return n}function deepFreeze(e){if(null===e||void 0===e||"function"==typeof e.toJS||"object"!=typeof e)return e;var t=Object.getOwnPropertyNames(e),n={toJS:{value:mirror.bind(e)}};Array.isArray(e)&&(e=e.slice(0).map(deepFreeze),["map","forEach","find","indexOf","filter","some","every","lastIndexOf","slice"].forEach(function(t){n[t]={value:function(){return deepFreeze(Array.prototype[t].apply(e,arguments))}}}));for(var r=function(e,r){n[t[e]]={enumerable:!0,get:function(){return deepFreeze(r)},set:function(n){throw new Error('Cannot change property "'+t[e]+'" to "'+n+'" of an immutable object')}}},o=0,i=void 0;i=e[t[o]],o<t.length;o+=1)r(o,i);return Object.freeze(Object.create(Object.getPrototypeOf(e),n))}function bind(e,t,n){return function(r){return e.call(t,r,n)}}var Store=function(e,t){var n=this;this.name=e||"Unnamed"+Object.keys(data).length,Object.keys(events).forEach(function(t){"resetEvents"!==t&&(n[t]=function(n,r){n.indexOf(":")>=0?events[t](n,r):events[t](e+"-store:"+n,r)})}),this.actions(t),e&&(data[e]=data[e]||{loaded:!1,currentData:deepFreeze([])})},prototypeAccessors={data:{configurable:!0}};Store.prototype.actions=function(e){var t=this;if(!e||"object"!=typeof e)return this.actionDefinitions&&Object.keys(this.actionDefinitions)||[];var n=Object.keys(e);this.actionDefinitions=Object.assign({},this.actionDefinitions||{},e);for(var r=function(e,r){(function(e){this[e]=function(t){var n=r.call(this,data[this.name].currentData,t,bind(this.setState,this,e));void 0!==n&&this.setState(n,e)}.bind(this)}).call(t,n[e])},o=0,i=void 0;i=e[n[o]],o<n.length;o+=1)r(o,i);return Object.keys(this.actionDefinitions)},Store.prototype.watch=function(e,t,n){n=n||function(e,t){return e===t};var r=getProperty(e,this.data),o=function(o){var i=getProperty(e,o);n(r,i)||t(i,r,o)};return this.on(this.name+"-store:changed",o),function(){this.off(this.name+"-store:changed",o)}.bind(this)},prototypeAccessors.data.get=function(){return data[this.name]&&data[this.name].loaded?data[this.name].currentData:null},Store.prototype.loaded=function(){var e=Object.keys(data).filter(function(e){return data[e].loaded}).length;if(e===Object.keys(data).length&&!data.__triggered){var t={};Object.keys(data).map(function(e){t[e]=data[e].currentData.toJS()}),data.__triggered=!0,trigger$1("global:data-loaded",t)}},Store.prototype.reset=function(){return Object.getPrototypeOf(this)===Store.prototype&&(data=scope$1.__glassbilStoreData={},resetEvents(),!0)},Store.prototype.setState=function(e,t){void 0===t&&(t="setState"),data[this.name].loaded=!0,(e=deepFreeze(e))!==data[this.name].currentData&&(data[this.name].currentData=e,trigger$1(this.name+"-store:changed",data[this.name].currentData,t)),this.loaded()},Object.defineProperties(Store.prototype,prototypeAccessors),module.exports=Store;
  