!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("data-capsule",[],t):"object"==typeof exports?exports["data-capsule"]=t():e["data-capsule"]=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t.p="undefined"!=typeof window&&window.__STATICS_BASE_URL__||t.p,t(t.s=54)}({0:function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:l;if(!e||"string"!=typeof e)throw new Error("listener function expects to recieve a scope as a first argument");var r=function(r){if(n(r.data,e)){var a=o(r);a&&(i(a),(0,f.default)(a,t))}};return window.addEventListener("message",r),function(){return window.removeEventListener("message",r)}}var s=r(4),u=r(3),c=r(12),f=function(e){return e&&e.__esModule?e:{default:e}}(c),l=function(){};e.exports=a},12:function(e,t,r){"use strict";function n(e,t){e.onmessage=function(r){var n=r.data,i=(0,o.parseChannelMessage)(n),a=i.id,s=i.payload,u=function(t){e.postMessage((0,o.constructChannelMessage)(t,a))},c={data:s,origin:r.origin,lastEventId:r.lastEventId,source:r.source,ports:r.ports};t(c,u)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n;var o=r(3)},13:function(e,t,r){"use strict";function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.records[0];return localStorage.removeItem(t.originalKey),{records:t===e.records[0]?e.records.slice(1):e.records.filter(function(e){return e.originalKey!==t.originalKey}),requiredSpace:e.requiredSpace-t.size}}function o(e){return e.records.filter(function(e){return l(e)}).forEach(function(t){return e=n(e,t)}),e}function i(e,t){return e.lastUsed-t.lastUsed}function a(e){return e.records.length>0&&e.requiredSpace>0}function s(e){for(e.records.sort(i);a(e);)e=n(e);return e}function u(e){var t={records:f(),requiredSpace:e};t=o(t),s(t)}var c=r(7),f=c.getCacheRecords,l=c.isExpired;e.exports=u},3:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseConnectionMessage=t.constructConnectionMessage=t.parseChannelMessage=t.constructChannelMessage=void 0;var n=r(4);t.constructChannelMessage=function(e,t){return t?t+n.messageDelimiter+e:e},t.parseChannelMessage=function(e){var t=e.indexOf(n.messageDelimiter);return-1===t?{id:null,payload:e}:{id:e.slice(0,t),payload:e.slice(t+1)}},t.constructConnectionMessage=function(e){return n.connectionRequestMsg+n.messageDelimiter+e},t.parseConnectionMessage=function(e){var t=e.indexOf(n.messageDelimiter);if(-1===t||e.slice(0,t)!==n.connectionRequestMsg)throw new Error("Invalid connection message");return e.slice(t+1)}},4:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.connectionRequestMsg="req_con",t.connectionSuccessMsg="connection_success",t.messageDelimiter="|",t.deafultConnectionMaxTimeout=200,t.deafultMessageMaxTimeout=5e3},5:function(e,t,r){"use strict";function n(e,t,r){var n=e.split(t,r);if(n.length===r){var o=0;o="string"==typeof t?n.join(t).length:n.reduce(function(n,o,i){var a=0;return i+10&&void 0!==arguments[0]?arguments[0]:c+f,t=[],r=0;r0&&void 0!==arguments[0]?arguments[0]:new f;o(this,e),this.storageStrategy=c.verify(t),this.stopListener}return a(e,[{key:"start",value:function(e,t){function r(r,a){if("string"==typeof r.data){var s=u(r.data,"|",3),c=i(s,3),f=c[0],l=c[1],p=c[2],g=function(e,t){if("resolve"===e){var r=[e,JSON.stringify({data:t})].join("|");return a(r)}var n=[e,t].join("|");return a(n)};if(!e(r.source,r.origin,f))return g("reject",new Error("message was not authorized"));var y=o[l].bind(o),v=JSON.parse(p).data,d=v[v.length-1],h=t?t(d,r.source,r.origin,f):d;return v[v.length-1]=h,y.apply(void 0,n(v)).then(function(e){return g("resolve",e)}).catch(function(e){return g("reject",e.message||e)})}}if(!e||"function"!=typeof e)throw new Error("start function must get a verifier function as a first argument");if(t&&"function"!=typeof t)throw new Error("the interceptor must be a function");var o=c.verify(this.storageStrategy);this.stopListener=s("data-capsule",r)}},{key:"stop",value:function(){this.stopListener&&this.stopListener()}}]),e}();e.exports=l}})}); //# sourceMappingURL=frame-listener.bundle.min.js.map